Bug 826723 - Don't show suggestions or prompt in private tabs. r=mfinkle

This commit is contained in:
Brian Nicholson 2013-01-14 11:21:26 -08:00
parent b6b0bb54c1
commit e23c3d60d2
2 changed files with 16 additions and 1 deletions

View File

@ -156,6 +156,14 @@ public class Tabs implements GeckoEventListener {
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;
}

View File

@ -575,6 +575,13 @@ public class AllPagesTab extends AwesomeBarTab implements GeckoEventListener {
if (name.equals(suggestEngine) && suggestTemplate != null) {
// suggest engine should be at the front of the list
mSearchEngines.add(0, new SearchEngine(name, icon));
// 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));