Index: chrome/browser/ui/search/search_model.cc |
diff --git a/chrome/browser/ui/search/search_model.cc b/chrome/browser/ui/search/search_model.cc |
index 53d0fcc9efd245bd685085d5c55051b98176cf6e..87c1303c57ae2f200b8cc5433fa28d60606bbe91 100644 |
--- a/chrome/browser/ui/search/search_model.cc |
+++ b/chrome/browser/ui/search/search_model.cc |
@@ -7,6 +7,25 @@ |
#include "chrome/browser/search/search.h" |
#include "chrome/browser/ui/search/search_model_observer.h" |
+SearchModel::State::State() |
+ : top_bars_visible(true), |
+ voice_search_supported(false) { |
+} |
+ |
+SearchModel::State::State(const SearchMode& mode, |
+ bool top_bars_visible, |
+ bool voice_search_supported) |
+ : mode(mode), |
+ top_bars_visible(top_bars_visible), |
+ voice_search_supported(voice_search_supported) { |
+} |
+ |
+bool SearchModel::State::operator==(const State& rhs) const { |
+ return mode == rhs.mode && top_bars_visible == rhs.top_bars_visible && |
+ voice_search_supported == rhs.voice_search_supported; |
+} |
+ |
+ |
SearchModel::SearchModel() { |
} |
@@ -64,7 +83,7 @@ void SearchModel::SetMode(const SearchMode& new_mode) { |
void SearchModel::SetTopBarsVisible(bool visible) { |
DCHECK(chrome::IsInstantExtendedAPIEnabled()) |
- << "Please do not try to set the SearchModel mode without first " |
+ << "Please do not try to set the SearchModel state without first " |
<< "checking if Search is enabled."; |
if (state_.top_bars_visible == visible) |
@@ -77,6 +96,21 @@ void SearchModel::SetTopBarsVisible(bool visible) { |
ModelChanged(old_state, state_)); |
} |
+void SearchModel::SetVoiceSearchSupported(bool supported) { |
+ DCHECK(chrome::IsInstantExtendedAPIEnabled()) |
+ << "Please do not try to set the SearchModel state without first " |
+ << "checking if Search is enabled."; |
+ |
+ if (state_.voice_search_supported == supported) |
+ return; |
+ |
+ const State old_state = state_; |
+ state_.voice_search_supported = supported; |
+ |
+ FOR_EACH_OBSERVER(SearchModelObserver, observers_, |
+ ModelChanged(old_state, state_)); |
+} |
+ |
void SearchModel::AddObserver(SearchModelObserver* observer) { |
observers_.AddObserver(observer); |
} |