Chromium Code Reviews| Index: content/renderer/speech_recognition_dispatcher.h |
| diff --git a/content/renderer/speech_recognition_dispatcher.h b/content/renderer/speech_recognition_dispatcher.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..9c7fff5bbf77dd650a21377df4f4afce38432c75 |
| --- /dev/null |
| +++ b/content/renderer/speech_recognition_dispatcher.h |
| @@ -0,0 +1,71 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CONTENT_RENDERER_SPEECH_RECOGNITION_DISPATCHER_H_ |
| +#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!
|
| + |
| +#include <map> |
| + |
| +#include "base/basictypes.h" |
| +#include "content/public/renderer/render_view_observer.h" |
| +#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h" |
| +#include "third_party/WebKit/Source/WebKit/chromium/public/WebSpeechRecognitionHandle.h" |
| +#include "third_party/WebKit/Source/WebKit/chromium/public/WebSpeechRecognizer.h" |
| + |
| +class RenderViewImpl; |
| + |
| +namespace content { |
| +struct SpeechRecognitionError; |
| +struct SpeechRecognitionResult; |
| +} |
| + |
| +namespace WebKit { |
| +class WebSpeechRecognitionParams; |
| +class WebSpeechRecognizerClient; |
| +} |
| + |
| +// SpeechRecognitionDispatcher is a delegate for messages used by WebKit for |
| +// scripted JS speech APIs. It's the complement of |
| +// SpeechRecognitionDispatcherHost (owned by RenderViewHost). |
| +class SpeechRecognitionDispatcher : public content::RenderViewObserver, |
| + public WebKit::WebSpeechRecognizer { |
| + public: |
| + SpeechRecognitionDispatcher(RenderViewImpl* render_view); |
| + virtual ~SpeechRecognitionDispatcher(); |
| + |
| + private: |
| + // RenderView::Observer implementation. |
| + virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| + |
| + // WebKit::WebSpeechRecognizer implementation. |
| + virtual void start(const WebKit::WebSpeechRecognitionHandle&, |
| + const WebKit::WebSpeechRecognitionParams&, |
| + WebKit::WebSpeechRecognizerClient*) OVERRIDE; |
| + virtual void stop(const WebKit::WebSpeechRecognitionHandle&, |
| + WebKit::WebSpeechRecognizerClient*) OVERRIDE; |
| + virtual void abort(const WebKit::WebSpeechRecognitionHandle&, |
| + WebKit::WebSpeechRecognizerClient*) OVERRIDE; |
| + |
| + void OnRecognitionStarted(int js_handle_id); |
| + void OnAudioStarted(int js_handle_id); |
| + void OnSoundStarted(int js_handle_id); |
| + void OnSoundEnded(int js_handle_id); |
| + void OnAudioEnded(int js_handle_id); |
| + void OnErrorOccurred(int js_handle_id, |
| + const content::SpeechRecognitionError& error); |
| + void OnRecognitionEnded(int js_handle_id); |
| + void OnResultRetrieved(int js_handle_id, |
| + const content::SpeechRecognitionResult& result); |
| + 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!
|
| + const WebKit::WebSpeechRecognitionHandle& GetHandleFromID(int handle_id); |
| + |
| + 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
|
| + typedef std::map<int, WebKit::WebSpeechRecognitionHandle> HandleMap; |
| + 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.
|
| + int last_mapping_id_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(SpeechRecognitionDispatcher); |
| +}; |
| + |
| +#endif // CONTENT_RENDERER_SPEECH_RECOGNITION_DISPATCHER_H_ |