Services.jsm 编辑
The Services.jsm
JavaScript code module offers a wide assortment of lazy getters that simplify the process of obtaining references to commonly used services.
To use it, you first need to import the code module into your JavaScript scope:
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
Then you can obtain references to services by simply accessing them from the Services
object exported by the code module. For example, to obtain a reference to the preferences service:
var prefsService = Services.prefs;
Provided service getters
Service accessor | Service interface | Service name |
androidBridge | nsIAndroidBridge | 1 |
appinfo | nsIXULAppInfo nsIXULRuntime | Application information service |
appShell | nsIAppShellService | Application shell service |
blocklist | nsIBlocklistService | Blocklist service |
cache | nsICacheService | Cache service |
cache2 | nsICacheStorageService | Cache storage service |
clipboard | nsIClipboard | Clipboard |
console | nsIConsoleService | Error console service |
contentPrefs | nsIContentPrefService | Content Preferences service |
cookies | nsICookieManager2 | Cookie Manager 2 service |
cpmm | nsIMessageSender | Child process message manager4 |
crashmanager | CrashManager.jsm | |
dirsvc | nsIDirectoryService nsIProperties | Directory service |
domStorageManager | nsIDOMStorageManager | DOM Storage Manager |
DOMRequest | nsIDOMRequestService | DOMRequest service |
downloads | nsIDownloadManager | Download manager |
droppedLinkHandler | nsIDroppedLinkHandler | Dropped link handler service |
els | nsIEventListenerService | Event listener service |
eTLD | nsIEffectiveTLDService | EffectiveTLD service |
focus | nsIFocusManager | Focus manager |
io | nsIIOService nsIIOService2 | I/O Service |
locale | nsILocaleService | Locale service |
logins | nsILoginManager | Password Manager service |
metro | nsIWinMetroUtils | 2 |
mm | nsIMessageBroadcaster nsIFrameScriptLoader | Global frame message manager3 |
obs | nsIObserverService | Observer service |
perms | nsIPermissionManager | Permission manager service |
ppmm | nsIMessageBroadcaster nsIProcessScriptLoader | Global parent process message manager3 |
prefs | nsIPrefBranch nsIPrefBranch2 nsIPrefService | Preferences service |
prompt | nsIPromptService | Prompt service |
scriptloader | mozIJSSubScriptLoader | JavaScript subscript loader service |
scriptSecurityManager | nsIScriptSecurityManager | Script security manager |
search | nsIBrowserSearchService | Browser search service |
startup | nsIAppStartup | Application startup service |
storage | mozIStorageService | Storage API service |
strings | nsIStringBundleService | String bundle service |
sysinfo | nsIPropertyBag2 | System info service |
telemetry | nsITelemetry | Telemetry service |
tm | nsIThreadManager | Thread Manager service |
uriFixup | nsIURIFixup | URI Fixup service |
urlFormatter | nsIURLFormatter | URL Formatter service |
vc | nsIVersionComparator | Version comparator service |
wm | nsIWindowMediator | Window mediator service |
ww | nsIWindowWatcher | Window watcher service |
1 Mobile only
2 Windows only
3 Main process only
4 Child process only
See also
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论