From 63e0465fc6ee7dee5607390a8c1386cf541579d4 Mon Sep 17 00:00:00 2001 From: Jonas Sicking Date: Sat, 21 Jul 2012 00:29:40 -0700 Subject: [PATCH] Bug 774585: Rename getCodebasePrincipal to getSimpleCodebasePrincipal since the behavior has semantically changed. r=mounir --- browser/base/content/test/browser_bug413915.js | 2 +- browser/components/feeds/src/FeedWriter.js | 2 +- caps/idl/nsIScriptSecurityManager.idl | 2 +- caps/include/nsScriptSecurityManager.h | 5 +++-- caps/src/nsScriptSecurityManager.cpp | 15 ++++++++------- content/base/src/contentAreaDropListener.js | 2 +- content/base/src/nsDOMParser.cpp | 3 ++- .../xslt/src/xslt/txMozillaStylesheetCompiler.cpp | 6 ++++-- docshell/base/nsDocShell.cpp | 4 ++-- ipc/testshell/XPCShellEnvironment.cpp | 10 +++++----- js/xpconnect/shell/xpcshell.cpp | 10 +++++----- layout/tools/reftest/reftest.js | 2 +- toolkit/components/places/nsLivemarkService.js | 5 +++-- toolkit/content/nsDragAndDrop.js | 2 +- 14 files changed, 38 insertions(+), 32 deletions(-) diff --git a/browser/base/content/test/browser_bug413915.js b/browser/base/content/test/browser_bug413915.js index b4ca848099cb..1f22043b908b 100644 --- a/browser/base/content/test/browser_bug413915.js +++ b/browser/base/content/test/browser_bug413915.js @@ -1,7 +1,7 @@ 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 }; diff --git a/browser/components/feeds/src/FeedWriter.js b/browser/components/feeds/src/FeedWriter.js index 2c15e6e53323..843925085b78 100644 --- a/browser/components/feeds/src/FeedWriter.js +++ b/browser/components/feeds/src/FeedWriter.js @@ -1119,7 +1119,7 @@ FeedWriter.prototype = { 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); diff --git a/caps/idl/nsIScriptSecurityManager.idl b/caps/idl/nsIScriptSecurityManager.idl index ed3ba11e771f..00fa60b67d15 100644 --- a/caps/idl/nsIScriptSecurityManager.idl +++ b/caps/idl/nsIScriptSecurityManager.idl @@ -151,7 +151,7 @@ interface nsIScriptSecurityManager : nsIXPCSecurityManager * 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. diff --git a/caps/include/nsScriptSecurityManager.h b/caps/include/nsScriptSecurityManager.h index ae6ee7ca692c..65c257650166 100644 --- a/caps/include/nsScriptSecurityManager.h +++ b/caps/include/nsScriptSecurityManager.h @@ -436,8 +436,9 @@ private: 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, diff --git a/caps/src/nsScriptSecurityManager.cpp b/caps/src/nsScriptSecurityManager.cpp index 9022e46b597c..95613c44ba1f 100644 --- a/caps/src/nsScriptSecurityManager.cpp +++ b/caps/src/nsScriptSecurityManager.cpp @@ -1990,11 +1990,12 @@ nsScriptSecurityManager::CreateCodebasePrincipal(nsIURI* aURI, PRUint32 aAppId, } 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 @@ -2002,7 +2003,7 @@ nsScriptSecurityManager::GetNoAppCodebasePrincipal(nsIURI* aURI, nsIPrincipal** aPrincipal) { return GetCodebasePrincipalInternal(aURI, nsIScriptSecurityManager::NO_APP_ID, - false, aPrincipal); + false, aPrincipal); } NS_IMETHODIMP @@ -2035,9 +2036,9 @@ nsScriptSecurityManager::GetDocShellCodebasePrincipal(nsIURI* aURI, nsresult nsScriptSecurityManager::GetCodebasePrincipalInternal(nsIURI *aURI, - PRUint32 aAppId, - bool aInMozBrowser, - nsIPrincipal **result) + PRUint32 aAppId, + bool aInMozBrowser, + nsIPrincipal **result) { NS_ENSURE_ARG(aURI); diff --git a/content/base/src/contentAreaDropListener.js b/content/base/src/contentAreaDropListener.js index 2178e3fbf713..5a7ae4f63358 100644 --- a/content/base/src/contentAreaDropListener.js +++ b/content/base/src/contentAreaDropListener.js @@ -86,7 +86,7 @@ ContentAreaDropListener.prototype = // 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); diff --git a/content/base/src/nsDOMParser.cpp b/content/base/src/nsDOMParser.cpp index b982c896cdd9..a63ca0221dd0 100644 --- a/content/base/src/nsDOMParser.cpp +++ b/content/base/src/nsDOMParser.cpp @@ -265,7 +265,8 @@ nsDOMParser::Init(nsIPrincipal* principal, nsIURI* documentURI, 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 { diff --git a/content/xslt/src/xslt/txMozillaStylesheetCompiler.cpp b/content/xslt/src/xslt/txMozillaStylesheetCompiler.cpp index c5373debc0df..9f9957b9e284 100644 --- a/content/xslt/src/xslt/txMozillaStylesheetCompiler.cpp +++ b/content/xslt/src/xslt/txMozillaStylesheetCompiler.cpp @@ -412,7 +412,8 @@ txCompileObserver::loadURI(const nsAString& aUri, nsCOMPtr referrerPrincipal; rv = nsContentUtils::GetSecurityManager()-> - GetCodebasePrincipal(referrerUri, getter_AddRefs(referrerPrincipal)); + GetSimpleCodebasePrincipal(referrerUri, + getter_AddRefs(referrerPrincipal)); NS_ENSURE_SUCCESS(rv, rv); // Content Policy @@ -633,7 +634,8 @@ txSyncCompileObserver::loadURI(const nsAString& aUri, nsCOMPtr referrerPrincipal; rv = nsContentUtils::GetSecurityManager()-> - GetCodebasePrincipal(referrerUri, getter_AddRefs(referrerPrincipal)); + GetSimpleCodebasePrincipal(referrerUri, + getter_AddRefs(referrerPrincipal)); NS_ENSURE_SUCCESS(rv, rv); // Content Policy diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index a0fadd9ce7a1..cc3c63f06023 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -8179,8 +8179,8 @@ nsDocShell::InternalLoad(nsIURI * aURI, 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, diff --git a/ipc/testshell/XPCShellEnvironment.cpp b/ipc/testshell/XPCShellEnvironment.cpp index c849c3853d4b..6820fc49076a 100644 --- a/ipc/testshell/XPCShellEnvironment.cpp +++ b/ipc/testshell/XPCShellEnvironment.cpp @@ -765,8 +765,8 @@ FullTrustSecMan::GetCertificatePrincipal(const nsACString & aCertFingerprint, } 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; @@ -776,7 +776,7 @@ NS_IMETHODIMP FullTrustSecMan::GetNoAppCodebasePrincipal(nsIURI *aURI, nsIPrincipal **_retval) { - return GetCodebasePrincipal(aURI, _retval); + return GetSimpleCodebasePrincipal(aURI, _retval); } NS_IMETHODIMP @@ -785,7 +785,7 @@ FullTrustSecMan::GetAppCodebasePrincipal(nsIURI *aURI, bool aInMozBrowser, nsIPrincipal **_retval) { - return GetCodebasePrincipal(aURI, _retval); + return GetSimpleCodebasePrincipal(aURI, _retval); } NS_IMETHODIMP @@ -793,7 +793,7 @@ FullTrustSecMan::GetDocShellCodebasePrincipal(nsIURI *aURI, nsIDocShell* aDocShell, nsIPrincipal **_retval) { - return GetCodebasePrincipal(aURI, _retval); + return GetSimpleCodebasePrincipal(aURI, _retval); } NS_IMETHODIMP diff --git a/js/xpconnect/shell/xpcshell.cpp b/js/xpconnect/shell/xpcshell.cpp index 38622528c060..cf9ff382b914 100644 --- a/js/xpconnect/shell/xpcshell.cpp +++ b/js/xpconnect/shell/xpcshell.cpp @@ -1386,9 +1386,9 @@ FullTrustSecMan::GetCertificatePrincipal(const nsACString & aCertFingerprint, 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; @@ -1398,21 +1398,21 @@ FullTrustSecMan::GetCodebasePrincipal(nsIURI *aURI, nsIPrincipal **_retval) 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); */ diff --git a/layout/tools/reftest/reftest.js b/layout/tools/reftest/reftest.js index 0e6833fe67fb..6be9317823e8 100644 --- a/layout/tools/reftest/reftest.js +++ b/layout/tools/reftest/reftest.js @@ -809,7 +809,7 @@ function ReadManifest(aURL, inherited_status) } } - var principal = secMan.getCodebasePrincipal(aURL); + var principal = secMan.getSimpleCodebasePrincipal(aURL); if (items[0] == "include") { if (items.length != 2 || runHttp) diff --git a/toolkit/components/places/nsLivemarkService.js b/toolkit/components/places/nsLivemarkService.js index d989aa1bbe97..8af451cff795 100644 --- a/toolkit/components/places/nsLivemarkService.js +++ b/toolkit/components/places/nsLivemarkService.js @@ -756,7 +756,7 @@ Livemark.prototype = { } // 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); } @@ -1090,7 +1090,8 @@ LivemarkLoadListener.prototype = { 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) { diff --git a/toolkit/content/nsDragAndDrop.js b/toolkit/content/nsDragAndDrop.js index bbf637706aef..65a2995b55c0 100644 --- a/toolkit/content/nsDragAndDrop.js +++ b/toolkit/content/nsDragAndDrop.js @@ -588,7 +588,7 @@ var nsDragAndDrop = { // 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,