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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/search/search_model.h"
6
7 #include "chrome/browser/ui/search/search.h"
8 #include "chrome/browser/ui/search/search_model_observer.h"
9 #include "chrome/browser/ui/tab_contents/tab_contents.h"
10
11 namespace chrome {
12 namespace search {
13
14 SearchModel::SearchModel(TabContents* contents)
15 : contents_(contents) {
16 }
17
18 SearchModel::~SearchModel() {
19 }
20
21 void SearchModel::SetMode(const Mode& mode) {
22 if (!contents_)
23 return;
24
25 DCHECK(IsInstantExtendedAPIEnabled(contents_->profile()))
26 << "Please do not try to set the SearchModel mode without first "
27 << "checking if Search is enabled.";
28
29 if (mode_ == mode)
30 return;
31
32 mode_ = mode;
33
34 FOR_EACH_OBSERVER(SearchModelObserver, observers_, ModeChanged(mode_));
35
36 // Animation is transient, it is cleared after observers are notified.
37 mode_.animate = false;
38 }
39
40 void SearchModel::MaybeChangeMode(Mode::Type from_mode, Mode::Type to_mode) {
41 if (mode_.mode == from_mode) {
42 Mode mode(to_mode, true);
43 SetMode(mode);
44 }
45 }
46
47 void SearchModel::AddObserver(SearchModelObserver* observer) {
48 observers_.AddObserver(observer);
49 }
50
51 void SearchModel::RemoveObserver(SearchModelObserver* observer) {
52 observers_.RemoveObserver(observer);
53 }
54
55 } // namespace search
56 } // namespace chrome
OLDNEW
« 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