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

Side by Side Diff: chrome/renderer/speech_input_dispatcher.cc

Issue 3035035: Adds chromium side plumbing to pass speech input calls back and forth with WebKit. (Closed)
Patch Set: Addressed all comments. Created 10 years, 4 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/renderer/speech_input_dispatcher.h"
6
7 #include "chrome/renderer/render_view.h"
8 #include "third_party/WebKit/WebKit/chromium/public/WebCString.h"
9 #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h"
10 #include "third_party/WebKit/WebKit/chromium/public/WebSpeechInputListener.h"
11
12 using WebKit::WebFrame;
13
14 SpeechInputDispatcher::SpeechInputDispatcher(
15 RenderView* render_view, WebKit::WebSpeechInputListener* listener)
16 : render_view_(render_view),
17 listener_(listener) {
18 }
19
20 bool SpeechInputDispatcher::OnMessageReceived(const IPC::Message& message) {
21 bool handled = true;
22 IPC_BEGIN_MESSAGE_MAP(SpeechInputDispatcher, message)
23 IPC_MESSAGE_HANDLER(ViewMsg_SpeechInput_SetRecognitionResult,
24 OnSpeechRecognitionResult)
25 IPC_MESSAGE_HANDLER(ViewMsg_SpeechInput_RecordingComplete,
26 OnSpeechRecordingComplete)
27 IPC_MESSAGE_HANDLER(ViewMsg_SpeechInput_RecognitionComplete,
28 OnSpeechRecognitionComplete)
29 IPC_MESSAGE_UNHANDLED(handled = false)
30 IPC_END_MESSAGE_MAP()
31 return handled;
32 }
33
34 bool SpeechInputDispatcher::startRecognition() {
35 render_view_->Send(new ViewHostMsg_SpeechInput_StartRecognition(
36 render_view_->routing_id()));
37 return true;
38 }
39
40 void SpeechInputDispatcher::cancelRecognition() {
41 render_view_->Send(new ViewHostMsg_SpeechInput_CancelRecognition(
42 render_view_->routing_id()));
43 }
44
45 void SpeechInputDispatcher::stopRecording() {
46 render_view_->Send(new ViewHostMsg_SpeechInput_StopRecording(
47 render_view_->routing_id()));
48 }
49
50 void SpeechInputDispatcher::OnSpeechRecognitionResult(
51 const string16& result) {
52 listener_->setRecognitionResult(result);
53 }
54
55 void SpeechInputDispatcher::OnSpeechRecordingComplete() {
56 listener_->didCompleteRecording();
57 }
58
59 void SpeechInputDispatcher::OnSpeechRecognitionComplete() {
60 listener_->didCompleteRecognition();
61 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698