summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/browser_instant_controller.cc
diff options
context:
space:
mode:
authorjered@chromium.org <jered@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-08 01:01:12 +0000
committerjered@chromium.org <jered@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-08 01:01:12 +0000
commit9d3d117085a5f9a68b64764b162ebd405723b713 (patch)
tree40a23bdd49b7ab5847e56b391a41b8bfd812d382 /chrome/browser/ui/browser_instant_controller.cc
parentff2367e21e86d78b8bf25fc9048f6ef9cbc618f5 (diff)
downloadchromium_src-9d3d117085a5f9a68b64764b162ebd405723b713.zip
chromium_src-9d3d117085a5f9a68b64764b162ebd405723b713.tar.gz
chromium_src-9d3d117085a5f9a68b64764b162ebd405723b713.tar.bz2
InstantExtended: Show custom new tab page content.
Allow extended mode Instant pages to show custom new tab page content. BUG=1590121 Review URL: https://chromiumcodereview.appspot.com/11362093 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@166567 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui/browser_instant_controller.cc')
-rw-r--r--chrome/browser/ui/browser_instant_controller.cc33
1 files changed, 30 insertions, 3 deletions
diff --git a/chrome/browser/ui/browser_instant_controller.cc b/chrome/browser/ui/browser_instant_controller.cc
index 5f6319a..b1252c5 100644
--- a/chrome/browser/ui/browser_instant_controller.cc
+++ b/chrome/browser/ui/browser_instant_controller.cc
@@ -14,6 +14,7 @@
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/omnibox/location_bar.h"
#include "chrome/browser/ui/search/search_model.h"
+#include "chrome/browser/ui/search/search_tab_helper.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/tab_contents/tab_contents.h"
#include "chrome/browser/ui/webui/ntp/app_launcher_handler.h"
@@ -22,6 +23,22 @@
#include "content/public/browser/notification_service.h"
#include "content/public/browser/web_contents.h"
+namespace {
+
+// Returns true iff the search model for |tab| is in an NTP state, that is, a
+// state in which the Instant overlay may be showing custom NTP content in
+// EXTENDED mode.
+bool IsSearchModelNTP(TabContents* tab) {
+ if (!tab || !tab->web_contents())
+ return false;
+ content::WebContents* web_contents = tab->web_contents();
+ chrome::search::SearchModel* model =
+ chrome::search::SearchTabHelper::FromWebContents(web_contents)->model();
+ return model && model->mode().is_ntp();
+}
+
+} // namespace
+
namespace chrome {
////////////////////////////////////////////////////////////////////////////////
@@ -116,9 +133,19 @@ void BrowserInstantController::OnPreferenceChanged(
////////////////////////////////////////////////////////////////////////////////
// BrowserInstantController, TabStripModelObserver implementation:
-void BrowserInstantController::TabDeactivated(TabContents* contents) {
- if (instant())
- instant_->Hide();
+void BrowserInstantController::ActiveTabChanged(
+ TabContents* old_contents,
+ TabContents* new_contents,
+ int index,
+ bool user_gesture) {
+ if (instant()) {
+ const bool old_is_ntp = IsSearchModelNTP(old_contents);
+ const bool new_is_ntp = IsSearchModelNTP(new_contents);
+ // Do not hide Instant if switching from an NTP to another NTP since that
+ // would cause custom NTP content to flicker.
+ if (!(old_is_ntp && new_is_ntp))
+ instant()->Hide();
+ }
}
////////////////////////////////////////////////////////////////////////////////