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

Side by Side Diff: content/browser/speech/speech_recognition_dispatcher_host.cc

Issue 415933002: Turn webspeech on/off when tab goes fore/background (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 months 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 | Annotate | Revision Log
OLDNEW
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_dispatcher_host.h" 5 #include "content/browser/speech/speech_recognition_dispatcher_host.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "content/browser/browser_plugin/browser_plugin_guest.h" 10 #include "content/browser/browser_plugin/browser_plugin_guest.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 bool SpeechRecognitionDispatcherHost::OnMessageReceived( 45 bool SpeechRecognitionDispatcherHost::OnMessageReceived(
46 const IPC::Message& message) { 46 const IPC::Message& message) {
47 bool handled = true; 47 bool handled = true;
48 IPC_BEGIN_MESSAGE_MAP(SpeechRecognitionDispatcherHost, message) 48 IPC_BEGIN_MESSAGE_MAP(SpeechRecognitionDispatcherHost, message)
49 IPC_MESSAGE_HANDLER(SpeechRecognitionHostMsg_StartRequest, 49 IPC_MESSAGE_HANDLER(SpeechRecognitionHostMsg_StartRequest,
50 OnStartRequest) 50 OnStartRequest)
51 IPC_MESSAGE_HANDLER(SpeechRecognitionHostMsg_AbortRequest, 51 IPC_MESSAGE_HANDLER(SpeechRecognitionHostMsg_AbortRequest,
52 OnAbortRequest) 52 OnAbortRequest)
53 IPC_MESSAGE_HANDLER(SpeechRecognitionHostMsg_StopCaptureRequest, 53 IPC_MESSAGE_HANDLER(SpeechRecognitionHostMsg_StopCaptureRequest,
54 OnStopCaptureRequest) 54 OnStopCaptureRequest)
55 IPC_MESSAGE_HANDLER(SpeechRecognitionHostMsg_AbortAllRequest,
56 OnAbortAllRequest)
55 IPC_MESSAGE_UNHANDLED(handled = false) 57 IPC_MESSAGE_UNHANDLED(handled = false)
56 IPC_END_MESSAGE_MAP() 58 IPC_END_MESSAGE_MAP()
57 return handled; 59 return handled;
58 } 60 }
59 61
60 void SpeechRecognitionDispatcherHost::OverrideThreadForMessage( 62 void SpeechRecognitionDispatcherHost::OverrideThreadForMessage(
61 const IPC::Message& message, 63 const IPC::Message& message,
62 BrowserThread::ID* thread) { 64 BrowserThread::ID* thread) {
63 if (message.type() == SpeechRecognitionHostMsg_StartRequest::ID) 65 if (message.type() == SpeechRecognitionHostMsg_StartRequest::ID)
64 *thread = BrowserThread::UI; 66 *thread = BrowserThread::UI;
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 int request_id) { 168 int request_id) {
167 int session_id = SpeechRecognitionManager::GetInstance()->GetSession( 169 int session_id = SpeechRecognitionManager::GetInstance()->GetSession(
168 render_process_id_, render_view_id, request_id); 170 render_process_id_, render_view_id, request_id);
169 171
170 // The renderer might provide an invalid |request_id| if the session was not 172 // The renderer might provide an invalid |request_id| if the session was not
171 // started as expected, e.g., due to unsatisfied security requirements. 173 // started as expected, e.g., due to unsatisfied security requirements.
172 if (session_id != SpeechRecognitionManager::kSessionIDInvalid) 174 if (session_id != SpeechRecognitionManager::kSessionIDInvalid)
173 SpeechRecognitionManager::GetInstance()->AbortSession(session_id); 175 SpeechRecognitionManager::GetInstance()->AbortSession(session_id);
174 } 176 }
175 177
178 void SpeechRecognitionDispatcherHost::OnAbortAllRequest(int render_view_id) {
179 SpeechRecognitionManager::GetInstance()->AbortAllSessionsForRenderView(
180 render_process_id_, render_view_id);
181 }
182
176 void SpeechRecognitionDispatcherHost::OnStopCaptureRequest( 183 void SpeechRecognitionDispatcherHost::OnStopCaptureRequest(
177 int render_view_id, int request_id) { 184 int render_view_id, int request_id) {
178 int session_id = SpeechRecognitionManager::GetInstance()->GetSession( 185 int session_id = SpeechRecognitionManager::GetInstance()->GetSession(
179 render_process_id_, render_view_id, request_id); 186 render_process_id_, render_view_id, request_id);
180 187
181 // The renderer might provide an invalid |request_id| if the session was not 188 // The renderer might provide an invalid |request_id| if the session was not
182 // started as expected, e.g., due to unsatisfied security requirements. 189 // started as expected, e.g., due to unsatisfied security requirements.
183 if (session_id != SpeechRecognitionManager::kSessionIDInvalid) { 190 if (session_id != SpeechRecognitionManager::kSessionIDInvalid) {
184 SpeechRecognitionManager::GetInstance()->StopAudioCaptureForSession( 191 SpeechRecognitionManager::GetInstance()->StopAudioCaptureForSession(
185 session_id); 192 session_id);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 void SpeechRecognitionDispatcherHost::OnAudioLevelsChange(int session_id, 261 void SpeechRecognitionDispatcherHost::OnAudioLevelsChange(int session_id,
255 float volume, 262 float volume,
256 float noise_volume) { 263 float noise_volume) {
257 } 264 }
258 265
259 void SpeechRecognitionDispatcherHost::OnEnvironmentEstimationComplete( 266 void SpeechRecognitionDispatcherHost::OnEnvironmentEstimationComplete(
260 int session_id) { 267 int session_id) {
261 } 268 }
262 269
263 } // namespace content 270 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698