Services.jsm

Table of contents

  1. 1. Provided service getters
  2. 2. See also
Table of contents
  1. 1. Provided service getters
  2. 2. See also

Introduced in Gecko 2

(Firefox 4 / Thunderbird 3.3 / SeaMonkey 2.1)

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:

Components.utils.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
appinfo nsIXULAppInfo
nsIXULRuntime
Application information service
console nsIConsoleService Error console service
contentPrefs nsIContentPrefService

Content Preferences service

cookies nsICookieManager2

Cookie Manager 2 service

dirsvc nsIDirectoryService
nsIProperties
Directory service
droppedLinkHandler nsIDroppedLinkHandler Dropped link handler service
eTLD nsIEffectiveTLDService

EffectiveTLD service

io nsIIOService
nsIIOService2
I/O Service
locale nsILocaleService Locale service
logins nsILoginManager

Password Manager service

obs nsIObserverService Observer service
perms nsIPermissionManager Permission manager service
prefs nsIPrefBranch
nsIPrefBranch2
nsIPrefService
Preferences service
prompt nsIPromptService Prompt service
scriptloader mozIJSSubScriptLoader JavaScript subscript loader service
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
urlFormatter nsIURLFormatter

URL Formatter service

vc nsIVersionComparator Version comparator service
wm nsIWindowMediator Window mediator service
ww nsIWindowWatcher Window watcher service
DOMRequest nsIDOMRequestService DOMRequest service
cpmm nsIFrameMessageManager Child Process Message Manager
ppmm nsIFrameMessageManager Parent Process Message Manager

¹Not present in Thunderbird or SeaMonkey.

Tags (7)

Edit tags

Attachments (0)

 

Attach file