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

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