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

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

Issue 1428423002: 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() 10 SearchModel::State::State()
11 : instant_support(INSTANT_SUPPORT_UNKNOWN), 11 : instant_support(INSTANT_SUPPORT_UNKNOWN) {
msw 2015/11/06 23:59:23 nit: fits on line above
12 voice_search_supported(false) {
13 } 12 }
14 13
15 SearchModel::State::State(const SearchMode& mode, 14 SearchModel::State::State(const SearchMode& mode,
16 InstantSupportState instant_support, 15 InstantSupportState instant_support)
17 bool voice_search_supported)
18 : mode(mode), 16 : mode(mode),
19 instant_support(instant_support), 17 instant_support(instant_support) {
20 voice_search_supported(voice_search_supported) {
21 } 18 }
22 19
23 bool SearchModel::State::operator==(const State& rhs) const { 20 bool SearchModel::State::operator==(const State& rhs) const {
24 return mode == rhs.mode && instant_support == rhs.instant_support && 21 return mode == rhs.mode && instant_support == rhs.instant_support;
25 voice_search_supported == rhs.voice_search_supported;
26 } 22 }
27 23
28 SearchModel::SearchModel() { 24 SearchModel::SearchModel() {
29 } 25 }
30 26
31 SearchModel::~SearchModel() { 27 SearchModel::~SearchModel() {
32 } 28 }
33 29
34 void SearchModel::SetState(const State& new_state) { 30 void SearchModel::SetState(const State& new_state) {
35 DCHECK(search::IsInstantExtendedAPIEnabled()) 31 DCHECK(search::IsInstantExtendedAPIEnabled())
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 64
69 if (state_.instant_support == instant_support) 65 if (state_.instant_support == instant_support)
70 return; 66 return;
71 67
72 const State old_state = state_; 68 const State old_state = state_;
73 state_.instant_support = instant_support; 69 state_.instant_support = instant_support;
74 FOR_EACH_OBSERVER(SearchModelObserver, observers_, 70 FOR_EACH_OBSERVER(SearchModelObserver, observers_,
75 ModelChanged(old_state, state_)); 71 ModelChanged(old_state, state_));
76 } 72 }
77 73
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
93 void SearchModel::AddObserver(SearchModelObserver* observer) { 74 void SearchModel::AddObserver(SearchModelObserver* observer) {
94 observers_.AddObserver(observer); 75 observers_.AddObserver(observer);
95 } 76 }
96 77
97 void SearchModel::RemoveObserver(SearchModelObserver* observer) { 78 void SearchModel::RemoveObserver(SearchModelObserver* observer) {
98 observers_.RemoveObserver(observer); 79 observers_.RemoveObserver(observer);
99 } 80 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698