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

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

Issue 1260033003: Partially componentize //chrome/browser/search/search.{h,cc} (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix compilation on iOS Created 5 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
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_model_observer.h" 7 #include "chrome/browser/ui/search/search_model_observer.h"
8 #include "components/search/search.h" 8 #include "components/search/search.h"
9 9
10 SearchModel::State::State() 10 SearchModel::State::State()
(...skipping 14 matching lines...) Expand all
25 voice_search_supported == rhs.voice_search_supported; 25 voice_search_supported == rhs.voice_search_supported;
26 } 26 }
27 27
28 SearchModel::SearchModel() { 28 SearchModel::SearchModel() {
29 } 29 }
30 30
31 SearchModel::~SearchModel() { 31 SearchModel::~SearchModel() {
32 } 32 }
33 33
34 void SearchModel::SetState(const State& new_state) { 34 void SearchModel::SetState(const State& new_state) {
35 DCHECK(chrome::IsInstantExtendedAPIEnabled()) 35 DCHECK(search::IsInstantExtendedAPIEnabled())
36 << "Please do not try to set the SearchModel mode without first " 36 << "Please do not try to set the SearchModel mode without first "
37 << "checking if Search is enabled."; 37 << "checking if Search is enabled.";
38 38
39 if (state_ == new_state) 39 if (state_ == new_state)
40 return; 40 return;
41 41
42 const State old_state = state_; 42 const State old_state = state_;
43 state_ = new_state; 43 state_ = new_state;
44 44
45 FOR_EACH_OBSERVER(SearchModelObserver, observers_, 45 FOR_EACH_OBSERVER(SearchModelObserver, observers_,
46 ModelChanged(old_state, state_)); 46 ModelChanged(old_state, state_));
47 } 47 }
48 48
49 void SearchModel::SetMode(const SearchMode& new_mode) { 49 void SearchModel::SetMode(const SearchMode& new_mode) {
50 DCHECK(chrome::IsInstantExtendedAPIEnabled()) 50 DCHECK(search::IsInstantExtendedAPIEnabled())
51 << "Please do not try to set the SearchModel mode without first " 51 << "Please do not try to set the SearchModel mode without first "
52 << "checking if Search is enabled."; 52 << "checking if Search is enabled.";
53 53
54 if (state_.mode == new_mode) 54 if (state_.mode == new_mode)
55 return; 55 return;
56 56
57 const State old_state = state_; 57 const State old_state = state_;
58 state_.mode = new_mode; 58 state_.mode = new_mode;
59 59
60 FOR_EACH_OBSERVER(SearchModelObserver, observers_, 60 FOR_EACH_OBSERVER(SearchModelObserver, observers_,
61 ModelChanged(old_state, state_)); 61 ModelChanged(old_state, state_));
62 } 62 }
63 63
64 void SearchModel::SetInstantSupportState(InstantSupportState instant_support) { 64 void SearchModel::SetInstantSupportState(InstantSupportState instant_support) {
65 DCHECK(chrome::IsInstantExtendedAPIEnabled()) 65 DCHECK(search::IsInstantExtendedAPIEnabled())
66 << "Please do not try to set the SearchModel state without first " 66 << "Please do not try to set the SearchModel state without first "
67 << "checking if Search is enabled."; 67 << "checking if Search is enabled.";
68 68
69 if (state_.instant_support == instant_support) 69 if (state_.instant_support == instant_support)
70 return; 70 return;
71 71
72 const State old_state = state_; 72 const State old_state = state_;
73 state_.instant_support = instant_support; 73 state_.instant_support = instant_support;
74 FOR_EACH_OBSERVER(SearchModelObserver, observers_, 74 FOR_EACH_OBSERVER(SearchModelObserver, observers_,
75 ModelChanged(old_state, state_)); 75 ModelChanged(old_state, state_));
76 } 76 }
77 77
78 void SearchModel::SetVoiceSearchSupported(bool supported) { 78 void SearchModel::SetVoiceSearchSupported(bool supported) {
79 DCHECK(chrome::IsInstantExtendedAPIEnabled()) 79 DCHECK(search::IsInstantExtendedAPIEnabled())
80 << "Please do not try to set the SearchModel state without first " 80 << "Please do not try to set the SearchModel state without first "
81 << "checking if Search is enabled."; 81 << "checking if Search is enabled.";
82 82
83 if (state_.voice_search_supported == supported) 83 if (state_.voice_search_supported == supported)
84 return; 84 return;
85 85
86 const State old_state = state_; 86 const State old_state = state_;
87 state_.voice_search_supported = supported; 87 state_.voice_search_supported = supported;
88 88
89 FOR_EACH_OBSERVER(SearchModelObserver, observers_, 89 FOR_EACH_OBSERVER(SearchModelObserver, observers_,
90 ModelChanged(old_state, state_)); 90 ModelChanged(old_state, state_));
91 } 91 }
92 92
93 void SearchModel::AddObserver(SearchModelObserver* observer) { 93 void SearchModel::AddObserver(SearchModelObserver* observer) {
94 observers_.AddObserver(observer); 94 observers_.AddObserver(observer);
95 } 95 }
96 96
97 void SearchModel::RemoveObserver(SearchModelObserver* observer) { 97 void SearchModel::RemoveObserver(SearchModelObserver* observer) {
98 observers_.RemoveObserver(observer); 98 observers_.RemoveObserver(observer);
99 } 99 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/search/search_ipc_router_unittest.cc ('k') | chrome/browser/ui/search/search_tab_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698