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

Side by Side Diff: chrome/browser/ui/search/search_model.cc

Issue 10816027: alternate ntp: toolbar background and separator animation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix android build break Created 8 years, 4 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/search/search_model.h" 5 #include "chrome/browser/ui/search/search_model.h"
6 6
7 #include "chrome/browser/ui/search/search.h" 7 #include "chrome/browser/ui/search/search.h"
8 #include "chrome/browser/ui/search/search_model_observer.h" 8 #include "chrome/browser/ui/search/search_model_observer.h"
9 #include "chrome/browser/ui/tab_contents/tab_contents.h" 9 #include "chrome/browser/ui/tab_contents/tab_contents.h"
10 10
11 namespace chrome { 11 namespace chrome {
12 namespace search { 12 namespace search {
13 13
14 SearchModel::SearchModel(TabContents* contents) 14 SearchModel::SearchModel(TabContents* contents)
15 : contents_(contents) { 15 : contents_(contents) {
16 } 16 }
17 17
18 SearchModel::~SearchModel() { 18 SearchModel::~SearchModel() {
19 } 19 }
20 20
21 void SearchModel::SetMode(const Mode& mode) { 21 void SearchModel::SetMode(const Mode& new_mode) {
22 if (!contents_) 22 if (!contents_)
23 return; 23 return;
24 24
25 DCHECK(IsInstantExtendedAPIEnabled(contents_->profile())) 25 DCHECK(IsInstantExtendedAPIEnabled(contents_->profile()))
26 << "Please do not try to set the SearchModel mode without first " 26 << "Please do not try to set the SearchModel mode without first "
27 << "checking if Search is enabled."; 27 << "checking if Search is enabled.";
28 28
29 if (mode_ == mode) 29 if (mode_ == new_mode)
30 return; 30 return;
31 31
32 mode_ = mode; 32 const Mode old_mode = mode_;
33 mode_ = new_mode;
33 34
34 FOR_EACH_OBSERVER(SearchModelObserver, observers_, ModeChanged(mode_)); 35 FOR_EACH_OBSERVER(SearchModelObserver, observers_,
36 ModeChanged(old_mode, mode_));
35 37
36 // Animation is transient, it is cleared after observers are notified. 38 // Animation is transient, it is cleared after observers are notified.
37 mode_.animate = false; 39 mode_.animate = false;
38 } 40 }
39 41
40 void SearchModel::MaybeChangeMode(Mode::Type from_mode, Mode::Type to_mode) { 42 void SearchModel::MaybeChangeMode(Mode::Type from_mode, Mode::Type to_mode) {
41 if (mode_.mode == from_mode) { 43 if (mode_.mode == from_mode) {
42 Mode mode(to_mode, true); 44 Mode mode(to_mode, true);
43 SetMode(mode); 45 SetMode(mode);
44 } 46 }
45 } 47 }
46 48
47 void SearchModel::AddObserver(SearchModelObserver* observer) { 49 void SearchModel::AddObserver(SearchModelObserver* observer) {
48 observers_.AddObserver(observer); 50 observers_.AddObserver(observer);
49 } 51 }
50 52
51 void SearchModel::RemoveObserver(SearchModelObserver* observer) { 53 void SearchModel::RemoveObserver(SearchModelObserver* observer) {
52 observers_.RemoveObserver(observer); 54 observers_.RemoveObserver(observer);
53 } 55 }
54 56
55 } // namespace search 57 } // namespace search
56 } // namespace chrome 58 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/ui/search/search_delegate.cc ('k') | chrome/browser/ui/search/search_model_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698