OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/speech/speech_input_manager.h" | 5 #include "chrome/browser/speech/speech_input_manager.h" |
6 | 6 |
7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
8 #include "base/ref_counted.h" | 8 #include "base/ref_counted.h" |
9 #include "base/singleton.h" | 9 #include "base/singleton.h" |
10 #include "chrome/browser/browser_thread.h" | 10 #include "chrome/browser/browser_thread.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 // SpeechInputManager methods. | 26 // SpeechInputManager methods. |
27 virtual void StartRecognition(SpeechInputManagerDelegate* delegate, | 27 virtual void StartRecognition(SpeechInputManagerDelegate* delegate, |
28 int caller_id, | 28 int caller_id, |
29 int render_process_id, | 29 int render_process_id, |
30 int render_view_id, | 30 int render_view_id, |
31 const gfx::Rect& element_rect); | 31 const gfx::Rect& element_rect); |
32 virtual void CancelRecognition(int caller_id); | 32 virtual void CancelRecognition(int caller_id); |
33 virtual void StopRecording(int caller_id); | 33 virtual void StopRecording(int caller_id); |
34 | 34 |
35 // SpeechRecognizer::Delegate methods. | 35 // SpeechRecognizer::Delegate methods. |
36 virtual void SetRecognitionResult(int caller_id, bool error, | 36 virtual void SetRecognitionResult(int caller_id, |
37 const string16& value); | 37 bool error, |
| 38 const SpeechInputResultArray& result); |
38 virtual void DidCompleteRecording(int caller_id); | 39 virtual void DidCompleteRecording(int caller_id); |
39 virtual void DidCompleteRecognition(int caller_id); | 40 virtual void DidCompleteRecognition(int caller_id); |
40 virtual void OnRecognizerError(int caller_id, | 41 virtual void OnRecognizerError(int caller_id, |
41 SpeechRecognizer::ErrorCode error); | 42 SpeechRecognizer::ErrorCode error); |
42 virtual void DidCompleteEnvironmentEstimation(int caller_id); | 43 virtual void DidCompleteEnvironmentEstimation(int caller_id); |
43 virtual void SetInputVolume(int caller_id, float volume); | 44 virtual void SetInputVolume(int caller_id, float volume); |
44 | 45 |
45 // SpeechInputBubbleController::Delegate methods. | 46 // SpeechInputBubbleController::Delegate methods. |
46 virtual void InfoBubbleButtonClicked(int caller_id, | 47 virtual void InfoBubbleButtonClicked(int caller_id, |
47 SpeechInputBubble::Button button); | 48 SpeechInputBubble::Button button); |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 if (recording_caller_id_ == caller_id) | 143 if (recording_caller_id_ == caller_id) |
143 recording_caller_id_ = 0; | 144 recording_caller_id_ = 0; |
144 bubble_controller_->CloseBubble(caller_id); | 145 bubble_controller_->CloseBubble(caller_id); |
145 } | 146 } |
146 | 147 |
147 void SpeechInputManagerImpl::StopRecording(int caller_id) { | 148 void SpeechInputManagerImpl::StopRecording(int caller_id) { |
148 DCHECK(HasPendingRequest(caller_id)); | 149 DCHECK(HasPendingRequest(caller_id)); |
149 requests_[caller_id].recognizer->StopRecording(); | 150 requests_[caller_id].recognizer->StopRecording(); |
150 } | 151 } |
151 | 152 |
152 void SpeechInputManagerImpl::SetRecognitionResult(int caller_id, | 153 void SpeechInputManagerImpl::SetRecognitionResult( |
153 bool error, | 154 int caller_id, bool error, const SpeechInputResultArray& result) { |
154 const string16& value) { | |
155 DCHECK(HasPendingRequest(caller_id)); | 155 DCHECK(HasPendingRequest(caller_id)); |
156 GetDelegate(caller_id)->SetRecognitionResult(caller_id, | 156 GetDelegate(caller_id)->SetRecognitionResult(caller_id, result); |
157 (error ? string16() : value)); | |
158 } | 157 } |
159 | 158 |
160 void SpeechInputManagerImpl::DidCompleteRecording(int caller_id) { | 159 void SpeechInputManagerImpl::DidCompleteRecording(int caller_id) { |
161 DCHECK(recording_caller_id_ == caller_id); | 160 DCHECK(recording_caller_id_ == caller_id); |
162 DCHECK(HasPendingRequest(caller_id)); | 161 DCHECK(HasPendingRequest(caller_id)); |
163 recording_caller_id_ = 0; | 162 recording_caller_id_ = 0; |
164 GetDelegate(caller_id)->DidCompleteRecording(caller_id); | 163 GetDelegate(caller_id)->DidCompleteRecording(caller_id); |
165 bubble_controller_->SetBubbleRecognizingMode(caller_id); | 164 bubble_controller_->SetBubbleRecognizingMode(caller_id); |
166 } | 165 } |
167 | 166 |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 // to the user, abort it since user has switched focus. Otherwise | 245 // to the user, abort it since user has switched focus. Otherwise |
247 // recognition has started and keep that going so user can start speaking to | 246 // recognition has started and keep that going so user can start speaking to |
248 // another element while this gets the results in parallel. | 247 // another element while this gets the results in parallel. |
249 if (recording_caller_id_ == caller_id || !requests_[caller_id].is_active) { | 248 if (recording_caller_id_ == caller_id || !requests_[caller_id].is_active) { |
250 CancelRecognitionAndInformDelegate(caller_id); | 249 CancelRecognitionAndInformDelegate(caller_id); |
251 } | 250 } |
252 } | 251 } |
253 } | 252 } |
254 | 253 |
255 } // namespace speech_input | 254 } // namespace speech_input |
OLD | NEW |