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