Bug 1367830 - Refactor to share more code between private and non-private hidden window creation. r=mystor draft
authorL. David Baron <dbaron@dbaron.org>
Fri, 26 May 2017 13:49:51 -0400
changeset 585228 24cdff62dde36e9c9c982557d9c95967eee87d12
parent 584507 f7adbf457ee20eeffde72694e0d17d73616e3cfd
child 585229 aab0a239b733b9256a7ef398e18fc8accaa91cfd
push id61063
push userdbaron@mozilla.com
push dateFri, 26 May 2017 17:54:58 +0000
reviewersmystor
bugs1367830
milestone55.0a1
Bug 1367830 - Refactor to share more code between private and non-private hidden window creation. r=mystor MozReview-Commit-ID: 8NZPbcJtvsE
xpfe/appshell/nsAppShellService.cpp
--- a/xpfe/appshell/nsAppShellService.cpp
+++ b/xpfe/appshell/nsAppShellService.cpp
@@ -126,43 +126,39 @@ nsAppShellService::CreateHiddenWindowHel
   static const char hiddenWindowURL[] = DEFAULT_HIDDENWINDOW_URL;
   uint32_t    chromeMask =  nsIWebBrowserChrome::CHROME_ALL;
 #endif
 
   nsCOMPtr<nsIURI> url;
   rv = NS_NewURI(getter_AddRefs(url), hiddenWindowURL);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  RefPtr<nsWebShellWindow> newWindow;
-  if (!aIsPrivate) {
-    rv = JustCreateTopWindow(nullptr, url,
-                             chromeMask, initialWidth, initialHeight,
-                             true, nullptr, nullptr, getter_AddRefs(newWindow));
-    NS_ENSURE_SUCCESS(rv, rv);
+  if (aIsPrivate) {
+    chromeMask |= nsIWebBrowserChrome::CHROME_PRIVATE_WINDOW;
+  }
 
-    mHiddenWindow.swap(newWindow);
-  } else {
-    // Create the hidden private window
-    chromeMask |= nsIWebBrowserChrome::CHROME_PRIVATE_WINDOW;
+  RefPtr<nsWebShellWindow> newWindow;
+  rv = JustCreateTopWindow(nullptr, url,
+                           chromeMask, initialWidth, initialHeight,
+                           true, nullptr, nullptr, getter_AddRefs(newWindow));
+  NS_ENSURE_SUCCESS(rv, rv);
 
-    rv = JustCreateTopWindow(nullptr, url,
-                             chromeMask, initialWidth, initialHeight,
-                             true, nullptr, nullptr, getter_AddRefs(newWindow));
-    NS_ENSURE_SUCCESS(rv, rv);
-
-    nsCOMPtr<nsIDocShell> docShell;
-    newWindow->GetDocShell(getter_AddRefs(docShell));
-    if (docShell) {
+  nsCOMPtr<nsIDocShell> docShell;
+  newWindow->GetDocShell(getter_AddRefs(docShell));
+  if (docShell) {
+    if (aIsPrivate) {
       docShell->SetAffectPrivateSessionLifetime(false);
     }
-
-    mHiddenPrivateWindow.swap(newWindow);
   }
 
-  // RegisterTopLevelWindow(newWindow); -- Mac only
+  if (aIsPrivate) {
+    mHiddenPrivateWindow.swap(newWindow);
+  } else {
+    mHiddenWindow.swap(newWindow);
+  }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsAppShellService::DestroyHiddenWindow()
 {
   if (mHiddenWindow) {