Bug 803675 - part0: Reduce to check caller context in nsWindowWatcher::CalculateChromeFlags(). r=bz
authorTetsuharu OHZEKI <saneyuki.s.snyk@gmail.com>
Mon, 18 Feb 2013 20:27:48 +0900
changeset 132105 9a708c976f45bfa822b3d7a634faf7afe263a366
parent 132104 725e172de3586cdcce4bacbff14b41d3a02efd7a
child 132106 a71e34325926548ba83c33e0a07e9c6106db13e4
push id2323
push userbbajaj@mozilla.com
push dateMon, 01 Apr 2013 19:47:02 +0000
treeherdermozilla-beta@7712be144d91 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs803675
milestone21.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 803675 - part0: Reduce to check caller context in nsWindowWatcher::CalculateChromeFlags(). r=bz
embedding/components/windowwatcher/src/nsWindowWatcher.cpp
--- a/embedding/components/windowwatcher/src/nsWindowWatcher.cpp
+++ b/embedding/components/windowwatcher/src/nsWindowWatcher.cpp
@@ -1437,18 +1437,18 @@ nsWindowWatcher::URIfromURL(const char *
   }
 
   // build and return the absolute URI
   return NS_NewURI(aURI, aURL, baseURI);
 }
 
 #define NS_CALCULATE_CHROME_FLAG_FOR(feature, flag)               \
     prefBranch->GetBoolPref(feature, &forceEnable);               \
-    if (forceEnable && !(aDialog && isChrome) &&                  \
-        !(isChrome && aHasChromeParent) && !aChromeURL) {         \
+    if (forceEnable && !(aDialog && isCallerChrome) &&            \
+        !(isCallerChrome && aHasChromeParent) && !aChromeURL) {   \
       chromeFlags |= flag;                                        \
     } else {                                                      \
       chromeFlags |= WinHasOption(aFeatures, feature,             \
                                   0, &presenceFlag)               \
                      ? flag : 0;                                  \
     }
 
 /**
@@ -1489,36 +1489,28 @@ uint32_t nsWindowWatcher::CalculateChrom
   bool presenceFlag = false;
 
   chromeFlags = nsIWebBrowserChrome::CHROME_WINDOW_BORDERS;
   if (aDialog && WinHasOption(aFeatures, "all", 0, &presenceFlag))
     chromeFlags = nsIWebBrowserChrome::CHROME_ALL;
 
   /* Next, allow explicitly named options to override the initial settings */
 
-  nsCOMPtr<nsIScriptSecurityManager>
-    securityManager(do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID));
-
-  bool isChrome = false;
-  nsresult rv;
-  if (securityManager) {
-    rv = securityManager->SubjectPrincipalIsSystem(&isChrome);
-    if (NS_FAILED(rv)) {
-      isChrome = false;
-    }
-  }
+  bool isCallerChrome = nsContentUtils::IsCallerChrome();
 
   // Determine whether the window is a private browsing window
-  if (isChrome) {
+  if (isCallerChrome) {
     chromeFlags |= WinHasOption(aFeatures, "private", 0, &presenceFlag) ?
       nsIWebBrowserChrome::CHROME_PRIVATE_WINDOW : 0;
     chromeFlags |= WinHasOption(aFeatures, "non-private", 0, &presenceFlag) ?
       nsIWebBrowserChrome::CHROME_NON_PRIVATE_WINDOW : 0;
   }
 
+  nsresult rv;
+
   nsCOMPtr<nsIPrefBranch> prefBranch;
   nsCOMPtr<nsIPrefService> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv, true);
 
   rv = prefs->GetBranch("dom.disable_window_open_feature.", getter_AddRefs(prefBranch));
   NS_ENSURE_SUCCESS(rv, true);
 
   bool forceEnable = false;
@@ -1609,17 +1601,17 @@ uint32_t nsWindowWatcher::CalculateChrom
       chromeFlags |= nsIWebBrowserChrome::CHROME_OPENAS_CHROME;
   }
 
   /* missing
      chromeFlags->copy_history
    */
 
   // Check security state for use in determing window dimensions
-  if (!nsContentUtils::IsCallerChrome() || (isChrome && !aHasChromeParent)) {
+  if (!isCallerChrome || !aHasChromeParent) {
     // If priv check fails (or if we're called from chrome, but the
     // parent is not a chrome window), set all elements to minimum
     // reqs., else leave them alone.
     chromeFlags |= nsIWebBrowserChrome::CHROME_TITLEBAR;
     chromeFlags |= nsIWebBrowserChrome::CHROME_WINDOW_CLOSE;
     chromeFlags &= ~nsIWebBrowserChrome::CHROME_WINDOW_LOWERED;
     chromeFlags &= ~nsIWebBrowserChrome::CHROME_WINDOW_RAISED;
     chromeFlags &= ~nsIWebBrowserChrome::CHROME_WINDOW_POPUP;