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 accessorService interfaceService name
androidBridgensIAndroidBridge1
appinfonsIXULAppInfo
nsIXULRuntime
Application information service
appShellnsIAppShellServiceApplication shell service
blocklistnsIBlocklistServiceBlocklist service
cachensICacheServiceCache service
cache2nsICacheStorageServiceCache storage service
clipboardnsIClipboardClipboard
consolensIConsoleServiceError console service
contentPrefsnsIContentPrefServiceContent Preferences service
cookiesnsICookieManager2Cookie Manager 2 service
cpmmnsIMessageSenderChild process message manager4
crashmanagerCrashManager.jsm 
dirsvcnsIDirectoryService
nsIProperties
Directory service
domStorageManagernsIDOMStorageManagerDOM Storage Manager
DOMRequestnsIDOMRequestServiceDOMRequest service
downloadsnsIDownloadManagerDownload manager
droppedLinkHandlernsIDroppedLinkHandlerDropped link handler service
elsnsIEventListenerServiceEvent listener service
eTLDnsIEffectiveTLDServiceEffectiveTLD service
focusnsIFocusManagerFocus manager
ionsIIOService
nsIIOService2
I/O Service
localensILocaleServiceLocale service
loginsnsILoginManagerPassword Manager service
metronsIWinMetroUtils2
mmnsIMessageBroadcaster
nsIFrameScriptLoader
Global frame message manager3
obsnsIObserverServiceObserver service
permsnsIPermissionManagerPermission manager service
ppmmnsIMessageBroadcaster
nsIProcessScriptLoader
Global parent process message manager3
prefsnsIPrefBranch
nsIPrefBranch2
nsIPrefService
Preferences service
promptnsIPromptServicePrompt service
scriptloadermozIJSSubScriptLoaderJavaScript subscript loader service
scriptSecurityManagernsIScriptSecurityManagerScript security manager
searchnsIBrowserSearchServiceBrowser search service
startupnsIAppStartupApplication startup service
storagemozIStorageServiceStorage API service
stringsnsIStringBundleServiceString bundle service
sysinfonsIPropertyBag2System info service
telemetrynsITelemetryTelemetry service
tmnsIThreadManagerThread Manager service
uriFixupnsIURIFixupURI Fixup service
urlFormatternsIURLFormatterURL Formatter service
vcnsIVersionComparatorVersion comparator service
wmnsIWindowMediatorWindow mediator service
wwnsIWindowWatcherWindow watcher service

1 Mobile only
2 Windows only
3 Main process only
4 Child process only

See also

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:109 次

字数:12639

最后编辑:7年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文