OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CONTENT_RENDERER_SPEECH_RECOGNITION_DISPATCHER_H_ | |
6 #define CONTENT_RENDERER_SPEECH_RECOGNITION_DISPATCHER_H_ | |
7 #pragma once | |
8 | |
9 #include <map> | |
10 | |
11 #include "base/basictypes.h" | |
12 #include "content/public/renderer/render_view_observer.h" | |
13 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h" | |
14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSpeechRecognitionH andle.h" | |
15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSpeechRecognizer.h " | |
16 | |
17 class RenderViewImpl; | |
18 | |
19 namespace content { | |
20 struct SpeechRecognitionError; | |
21 struct SpeechRecognitionResult; | |
22 } | |
23 | |
24 namespace WebKit { | |
25 class WebSpeechRecognitionParams; | |
26 class WebSpeechRecognizerClient; | |
27 } | |
28 | |
29 // SpeechRecognitionDispatcher is a delegate for messages used by WebKit for | |
30 // scripted JS speech APIs. It's the complement of | |
31 // SpeechRecognitionDispatcherHost (owned by RenderViewHost). | |
32 class SpeechRecognitionDispatcher : public content::RenderViewObserver, | |
33 public WebKit::WebSpeechRecognizer { | |
34 public: | |
35 SpeechRecognitionDispatcher(RenderViewImpl* render_view); | |
36 virtual ~SpeechRecognitionDispatcher(); | |
37 | |
38 private: | |
39 // RenderView::Observer implementation. | |
40 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | |
41 | |
42 // WebKit::WebSpeechRecognizer implementation. | |
43 virtual void start(const WebKit::WebSpeechRecognitionHandle&, | |
44 const WebKit::WebSpeechRecognitionParams&, | |
45 WebKit::WebSpeechRecognizerClient*) OVERRIDE; | |
46 virtual void stop(const WebKit::WebSpeechRecognitionHandle&, | |
47 WebKit::WebSpeechRecognizerClient*) OVERRIDE; | |
48 virtual void abort(const WebKit::WebSpeechRecognitionHandle&, | |
49 WebKit::WebSpeechRecognizerClient*) OVERRIDE; | |
50 | |
51 void OnRecognitionStarted(int js_handle_id); | |
52 void OnAudioStarted(int js_handle_id); | |
53 void OnSoundStarted(int js_handle_id); | |
54 void OnSoundEnded(int js_handle_id); | |
55 void OnAudioEnded(int js_handle_id); | |
56 void OnErrorOccurred(int js_handle_id, | |
57 const content::SpeechRecognitionError& error); | |
58 void OnRecognitionEnded(int js_handle_id); | |
59 void OnResultRetrieved(int js_handle_id, | |
60 const content::SpeechRecognitionResult& result); | |
61 | |
62 int GetIDForHandle(const WebKit::WebSpeechRecognitionHandle& handle); | |
63 const WebKit::WebSpeechRecognitionHandle& GetHandleFromID(int handle_id); | |
64 | |
65 // The WebKit client class that we use to send events back to the JS world. | |
66 WebKit::WebSpeechRecognizerClient* recognizer_client_; | |
67 typedef std::map<int, WebKit::WebSpeechRecognitionHandle> HandleMap; | |
hans
2012/05/14 14:04:52
maybe a blank before this line to separate the "ha
| |
68 HandleMap handle_map_; | |
69 int last_mapping_id_; | |
70 | |
71 DISALLOW_COPY_AND_ASSIGN(SpeechRecognitionDispatcher); | |
72 }; | |
73 | |
74 #endif // CONTENT_RENDERER_SPEECH_RECOGNITION_DISPATCHER_H_ | |
OLD | NEW |