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

Unified Diff: chrome/browser/speech/speech_input_dispatcher_host.cc

Issue 6128001: If speech input is disabled and we receive IPC calls, terminate the renderer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/speech/speech_input_dispatcher_host.cc
diff --git a/chrome/browser/speech/speech_input_dispatcher_host.cc b/chrome/browser/speech/speech_input_dispatcher_host.cc
index f1abebf7501ea2058be5b122a9f10585cb1d0fdb..829fd68e94788f7a94863305a71dd927784b4a69 100644
--- a/chrome/browser/speech/speech_input_dispatcher_host.cc
+++ b/chrome/browser/speech/speech_input_dispatcher_host.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/speech/speech_input_dispatcher_host.h"
#include "base/lazy_instance.h"
+#include "chrome/browser/renderer_host/render_process_host.h"
#include "chrome/common/render_messages.h"
namespace speech_input {
@@ -121,17 +122,29 @@ SpeechInputManager* SpeechInputDispatcherHost::manager() {
bool SpeechInputDispatcherHost::OnMessageReceived(
const IPC::Message& message, bool* message_was_ok) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- bool handled = true;
- IPC_BEGIN_MESSAGE_MAP_EX(SpeechInputDispatcherHost, message, *message_was_ok)
- IPC_MESSAGE_HANDLER(ViewHostMsg_SpeechInput_StartRecognition,
- OnStartRecognition)
- IPC_MESSAGE_HANDLER(ViewHostMsg_SpeechInput_CancelRecognition,
- OnCancelRecognition)
- IPC_MESSAGE_HANDLER(ViewHostMsg_SpeechInput_StopRecording,
- OnStopRecording)
- IPC_MESSAGE_UNHANDLED(handled = false)
- IPC_END_MESSAGE_MAP()
- return handled;
+
+ uint32 message_type = message.type();
+ if (message_type == ViewHostMsg_SpeechInput_StartRecognition::ID ||
+ message_type == ViewHostMsg_SpeechInput_CancelRecognition::ID ||
+ message_type == ViewHostMsg_SpeechInput_StopRecording::ID) {
+ if (!SpeechInputManager::IsFeatureEnabled()) {
+ RenderProcessHost::FromID(render_process_id_)->ReceivedBadMessage();
+ return false;
+ }
+
+ IPC_BEGIN_MESSAGE_MAP_EX(SpeechInputDispatcherHost, message,
+ *message_was_ok)
+ IPC_MESSAGE_HANDLER(ViewHostMsg_SpeechInput_StartRecognition,
+ OnStartRecognition)
+ IPC_MESSAGE_HANDLER(ViewHostMsg_SpeechInput_CancelRecognition,
+ OnCancelRecognition)
+ IPC_MESSAGE_HANDLER(ViewHostMsg_SpeechInput_StopRecording,
+ OnStopRecording)
+ IPC_END_MESSAGE_MAP()
+ return true;
+ }
+
+ return false;
}
void SpeechInputDispatcherHost::OnStartRecognition(
« no previous file with comments | « chrome/browser/renderer_host/browser_render_process_host.cc ('k') | chrome/browser/speech/speech_input_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698