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

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

Issue 6139001: If speech input is disabled and we receive IPC calls, terminate the renderer.... (Closed) Base URL: svn://svn.chromium.org/chrome/branches/552/src/
Patch Set: '' Created 9 years, 11 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
« no previous file with comments | « no previous file | chrome/browser/speech/speech_input_manager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_dispatcher_host.h" 5 #include "chrome/browser/speech/speech_input_dispatcher_host.h"
6 6
7 #include "base/singleton.h" 7 #include "base/singleton.h"
8 #include "chrome/browser/renderer_host/render_process_host.h" 8 #include "chrome/browser/renderer_host/render_process_host.h"
9 #include "chrome/browser/renderer_host/render_view_host.h" 9 #include "chrome/browser/renderer_host/render_view_host.h"
10 #include "chrome/browser/renderer_host/render_view_host_notification_task.h" 10 #include "chrome/browser/renderer_host/render_view_host_notification_task.h"
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 } 111 }
112 112
113 SpeechInputDispatcherHost::~SpeechInputDispatcherHost() { 113 SpeechInputDispatcherHost::~SpeechInputDispatcherHost() {
114 } 114 }
115 115
116 SpeechInputManager* SpeechInputDispatcherHost::manager() { 116 SpeechInputManager* SpeechInputDispatcherHost::manager() {
117 return (*manager_accessor_)(); 117 return (*manager_accessor_)();
118 } 118 }
119 119
120 bool SpeechInputDispatcherHost::OnMessageReceived( 120 bool SpeechInputDispatcherHost::OnMessageReceived(
121 const IPC::Message& msg, bool* msg_was_ok) { 121 const IPC::Message& message, bool* message_was_ok) {
122 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 122 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
123 bool handled = true; 123
124 IPC_BEGIN_MESSAGE_MAP_EX(SpeechInputDispatcherHost, msg, *msg_was_ok) 124 uint32 message_type = message.type();
125 IPC_MESSAGE_HANDLER(ViewHostMsg_SpeechInput_StartRecognition, 125 if (message_type == ViewHostMsg_SpeechInput_StartRecognition::ID ||
126 OnStartRecognition) 126 message_type == ViewHostMsg_SpeechInput_CancelRecognition::ID ||
127 IPC_MESSAGE_HANDLER(ViewHostMsg_SpeechInput_CancelRecognition, 127 message_type == ViewHostMsg_SpeechInput_StopRecording::ID) {
128 OnCancelRecognition) 128 if (!SpeechInputManager::IsFeatureEnabled()) {
129 IPC_MESSAGE_HANDLER(ViewHostMsg_SpeechInput_StopRecording, 129 *message_was_ok = false;
130 OnStopRecording) 130 return true;
131 IPC_MESSAGE_UNHANDLED(handled = false) 131 }
132 IPC_END_MESSAGE_MAP() 132
133 return handled; 133 IPC_BEGIN_MESSAGE_MAP_EX(SpeechInputDispatcherHost, message,
134 *message_was_ok)
135 IPC_MESSAGE_HANDLER(ViewHostMsg_SpeechInput_StartRecognition,
136 OnStartRecognition)
137 IPC_MESSAGE_HANDLER(ViewHostMsg_SpeechInput_CancelRecognition,
138 OnCancelRecognition)
139 IPC_MESSAGE_HANDLER(ViewHostMsg_SpeechInput_StopRecording,
140 OnStopRecording)
141 IPC_END_MESSAGE_MAP()
142 return true;
143 }
144
145 return false;
134 } 146 }
135 147
136 void SpeechInputDispatcherHost::OnStartRecognition( 148 void SpeechInputDispatcherHost::OnStartRecognition(
137 int render_view_id, 149 int render_view_id,
138 int request_id, 150 int request_id,
139 const gfx::Rect& element_rect) { 151 const gfx::Rect& element_rect) {
140 int caller_id = callers_->CreateId(resource_message_filter_process_id_, 152 int caller_id = callers_->CreateId(resource_message_filter_process_id_,
141 render_view_id, request_id); 153 render_view_id, request_id);
142 manager()->StartRecognition(this, caller_id, 154 manager()->StartRecognition(this, caller_id,
143 resource_message_filter_process_id_, 155 resource_message_filter_process_id_,
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 int caller_request_id = callers_->request_id(caller_id); 211 int caller_request_id = callers_->request_id(caller_id);
200 SendMessageToRenderView( 212 SendMessageToRenderView(
201 new ViewMsg_SpeechInput_RecognitionComplete(caller_render_view_id, 213 new ViewMsg_SpeechInput_RecognitionComplete(caller_render_view_id,
202 caller_request_id), 214 caller_request_id),
203 caller_render_view_id); 215 caller_render_view_id);
204 callers_->RemoveId(caller_id); // Request sequence ended, so remove mapping. 216 callers_->RemoveId(caller_id); // Request sequence ended, so remove mapping.
205 LOG(INFO) << "SpeechInputDispatcherHost::DidCompleteRecognition exit"; 217 LOG(INFO) << "SpeechInputDispatcherHost::DidCompleteRecognition exit";
206 } 218 }
207 219
208 } // namespace speech_input 220 } // namespace speech_input
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/speech/speech_input_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698