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

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: Respond and revert changes. 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
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);
}

Powered by Google App Engine
This is Rietveld 408576698