summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/browser_instant_controller.cc
diff options
context:
space:
mode:
authorsamarth@chromium.org <samarth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-09 17:31:55 +0000
committersamarth@chromium.org <samarth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-09 17:31:55 +0000
commit0b10c9ffc2c13c44c848a03a5a885ac358ad4283 (patch)
treec1cb29b64994e3249f9bad02340a8405ffbaea01 /chrome/browser/ui/browser_instant_controller.cc
parentcb65f13f1259423dee5bd48536b31319c9c176fd (diff)
downloadchromium_src-0b10c9ffc2c13c44c848a03a5a885ac358ad4283.zip
chromium_src-0b10c9ffc2c13c44c848a03a5a885ac358ad4283.tar.gz
chromium_src-0b10c9ffc2c13c44c848a03a5a885ac358ad4283.tar.bz2
Implement context and oncontextchange for the SearchBox API
At the moment, context only represents whether the current active tab is the NTP or not. BUG=142785 Review URL: https://chromiumcodereview.appspot.com/11051016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@160863 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui/browser_instant_controller.cc')
-rw-r--r--chrome/browser/ui/browser_instant_controller.cc12
1 files changed, 12 insertions, 0 deletions
diff --git a/chrome/browser/ui/browser_instant_controller.cc b/chrome/browser/ui/browser_instant_controller.cc
index d4fd88b..6b35042 100644
--- a/chrome/browser/ui/browser_instant_controller.cc
+++ b/chrome/browser/ui/browser_instant_controller.cc
@@ -13,6 +13,7 @@
#include "chrome/browser/ui/browser_tabstrip.h"
#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/tabs/tab_strip_model.h"
#include "chrome/browser/ui/tab_contents/tab_contents.h"
#include "chrome/browser/ui/webui/ntp/app_launcher_handler.h"
@@ -33,10 +34,12 @@ BrowserInstantController::BrowserInstantController(Browser* browser)
profile_pref_registrar_.Add(prefs::kInstantEnabled, this);
ResetInstant();
browser_->tab_strip_model()->AddObserver(this);
+ browser_->search_model()->AddObserver(this);
}
BrowserInstantController::~BrowserInstantController() {
browser_->tab_strip_model()->RemoveObserver(this);
+ browser_->search_model()->RemoveObserver(this);
}
bool BrowserInstantController::OpenInstant(WindowOpenDisposition disposition) {
@@ -135,6 +138,15 @@ void BrowserInstantController::TabDeactivated(TabContents* contents) {
}
////////////////////////////////////////////////////////////////////////////////
+// BrowserInstantController, search::SearchModelObserver implementation:
+
+void BrowserInstantController::ModeChanged(const search::Mode& old_mode,
+ const search::Mode& new_mode) {
+ if (instant() && old_mode.is_ntp() != new_mode.is_ntp())
+ instant_->OnActiveTabModeChanged(new_mode.is_ntp());
+}
+
+////////////////////////////////////////////////////////////////////////////////
// BrowserInstantController, private:
void BrowserInstantController::ResetInstant() {