Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5452)

Unified Diff: chrome/browser/ui/search/search_model.cc

Issue 14911005: Move instant support to SearchTabHelper. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: '' Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/search/search_model.cc
diff --git a/chrome/browser/ui/search/search_model.cc b/chrome/browser/ui/search/search_model.cc
index 53d0fcc9efd245bd685085d5c55051b98176cf6e..c77eb1fc70e1ec9d100d9592375af9a99ad483a5 100644
--- a/chrome/browser/ui/search/search_model.cc
+++ b/chrome/browser/ui/search/search_model.cc
@@ -7,6 +7,22 @@
#include "chrome/browser/search/search.h"
#include "chrome/browser/ui/search/search_model_observer.h"
+SearchModel::State::State()
+ : top_bars_visible(true),
+ instant_support(INSTANT_SUPPORT_UNKNOWN) {
+}
+
+SearchModel::State::State(const SearchMode& mode, bool top_bars_visible)
samarth 2013/05/08 02:38:48 How is this constructor used. Does it also make s
kmadhusu 2013/05/09 02:40:40 This constructor is used in SearchTabHelper::Updat
+ : mode(mode),
+ top_bars_visible(top_bars_visible),
samarth 2013/05/08 02:38:48 nit: indent
kmadhusu 2013/05/09 02:40:40 Done.
+ instant_support(INSTANT_SUPPORT_UNKNOWN) {
+}
+
+bool SearchModel::State::operator==(const State& rhs) const {
+ return (mode == rhs.mode) && (top_bars_visible == rhs.top_bars_visible) &&
samarth 2013/05/08 02:38:48 nit: leave out the parens here.
kmadhusu 2013/05/09 02:40:40 Done.
+ (instant_support == rhs.instant_support);
+}
+
SearchModel::SearchModel() {
}
@@ -77,6 +93,24 @@ void SearchModel::SetTopBarsVisible(bool visible) {
ModelChanged(old_state, state_));
}
+void SearchModel::SetSupportsInstant(bool supports_instant) {
+ DCHECK(chrome::IsInstantExtendedAPIEnabled())
+ << "Please do not try to set the SearchModel mode without first "
+ << "checking if Search is enabled.";
+
+ InstantSupportState new_instant_support = supports_instant ?
+ INSTANT_SUPPORT_YES : INSTANT_SUPPORT_NO;
+
+ if (state_.instant_support == new_instant_support)
+ return;
+
+ const State old_state = state_;
+ state_.instant_support = new_instant_support;
+
+ FOR_EACH_OBSERVER(SearchModelObserver, observers_,
+ ModelChanged(old_state, state_));
+}
+
void SearchModel::AddObserver(SearchModelObserver* observer) {
observers_.AddObserver(observer);
}

Powered by Google App Engine
This is Rietveld 408576698