Bug 548646 - Permission manager getter in Services.jsm should be more descriptive. r=gavin
authorJustin Dolske <dolske>
Thu, 25 Feb 2010 14:13:00 -0800
changeset 38713 633a33a635f38a9c3ffa5e5bbf43912115c036ab
parent 38712 2dc00d4b379a66f0830a8af40341de5354c7c3c2
child 38714 dd4ac841e90b25e8ff551a9cb24244d479c9c23e
push id11817
push userjdolske@mozilla.com
push dateThu, 25 Feb 2010 23:00:25 +0000
treeherderautoland@633a33a635f3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgavin
bugs548646
milestone1.9.3a2pre
Bug 548646 - Permission manager getter in Services.jsm should be more descriptive. r=gavin
browser/base/content/browser.js
toolkit/content/Services.jsm
toolkit/content/tests/browser/browser_Services.js
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -387,17 +387,17 @@ const gPopupBlockerObserver = {
       // Record the fact that we've reported this blocked popup, so we don't
       // show it again.
       gBrowser.pageReport.reported = true;
     }
   },
 
   toggleAllowPopupsForSite: function (aEvent)
   {
-    var pm = Services.pm;
+    var pm = Services.perms;
     var shouldBlock = aEvent.target.getAttribute("block") == "true";
     var perm = shouldBlock ? pm.DENY_ACTION : pm.ALLOW_ACTION;
     pm.add(gBrowser.currentURI, "popup", perm);
 
     gBrowser.getNotificationBox().removeCurrentNotification();
   },
 
   fillPopupList: function (aEvent)
@@ -411,17 +411,17 @@ const gPopupBlockerObserver = {
     //          also back out the fix for bug 343772 where
     //          nsGlobalWindow::CheckOpenAllow() was changed to also
     //          check if the top window's location is whitelisted.
     var uri = gBrowser.currentURI;
     var blockedPopupAllowSite = document.getElementById("blockedPopupAllowSite");
     try {
       blockedPopupAllowSite.removeAttribute("hidden");
 
-      var pm = Services.pm;
+      var pm = Services.perms;
       if (pm.testPermission(uri, "popup") == pm.ALLOW_ACTION) {
         // Offer an item to block popups for this site, if a whitelist entry exists
         // already for it.
         let blockString = gNavigatorBundle.getFormattedString("popupBlock", [uri.host]);
         blockedPopupAllowSite.setAttribute("label", blockString);
         blockedPopupAllowSite.setAttribute("block", "true");
       }
       else {
@@ -5525,18 +5525,18 @@ var OfflineApps = {
 
       notificationBox.appendNotification(message, "offline-app-usage",
                                          "chrome://browser/skin/Info.png",
                                          priority, buttons);
     }
 
     // Now that we've warned once, prevent the warning from showing up
     // again.
-    Services.pm.add(aURI, "offline-app",
-                    Ci.nsIOfflineCacheUpdateService.ALLOW_NO_WARN);
+    Services.perms.add(aURI, "offline-app",
+                       Ci.nsIOfflineCacheUpdateService.ALLOW_NO_WARN);
   },
 
   // XXX: duplicated in preferences/advanced.js
   _getOfflineAppUsage: function (host, groups)
   {
     var cacheService = Cc["@mozilla.org/network/application-cache-service;1"].
                        getService(Ci.nsIApplicationCacheService);
     if (!groups)
@@ -5555,17 +5555,17 @@ var OfflineApps = {
                          getService(Ci.nsIDOMStorageManager);
     usage += storageManager.getUsage(host);
 
     return usage;
   },
 
   _checkUsage: function(aURI) {
     // if the user has already allowed excessive usage, don't bother checking
-    if (Services.pm.testExactPermission(aURI, "offline-app") !=
+    if (Services.perms.testExactPermission(aURI, "offline-app") !=
         Ci.nsIOfflineCacheUpdateService.ALLOW_NO_WARN) {
       var usage = this._getOfflineAppUsage(aURI.asciiHost);
       var warnQuota = gPrefService.getIntPref("offline-apps.quota.warn");
       if (usage >= warnQuota * 1024) {
         return true;
       }
     }
 
@@ -5579,17 +5579,17 @@ var OfflineApps = {
 
     var browserWindow = this._getBrowserWindowForContentWindow(aContentWindow);
     var browser = this._getBrowserForContentWindow(browserWindow,
                                                    aContentWindow);
 
     var currentURI = aContentWindow.document.documentURIObject;
 
     // don't bother showing UI if the user has already made a decision
-    if (Services.pm.testExactPermission(currentURI, "offline-app") != Services.pm.UNKNOWN_ACTION)
+    if (Services.perms.testExactPermission(currentURI, "offline-app") != Services.perms.UNKNOWN_ACTION)
       return;
 
     try {
       if (gPrefService.getBoolPref("offline-apps.allow_by_default")) {
         // all pages can use offline capabilities, no need to ask the user
         return;
       }
     } catch(e) {
@@ -5633,26 +5633,26 @@ var OfflineApps = {
         notificationBox.appendNotification(message, notificationID,
                                            "chrome://browser/skin/Info.png",
                                            priority, buttons);
       notification.documents = [ aContentWindow.document ];
     }
   },
 
   allowSite: function(aDocument) {
-    Services.pm.add(aDocument.documentURIObject, "offline-app", Services.pm.ALLOW_ACTION);
+    Services.perms.add(aDocument.documentURIObject, "offline-app", Services.perms.ALLOW_ACTION);
 
     // When a site is enabled while loading, manifest resources will
     // start fetching immediately.  This one time we need to do it
     // ourselves.
     this._startFetching(aDocument);
   },
 
   disallowSite: function(aDocument) {
-    Services.pm.add(aDocument.documentURIObject, "offline-app", Services.pm.DENY_ACTION);
+    Services.perms.add(aDocument.documentURIObject, "offline-app", Services.perms.DENY_ACTION);
   },
 
   manage: function() {
     openAdvancedPreferences("networkTab");
   },
 
   _startFetching: function(aDocument) {
     if (!aDocument.documentElement)
@@ -7446,17 +7446,17 @@ var LightWeightThemeWebInstaller = {
     this._previewWindow.removeEventListener("pagehide", this, true);
     this._previewWindow = null;
     gBrowser.tabContainer.removeEventListener("TabSelect", this, false);
 
     this._manager.resetPreview();
   },
 
   _isAllowed: function (node) {
-    var pm = Services.pm;
+    var pm = Services.perms;
 
     var prefs = [["xpinstall.whitelist.add", pm.ALLOW_ACTION],
                  ["xpinstall.whitelist.add.36", pm.ALLOW_ACTION],
                  ["xpinstall.blacklist.add", pm.DENY_ACTION]];
     prefs.forEach(function ([pref, permission]) {
       try {
         var hosts = gPrefService.getCharPref(pref);
       } catch (e) {}
--- a/toolkit/content/Services.jsm
+++ b/toolkit/content/Services.jsm
@@ -52,17 +52,17 @@ XPCOMUtils.defineLazyGetter(Services, "p
 XPCOMUtils.defineLazyServiceGetter(Services, "wm",
                                    "@mozilla.org/appshell/window-mediator;1",
                                    "nsIWindowMediator");
 
 XPCOMUtils.defineLazyServiceGetter(Services, "obs",
                                    "@mozilla.org/observer-service;1",
                                    "nsIObserverService");
 
-XPCOMUtils.defineLazyServiceGetter(Services, "pm",
+XPCOMUtils.defineLazyServiceGetter(Services, "perms",
                                    "@mozilla.org/permissionmanager;1",
                                    "nsIPermissionManager");
 
 XPCOMUtils.defineLazyServiceGetter(Services, "io",
                                    "@mozilla.org/network/io-service;1",
                                    "nsIIOService2");
 
 XPCOMUtils.defineLazyServiceGetter(Services, "prompt",
--- a/toolkit/content/tests/browser/browser_Services.js
+++ b/toolkit/content/tests/browser/browser_Services.js
@@ -39,14 +39,14 @@ function test() {
   ok(Services, "Services object exists");
   checkServices();
 }
 
 function checkServices() {
   ok(Services.prefs instanceof Ci.nsIPrefBranch2, "Services.prefs is an nsIPrefBranch2");
   ok(Services.prefs instanceof Ci.nsIPrefService, "Services.prefs is an nsIPrefService");
   ok(Services.wm instanceof Ci.nsIWindowMediator, "Services.wm is an nsIWindowMediator");
-  ok(Services.pm instanceof Ci.nsIPermissionManager, "Services.pm is an nsIPermissionManager");
+  ok(Services.perms instanceof Ci.nsIPermissionManager, "Services.perms is an nsIPermissionManager");
   ok(Services.io instanceof Ci.nsIIOService, "Services.io is an nsIIOService");
   ok(Services.io instanceof Ci.nsIIOService2, "Services.io is an nsIIOService2");
   ok(Services.prompt instanceof Ci.nsIPromptService, "Services.prompt is an nsIPromptService");
   ok(Services.search instanceof Ci.nsIBrowserSearchService, "Services.search is an nsIBrowserSearchService");
 }