OLD | NEW |
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 #ifndef CHROME_RENDERER_SPEECH_INPUT_DISPATCHER_H_ | 5 #ifndef CHROME_RENDERER_SPEECH_INPUT_DISPATCHER_H_ |
6 #define CHROME_RENDERER_SPEECH_INPUT_DISPATCHER_H_ | 6 #define CHROME_RENDERER_SPEECH_INPUT_DISPATCHER_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "chrome/common/speech_input_result.h" | 9 #include "chrome/common/speech_input_result.h" |
10 #include "ipc/ipc_channel.h" | 10 #include "chrome/renderer/render_view_observer.h" |
11 #include "third_party/WebKit/WebKit/chromium/public/WebSpeechInputController.h" | 11 #include "third_party/WebKit/WebKit/chromium/public/WebSpeechInputController.h" |
12 | 12 |
13 class GURL; | 13 class GURL; |
14 class RenderView; | |
15 | 14 |
16 namespace WebKit { | 15 namespace WebKit { |
17 class WebSpeechInputListener; | 16 class WebSpeechInputListener; |
18 class WebString; | |
19 struct WebRect; | |
20 } | 17 } |
21 | 18 |
22 // SpeechInputDispatcher is a delegate for speech input messages used by WebKit. | 19 // SpeechInputDispatcher is a delegate for speech input messages used by WebKit. |
23 // It's the complement of SpeechInputDispatcherHost (owned by RenderViewHost). | 20 // It's the complement of SpeechInputDispatcherHost (owned by RenderViewHost). |
24 class SpeechInputDispatcher : public WebKit::WebSpeechInputController, | 21 class SpeechInputDispatcher : public RenderViewObserver, |
25 public IPC::Channel::Listener { | 22 public WebKit::WebSpeechInputController { |
26 public: | 23 public: |
27 SpeechInputDispatcher(RenderView* render_view, | 24 SpeechInputDispatcher(RenderView* render_view, |
28 WebKit::WebSpeechInputListener* listener); | 25 WebKit::WebSpeechInputListener* listener); |
29 | 26 |
30 // IPC::Channel::Listener implementation. | 27 private: |
31 bool OnMessageReceived(const IPC::Message& msg); | 28 // RenderView::Observer implementation. |
| 29 bool OnMessageReceived(const IPC::Message& message); |
32 | 30 |
33 // WebKit::WebSpeechInputController. | 31 // WebKit::WebSpeechInputController. |
34 virtual bool startRecognition(int request_id, | 32 virtual bool startRecognition(int request_id, |
35 const WebKit::WebRect& element_rect, | 33 const WebKit::WebRect& element_rect, |
36 const WebKit::WebString& language, | 34 const WebKit::WebString& language, |
37 const WebKit::WebString& grammar); | 35 const WebKit::WebString& grammar); |
38 | 36 |
39 virtual void cancelRecognition(int request_id); | 37 virtual void cancelRecognition(int request_id); |
40 virtual void stopRecording(int request_id); | 38 virtual void stopRecording(int request_id); |
41 | 39 |
42 private: | |
43 void OnSpeechRecognitionResult( | 40 void OnSpeechRecognitionResult( |
44 int request_id, const speech_input::SpeechInputResultArray& result); | 41 int request_id, const speech_input::SpeechInputResultArray& result); |
45 void OnSpeechRecordingComplete(int request_id); | 42 void OnSpeechRecordingComplete(int request_id); |
46 void OnSpeechRecognitionComplete(int request_id); | 43 void OnSpeechRecognitionComplete(int request_id); |
47 | 44 |
48 RenderView* render_view_; | |
49 WebKit::WebSpeechInputListener* listener_; | 45 WebKit::WebSpeechInputListener* listener_; |
50 | 46 |
51 DISALLOW_COPY_AND_ASSIGN(SpeechInputDispatcher); | 47 DISALLOW_COPY_AND_ASSIGN(SpeechInputDispatcher); |
52 }; | 48 }; |
53 | 49 |
54 #endif // CHROME_RENDERER_SPEECH_INPUT_DISPATCHER_H_ | 50 #endif // CHROME_RENDERER_SPEECH_INPUT_DISPATCHER_H_ |
OLD | NEW |