Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | this.EXPORTED_SYMBOLS = ["Services"]; |
michael@0 | 6 | |
michael@0 | 7 | const Ci = Components.interfaces; |
michael@0 | 8 | const Cc = Components.classes; |
michael@0 | 9 | const Cr = Components.results; |
michael@0 | 10 | |
michael@0 | 11 | Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); |
michael@0 | 12 | |
michael@0 | 13 | this.Services = {}; |
michael@0 | 14 | |
michael@0 | 15 | XPCOMUtils.defineLazyGetter(Services, "prefs", function () { |
michael@0 | 16 | return Cc["@mozilla.org/preferences-service;1"] |
michael@0 | 17 | .getService(Ci.nsIPrefService) |
michael@0 | 18 | .QueryInterface(Ci.nsIPrefBranch); |
michael@0 | 19 | }); |
michael@0 | 20 | |
michael@0 | 21 | XPCOMUtils.defineLazyGetter(Services, "appinfo", function () { |
michael@0 | 22 | let appinfo = Cc["@mozilla.org/xre/app-info;1"] |
michael@0 | 23 | .getService(Ci.nsIXULRuntime); |
michael@0 | 24 | try { |
michael@0 | 25 | appinfo.QueryInterface(Ci.nsIXULAppInfo); |
michael@0 | 26 | } catch (ex if ex instanceof Components.Exception && |
michael@0 | 27 | ex.result == Cr.NS_NOINTERFACE) { |
michael@0 | 28 | // Not all applications implement nsIXULAppInfo (e.g. xpcshell doesn't). |
michael@0 | 29 | } |
michael@0 | 30 | return appinfo; |
michael@0 | 31 | }); |
michael@0 | 32 | |
michael@0 | 33 | XPCOMUtils.defineLazyGetter(Services, "dirsvc", function () { |
michael@0 | 34 | return Cc["@mozilla.org/file/directory_service;1"] |
michael@0 | 35 | .getService(Ci.nsIDirectoryService) |
michael@0 | 36 | .QueryInterface(Ci.nsIProperties); |
michael@0 | 37 | }); |
michael@0 | 38 | |
michael@0 | 39 | #ifdef MOZ_CRASHREPORTER |
michael@0 | 40 | XPCOMUtils.defineLazyGetter(Services, "crashmanager", () => { |
michael@0 | 41 | let ns = {}; |
michael@0 | 42 | Components.utils.import("resource://gre/modules/CrashManager.jsm", ns); |
michael@0 | 43 | |
michael@0 | 44 | return ns.CrashManager.Singleton; |
michael@0 | 45 | }); |
michael@0 | 46 | #endif |
michael@0 | 47 | |
michael@0 | 48 | let initTable = [ |
michael@0 | 49 | #ifdef MOZ_WIDGET_ANDROID |
michael@0 | 50 | ["androidBridge", "@mozilla.org/android/bridge;1", "nsIAndroidBridge"], |
michael@0 | 51 | #endif |
michael@0 | 52 | ["appShell", "@mozilla.org/appshell/appShellService;1", "nsIAppShellService"], |
michael@0 | 53 | ["cache", "@mozilla.org/network/cache-service;1", "nsICacheService"], |
michael@0 | 54 | ["cache2", "@mozilla.org/netwerk/cache-storage-service;1", "nsICacheStorageService"], |
michael@0 | 55 | ["console", "@mozilla.org/consoleservice;1", "nsIConsoleService"], |
michael@0 | 56 | ["contentPrefs", "@mozilla.org/content-pref/service;1", "nsIContentPrefService"], |
michael@0 | 57 | ["cookies", "@mozilla.org/cookiemanager;1", "nsICookieManager2"], |
michael@0 | 58 | ["downloads", "@mozilla.org/download-manager;1", "nsIDownloadManager"], |
michael@0 | 59 | ["droppedLinkHandler", "@mozilla.org/content/dropped-link-handler;1", "nsIDroppedLinkHandler"], |
michael@0 | 60 | ["eTLD", "@mozilla.org/network/effective-tld-service;1", "nsIEffectiveTLDService"], |
michael@0 | 61 | ["io", "@mozilla.org/network/io-service;1", "nsIIOService2"], |
michael@0 | 62 | ["locale", "@mozilla.org/intl/nslocaleservice;1", "nsILocaleService"], |
michael@0 | 63 | ["logins", "@mozilla.org/login-manager;1", "nsILoginManager"], |
michael@0 | 64 | ["obs", "@mozilla.org/observer-service;1", "nsIObserverService"], |
michael@0 | 65 | ["perms", "@mozilla.org/permissionmanager;1", "nsIPermissionManager"], |
michael@0 | 66 | ["prompt", "@mozilla.org/embedcomp/prompt-service;1", "nsIPromptService"], |
michael@0 | 67 | ["scriptloader", "@mozilla.org/moz/jssubscript-loader;1", "mozIJSSubScriptLoader"], |
michael@0 | 68 | ["scriptSecurityManager", "@mozilla.org/scriptsecuritymanager;1", "nsIScriptSecurityManager"], |
michael@0 | 69 | #ifdef MOZ_TOOLKIT_SEARCH |
michael@0 | 70 | ["search", "@mozilla.org/browser/search-service;1", "nsIBrowserSearchService"], |
michael@0 | 71 | #endif |
michael@0 | 72 | ["storage", "@mozilla.org/storage/service;1", "mozIStorageService"], |
michael@0 | 73 | ["domStorageManager", "@mozilla.org/dom/localStorage-manager;1", "nsIDOMStorageManager"], |
michael@0 | 74 | ["strings", "@mozilla.org/intl/stringbundle;1", "nsIStringBundleService"], |
michael@0 | 75 | ["telemetry", "@mozilla.org/base/telemetry;1", "nsITelemetry"], |
michael@0 | 76 | ["tm", "@mozilla.org/thread-manager;1", "nsIThreadManager"], |
michael@0 | 77 | ["urlFormatter", "@mozilla.org/toolkit/URLFormatterService;1", "nsIURLFormatter"], |
michael@0 | 78 | ["vc", "@mozilla.org/xpcom/version-comparator;1", "nsIVersionComparator"], |
michael@0 | 79 | ["wm", "@mozilla.org/appshell/window-mediator;1", "nsIWindowMediator"], |
michael@0 | 80 | ["ww", "@mozilla.org/embedcomp/window-watcher;1", "nsIWindowWatcher"], |
michael@0 | 81 | ["startup", "@mozilla.org/toolkit/app-startup;1", "nsIAppStartup"], |
michael@0 | 82 | ["sysinfo", "@mozilla.org/system-info;1", "nsIPropertyBag2"], |
michael@0 | 83 | ["clipboard", "@mozilla.org/widget/clipboard;1", "nsIClipboard"], |
michael@0 | 84 | ["DOMRequest", "@mozilla.org/dom/dom-request-service;1", "nsIDOMRequestService"], |
michael@0 | 85 | ["focus", "@mozilla.org/focus-manager;1", "nsIFocusManager"], |
michael@0 | 86 | ["uriFixup", "@mozilla.org/docshell/urifixup;1", "nsIURIFixup"], |
michael@0 | 87 | ["blocklist", "@mozilla.org/extensions/blocklist;1", "nsIBlocklistService"], |
michael@0 | 88 | #ifdef XP_WIN |
michael@0 | 89 | #ifdef MOZ_METRO |
michael@0 | 90 | ["metro", "@mozilla.org/windows-metroutils;1", "nsIWinMetroUtils"], |
michael@0 | 91 | #endif |
michael@0 | 92 | #endif |
michael@0 | 93 | ]; |
michael@0 | 94 | |
michael@0 | 95 | initTable.forEach(function ([name, contract, intf]) |
michael@0 | 96 | XPCOMUtils.defineLazyServiceGetter(Services, name, contract, intf)); |
michael@0 | 97 | |
michael@0 | 98 | initTable = undefined; |