| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "content/browser/speech/speech_input_manager.h" | 5 #include "content/browser/speech/speech_input_manager.h" |
| 6 | 6 |
| 7 #include "content/browser/browser_thread.h" | 7 #include "content/browser/browser_thread.h" |
| 8 #include "content/browser/speech/speech_input_preferences.h" |
| 8 #include "media/audio/audio_manager.h" | 9 #include "media/audio/audio_manager.h" |
| 9 | 10 |
| 10 namespace speech_input { | 11 namespace speech_input { |
| 11 | 12 |
| 12 SpeechInputManager::SpeechInputManager() | 13 SpeechInputManager::SpeechInputManager() |
| 13 : can_report_metrics_(false), | 14 : can_report_metrics_(false), |
| 14 censor_results_(true), | |
| 15 recording_caller_id_(0) { | 15 recording_caller_id_(0) { |
| 16 } | 16 } |
| 17 | 17 |
| 18 SpeechInputManager::~SpeechInputManager() { | 18 SpeechInputManager::~SpeechInputManager() { |
| 19 while (requests_.begin() != requests_.end()) | 19 while (requests_.begin() != requests_.end()) |
| 20 CancelRecognition(requests_.begin()->first); | 20 CancelRecognition(requests_.begin()->first); |
| 21 } | 21 } |
| 22 | 22 |
| 23 bool SpeechInputManager::HasPendingRequest(int caller_id) const { | 23 bool SpeechInputManager::HasPendingRequest(int caller_id) const { |
| 24 return requests_.find(caller_id) != requests_.end(); | 24 return requests_.find(caller_id) != requests_.end(); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 45 } | 45 } |
| 46 | 46 |
| 47 void SpeechInputManager::StartRecognition( | 47 void SpeechInputManager::StartRecognition( |
| 48 SpeechInputManagerDelegate* delegate, | 48 SpeechInputManagerDelegate* delegate, |
| 49 int caller_id, | 49 int caller_id, |
| 50 int render_process_id, | 50 int render_process_id, |
| 51 int render_view_id, | 51 int render_view_id, |
| 52 const gfx::Rect& element_rect, | 52 const gfx::Rect& element_rect, |
| 53 const std::string& language, | 53 const std::string& language, |
| 54 const std::string& grammar, | 54 const std::string& grammar, |
| 55 const std::string& origin_url) { | 55 const std::string& origin_url, |
| 56 net::URLRequestContextGetter* context_getter, |
| 57 SpeechInputPreferences* speech_input_prefs) { |
| 56 DCHECK(!HasPendingRequest(caller_id)); | 58 DCHECK(!HasPendingRequest(caller_id)); |
| 57 | 59 |
| 58 ShowRecognitionRequested( | 60 ShowRecognitionRequested( |
| 59 caller_id, render_process_id, render_view_id, element_rect); | 61 caller_id, render_process_id, render_view_id, element_rect); |
| 60 GetRequestInfo(&can_report_metrics_, &request_info_); | 62 GetRequestInfo(&can_report_metrics_, &request_info_); |
| 61 | 63 |
| 62 SpeechInputRequest* request = &requests_[caller_id]; | 64 SpeechInputRequest* request = &requests_[caller_id]; |
| 63 request->delegate = delegate; | 65 request->delegate = delegate; |
| 64 request->recognizer = new SpeechRecognizer( | 66 request->recognizer = new SpeechRecognizer( |
| 65 this, caller_id, language, grammar, censor_results(), | 67 this, caller_id, language, grammar, context_getter, |
| 68 speech_input_prefs->censor_results(), |
| 66 request_info_, can_report_metrics_ ? origin_url : ""); | 69 request_info_, can_report_metrics_ ? origin_url : ""); |
| 67 request->is_active = false; | 70 request->is_active = false; |
| 68 | 71 |
| 69 StartRecognitionForRequest(caller_id); | 72 StartRecognitionForRequest(caller_id); |
| 70 } | 73 } |
| 71 | 74 |
| 72 void SpeechInputManager::StartRecognitionForRequest(int caller_id) { | 75 void SpeechInputManager::StartRecognitionForRequest(int caller_id) { |
| 73 DCHECK(HasPendingRequest(caller_id)); | 76 DCHECK(HasPendingRequest(caller_id)); |
| 74 | 77 |
| 75 // If we are currently recording audio for another caller, abort that cleanly. | 78 // If we are currently recording audio for another caller, abort that cleanly. |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 | 189 |
| 187 SpeechInputManager::SpeechInputRequest::SpeechInputRequest() | 190 SpeechInputManager::SpeechInputRequest::SpeechInputRequest() |
| 188 : delegate(NULL), | 191 : delegate(NULL), |
| 189 is_active(false) { | 192 is_active(false) { |
| 190 } | 193 } |
| 191 | 194 |
| 192 SpeechInputManager::SpeechInputRequest::~SpeechInputRequest() { | 195 SpeechInputManager::SpeechInputRequest::~SpeechInputRequest() { |
| 193 } | 196 } |
| 194 | 197 |
| 195 } // namespace speech_input | 198 } // namespace speech_input |
| OLD | NEW |