1 /* ***** BEGIN LICENSE BLOCK ***** 2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 3 * 4 * The contents of this file are subject to the Mozilla Public License Version 5 * 1.1 (the "License"); you may not use this file except in compliance with 6 * the License. You may obtain a copy of the License at 7 * http://www.mozilla.org/MPL/ 8 * 9 * Software distributed under the License is distributed on an "AS IS" basis, 10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 11 * for the specific language governing rights and limitations under the 12 * License. 13 * 14 * The Original Code is MozMill Test code. 15 * 16 * The Initial Developer of the Original Code is the Mozilla Foundation. 17 * Portions created by the Initial Developer are Copyright (C) 2011 18 * the Initial Developer. All Rights Reserved. 19 * 20 * Contributor(s): 21 * Henrik Skupin <mail@hskupin.info> (Original Author) 22 * 23 * Alternatively, the contents of this file may be used under the terms of 24 * either the GNU General Public License Version 2 or later (the "GPL"), or 25 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 26 * in which case the provisions of the GPL or the LGPL are applicable instead 27 * of those above. If you wish to allow use of your version of this file only 28 * under the terms of either the GPL or the LGPL, and not to allow others to 29 * use your version of this file under the terms of the MPL, indicate your 30 * decision by deleting the provisions above and replace them with the notice 31 * and other provisions required by the GPL or the LGPL. If you do not delete 32 * the provisions above, a recipient may use your version of this file under 33 * the terms of any one of the MPL, the GPL or the LGPL. 34 * 35 * ***** END LICENSE BLOCK ***** */ 36 37 38 /** 39 * @name services 40 * @namespace Defines wrapper methods for back-end services 41 */ 42 var services = exports; 43 44 45 // Import global Javascript modules offered by Firefox 46 Components.utils.import('resource://gre/modules/Services.jsm'); 47 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); 48 49 50 /**#@+ 51 @memberOf services 52 */ 53 54 /** 55 * Service for application related properties 56 * 57 * @see <a href="http://mxr.mozilla.org/mozilla-central/source/xpcom/system/nsIXULAppInfo.idl">nsIXULAppInfo</a> 58 * @see <a href="http://mxr.mozilla.org/mozilla-central/source/xpcom/system/nsIXULRuntime.idl">nsIXULRuntime</a> 59 */ 60 services.appinfo = Services.appinfo; 61 62 63 /** 64 * Service for handling bookmarks 65 * 66 * @see <a href="http://mxr.mozilla.org/mozilla-central/source/toolkit/components/places/public/nsINavBookmarksService.idl">nsINavBookmarksService</a> 67 */ 68 XPCOMUtils.defineLazyGetter(services, "bookmarks", function () { 69 return Cc["@mozilla.org/browser/nav-bookmarks-service;1"]. 70 getService(Ci.nsINavBookmarksService); 71 }); 72 73 74 /** 75 * Service for handling the browser's global history 76 * 77 * @see <a href="http://mxr.mozilla.org/mozilla-central/source/toolkit/components/places/public/nsIBrowserHistory.idl">nsIBrowserHistory</a> 78 */ 79 XPCOMUtils.defineLazyGetter(services, "browserHistory", function () { 80 return Cc["@mozilla.org/browser/nav-history-service;1"]. 81 getService(Ci.nsIBrowserHistory); 82 }); 83 84 85 /** 86 * Service to access the clipboard 87 * 88 * @see <a href="http://mxr.mozilla.org/mozilla-central/source/widget/public/nsIClipboardHelper.idl">nsIClipboardHelper</a> 89 */ 90 XPCOMUtils.defineLazyGetter(services, "clipboard", function () { 91 return Cc["@mozilla.org/widget/clipboardhelper;1"]. 92 getService(Ci.nsIClipboardHelper); 93 }); 94 95 96 /** 97 * Service to access the Error Console 98 * 99 * @see <a href="http://mxr.mozilla.org/mozilla-central/source/xpcom/base/nsIConsoleService.idl">nsIConsoleService</a> 100 */ 101 services.console = Services.console; 102 103 104 /** 105 * Service for handling content related preferences 106 * 107 * @see <a href="http://mxr.mozilla.org/mozilla-central/source/dom/interfaces/base/nsIContentPrefService.idl">nsIContentPrefService</a> 108 */ 109 services.contentPrefs = Services.contentPrefs; 110 111 112 /** 113 * Service for handling cookies 114 * 115 * @see <a href="http://mxr.mozilla.org/mozilla-central/source/netwerk/cookie/nsICookieManager2.idl">nsICookieManager2</a> 116 */ 117 XPCOMUtils.defineLazyGetter(services, "cookies", function () { 118 return Cc["@mozilla.org/cookiemanager;1"]. 119 getService(Ci.nsICookieManager2); 120 }); 121 122 123 /** 124 * Service for handling files and directories 125 * 126 * @see <a href="http://mxr.mozilla.org/mozilla-central/source/xpcom/io/nsIDirectoryService.idl">nsIDirectoryService</a> 127 */ 128 services.dirsvc = Services.dirsvc; 129 130 131 /** 132 * Service for handling downloads 133 * 134 * @see <a href="http://mxr.mozilla.org/mozilla-central/source/toolkit/components/downloads/public/nsIDownloadManager.idl">nsIDownloadManager</a> 135 */ 136 XPCOMUtils.defineLazyGetter(services, "downloads", function () { 137 return Cc["@mozilla.org/download-manager;1"]. 138 getService(Ci.nsIDownloadManager); 139 }); 140 141 142 /** 143 * Service for handling data of certificates 144 * 145 * @see <a href="http://mxr.mozilla.org/mozilla-central/source/netwerk/dns/nsIEffectiveTLDService.idl">nsIEffectiveTLDService</a> 146 */ 147 services.eTLD = Services.eTLD; 148 149 150 /** 151 * Service for handling the history of form elements 152 * 153 * @see <a href="http://mxr.mozilla.org/mozilla-central/source/toolkit/components/satchel/public/nsIFormHistory.idl">nsIFormHistory2</a> 154 */ 155 XPCOMUtils.defineLazyGetter(services, "forms", function () { 156 return Cc["@mozilla.org/satchel/form-history;1"]. 157 getService(Ci.nsIFormHistory2); 158 }); 159 160 161 /** 162 * Service to handle network related I/O operations 163 * 164 * @see <a href="http://mxr.mozilla.org/mozilla-central/source/netwerk/base/public/nsIIOService.idl">nsIIOService</a> 165 * @see <a href="http://mxr.mozilla.org/mozilla-central/source/netwerk/base/public/nsIIOService2.idl">nsIIOService2</a> 166 */ 167 services.io = Services.io; 168 169 170 /** 171 * Service to handle the Places history 172 * 173 * @see <a href="http://mxr.mozilla.org/mozilla-central/source/toolkit/components/places/public/nsINavHistoryService.idl">nsINavHistoryService</a> 174 */ 175 XPCOMUtils.defineLazyGetter(services, "history", function () { 176 return Cc["@mozilla.org/browser/nav-history-service;1"]. 177 getService(Ci.nsINavHistoryService); 178 }); 179 180 181 /** 182 * Service to handle locale related information 183 * 184 * @see <a href="http://mxr.mozilla.org/mozilla-central/source/intl/locale/idl/nsILocaleService.idl">nsILocaleService</a> 185 */ 186 services.locale = Services.locale; 187 188 189 /** 190 * Service to handle the password manager 191 * 192 * @see <a href="http://mxr.mozilla.org/mozilla-central/source/toolkit/components/passwordmgr/public/nsILoginManager.idl">nsILoginManager</a> 193 */ 194 XPCOMUtils.defineLazyGetter(services, "logins", function () { 195 return Cc["@mozilla.org/login-manager;1"]. 196 getService(Ci.nsILoginManager); 197 }); 198 199 200 /** 201 * Service to handle the observer service 202 * 203 * @see <a href="http://mxr.mozilla.org/mozilla-central/source/xpcom/ds/nsIObserverService.idl">nsIObserverService</a> 204 */ 205 services.obs = Services.obs; 206 207 208 /** 209 * Service to handle Private Browsing 210 * 211 * @see <a href="http://mxr.mozilla.org/mozilla-central/source/netwerk/base/public/nsIPrivateBrowsingService.idl">nsIPrivateBrowsingService</a> 212 */ 213 XPCOMUtils.defineLazyGetter(services, "pbs", function () { 214 return Cc["@mozilla.org/privatebrowsing;1"]. 215 getService(Ci.nsIPrivateBrowsingService); 216 }); 217 218 219 /** 220 * Service to access the permission manager on a site-by-site basis 221 * 222 * @see <a href="http://mxr.mozilla.org/mozilla-central/source/netwerk/base/public/nsIPermissionManager.idl">nsIPermissionManager</a> 223 */ 224 services.perms = Services.perms; 225 226 227 /** 228 * Service to access preferences 229 * 230 * @see <a href="http://mxr.mozilla.org/mozilla-central/source/modules/libpref/public/nsIPrefService.idl">nsIPrefService</a> 231 */ 232 // XXX: We can't use the native prefs service yet because it QI to nsIPrefBranch2 233 // and our preferences module doesn't support it 234 // services.prefs = Services.prefs; 235 XPCOMUtils.defineLazyGetter(services, "prefs", function () { 236 return Cc["@mozilla.org/preferences-service;1"]. 237 getService(Ci.nsIPrefService); 238 }); 239 240 241 /** 242 * Service to handle prompts 243 * 244 * @see <a href="http://mxr.mozilla.org/mozilla-central/source/embedding/components/windowwatcher/public/nsIPromptService.idl">nsIPromptService</a> 245 */ 246 services.prompt = Services.prompt; 247 248 249 /** 250 * Service to handle the browser's search feature 251 * 252 * @see <a href="http://mxr.mozilla.org/mozilla-central/source/netwerk/base/public/nsIBrowserSearchService.idl">nsIBrowserSearchService</a> 253 */ 254 services.search = Services.search; 255 256 257 /** 258 * Service to handle sessions 259 * 260 * @see <a href="http://mxr.mozilla.org/mozilla-central/source/browser/components/sessionstore/nsISessionStore.idl">nsISessionStore</a> 261 */ 262 XPCOMUtils.defineLazyGetter(services, "session", function () { 263 return Cc["@mozilla.org/browser/sessionstore;1"]. 264 getService(Ci.nsISessionStore); 265 }); 266 267 268 /** 269 * Service to access the storage service 270 * 271 * @see <a href="http://mxr.mozilla.org/mozilla-central/source/storage/public/mozIStorageService.idl">mozIStorageService</a> 272 */ 273 services.storage = Services.storage; 274 275 276 /** 277 * Service to handle strings 278 * 279 * @see <a href="http://mxr.mozilla.org/mozilla-central/source/intl/strres/public/nsIStringBundle.idl">nsIStringBundleService</a> 280 */ 281 services.strings = Services.strings; 282 283 284 /** 285 * Service to handle formatting of URLs based on application properties 286 * 287 * @see <a href="http://mxr.mozilla.org/mozilla-central/source/toolkit/components/urlformatter/public/nsIURLFormatter.idl">nsIURLFormatter</a> 288 */ 289 services.urlFormatter = Services.urlFormatter; 290 291 292 /** 293 * Service to compare application versions 294 * 295 * @see <a href="http://mxr.mozilla.org/mozilla-central/source/xpcom/base/nsIVersionComparator.idl">nsIVersionComparator</a> 296 */ 297 services.vc = Services.vc; 298 299 300 /** 301 * Service to handle windows 302 * 303 * @see <a href="http://mxr.mozilla.org/mozilla-central/source/xpfe/appshell/public/nsIWindowMediator.idl">nsIWindowMediator</a> 304 */ 305 services.wm = Services.wm; 306 307 308 /** 309 * Service to operate on windows 310 * 311 * @see <a href="http://mxr.mozilla.org/mozilla-central/source/embedding/components/windowwatcher/public/nsIWindowWatcher.idl">nsIWindowWatcher</a> 312 */ 313 services.ww = Services.ww; 314