Bug 858825 Can't undo close tab in a private window r=IanN f=Ratty a=IanN
authorNeil Rashbrook <neil@parkwaycc.co.uk>
Sun, 21 Apr 2013 10:33:28 +0100
changeset 24224 9a85f4353a9cbb0e9df98f4027a81d55454d04a7
parent 24223 60638c26d64525ae4aafb7a03f7e8e11520bedb4
child 24225 75c893612b002b564d8f5adf155ed493cb10a9fa
push id1850
push userclokep@gmail.com
push dateWed, 08 Mar 2017 19:29:12 +0000
treeherdercomm-esr52@028df196b2d9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersIanN, IanN
bugs858825
Bug 858825 Can't undo close tab in a private window r=IanN f=Ratty a=IanN
suite/browser/navigator.js
suite/browser/tabbrowser.xml
--- a/suite/browser/navigator.js
+++ b/suite/browser/navigator.js
@@ -470,17 +470,16 @@ function Startup()
     gPrivate = window;
     document.documentElement.setAttribute("windowtype", "navigator:private");
     var titlemodifier = document.documentElement.getAttribute("titlemodifier");
     if (titlemodifier)
       titlemodifier += " ";
     titlemodifier += document.documentElement.getAttribute("titleprivate");
     document.documentElement.setAttribute("titlemodifier", titlemodifier);
     document.title = titlemodifier;
-    gBrowser.mFaviconFlags = gBrowser.mFaviconService.FAVICON_LOAD_PRIVATE;
   }
 
   // initialize observers and listeners
   var xw = lc.QueryInterface(Components.interfaces.nsIDocShellTreeItem)
              .treeOwner
              .QueryInterface(Components.interfaces.nsIInterfaceRequestor)
              .getInterface(Components.interfaces.nsIXULWindow);
   xw.XULBrowserWindow = window.XULBrowserWindow = new nsBrowserStatusHandler();
--- a/suite/browser/tabbrowser.xml
+++ b/suite/browser/tabbrowser.xml
@@ -154,18 +154,21 @@
         new Array()
       </field>
       <field name="mTabFilters">
         new Array()
       </field>
       <field name="mLastRelatedIndex">
         0
       </field>
-      <field name="mFaviconFlags">
-        this.mFaviconService.FAVICON_LOAD_NON_PRIVATE
+      <field name="usePrivateBrowsing" readonly="true">
+        window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
+              .getInterface(Components.interfaces.nsIWebNavigation)
+              .QueryInterface(Components.interfaces.nsILoadContext)
+              .usePrivateBrowsing
       </field>
       <field name="mContextTab">
         null
       </field>
       <field name="_keyEventHandler" readonly="true">
       <![CDATA[({
         handleEvent: function handleEvent(aEvent) {
           if (aEvent.altKey)
@@ -700,19 +703,22 @@
         <body>
           <![CDATA[
             var browser = aTab.linkedBrowser;
             if (!(aURI instanceof Components.interfaces.nsIURI))
               aURI = this.mIOService.newURI(aURI, null, null);
             browser.mIconURL = aURI.spec;
 
             if (aURI && this.mFaviconService) {
+              var faviconFlags = this.usePrivateBrowsing ?
+                  this.mFaviconService.FAVICON_LOAD_PRIVATE :
+                  this.mFaviconService.FAVICON_LOAD_NON_PRIVATE;
               this.mFaviconService.setAndFetchFaviconForPage(browser.currentURI,
                                                              aURI, false,
-                                                             this.mFaviconFlags);
+                                                             faviconFlags);
             }
 
             this.updateIcon(aTab);
 
             this._callProgressListeners(browser, "onLinkIconAvailable",
                                         [browser.mIconURL]);
           ]]>
         </body>
@@ -774,17 +780,20 @@
         <parameter name="aURI"/>
         <parameter name="aAttr"/>
         <parameter name="aElt"/>
         <body>
           <![CDATA[
             var iconURL = this.buildFavIconString(aURI);
             if (this.mFaviconService) {
               let uri = this.mIOService.newURI(iconURL, null, null);
-              this.mFaviconService.setAndFetchFaviconForPage(aURI, uri, false, this.mFaviconFlags);
+              var faviconFlags = this.usePrivateBrowsing ?
+                  this.mFaviconService.FAVICON_LOAD_PRIVATE :
+                  this.mFaviconService.FAVICON_LOAD_NON_PRIVATE;
+              this.mFaviconService.setAndFetchFaviconForPage(aURI, uri, false, faviconFlags);
               if (this.mFaviconService.isFailedFavicon(uri))
                 return;
             }
             aElt.setAttribute(aAttr, iconURL);
           ]]>
         </body>
       </method>
 
@@ -927,19 +936,22 @@
             // The user might right-click on a tab or an empty part of the tabbar.
             var isTab = this.mContextTab.localName == "tab";
             var isMultiple = this.tabs.length > 1;
             var menuItems = aPopupMenu.getElementsByAttribute("tbattr", "*");
             for (let menuitem of menuItems) {
               let tbattr = menuitem.getAttribute("tbattr");
 
               if (tbattr.contains("tabbrowser-undoclosetab")) {
-                menuitem.setAttribute("disabled", this.mSessionStore.getClosedTabCount(window) == 0);
-                menuitem.hidden = this.mPrefs.getIntPref("browser.tabs.max_tabs_undo") <= 0 &&
-                                  this.mPrefs.getIntPref("browser.sessionstore.max_tabs_undo") <= 0;
+                menuitem.setAttribute("disabled", (this.usePrivateBrowsing ?
+                    this.savedBrowsers.length :
+                    this.mSessionStore.getClosedTabCount(window)) == 0);
+                menuitem.hidden = (this.usePrivateBrowsing ||
+                                   this.mPrefs.getIntPref("browser.sessionstore.max_tabs_undo") <= 0) &&
+                                  this.mPrefs.getIntPref("browser.tabs.max_tabs_undo") <= 0;
               }
               else
                 menuitem.setAttribute("disabled", tbattr.contains("tabbrowser-multiple") && !isMultiple ||
                                                   tbattr.contains("tabbrowser-tab") && !isTab)
             }
           ]]>
         </body>
       </method>
@@ -1505,26 +1517,30 @@
                    !aBrowser.contentDocument.body.hasChildNodes();
           ]]>
         </body>
       </method>
 
       <method name="getUndoList">
         <body>
           <![CDATA[
-            return JSON.parse(this.mSessionStore.getClosedTabData(window))
-                       .map(function(aTabData) { return aTabData.title; });
+            var tabData = this.usePrivateBrowsing ?  this.savedBrowsers :
+                JSON.parse(this.mSessionStore.getClosedTabData(window));
+            return tabData.map(function(aTabData) { return aTabData.title; });
           ]]>
         </body>
       </method>
 
       <method name="undoCloseTab">
         <parameter name="aIndex"/>
         <body>
           <![CDATA[
+            if (this.usePrivateBrowsing)
+              return this.savedBrowsers.length ? this.restoreTab(aIndex) : null;
+
             return this.mSessionStore.getClosedTabCount(window) ?
                      this.mSessionStore.undoCloseTab(window, aIndex) : null;
           ]]>
         </body>
       </method>
 
       <method name="restoreTab">
         <parameter name="aIndex"/>