OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_recognition_manager_impl.h" | 5 #include "content/browser/speech/speech_recognition_manager_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "content/browser/browser_main_loop.h" | 8 #include "content/browser/browser_main_loop.h" |
9 #include "content/browser/renderer_host/media/media_stream_manager.h" | 9 #include "content/browser/renderer_host/media/media_stream_manager.h" |
10 #include "content/browser/speech/google_one_shot_remote_engine.h" | 10 #include "content/browser/speech/google_one_shot_remote_engine.h" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 const int session_id = GetNextSessionID(); | 79 const int session_id = GetNextSessionID(); |
80 DCHECK(!SessionExists(session_id)); | 80 DCHECK(!SessionExists(session_id)); |
81 // Set-up the new session. | 81 // Set-up the new session. |
82 Session& session = sessions_[session_id]; | 82 Session& session = sessions_[session_id]; |
83 session.id = session_id; | 83 session.id = session_id; |
84 session.config = config; | 84 session.config = config; |
85 session.context = config.initial_context; | 85 session.context = config.initial_context; |
86 | 86 |
87 std::string hardware_info; | 87 std::string hardware_info; |
88 bool can_report_metrics = false; | 88 bool can_report_metrics = false; |
89 if (delegate_.get()) | 89 if (delegate_) |
90 delegate_->GetDiagnosticInformation(&can_report_metrics, &hardware_info); | 90 delegate_->GetDiagnosticInformation(&can_report_metrics, &hardware_info); |
91 | 91 |
92 SpeechRecognitionEngineConfig remote_engine_config; | 92 SpeechRecognitionEngineConfig remote_engine_config; |
93 remote_engine_config.language = config.language; | 93 remote_engine_config.language = config.language; |
94 remote_engine_config.grammars = config.grammars; | 94 remote_engine_config.grammars = config.grammars; |
95 remote_engine_config.audio_sample_rate = SpeechRecognizer::kAudioSampleRate; | 95 remote_engine_config.audio_sample_rate = SpeechRecognizer::kAudioSampleRate; |
96 remote_engine_config.audio_num_bits_per_sample = | 96 remote_engine_config.audio_num_bits_per_sample = |
97 SpeechRecognizer::kNumBitsPerAudioSample; | 97 SpeechRecognizer::kNumBitsPerAudioSample; |
98 remote_engine_config.filter_profanities = config.filter_profanities; | 98 remote_engine_config.filter_profanities = config.filter_profanities; |
99 remote_engine_config.continuous = config.continuous; | 99 remote_engine_config.continuous = config.continuous; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 return; | 131 return; |
132 | 132 |
133 // If there is another active session, abort that. | 133 // If there is another active session, abort that. |
134 if (primary_session_id_ != kSessionIDInvalid && | 134 if (primary_session_id_ != kSessionIDInvalid && |
135 primary_session_id_ != session_id) { | 135 primary_session_id_ != session_id) { |
136 AbortSession(primary_session_id_); | 136 AbortSession(primary_session_id_); |
137 } | 137 } |
138 | 138 |
139 primary_session_id_ = session_id; | 139 primary_session_id_ = session_id; |
140 | 140 |
141 if (delegate_.get()) { | 141 if (delegate_) { |
142 delegate_->CheckRecognitionIsAllowed( | 142 delegate_->CheckRecognitionIsAllowed( |
143 session_id, | 143 session_id, |
144 base::Bind(&SpeechRecognitionManagerImpl::RecognitionAllowedCallback, | 144 base::Bind(&SpeechRecognitionManagerImpl::RecognitionAllowedCallback, |
145 weak_factory_.GetWeakPtr(), | 145 weak_factory_.GetWeakPtr(), |
146 session_id)); | 146 session_id)); |
147 } | 147 } |
148 } | 148 } |
149 | 149 |
150 void SpeechRecognitionManagerImpl::RecognitionAllowedCallback(int session_id, | 150 void SpeechRecognitionManagerImpl::RecognitionAllowedCallback(int session_id, |
151 bool ask_user, | 151 bool ask_user, |
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
642 | 642 |
643 SpeechRecognitionManagerImpl::Session::Session() | 643 SpeechRecognitionManagerImpl::Session::Session() |
644 : id(kSessionIDInvalid), | 644 : id(kSessionIDInvalid), |
645 listener_is_active(true) { | 645 listener_is_active(true) { |
646 } | 646 } |
647 | 647 |
648 SpeechRecognitionManagerImpl::Session::~Session() { | 648 SpeechRecognitionManagerImpl::Session::~Session() { |
649 } | 649 } |
650 | 650 |
651 } // namespace content | 651 } // namespace content |
OLD | NEW |