Bug 802366 - Prelude, part 4: Use and simplify nsScriptSecurityManager::GetDocShellCodebasePrincipal. r=bz
☠☠ backed out by 2729e28870be ☠ ☠
authorJustin Lebar <justin.lebar@gmail.com>
Tue, 30 Oct 2012 15:55:05 -0400
changeset 111932 37357ffceb05b6bfad93f1c150feceb4b02977c8
parent 111931 212e1383eb6ed9d9f6c13530e320bc65815501aa
child 111933 8048f22347ebf691a363bc9ccfb9aef06d5c6d2c
push id93
push usernmatsakis@mozilla.com
push dateWed, 31 Oct 2012 21:26:57 +0000
reviewersbz
bugs802366
milestone19.0a1
Bug 802366 - Prelude, part 4: Use and simplify nsScriptSecurityManager::GetDocShellCodebasePrincipal. r=bz
caps/src/nsScriptSecurityManager.cpp
--- a/caps/src/nsScriptSecurityManager.cpp
+++ b/caps/src/nsScriptSecurityManager.cpp
@@ -330,29 +330,25 @@ nsScriptSecurityManager::GetChannelPrinc
     }
 
     // OK, get the principal from the URI.  Make sure this does the same thing
     // as nsDocument::Reset and nsXULDocument::StartDocumentLoad.
     nsCOMPtr<nsIURI> uri;
     nsresult rv = NS_GetFinalChannelURI(aChannel, getter_AddRefs(uri));
     NS_ENSURE_SUCCESS(rv, rv);
 
-    uint32_t appId = UNKNOWN_APP_ID;
-    bool isInBrowserElement = false;
-
     nsCOMPtr<nsIDocShell> docShell;
     NS_QueryNotificationCallbacks(aChannel, docShell);
 
     if (docShell) {
-        docShell->GetAppId(&appId);
-        docShell->GetIsInBrowserElement(&isInBrowserElement);
+        return GetDocShellCodebasePrincipal(uri, docShell, aPrincipal);
     }
 
-    return GetCodebasePrincipalInternal(uri, appId, isInBrowserElement,
-                                        aPrincipal);
+    return GetCodebasePrincipalInternal(uri, UNKNOWN_APP_ID,
+        /* isInBrowserElement */ false, aPrincipal);
 }
 
 NS_IMETHODIMP
 nsScriptSecurityManager::IsSystemPrincipal(nsIPrincipal* aPrincipal,
                                            bool* aIsSystem)
 {
     *aIsSystem = (aPrincipal == mSystemPrincipal);
     return NS_OK;
@@ -1886,24 +1882,19 @@ nsScriptSecurityManager::GetAppCodebaseP
   return GetCodebasePrincipalInternal(aURI, aAppId, aInMozBrowser, aPrincipal);
 }
 
 NS_IMETHODIMP
 nsScriptSecurityManager::GetDocShellCodebasePrincipal(nsIURI* aURI,
                                                       nsIDocShell* aDocShell,
                                                       nsIPrincipal** aPrincipal)
 {
-  MOZ_ASSERT(aDocShell);
-
-  uint32_t appId;
-  bool isInBrowserElement;
-  aDocShell->GetAppId(&appId);
-  aDocShell->GetIsInBrowserElement(&isInBrowserElement);
-
-  return GetCodebasePrincipalInternal(aURI, appId, isInBrowserElement,
+  return GetCodebasePrincipalInternal(aURI,
+                                      aDocShell->GetAppId(),
+                                      aDocShell->GetIsInBrowserElement(),
                                       aPrincipal);
 }
 
 nsresult
 nsScriptSecurityManager::GetCodebasePrincipalInternal(nsIURI *aURI,
                                                       uint32_t aAppId,
                                                       bool aInMozBrowser,
                                                       nsIPrincipal **result)