diff options
author | hans@chromium.org <hans@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-25 10:10:34 +0000 |
---|---|---|
committer | hans@chromium.org <hans@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-25 10:10:34 +0000 |
commit | 64d09224049a393ad66c565299001beab3616c1e (patch) | |
tree | d7bb1d841856eaf297087711c6269e2f998057c3 /content/renderer/speech_recognition_dispatcher.h | |
parent | c4205b9ed7bd1096500828e2893036c0f38a51df (diff) | |
download | chromium_src-64d09224049a393ad66c565299001beab3616c1e.zip chromium_src-64d09224049a393ad66c565299001beab3616c1e.tar.gz chromium_src-64d09224049a393ad66c565299001beab3616c1e.tar.bz2 |
Introduced SpeechRecognitionDispatcher(Host) classes, handling dispatch of IPC messages for continuous speech recognition. (Speech CL2.1)
BUG=116954
TEST=none
Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=138801
Review URL: https://chromiumcodereview.appspot.com/10273006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@139015 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/renderer/speech_recognition_dispatcher.h')
-rw-r--r-- | content/renderer/speech_recognition_dispatcher.h | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/content/renderer/speech_recognition_dispatcher.h b/content/renderer/speech_recognition_dispatcher.h new file mode 100644 index 0000000..3e3b141 --- /dev/null +++ b/content/renderer/speech_recognition_dispatcher.h @@ -0,0 +1,70 @@ +// 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_ +#pragma once + +#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; +} + +// SpeechRecognitionDispatcher is a delegate for methods 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: + explicit SpeechRecognitionDispatcher(RenderViewImpl* render_view); + virtual ~SpeechRecognitionDispatcher(); + + private: + // RenderViewObserver 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 request_id); + void OnAudioStarted(int request_id); + void OnSoundStarted(int request_id); + void OnSoundEnded(int request_id); + void OnAudioEnded(int request_id); + void OnErrorOccurred(int request_id, + const content::SpeechRecognitionError& error); + void OnRecognitionEnded(int request_id); + void OnResultRetrieved(int request_id, + const content::SpeechRecognitionResult& result); + + int GetIDForHandle(const WebKit::WebSpeechRecognitionHandle& handle); + const WebKit::WebSpeechRecognitionHandle& GetHandleFromID(int handle_id); + + // The WebKit client class that we use to send events back to the JS world. + WebKit::WebSpeechRecognizerClient* recognizer_client_; + + typedef std::map<int, WebKit::WebSpeechRecognitionHandle> HandleMap; + HandleMap handle_map_; + int next_id_; + + DISALLOW_COPY_AND_ASSIGN(SpeechRecognitionDispatcher); +}; + +#endif // CONTENT_RENDERER_SPEECH_RECOGNITION_DISPATCHER_H_ |