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

Side by Side Diff: chrome/browser/speech/speech_input_manager.cc

Issue 3595018: Language tag for speech. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: rebase. Created 10 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) 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 11 matching lines...) Expand all
22 class SpeechInputManagerImpl : public SpeechInputManager, 22 class SpeechInputManagerImpl : public SpeechInputManager,
23 public SpeechInputBubbleControllerDelegate, 23 public SpeechInputBubbleControllerDelegate,
24 public SpeechRecognizerDelegate { 24 public SpeechRecognizerDelegate {
25 public: 25 public:
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 const std::string& language,
32 const std::string& grammar); 33 const std::string& grammar);
33 virtual void CancelRecognition(int caller_id); 34 virtual void CancelRecognition(int caller_id);
34 virtual void StopRecording(int caller_id); 35 virtual void StopRecording(int caller_id);
35 36
36 // SpeechRecognizer::Delegate methods. 37 // SpeechRecognizer::Delegate methods.
37 virtual void SetRecognitionResult(int caller_id, 38 virtual void SetRecognitionResult(int caller_id,
38 bool error, 39 bool error,
39 const SpeechInputResultArray& result); 40 const SpeechInputResultArray& result);
40 virtual void DidCompleteRecording(int caller_id); 41 virtual void DidCompleteRecording(int caller_id);
41 virtual void DidCompleteRecognition(int caller_id); 42 virtual void DidCompleteRecognition(int caller_id);
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 int caller_id) const { 100 int caller_id) const {
100 return requests_.find(caller_id)->second.delegate; 101 return requests_.find(caller_id)->second.delegate;
101 } 102 }
102 103
103 void SpeechInputManagerImpl::StartRecognition( 104 void SpeechInputManagerImpl::StartRecognition(
104 SpeechInputManagerDelegate* delegate, 105 SpeechInputManagerDelegate* delegate,
105 int caller_id, 106 int caller_id,
106 int render_process_id, 107 int render_process_id,
107 int render_view_id, 108 int render_view_id,
108 const gfx::Rect& element_rect, 109 const gfx::Rect& element_rect,
110 const std::string& language,
109 const std::string& grammar) { 111 const std::string& grammar) {
110 DCHECK(!HasPendingRequest(caller_id)); 112 DCHECK(!HasPendingRequest(caller_id));
111 113
112 bubble_controller_->CreateBubble(caller_id, render_process_id, render_view_id, 114 bubble_controller_->CreateBubble(caller_id, render_process_id, render_view_id,
113 element_rect); 115 element_rect);
114 116
115 SpeechInputRequest* request = &requests_[caller_id]; 117 SpeechInputRequest* request = &requests_[caller_id];
116 request->delegate = delegate; 118 request->delegate = delegate;
117 request->recognizer = new SpeechRecognizer(this, caller_id, grammar); 119 request->recognizer = new SpeechRecognizer(this, caller_id, language,
120 grammar);
118 request->is_active = false; 121 request->is_active = false;
119 122
120 StartRecognitionForRequest(caller_id); 123 StartRecognitionForRequest(caller_id);
121 } 124 }
122 125
123 void SpeechInputManagerImpl::StartRecognitionForRequest(int caller_id) { 126 void SpeechInputManagerImpl::StartRecognitionForRequest(int caller_id) {
124 DCHECK(HasPendingRequest(caller_id)); 127 DCHECK(HasPendingRequest(caller_id));
125 128
126 // If we are currently recording audio for another caller, abort that cleanly. 129 // If we are currently recording audio for another caller, abort that cleanly.
127 if (recording_caller_id_) 130 if (recording_caller_id_)
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 // to the user, abort it since user has switched focus. Otherwise 250 // to the user, abort it since user has switched focus. Otherwise
248 // recognition has started and keep that going so user can start speaking to 251 // recognition has started and keep that going so user can start speaking to
249 // another element while this gets the results in parallel. 252 // another element while this gets the results in parallel.
250 if (recording_caller_id_ == caller_id || !requests_[caller_id].is_active) { 253 if (recording_caller_id_ == caller_id || !requests_[caller_id].is_active) {
251 CancelRecognitionAndInformDelegate(caller_id); 254 CancelRecognitionAndInformDelegate(caller_id);
252 } 255 }
253 } 256 }
254 } 257 }
255 258
256 } // namespace speech_input 259 } // namespace speech_input
OLDNEW
« no previous file with comments | « chrome/browser/speech/speech_input_manager.h ('k') | chrome/browser/speech/speech_recognition_request.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698