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

Side by Side Diff: ui/app_list/speech_ui_model.cc

Issue 149753002: Enables the 'hotword not listening' icon in the search box. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix breaks Created 6 years, 10 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/app_list/speech_ui_model.h ('k') | ui/app_list/speech_ui_model_observer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "ui/app_list/speech_ui_model.h" 5 #include "ui/app_list/speech_ui_model.h"
6 6
7 namespace app_list { 7 namespace app_list {
8 8
9 namespace { 9 namespace {
10 10
11 // The default sound level, just gotten from the developer device. 11 // The default sound level, just gotten from the developer device.
12 const int16 kDefaultSoundLevel = 200; 12 const int16 kDefaultSoundLevel = 200;
13 13
14 } // namespace 14 } // namespace
15 15
16 SpeechUIModel::SpeechUIModel() 16 SpeechUIModel::SpeechUIModel(SpeechRecognitionState initial_state)
17 : minimum_sound_level_(kDefaultSoundLevel), 17 : state_(initial_state),
18 minimum_sound_level_(kDefaultSoundLevel),
18 maximum_sound_level_(kDefaultSoundLevel) {} 19 maximum_sound_level_(kDefaultSoundLevel) {}
19 20
20 SpeechUIModel::~SpeechUIModel() {} 21 SpeechUIModel::~SpeechUIModel() {}
21 22
22 void SpeechUIModel::SetSpeechResult(const base::string16& result, 23 void SpeechUIModel::SetSpeechResult(const base::string16& result,
23 bool is_final) { 24 bool is_final) {
24 if (result_ == result && is_final_ == is_final) 25 if (result_ == result && is_final_ == is_final)
25 return; 26 return;
26 27
27 result_ = result; 28 result_ = result;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 OnSpeechSoundLevelChanged(visible_level)); 68 OnSpeechSoundLevelChanged(visible_level));
68 } 69 }
69 70
70 void SpeechUIModel::SetSpeechRecognitionState( 71 void SpeechUIModel::SetSpeechRecognitionState(
71 SpeechRecognitionState new_state) { 72 SpeechRecognitionState new_state) {
72 if (state_ == new_state) 73 if (state_ == new_state)
73 return; 74 return;
74 75
75 state_ = new_state; 76 state_ = new_state;
76 // Revert the min/max sound level to the default. 77 // Revert the min/max sound level to the default.
77 if (state_ == SPEECH_RECOGNITION_ON) { 78 if (state_ != SPEECH_RECOGNITION_RECOGNIZING &&
79 state_ != SPEECH_RECOGNITION_IN_SPEECH) {
78 minimum_sound_level_ = kDefaultSoundLevel; 80 minimum_sound_level_ = kDefaultSoundLevel;
79 maximum_sound_level_ = kDefaultSoundLevel; 81 maximum_sound_level_ = kDefaultSoundLevel;
80 } 82 }
81 83
82 FOR_EACH_OBSERVER(SpeechUIModelObserver, 84 FOR_EACH_OBSERVER(SpeechUIModelObserver,
83 observers_, 85 observers_,
84 OnSpeechRecognitionStateChanged(new_state)); 86 OnSpeechRecognitionStateChanged(new_state));
85 } 87 }
86 88
87 void SpeechUIModel::AddObserver(SpeechUIModelObserver* observer) { 89 void SpeechUIModel::AddObserver(SpeechUIModelObserver* observer) {
88 observers_.AddObserver(observer); 90 observers_.AddObserver(observer);
89 } 91 }
90 92
91 void SpeechUIModel::RemoveObserver(SpeechUIModelObserver* observer) { 93 void SpeechUIModel::RemoveObserver(SpeechUIModelObserver* observer) {
92 observers_.RemoveObserver(observer); 94 observers_.RemoveObserver(observer);
93 } 95 }
94 96
95 } // namespace app_list 97 } // namespace app_list
OLDNEW
« no previous file with comments | « ui/app_list/speech_ui_model.h ('k') | ui/app_list/speech_ui_model_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698