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_ | |
| 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; | |
|
jam
2012/05/23 15:41:24
these forward declarations are already in WebSPeec
Primiano Tucci (use gerrit)
2012/05/23 17:11:56
Done.
| |
| 27 } | |
| 28 | |
| 29 // SpeechRecognitionDispatcher is a delegate for methods 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); | |
|
jam
2012/05/23 15:41:24
nit: explicit
Primiano Tucci (use gerrit)
2012/05/23 17:11:56
Done.
| |
| 36 virtual ~SpeechRecognitionDispatcher(); | |
| 37 | |
| 38 private: | |
| 39 // RenderView::Observer implementation. | |
|
jam
2012/05/23 15:41:24
nit: RenderViewObserver
Primiano Tucci (use gerrit)
2012/05/23 17:11:56
Done.
| |
| 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 request_id); | |
| 52 void OnAudioStarted(int request_id); | |
| 53 void OnSoundStarted(int request_id); | |
| 54 void OnSoundEnded(int request_id); | |
| 55 void OnAudioEnded(int request_id); | |
| 56 void OnErrorOccurred(int request_id, | |
| 57 const content::SpeechRecognitionError& error); | |
| 58 void OnRecognitionEnded(int request_id); | |
| 59 void OnResultRetrieved(int request_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 | |
| 68 typedef std::map<int, WebKit::WebSpeechRecognitionHandle> HandleMap; | |
| 69 HandleMap handle_map_; | |
| 70 int next_id_; | |
| 71 | |
| 72 DISALLOW_COPY_AND_ASSIGN(SpeechRecognitionDispatcher); | |
| 73 }; | |
| 74 | |
| 75 #endif // CONTENT_RENDERER_SPEECH_RECOGNITION_DISPATCHER_H_ | |
| OLD | NEW |