Bug 774585: Rename getCodebasePrincipal to getSimpleCodebasePrincipal since the behavior has semantically changed. r=mounir
authorJonas Sicking <jonas@sicking.cc>
Sat, 21 Jul 2012 00:29:40 -0700
changeset 100024 2328647c5d6dd4135a62c1bb98b3e4d233e1d0d2
parent 100023 c3972de3f4a56b467a31a843a3be7c3670de25a0
child 100025 c5cd832d82ef8a7c2b7c18471915909647f79166
push id12302
push usersicking@mozilla.com
push dateSat, 21 Jul 2012 07:29:34 +0000
treeherdermozilla-inbound@c5cd832d82ef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmounir
bugs774585
milestone17.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 774585: Rename getCodebasePrincipal to getSimpleCodebasePrincipal since the behavior has semantically changed. r=mounir
browser/base/content/test/browser_bug413915.js
browser/components/feeds/src/FeedWriter.js
caps/idl/nsIScriptSecurityManager.idl
caps/include/nsScriptSecurityManager.h
caps/src/nsScriptSecurityManager.cpp
content/base/src/contentAreaDropListener.js
content/base/src/nsDOMParser.cpp
content/xslt/src/xslt/txMozillaStylesheetCompiler.cpp
docshell/base/nsDocShell.cpp
ipc/testshell/XPCShellEnvironment.cpp
js/xpconnect/shell/xpcshell.cpp
layout/tools/reftest/reftest.js
toolkit/components/places/nsLivemarkService.js
toolkit/content/nsDragAndDrop.js
--- a/browser/base/content/test/browser_bug413915.js
+++ b/browser/base/content/test/browser_bug413915.js
@@ -1,12 +1,12 @@
 function test() {
   var exampleUri = makeURI("http://example.com/");
   var secman = Cc["@mozilla.org/scriptsecuritymanager;1"].getService(Ci.nsIScriptSecurityManager);
-  var principal = secman.getCodebasePrincipal(exampleUri);
+  var principal = secman.getSimpleCodebasePrincipal(exampleUri);
 
   function testIsFeed(aTitle, aHref, aType, aKnown) {
     var link = { title: aTitle, href: aHref, type: aType };
     return isValidFeed(link, principal, aKnown);
   }
 
   var href = "http://example.com/feed/";
   var atomType = "application/atom+xml";
--- a/browser/components/feeds/src/FeedWriter.js
+++ b/browser/components/feeds/src/FeedWriter.js
@@ -1114,17 +1114,17 @@ FeedWriter.prototype = {
 
     this._window = window;
     this._document = window.document;
     this._document.getElementById("feedSubscribeLine").offsetTop;
     this._handlersMenuList = this._getUIElement("handlersMenuList");
 
     var secman = Cc["@mozilla.org/scriptsecuritymanager;1"].
                  getService(Ci.nsIScriptSecurityManager);
-    this._feedPrincipal = secman.getCodebasePrincipal(this._feedURI);
+    this._feedPrincipal = secman.getSimpleCodebasePrincipal(this._feedURI);
 
     LOG("Subscribe Preview: feed uri = " + this._window.location.href);
 
     // Set up the subscription UI
     this._initSubscriptionUI();
     var prefs = Cc["@mozilla.org/preferences-service;1"].
                 getService(Ci.nsIPrefBranch);
     prefs.addObserver(PREF_SELECTED_ACTION, this, false);
--- a/caps/idl/nsIScriptSecurityManager.idl
+++ b/caps/idl/nsIScriptSecurityManager.idl
@@ -146,17 +146,17 @@ interface nsIScriptSecurityManager : nsI
                                  in nsISupports aCert,
                                  in nsIURI aURI);
 
     /**
      * Return a principal that has the same origin as aURI.
      * This principals should not be used for any data/permission check, it will
      * have appId = UNKNOWN_APP_ID.
      */
-    nsIPrincipal getCodebasePrincipal(in nsIURI aURI);
+    nsIPrincipal getSimpleCodebasePrincipal(in nsIURI aURI);
 
     /**
      * Returns a principal that has the given information.
      * @param appId is the app id of the principal. It can't be UNKNOWN_APP_ID.
      * @param inMozBrowser is true if the principal has to be considered as
      * inside a mozbrowser frame.
      */
     nsIPrincipal getAppCodebasePrincipal(in nsIURI uri,
--- a/caps/include/nsScriptSecurityManager.h
+++ b/caps/include/nsScriptSecurityManager.h
@@ -431,18 +431,19 @@ private:
     nsresult
     LookupPolicy(nsIPrincipal* principal,
                  ClassInfoData& aClassData, jsid aProperty,
                  PRUint32 aAction,
                  ClassPolicy** aCachedClassPolicy,
                  SecurityLevel* result);
 
     nsresult
-    GetCodebasePrincipalInternal(nsIURI* aURI, PRUint32 aAppId, bool aInMozBrowser,
-                         nsIPrincipal** result);
+    GetCodebasePrincipalInternal(nsIURI* aURI, PRUint32 aAppId,
+                                 bool aInMozBrowser,
+                                 nsIPrincipal** result);
 
     nsresult
     CreateCodebasePrincipal(nsIURI* aURI, PRUint32 aAppId, bool aInMozBrowser,
                             nsIPrincipal** result);
 
     // This is just like the API method, but it doesn't check that the subject
     // name is non-empty or aCertificate is non-null, and it doesn't change the
     // certificate in the table (if any) in any way if aModifyTable is false.
--- a/caps/src/nsScriptSecurityManager.cpp
+++ b/caps/src/nsScriptSecurityManager.cpp
@@ -1985,29 +1985,30 @@ nsScriptSecurityManager::CreateCodebaseP
         return rv;
 
     NS_ADDREF(*result = codebase);
 
     return NS_OK;
 }
 
 NS_IMETHODIMP
-nsScriptSecurityManager::GetCodebasePrincipal(nsIURI* aURI,
+nsScriptSecurityManager::GetSimpleCodebasePrincipal(nsIURI* aURI,
                                                     nsIPrincipal** aPrincipal)
 {
-  return GetCodebasePrincipalInternal(aURI, nsIScriptSecurityManager::UNKNOWN_APP_ID,
-                              false, aPrincipal);
+  return GetCodebasePrincipalInternal(aURI,
+                                      nsIScriptSecurityManager::UNKNOWN_APP_ID,
+                                      false, aPrincipal);
 }
 
 NS_IMETHODIMP
 nsScriptSecurityManager::GetNoAppCodebasePrincipal(nsIURI* aURI,
                                                    nsIPrincipal** aPrincipal)
 {
   return GetCodebasePrincipalInternal(aURI,  nsIScriptSecurityManager::NO_APP_ID,
-                              false, aPrincipal);
+                                      false, aPrincipal);
 }
 
 NS_IMETHODIMP
 nsScriptSecurityManager::GetAppCodebasePrincipal(nsIURI* aURI,
                                                  PRUint32 aAppId,
                                                  bool aInMozBrowser,
                                                  nsIPrincipal** aPrincipal)
 {
@@ -2030,19 +2031,19 @@ nsScriptSecurityManager::GetDocShellCode
   aDocShell->GetIsInBrowserElement(&isInBrowserElement);
 
   return GetCodebasePrincipalInternal(aURI, appId, isInBrowserElement,
                                       aPrincipal);
 }
 
 nsresult
 nsScriptSecurityManager::GetCodebasePrincipalInternal(nsIURI *aURI,
-                                              PRUint32 aAppId,
-                                              bool aInMozBrowser,
-                                              nsIPrincipal **result)
+                                                      PRUint32 aAppId,
+                                                      bool aInMozBrowser,
+                                                      nsIPrincipal **result)
 {
     NS_ENSURE_ARG(aURI);
 
     bool inheritsPrincipal;
     nsresult rv =
         NS_URIChainHasFlags(aURI,
                             nsIProtocolHandler::URI_INHERITS_SECURITY_CONTEXT,
                             &inheritsPrincipal);
--- a/content/base/src/contentAreaDropListener.js
+++ b/content/base/src/contentAreaDropListener.js
@@ -81,17 +81,17 @@ ContentAreaDropListener.prototype =
                    getService(Ci.nsIScriptSecurityManager);
     let sourceNode = dataTransfer.mozSourceNode;
     let flags = secMan.STANDARD;
     if (disallowInherit)
       flags |= secMan.DISALLOW_INHERIT_PRINCIPAL;
 
     // Use file:/// as the default uri so that drops of file URIs are always allowed
     let principal = sourceNode ? sourceNode.nodePrincipal
-                               : secMan.getCodebasePrincipal(ioService.newURI("file:///", null, null));
+                               : secMan.getSimpleCodebasePrincipal(ioService.newURI("file:///", null, null));
 
     secMan.checkLoadURIStrWithPrincipal(principal, uriString, flags);
 
     return uriString;
   },
 
   canDropLink: function(aEvent, aAllowSameDocument)
   {
--- a/content/base/src/nsDOMParser.cpp
+++ b/content/base/src/nsDOMParser.cpp
@@ -260,17 +260,18 @@ nsDOMParser::Init(nsIPrincipal* principa
 
   mScriptHandlingObject = do_GetWeakReference(aScriptObject);
   mPrincipal = principal;
   nsresult rv;
   if (!mPrincipal) {
     nsIScriptSecurityManager* secMan = nsContentUtils::GetSecurityManager();
     NS_ENSURE_TRUE(secMan, NS_ERROR_NOT_AVAILABLE);
     rv =
-      secMan->GetCodebasePrincipal(mDocumentURI, getter_AddRefs(mPrincipal));
+      secMan->GetSimpleCodebasePrincipal(mDocumentURI,
+                                         getter_AddRefs(mPrincipal));
     NS_ENSURE_SUCCESS(rv, rv);
     mOriginalPrincipal = mPrincipal;
   } else {
     mOriginalPrincipal = mPrincipal;
     if (nsContentUtils::IsSystemPrincipal(mPrincipal)) {
       // Don't give DOMParsers the system principal.  Use a null
       // principal instead.
       mPrincipal = do_CreateInstance("@mozilla.org/nullprincipal;1", &rv);
--- a/content/xslt/src/xslt/txMozillaStylesheetCompiler.cpp
+++ b/content/xslt/src/xslt/txMozillaStylesheetCompiler.cpp
@@ -407,17 +407,18 @@ txCompileObserver::loadURI(const nsAStri
     NS_ENSURE_SUCCESS(rv, rv);
 
     nsCOMPtr<nsIURI> referrerUri;
     rv = NS_NewURI(getter_AddRefs(referrerUri), aReferrerUri);
     NS_ENSURE_SUCCESS(rv, rv);
 
     nsCOMPtr<nsIPrincipal> referrerPrincipal;
     rv = nsContentUtils::GetSecurityManager()->
-      GetCodebasePrincipal(referrerUri, getter_AddRefs(referrerPrincipal));
+      GetSimpleCodebasePrincipal(referrerUri,
+                                 getter_AddRefs(referrerPrincipal));
     NS_ENSURE_SUCCESS(rv, rv);
 
     // Content Policy
     PRInt16 shouldLoad = nsIContentPolicy::ACCEPT;
     rv = NS_CheckContentLoadPolicy(nsIContentPolicy::TYPE_STYLESHEET,
                                    uri,
                                    referrerPrincipal,
                                    nsnull,
@@ -628,17 +629,18 @@ txSyncCompileObserver::loadURI(const nsA
     NS_ENSURE_SUCCESS(rv, rv);
 
     nsCOMPtr<nsIURI> referrerUri;
     rv = NS_NewURI(getter_AddRefs(referrerUri), aReferrerUri);
     NS_ENSURE_SUCCESS(rv, rv);
 
     nsCOMPtr<nsIPrincipal> referrerPrincipal;
     rv = nsContentUtils::GetSecurityManager()->
-      GetCodebasePrincipal(referrerUri, getter_AddRefs(referrerPrincipal));
+      GetSimpleCodebasePrincipal(referrerUri,
+                                 getter_AddRefs(referrerPrincipal));
     NS_ENSURE_SUCCESS(rv, rv);
 
     // Content Policy
     PRInt16 shouldLoad = nsIContentPolicy::ACCEPT;
     rv = NS_CheckContentLoadPolicy(nsIContentPolicy::TYPE_STYLESHEET,
                                    uri,
                                    referrerPrincipal,
                                    nsnull,
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -8174,18 +8174,18 @@ nsDocShell::InternalLoad(nsIURI * aURI,
 
     // XXXbz would be nice to know the loading principal here... but we don't
     nsCOMPtr<nsIPrincipal> loadingPrincipal = do_QueryInterface(aOwner);
     if (!loadingPrincipal && aReferrer) {
         nsCOMPtr<nsIScriptSecurityManager> secMan =
             do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv);
         NS_ENSURE_SUCCESS(rv, rv);
 
-        rv = secMan->GetCodebasePrincipal(aReferrer,
-                                          getter_AddRefs(loadingPrincipal));
+        rv = secMan->GetSimpleCodebasePrincipal(aReferrer,
+                                                getter_AddRefs(loadingPrincipal));
     }
 
     rv = NS_CheckContentLoadPolicy(contentType,
                                    aURI,
                                    loadingPrincipal,
                                    context,
                                    EmptyCString(), //mime guess
                                    nsnull,         //extra
--- a/ipc/testshell/XPCShellEnvironment.cpp
+++ b/ipc/testshell/XPCShellEnvironment.cpp
@@ -760,45 +760,45 @@ FullTrustSecMan::GetCertificatePrincipal
                                          nsIURI *aURI,
                                          nsIPrincipal **_retval)
 {
     NS_IF_ADDREF(*_retval = mSystemPrincipal);
     return *_retval ? NS_OK : NS_ERROR_FAILURE;
 }
 
 NS_IMETHODIMP
-FullTrustSecMan::GetCodebasePrincipal(nsIURI *aURI,
-                                      nsIPrincipal **_retval)
+FullTrustSecMan::GetSimpleCodebasePrincipal(nsIURI *aURI,
+                                            nsIPrincipal **_retval)
 {
     NS_IF_ADDREF(*_retval = mSystemPrincipal);
     return *_retval ? NS_OK : NS_ERROR_FAILURE;
 }
 
 NS_IMETHODIMP
 FullTrustSecMan::GetNoAppCodebasePrincipal(nsIURI *aURI,
                                            nsIPrincipal **_retval)
 {
-    return GetCodebasePrincipal(aURI, _retval);
+    return GetSimpleCodebasePrincipal(aURI, _retval);
 }
 
 NS_IMETHODIMP
 FullTrustSecMan::GetAppCodebasePrincipal(nsIURI *aURI,
                                          PRUint32 aAppId,
                                          bool aInMozBrowser,
                                          nsIPrincipal **_retval)
 {
-    return GetCodebasePrincipal(aURI, _retval);
+    return GetSimpleCodebasePrincipal(aURI, _retval);
 }
 
 NS_IMETHODIMP
 FullTrustSecMan::GetDocShellCodebasePrincipal(nsIURI *aURI,
                                               nsIDocShell* aDocShell,
                                               nsIPrincipal **_retval)
 {
-    return GetCodebasePrincipal(aURI, _retval);
+    return GetSimpleCodebasePrincipal(aURI, _retval);
 }
 
 NS_IMETHODIMP
 FullTrustSecMan::RequestCapability(nsIPrincipal *principal,
                                    const char *capability,
                                    PRInt16 *_retval)
 {
     *_retval = nsIPrincipal::ENABLE_GRANTED;
--- a/js/xpconnect/shell/xpcshell.cpp
+++ b/js/xpconnect/shell/xpcshell.cpp
@@ -1381,43 +1381,43 @@ FullTrustSecMan::GetCertificatePrincipal
                                          const nsACString & aPrettyName,
                                          nsISupports *aCert, nsIURI *aURI,
                                          nsIPrincipal **_retval)
 {
     NS_IF_ADDREF(*_retval = mSystemPrincipal);
     return *_retval ? NS_OK : NS_ERROR_FAILURE;
 }
 
-/* [noscript] nsIPrincipal getCodebasePrincipal (in nsIURI aURI); */
+/* [noscript] nsIPrincipal getSimpleCodebasePrincipal (in nsIURI aURI); */
 NS_IMETHODIMP
-FullTrustSecMan::GetCodebasePrincipal(nsIURI *aURI, nsIPrincipal **_retval)
+FullTrustSecMan::GetSimpleCodebasePrincipal(nsIURI *aURI, nsIPrincipal **_retval)
 {
     NS_IF_ADDREF(*_retval = mSystemPrincipal);
     return *_retval ? NS_OK : NS_ERROR_FAILURE;
 }
 
 /* [noscript] nsIPrincipal getNoAppCodebasePrincipal (in nsIURI aURI); */
 NS_IMETHODIMP
 FullTrustSecMan::GetNoAppCodebasePrincipal(nsIURI *aURI, nsIPrincipal **_retval)
 {
-    return GetCodebasePrincipal(aURI, _retval);
+    return GetSimpleCodebasePrincipal(aURI, _retval);
 }
 
 /* [noscript] nsIPrincipal getAppCodebasePrincipal (in nsIURI aURI, unsigned long appid, bool inMozBrowser); */
 NS_IMETHODIMP
 FullTrustSecMan::GetAppCodebasePrincipal(nsIURI *aURI, PRUint32 aAppId, bool aInMozBrowser, nsIPrincipal **_retval)
 {
-    return GetCodebasePrincipal(aURI, _retval);
+    return GetSimpleCodebasePrincipal(aURI, _retval);
 }
 
 /* [noscript] nsIPrincipal getDocShellCodebasePrincipal (in nsIURI aURI, nsIDocShell docShell); */
 NS_IMETHODIMP
 FullTrustSecMan::GetDocShellCodebasePrincipal(nsIURI *aURI, nsIDocShell* aDocShell, nsIPrincipal **_retval)
 {
-    return GetCodebasePrincipal(aURI, _retval);
+    return GetSimpleCodebasePrincipal(aURI, _retval);
 }
 
 /* [noscript] short requestCapability (in nsIPrincipal principal, in string capability); */
 NS_IMETHODIMP
 FullTrustSecMan::RequestCapability(nsIPrincipal *principal,
                                    const char *capability, PRInt16 *_retval)
 {
     *_retval = nsIPrincipal::ENABLE_GRANTED;
--- a/layout/tools/reftest/reftest.js
+++ b/layout/tools/reftest/reftest.js
@@ -804,17 +804,17 @@ function ReadManifest(aURL, inherited_st
             if (items.length > 1 && !items[1].match(gProtocolRE)) {
                 items[1] = urlprefix + items[1];
             }
             if (items.length > 2 && !items[2].match(gProtocolRE)) {
                 items[2] = urlprefix + items[2];
             }
         }
 
-        var principal = secMan.getCodebasePrincipal(aURL);
+        var principal = secMan.getSimpleCodebasePrincipal(aURL);
 
         if (items[0] == "include") {
             if (items.length != 2 || runHttp)
                 throw "Error 2 in manifest file " + aURL.spec + " line " + lineNo;
             var incURI = gIOService.newURI(items[1], null, listURL);
             secMan.checkLoadURIWithPrincipal(principal, incURI,
                                              CI.nsIScriptSecurityManager.DISALLOW_SCRIPT);
             ReadManifest(incURI, expected_status);
--- a/toolkit/components/places/nsLivemarkService.js
+++ b/toolkit/components/places/nsLivemarkService.js
@@ -751,17 +751,17 @@ Livemark.prototype = {
     if (!aSiteURI) {
       PlacesUtils.annotations.removeItemAnnotation(this.id,
                                                    PlacesUtils.LMANNO_SITEURI)
       this.siteURI = null;
       return;
     }
 
     // Security check the site URI against the feed URI principal.
-    let feedPrincipal = secMan.getCodebasePrincipal(this.feedURI);
+    let feedPrincipal = secMan.getSimpleCodebasePrincipal(this.feedURI);
     try {
       secMan.checkLoadURIWithPrincipal(feedPrincipal, aSiteURI, SEC_FLAGS);
     }
     catch (ex) {
       return;
     }
 
     this._setAnno(PlacesUtils.LMANNO_SITEURI, aSiteURI.spec)
@@ -1085,17 +1085,18 @@ LivemarkLoadListener.prototype = {
   handleResult: function LLL_handleResult(aResult)
   {
     if (this._isAborted) {
       return;
     }
 
     try {
       // We need this to make sure the item links are safe
-      let feedPrincipal = secMan.getCodebasePrincipal(this._livemark.feedURI);
+      let feedPrincipal =
+        secMan.getSimpleCodebasePrincipal(this._livemark.feedURI);
 
       // Enforce well-formedness because the existing code does
       if (!aResult || !aResult.doc || aResult.bozo) {
         throw new Components.Exception("", Cr.NS_ERROR_FAILURE);
       }
 
       let feed = aResult.doc.QueryInterface(Ci.nsIFeed);
       let siteURI = this._livemark.siteURI;
--- a/toolkit/content/nsDragAndDrop.js
+++ b/toolkit/content/nsDragAndDrop.js
@@ -583,17 +583,17 @@ var nsDragAndDrop = {
 
       if (!aDragSession)
         aDragSession = this.mDragService.getCurrentSession();
 
       var sourceDoc = aDragSession.sourceDocument;
       // Use "file:///" as the default sourceURI so that drops of file:// URIs
       // are always allowed.
       var principal = sourceDoc ? sourceDoc.nodePrincipal
-                                : secMan.getCodebasePrincipal(ioService.newURI("file:///", null, null));
+                                : secMan.getSimpleCodebasePrincipal(ioService.newURI("file:///", null, null));
 
       try {
         secMan.checkLoadURIStrWithPrincipal(principal, aDraggedText,
                                             nsIScriptSecurityManager.STANDARD);
       } catch (e) {
         // Stop event propagation right here.
         aEvent.stopPropagation();