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

Side by Side 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 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/search/search.h" 7 #include "chrome/browser/search/search.h"
8 #include "chrome/browser/ui/search/search_model_observer.h" 8 #include "chrome/browser/ui/search/search_model_observer.h"
9 9
10 SearchModel::State::State()
11 : top_bars_visible(true),
12 instant_support(INSTANT_SUPPORT_UNKNOWN) {
13 }
14
15 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
16 : mode(mode),
17 top_bars_visible(top_bars_visible),
samarth 2013/05/08 02:38:48 nit: indent
kmadhusu 2013/05/09 02:40:40 Done.
18 instant_support(INSTANT_SUPPORT_UNKNOWN) {
19 }
20
21 bool SearchModel::State::operator==(const State& rhs) const {
22 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.
23 (instant_support == rhs.instant_support);
24 }
25
10 SearchModel::SearchModel() { 26 SearchModel::SearchModel() {
11 } 27 }
12 28
13 SearchModel::~SearchModel() { 29 SearchModel::~SearchModel() {
14 } 30 }
15 31
16 // static. 32 // static.
17 bool SearchModel::ShouldChangeTopBarsVisibility(const State& old_state, 33 bool SearchModel::ShouldChangeTopBarsVisibility(const State& old_state,
18 const State& new_state) { 34 const State& new_state) {
19 // If mode has changed, only change top bars visibility if new mode is not 35 // If mode has changed, only change top bars visibility if new mode is not
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 if (state_.top_bars_visible == visible) 86 if (state_.top_bars_visible == visible)
71 return; 87 return;
72 88
73 const State old_state = state_; 89 const State old_state = state_;
74 state_.top_bars_visible = visible; 90 state_.top_bars_visible = visible;
75 91
76 FOR_EACH_OBSERVER(SearchModelObserver, observers_, 92 FOR_EACH_OBSERVER(SearchModelObserver, observers_,
77 ModelChanged(old_state, state_)); 93 ModelChanged(old_state, state_));
78 } 94 }
79 95
96 void SearchModel::SetSupportsInstant(bool supports_instant) {
97 DCHECK(chrome::IsInstantExtendedAPIEnabled())
98 << "Please do not try to set the SearchModel mode without first "
99 << "checking if Search is enabled.";
100
101 InstantSupportState new_instant_support = supports_instant ?
102 INSTANT_SUPPORT_YES : INSTANT_SUPPORT_NO;
103
104 if (state_.instant_support == new_instant_support)
105 return;
106
107 const State old_state = state_;
108 state_.instant_support = new_instant_support;
109
110 FOR_EACH_OBSERVER(SearchModelObserver, observers_,
111 ModelChanged(old_state, state_));
112 }
113
80 void SearchModel::AddObserver(SearchModelObserver* observer) { 114 void SearchModel::AddObserver(SearchModelObserver* observer) {
81 observers_.AddObserver(observer); 115 observers_.AddObserver(observer);
82 } 116 }
83 117
84 void SearchModel::RemoveObserver(SearchModelObserver* observer) { 118 void SearchModel::RemoveObserver(SearchModelObserver* observer) {
85 observers_.RemoveObserver(observer); 119 observers_.RemoveObserver(observer);
86 } 120 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698