Bug 1035439 - Part 2: Show closed tabs of the current private state in RecentTabsPanel. r=margaret
authorBrian Nicholson <bnicholson@mozilla.com>
Mon, 14 Jul 2014 17:21:14 -0700
changeset 216007 81c71f117c6a83c7a38c60c2cd42eb2ca183b7a9
parent 216006 35cfb1f0291871f190ba90a53d044fa2fcc78473
child 216008 36cb524c546a16e20b3bc8f94c20b989fec66730
push id515
push userraliiev@mozilla.com
push dateMon, 06 Oct 2014 12:51:51 +0000
treeherdermozilla-release@267c7a481bef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmargaret
bugs1035439
milestone33.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 1035439 - Part 2: Show closed tabs of the current private state in RecentTabsPanel. r=margaret
mobile/android/base/home/RecentTabsPanel.java
mobile/android/components/SessionStore.js
--- a/mobile/android/base/home/RecentTabsPanel.java
+++ b/mobile/android/base/home/RecentTabsPanel.java
@@ -29,18 +29,16 @@ import android.app.Activity;
 import android.content.Context;
 import android.content.res.Configuration;
 import android.database.Cursor;
 import android.database.MatrixCursor;
 import android.database.MatrixCursor.RowBuilder;
 import android.os.Bundle;
 import android.support.v4.app.LoaderManager.LoaderCallbacks;
 import android.support.v4.content.Loader;
-import android.support.v4.widget.CursorAdapter;
-import android.util.Log;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
 import android.view.ViewStub;
 import android.widget.AdapterView;
 import android.widget.ImageView;
 import android.widget.TextView;
 
@@ -247,19 +245,17 @@ public class RecentTabsPanel extends Hom
 
         // Only modify mClosedTabs on the UI thread
         ThreadUtils.postToUiThread(new Runnable() {
             @Override
             public void run() {
                 mClosedTabs = closedTabs;
 
                 // Reload the cursor to show recently closed tabs.
-                if (mClosedTabs.length > 0 && canLoad()) {
-                    getLoaderManager().restartLoader(LOADER_ID_RECENT_TABS, null, mCursorLoaderCallbacks);
-                }
+                getLoaderManager().restartLoader(LOADER_ID_RECENT_TABS, null, mCursorLoaderCallbacks);
             }
         });
     }
 
     private void openTabsWithType(int type) {
         final Cursor c = mAdapter.getCursor();
         if (c == null || !c.moveToFirst()) {
             return;
@@ -305,18 +301,18 @@ public class RecentTabsPanel extends Hom
             if (closedTabs != null && closedTabs.length > 0) {
                 // How many closed tabs are actually displayed.
                 int visibleClosedTabs = 0;
 
                 final int length = closedTabs.length;
                 for (int i = 0; i < length; i++) {
                     final String url = closedTabs[i].url;
 
-                    // Don't show recent tabs for about:home.
-                    if (!AboutPages.isAboutHome(url)) {
+                    // Don't show recent tabs for about:home or about:privatebrowsing.
+                    if (!AboutPages.isTitlelessAboutPage(url)) {
                         // If this is the first closed tab we're adding, add a header for the section.
                         if (visibleClosedTabs == 0) {
                             addRow(c, null, context.getString(R.string.home_closed_tabs_title), RecentTabs.TYPE_HEADER);
                         }
                         addRow(c, url, closedTabs[i].title, RecentTabs.TYPE_CLOSED);
                         visibleClosedTabs++;
                     }
                 }
--- a/mobile/android/components/SessionStore.js
+++ b/mobile/android/components/SessionStore.js
@@ -13,16 +13,17 @@ Cu.import("resource://gre/modules/Servic
 #ifdef MOZ_CRASHREPORTER
 XPCOMUtils.defineLazyServiceGetter(this, "CrashReporter",
   "@mozilla.org/xre/app-info;1", "nsICrashReporter");
 #endif
 
 XPCOMUtils.defineLazyModuleGetter(this, "Task", "resource://gre/modules/Task.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "OS", "resource://gre/modules/osfile.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "sendMessageToJava", "resource://gre/modules/Messaging.jsm");
+XPCOMUtils.defineLazyModuleGetter(this, "PrivateBrowsingUtils", "resource://gre/modules/PrivateBrowsingUtils.jsm");
 
 function dump(a) {
   Services.console.logStringMessage(a);
 }
 
 // -----------------------------------------------------------------------
 // Session Store
 // -----------------------------------------------------------------------
@@ -368,16 +369,23 @@ SessionStore.prototype = {
         this._restoreHistory(data, aBrowser.sessionHistory);
 
       delete aBrowser.__SS_restore;
       aBrowser.removeAttribute("pending");
     }
 
     this.saveStateDelayed();
     this._updateCrashReportURL(aWindow);
+
+    // If the selected tab has changed while listening for closed tab
+    // notifications, we may have switched between different private browsing
+    // modes.
+    if (this._notifyClosedTabs) {
+      this._sendClosedTabsToJava(aWindow);
+    }
   },
 
   saveStateDelayed: function ss_saveStateDelayed() {
     if (!this._saveTimer) {
       // Interval until the next disk operation is allowed
       let minimalDelay = this._lastSaveTime + this._interval - Date.now();
 
       // If we have to wait, set a timer, otherwise saveState directly
@@ -918,19 +926,20 @@ SessionStore.prototype = {
     }
   },
 
   _sendClosedTabsToJava: function ss_sendClosedTabsToJava(aWindow) {
     if (!aWindow.__SSID)
       throw (Components.returnCode = Cr.NS_ERROR_INVALID_ARG);
 
     let closedTabs = this._windows[aWindow.__SSID].closedTabs;
+    let isPrivate = PrivateBrowsingUtils.isWindowPrivate(aWindow.BrowserApp.selectedBrowser.contentWindow);
 
     let tabs = closedTabs
-      .filter(tab => !tab.isPrivate)
+      .filter(tab => tab.isPrivate == isPrivate)
       .map(function (tab) {
         // Get the url and title for the last entry in the session history.
         let lastEntry = tab.entries[tab.entries.length - 1];
         return {
           url: lastEntry.url,
           title: lastEntry.title || ""
         };
       });