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

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: Address pkasting, tfarina, and remaining nits. 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
« no previous file with comments | « chrome/browser/ui/search/search_model.h ('k') | chrome/browser/ui/search/search_model_observer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..8d98be1ab8bc6821efc7b89c97a10daa51774178
--- /dev/null
+++ b/chrome/browser/ui/search/search_model.cc
@@ -0,0 +1,56 @@
+// 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/ui/search/search.h"
+#include "chrome/browser/ui/search/search_model_observer.h"
+#include "chrome/browser/ui/tab_contents/tab_contents.h"
+
+namespace chrome {
+namespace search {
+
+SearchModel::SearchModel(TabContents* contents)
+ : contents_(contents) {
+}
+
+SearchModel::~SearchModel() {
+}
+
+void SearchModel::SetMode(const Mode& mode) {
+ if (!contents_)
+ 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
« no previous file with comments | « chrome/browser/ui/search/search_model.h ('k') | chrome/browser/ui/search/search_model_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698