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

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

Issue 1436583002: Revert of Remove setVoiceSearchSupported part of EmbeddedSearch SearchBox API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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() : instant_support(INSTANT_SUPPORT_UNKNOWN) {} 10 SearchModel::State::State()
11 : instant_support(INSTANT_SUPPORT_UNKNOWN),
12 voice_search_supported(false) {
13 }
11 14
12 SearchModel::State::State(const SearchMode& mode, 15 SearchModel::State::State(const SearchMode& mode,
13 InstantSupportState instant_support) 16 InstantSupportState instant_support,
14 : mode(mode), instant_support(instant_support) {} 17 bool voice_search_supported)
18 : mode(mode),
19 instant_support(instant_support),
20 voice_search_supported(voice_search_supported) {
21 }
15 22
16 bool SearchModel::State::operator==(const State& rhs) const { 23 bool SearchModel::State::operator==(const State& rhs) const {
17 return mode == rhs.mode && instant_support == rhs.instant_support; 24 return mode == rhs.mode && instant_support == rhs.instant_support &&
25 voice_search_supported == rhs.voice_search_supported;
18 } 26 }
19 27
20 SearchModel::SearchModel() { 28 SearchModel::SearchModel() {
21 } 29 }
22 30
23 SearchModel::~SearchModel() { 31 SearchModel::~SearchModel() {
24 } 32 }
25 33
26 void SearchModel::SetState(const State& new_state) { 34 void SearchModel::SetState(const State& new_state) {
27 DCHECK(search::IsInstantExtendedAPIEnabled()) 35 DCHECK(search::IsInstantExtendedAPIEnabled())
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 68
61 if (state_.instant_support == instant_support) 69 if (state_.instant_support == instant_support)
62 return; 70 return;
63 71
64 const State old_state = state_; 72 const State old_state = state_;
65 state_.instant_support = instant_support; 73 state_.instant_support = instant_support;
66 FOR_EACH_OBSERVER(SearchModelObserver, observers_, 74 FOR_EACH_OBSERVER(SearchModelObserver, observers_,
67 ModelChanged(old_state, state_)); 75 ModelChanged(old_state, state_));
68 } 76 }
69 77
78 void SearchModel::SetVoiceSearchSupported(bool supported) {
79 DCHECK(search::IsInstantExtendedAPIEnabled())
80 << "Please do not try to set the SearchModel state without first "
81 << "checking if Search is enabled.";
82
83 if (state_.voice_search_supported == supported)
84 return;
85
86 const State old_state = state_;
87 state_.voice_search_supported = supported;
88
89 FOR_EACH_OBSERVER(SearchModelObserver, observers_,
90 ModelChanged(old_state, state_));
91 }
92
70 void SearchModel::AddObserver(SearchModelObserver* observer) { 93 void SearchModel::AddObserver(SearchModelObserver* observer) {
71 observers_.AddObserver(observer); 94 observers_.AddObserver(observer);
72 } 95 }
73 96
74 void SearchModel::RemoveObserver(SearchModelObserver* observer) { 97 void SearchModel::RemoveObserver(SearchModelObserver* observer) {
75 observers_.RemoveObserver(observer); 98 observers_.RemoveObserver(observer);
76 } 99 }
OLDNEW
« 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