Chromium Code Reviews| 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_ | |
|
hans
2012/05/11 16:56:32
#pragma once :)
Primiano Tucci (use gerrit)
2012/05/14 12:58:22
Again!
| |
| 7 | |
| 8 #include <map> | |
| 9 | |
| 10 #include "base/basictypes.h" | |
| 11 #include "content/public/renderer/render_view_observer.h" | |
| 12 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h" | |
| 13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSpeechRecognitionH andle.h" | |
| 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSpeechRecognizer.h " | |
| 15 | |
| 16 class RenderViewImpl; | |
| 17 | |
| 18 namespace content { | |
| 19 struct SpeechRecognitionError; | |
| 20 struct SpeechRecognitionResult; | |
| 21 } | |
| 22 | |
| 23 namespace WebKit { | |
| 24 class WebSpeechRecognitionParams; | |
| 25 class WebSpeechRecognizerClient; | |
| 26 } | |
| 27 | |
| 28 // SpeechRecognitionDispatcher is a delegate for messages used by WebKit for | |
| 29 // scripted JS speech APIs. It's the complement of | |
| 30 // SpeechRecognitionDispatcherHost (owned by RenderViewHost). | |
| 31 class SpeechRecognitionDispatcher : public content::RenderViewObserver, | |
| 32 public WebKit::WebSpeechRecognizer { | |
| 33 public: | |
| 34 SpeechRecognitionDispatcher(RenderViewImpl* render_view); | |
| 35 virtual ~SpeechRecognitionDispatcher(); | |
| 36 | |
| 37 private: | |
| 38 // RenderView::Observer implementation. | |
| 39 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | |
| 40 | |
| 41 // WebKit::WebSpeechRecognizer implementation. | |
| 42 virtual void start(const WebKit::WebSpeechRecognitionHandle&, | |
| 43 const WebKit::WebSpeechRecognitionParams&, | |
| 44 WebKit::WebSpeechRecognizerClient*) OVERRIDE; | |
| 45 virtual void stop(const WebKit::WebSpeechRecognitionHandle&, | |
| 46 WebKit::WebSpeechRecognizerClient*) OVERRIDE; | |
| 47 virtual void abort(const WebKit::WebSpeechRecognitionHandle&, | |
| 48 WebKit::WebSpeechRecognizerClient*) OVERRIDE; | |
| 49 | |
| 50 void OnRecognitionStarted(int js_handle_id); | |
| 51 void OnAudioStarted(int js_handle_id); | |
| 52 void OnSoundStarted(int js_handle_id); | |
| 53 void OnSoundEnded(int js_handle_id); | |
| 54 void OnAudioEnded(int js_handle_id); | |
| 55 void OnErrorOccurred(int js_handle_id, | |
| 56 const content::SpeechRecognitionError& error); | |
| 57 void OnRecognitionEnded(int js_handle_id); | |
| 58 void OnResultRetrieved(int js_handle_id, | |
| 59 const content::SpeechRecognitionResult& result); | |
| 60 int GetIDForHandle(const WebKit::WebSpeechRecognitionHandle& handle); | |
|
hans
2012/05/11 16:56:32
i'd put a blank before this to separate from the O
Primiano Tucci (use gerrit)
2012/05/14 12:58:22
Right!
| |
| 61 const WebKit::WebSpeechRecognitionHandle& GetHandleFromID(int handle_id); | |
| 62 | |
| 63 WebKit::WebSpeechRecognizerClient* event_proxy_; | |
|
hans
2012/05/11 16:56:32
hmm, i'd just call it recognizer_client_, and mayb
Primiano Tucci (use gerrit)
2012/05/14 12:58:22
Right and it fits better the ClassName -> instance
| |
| 64 typedef std::map<int, WebKit::WebSpeechRecognitionHandle> HandleMap; | |
| 65 HandleMap handle_mappings_; | |
|
hans
2012/05/11 16:56:32
or just handle_map_
Primiano Tucci (use gerrit)
2012/05/14 12:58:22
Done.
| |
| 66 int last_mapping_id_; | |
| 67 | |
| 68 DISALLOW_COPY_AND_ASSIGN(SpeechRecognitionDispatcher); | |
| 69 }; | |
| 70 | |
| 71 #endif // CONTENT_RENDERER_SPEECH_RECOGNITION_DISPATCHER_H_ | |
| OLD | NEW |