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

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

Issue 10644002: Add core plumbing for Instant Extended work (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed UI stuff from SearchModel Created 8 years, 6 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
new file mode 100644
index 0000000000000000000000000000000000000000..6cea8ef1413541e6c539822f51d10c36d2c05cee
--- /dev/null
+++ b/chrome/browser/ui/search/search_model.cc
@@ -0,0 +1,59 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/search/search_model.h"
+
+#include "chrome/browser/google/google_util.h"
tfarina 2012/06/21 22:49:55 do you need this, url_constants.h and web_contents
dhollowa 2012/06/21 23:53:42 Done.
+#include "chrome/browser/ui/search/search.h"
+#include "chrome/browser/ui/search/search_model_observer.h"
+#include "chrome/browser/ui/tab_contents/tab_contents.h"
+#include "chrome/common/url_constants.h"
+#include "content/public/browser/web_contents.h"
+
+namespace chrome {
+namespace search {
+
+SearchModel::SearchModel(TabContents* contents)
+ : contents_(contents) {
+}
+
+SearchModel::~SearchModel() {
+}
+
+void SearchModel::SetMode(const Mode& mode) {
+ if (contents_ == NULL)
tfarina 2012/06/21 22:49:55 nit: if (!contents_) return;
dhollowa 2012/06/21 23:53:42 Done.
+ return;
+
+ DCHECK(IsInstantExtendedAPIEnabled(contents_->profile()))
+ << "Please do not try to set the SearchModel mode without first "
+ << "checking if Search is enabled.";
+
+ if (mode_ == mode)
+ return;
+
+ mode_ = mode;
+
+ FOR_EACH_OBSERVER(SearchModelObserver, observers_, ModeChanged(mode_));
+
+ // Animation is transient, it is cleared after observers are notified.
+ mode_.animate = false;
+}
+
+void SearchModel::MaybeChangeMode(Mode::Type from_mode, Mode::Type to_mode) {
+ if (mode_.mode == from_mode) {
+ Mode mode(to_mode, true);
+ SetMode(mode);
+ }
+}
+
+void SearchModel::AddObserver(SearchModelObserver* observer) {
+ observers_.AddObserver(observer);
+}
+
+void SearchModel::RemoveObserver(SearchModelObserver* observer) {
+ observers_.RemoveObserver(observer);
+}
+
+} // namespace search
+} // namespace chrome

Powered by Google App Engine
This is Rietveld 408576698