Bug 1250639: Remove the nsIPrincipal shim for the older API style. r=rhelmer
authorDave Townsend <dtownsend@oxymoronical.com>
Tue, 23 Feb 2016 12:11:37 -0800
changeset 321582 5f2f4297e6bd18edc3e8811f178b63bbf8acd323
parent 321581 e176668613b9b466e911368a2e2c093c394ecbe5
child 321583 ce33e421e1da6a35c0ebe6c0a43401d13495f05f
push id5913
push userjlund@mozilla.com
push dateMon, 25 Apr 2016 16:57:49 +0000
treeherdermozilla-beta@dcaf0a6fa115 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrhelmer
bugs1250639
milestone47.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1250639: Remove the nsIPrincipal shim for the older API style. r=rhelmer MozReview-Commit-ID: DyX66KlOLCC
toolkit/mozapps/extensions/AddonManager.jsm
--- a/toolkit/mozapps/extensions/AddonManager.jsm
+++ b/toolkit/mozapps/extensions/AddonManager.jsm
@@ -303,47 +303,16 @@ function getLocale() {
     return Services.prefs.getCharPref(PREF_SELECTED_LOCALE);
   }
   catch (e) { }
 
   return "en-US";
 }
 
 /**
- * Previously the APIs for installing add-ons from webpages accepted nsIURI
- * arguments for the installing page. They now take an nsIPrincipal but for now
- * maintain backwards compatibility by converting an nsIURI to an nsIPrincipal.
- *
- * @param  aPrincipalOrURI
- *         The argument passed to the API function. Can be null, an nsIURI or
- *         an nsIPrincipal.
- * @return an nsIPrincipal.
- */
-function ensurePrincipal(principalOrURI) {
-  if (principalOrURI instanceof Ci.nsIPrincipal)
-    return principalOrURI;
-
-  logger.warn("Deprecated API call, please pass a non-null nsIPrincipal instead of an nsIURI");
-
-  // Previously a null installing URI meant allowing the install regardless.
-  if (!principalOrURI) {
-    return Services.scriptSecurityManager.getSystemPrincipal();
-  }
-
-  if (principalOrURI instanceof Ci.nsIURI) {
-    return Services.scriptSecurityManager.createCodebasePrincipal(principalOrURI, {
-      inBrowser: true
-    });
-  }
-
-  // Just return whatever we have, the API method will log an error about it.
-  return principalOrURI;
-}
-
-/**
  * A helper class to repeatedly call a listener with each object in an array
  * optionally checking whether the object has a method in it.
  *
  * @param  aObjects
  *         The array of objects to iterate through
  * @param  aMethod
  *         An optional method name, if not null any objects without this method
  *         will not be passed to the listener
@@ -3210,24 +3179,23 @@ this.AddonManager = {
     return AddonManagerInternal.mapURIToAddonID(aURI);
   },
 
   isInstallEnabled: function(aType) {
     return AddonManagerInternal.isInstallEnabled(aType);
   },
 
   isInstallAllowed: function(aType, aInstallingPrincipal) {
-    return AddonManagerInternal.isInstallAllowed(aType, ensurePrincipal(aInstallingPrincipal));
+    return AddonManagerInternal.isInstallAllowed(aType, aInstallingPrincipal);
   },
 
-  installAddonsFromWebpage: function(aType, aBrowser,
-                                                                 aInstallingPrincipal,
-                                                                 aInstalls) {
+  installAddonsFromWebpage: function(aType, aBrowser, aInstallingPrincipal,
+                                     aInstalls) {
     AddonManagerInternal.installAddonsFromWebpage(aType, aBrowser,
-                                                  ensurePrincipal(aInstallingPrincipal),
+                                                  aInstallingPrincipal,
                                                   aInstalls);
   },
 
   installTemporaryAddon: function(aDirectory) {
     return AddonManagerInternal.installTemporaryAddon(aDirectory);
   },
 
   addManagerListener: function(aListener) {