Bug 802366 - Prelude, part 4: Use and simplify nsScriptSecurityManager::GetDocShellCodebasePrincipal. r=bz, a=blocking-basecamp
authorJustin Lebar <justin.lebar@gmail.com>
Sat, 10 Nov 2012 10:32:36 -0800
changeset 114119 dc3a2243fef9c5b2bf88948ce88f9aa145813130
parent 114118 47a94e631253d2ad3cd46c824db605f5eeca80bf
child 114120 684f0b8beb12559162f932447ccef0945fa40687
push id2647
push userryanvm@gmail.com
push dateSat, 10 Nov 2012 22:23:29 +0000
treeherdermozilla-aurora@ca854140dd54 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz, blocking-basecamp
bugs802366
milestone18.0a2
Bug 802366 - Prelude, part 4: Use and simplify nsScriptSecurityManager::GetDocShellCodebasePrincipal. r=bz, a=blocking-basecamp
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;
@@ -1907,24 +1903,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)