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

Unified Diff: chrome/browser/ui/search/search_model.cc

Issue 17132011: Add setVoiceSearchSupported to the searchbox API. This will be used to determine whether to show a … (Closed) Base URL: https://git.chromium.org/chromium/src.git@master
Patch Set: Rebase past 16035020, add test. Created 7 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/search/search_model.h ('k') | chrome/browser/ui/search/search_model_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 67a276429c29eebcf6d1809703853d7fcfb8ae09..840fbfae49c0e4f48a07b238546b485981f1b7e7 100644
--- a/chrome/browser/ui/search/search_model.cc
+++ b/chrome/browser/ui/search/search_model.cc
@@ -9,20 +9,24 @@
SearchModel::State::State()
: top_bars_visible(true),
- instant_support(INSTANT_SUPPORT_UNKNOWN) {
+ instant_support(INSTANT_SUPPORT_UNKNOWN),
+ voice_search_supported(false) {
}
SearchModel::State::State(const SearchMode& mode,
bool top_bars_visible,
- InstantSupportState instant_support)
+ InstantSupportState instant_support,
+ bool voice_search_supported)
: mode(mode),
top_bars_visible(top_bars_visible),
- instant_support(instant_support) {
+ instant_support(instant_support),
+ 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 &&
- instant_support == rhs.instant_support;
+ instant_support == rhs.instant_support &&
+ voice_search_supported == rhs.voice_search_supported;
}
SearchModel::SearchModel() {
@@ -82,7 +86,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)
@@ -97,7 +101,7 @@ void SearchModel::SetTopBarsVisible(bool visible) {
void SearchModel::SetInstantSupportState(InstantSupportState instant_support) {
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_.instant_support == instant_support)
@@ -109,6 +113,21 @@ void SearchModel::SetInstantSupportState(InstantSupportState instant_support) {
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);
}
« no previous file with comments | « chrome/browser/ui/search/search_model.h ('k') | chrome/browser/ui/search/search_model_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698