OLD | NEW |
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 Loading... |
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 } |
OLD | NEW |