Bug 826723 - Don't show suggestions or prompt in private tabs. r=mfinkle
authorBrian Nicholson <bnicholson@mozilla.com>
Mon, 14 Jan 2013 11:21:26 -0800
changeset 118773 53dd117b51f2603e2e14e75f0ce983376c2092eb
parent 118772 145fb616b12aabd0307b3b2a0bb28d5475e30177
child 118774 0cc898fd66fcdc08ae446b27c14fb8bb8927adb3
push id21259
push userbnicholson@mozilla.com
push dateMon, 14 Jan 2013 19:21:33 +0000
treeherdermozilla-inbound@53dd117b51f2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle
bugs826723
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 826723 - Don't show suggestions or prompt in private tabs. r=mfinkle
mobile/android/base/Tabs.java
mobile/android/base/awesomebar/AllPagesTab.java
--- a/mobile/android/base/Tabs.java
+++ b/mobile/android/base/Tabs.java
@@ -151,16 +151,24 @@ public class Tabs implements GeckoEventL
 
     public Tab getTabAt(int index) {
         if (index >= 0 && index < mOrder.size())
             return mOrder.get(index);
         else
             return null;
     }
 
+    /**
+     * Gets the selected tab.
+     *
+     * The selected tab can be null if we're doing a session restore after a
+     * crash and Gecko isn't ready yet.
+     *
+     * @return the selected tab, or null if no tabs exist
+     */
     public Tab getSelectedTab() {
         return mSelectedTab;
     }
 
     public boolean isSelectedTab(Tab tab) {
         if (mSelectedTab == null)
             return false;
 
--- a/mobile/android/base/awesomebar/AllPagesTab.java
+++ b/mobile/android/base/awesomebar/AllPagesTab.java
@@ -570,17 +570,24 @@ public class AllPagesTab extends Awesome
             for (int i = 0; i < engines.length(); i++) {
                 JSONObject engineJSON = engines.getJSONObject(i);
                 String name = engineJSON.getString("name");
                 String iconURI = engineJSON.getString("iconURI");
                 Bitmap icon = BitmapUtils.getBitmapFromDataURI(iconURI);
                 if (name.equals(suggestEngine) && suggestTemplate != null) {
                     // suggest engine should be at the front of the list
                     mSearchEngines.add(0, new SearchEngine(name, icon));
-                    mSuggestClient = new SuggestClient(GeckoApp.mAppContext, suggestTemplate, SUGGESTION_TIMEOUT, SUGGESTION_MAX);
+
+                    // The only time Tabs.getInstance().getSelectedTab() should
+                    // be null is when we're restoring after a crash. We should
+                    // never restore private tabs when that happens, so it
+                    // should be safe to assume that null means non-private.
+                    Tab tab = Tabs.getInstance().getSelectedTab();
+                    if (tab == null || !tab.isPrivate())
+                        mSuggestClient = new SuggestClient(GeckoApp.mAppContext, suggestTemplate, SUGGESTION_TIMEOUT, SUGGESTION_MAX);
                 } else {
                     mSearchEngines.add(new SearchEngine(name, icon));
                 }
             }
             mCursorAdapter.notifyDataSetChanged();
 
             // show suggestions opt-in if user hasn't been prompted
             if (!suggestionsPrompted && mSuggestClient != null) {