| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 CONTENT_RENDERER_SPEECH_RECOGNITION_DISPATCHER_H_ | 5 #ifndef CONTENT_RENDERER_SPEECH_RECOGNITION_DISPATCHER_H_ |
| 6 #define CONTENT_RENDERER_SPEECH_RECOGNITION_DISPATCHER_H_ | 6 #define CONTENT_RENDERER_SPEECH_RECOGNITION_DISPATCHER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "content/public/common/speech_recognition_result.h" | 11 #include "content/public/common/speech_recognition_result.h" |
| 12 #include "content/public/renderer/render_view_observer.h" | 12 #include "content/public/renderer/render_view_observer.h" |
| 13 #include "third_party/WebKit/public/platform/WebVector.h" | 13 #include "third_party/WebKit/public/platform/WebVector.h" |
| 14 #include "third_party/WebKit/public/web/WebSpeechRecognitionHandle.h" | 14 #include "third_party/WebKit/public/web/WebSpeechRecognitionHandle.h" |
| 15 #include "third_party/WebKit/public/web/WebSpeechRecognizer.h" | 15 #include "third_party/WebKit/public/web/WebSpeechRecognizer.h" |
| 16 | 16 |
| 17 namespace content { | 17 namespace content { |
| 18 class RenderViewImpl; | 18 class RenderViewImpl; |
| 19 struct SpeechRecognitionError; | 19 struct SpeechRecognitionError; |
| 20 struct SpeechRecognitionResult; | 20 struct SpeechRecognitionResult; |
| 21 | 21 |
| 22 // SpeechRecognitionDispatcher is a delegate for methods used by WebKit for | 22 // SpeechRecognitionDispatcher is a delegate for methods used by WebKit for |
| 23 // scripted JS speech APIs. It's the complement of | 23 // scripted JS speech APIs. It's the complement of |
| 24 // SpeechRecognitionDispatcherHost (owned by RenderViewHost). | 24 // SpeechRecognitionDispatcherHost (owned by RenderViewHost). |
| 25 class SpeechRecognitionDispatcher : public RenderViewObserver, | 25 class SpeechRecognitionDispatcher : public RenderViewObserver, |
| 26 public WebKit::WebSpeechRecognizer { | 26 public blink::WebSpeechRecognizer { |
| 27 public: | 27 public: |
| 28 explicit SpeechRecognitionDispatcher(RenderViewImpl* render_view); | 28 explicit SpeechRecognitionDispatcher(RenderViewImpl* render_view); |
| 29 virtual ~SpeechRecognitionDispatcher(); | 29 virtual ~SpeechRecognitionDispatcher(); |
| 30 | 30 |
| 31 private: | 31 private: |
| 32 // RenderViewObserver implementation. | 32 // RenderViewObserver implementation. |
| 33 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 33 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 34 | 34 |
| 35 // WebKit::WebSpeechRecognizer implementation. | 35 // blink::WebSpeechRecognizer implementation. |
| 36 virtual void start(const WebKit::WebSpeechRecognitionHandle&, | 36 virtual void start(const blink::WebSpeechRecognitionHandle&, |
| 37 const WebKit::WebSpeechRecognitionParams&, | 37 const blink::WebSpeechRecognitionParams&, |
| 38 WebKit::WebSpeechRecognizerClient*) OVERRIDE; | 38 blink::WebSpeechRecognizerClient*) OVERRIDE; |
| 39 virtual void stop(const WebKit::WebSpeechRecognitionHandle&, | 39 virtual void stop(const blink::WebSpeechRecognitionHandle&, |
| 40 WebKit::WebSpeechRecognizerClient*) OVERRIDE; | 40 blink::WebSpeechRecognizerClient*) OVERRIDE; |
| 41 virtual void abort(const WebKit::WebSpeechRecognitionHandle&, | 41 virtual void abort(const blink::WebSpeechRecognitionHandle&, |
| 42 WebKit::WebSpeechRecognizerClient*) OVERRIDE; | 42 blink::WebSpeechRecognizerClient*) OVERRIDE; |
| 43 | 43 |
| 44 void OnRecognitionStarted(int request_id); | 44 void OnRecognitionStarted(int request_id); |
| 45 void OnAudioStarted(int request_id); | 45 void OnAudioStarted(int request_id); |
| 46 void OnSoundStarted(int request_id); | 46 void OnSoundStarted(int request_id); |
| 47 void OnSoundEnded(int request_id); | 47 void OnSoundEnded(int request_id); |
| 48 void OnAudioEnded(int request_id); | 48 void OnAudioEnded(int request_id); |
| 49 void OnErrorOccurred(int request_id, const SpeechRecognitionError& error); | 49 void OnErrorOccurred(int request_id, const SpeechRecognitionError& error); |
| 50 void OnRecognitionEnded(int request_id); | 50 void OnRecognitionEnded(int request_id); |
| 51 void OnResultsRetrieved(int request_id, | 51 void OnResultsRetrieved(int request_id, |
| 52 const SpeechRecognitionResults& result); | 52 const SpeechRecognitionResults& result); |
| 53 | 53 |
| 54 int GetOrCreateIDForHandle(const WebKit::WebSpeechRecognitionHandle& handle); | 54 int GetOrCreateIDForHandle(const blink::WebSpeechRecognitionHandle& handle); |
| 55 bool HandleExists(const WebKit::WebSpeechRecognitionHandle& handle); | 55 bool HandleExists(const blink::WebSpeechRecognitionHandle& handle); |
| 56 const WebKit::WebSpeechRecognitionHandle& GetHandleFromID(int handle_id); | 56 const blink::WebSpeechRecognitionHandle& GetHandleFromID(int handle_id); |
| 57 | 57 |
| 58 // The WebKit client class that we use to send events back to the JS world. | 58 // The WebKit client class that we use to send events back to the JS world. |
| 59 WebKit::WebSpeechRecognizerClient* recognizer_client_; | 59 blink::WebSpeechRecognizerClient* recognizer_client_; |
| 60 | 60 |
| 61 typedef std::map<int, WebKit::WebSpeechRecognitionHandle> HandleMap; | 61 typedef std::map<int, blink::WebSpeechRecognitionHandle> HandleMap; |
| 62 HandleMap handle_map_; | 62 HandleMap handle_map_; |
| 63 int next_id_; | 63 int next_id_; |
| 64 | 64 |
| 65 DISALLOW_COPY_AND_ASSIGN(SpeechRecognitionDispatcher); | 65 DISALLOW_COPY_AND_ASSIGN(SpeechRecognitionDispatcher); |
| 66 }; | 66 }; |
| 67 | 67 |
| 68 } // namespace content | 68 } // namespace content |
| 69 | 69 |
| 70 #endif // CONTENT_RENDERER_SPEECH_RECOGNITION_DISPATCHER_H_ | 70 #endif // CONTENT_RENDERER_SPEECH_RECOGNITION_DISPATCHER_H_ |
| OLD | NEW |