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_INPUT_TAG_SPEECH_DISPATCHER_H_ 6 #define CONTENT_RENDERER_INPUT_TAG_SPEECH_DISPATCHER_H_ 7 8 #include "base/basictypes.h" 9 #include "content/public/common/speech_recognition_result.h" 10 #include "content/public/renderer/render_view_observer.h" 11 #include "third_party/WebKit/public/web/WebSpeechInputController.h" 12 13 namespace WebKit { 14 class WebSpeechInputListener; 15 } 16 17 namespace content { 18 class RenderViewImpl; 19 struct SpeechRecognitionResult; 20 21 // InputTagSpeechDispatcher is a delegate for messages used by WebKit. It's 22 // the complement of InputTagSpeechDispatcherHost (owned by RenderViewHost). 23 class InputTagSpeechDispatcher : public RenderViewObserver, 24 public WebKit::WebSpeechInputController { 25 public: 26 InputTagSpeechDispatcher(RenderViewImpl* render_view, 27 WebKit::WebSpeechInputListener* listener); 28 29 private: 30 // RenderView::Observer implementation. 31 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 32 33 // WebKit::WebSpeechInputController. 34 virtual bool startRecognition(int request_id, 35 const WebKit::WebRect& element_rect, 36 const WebKit::WebString& language, 37 const WebKit::WebString& grammar, 38 const WebKit::WebSecurityOrigin& origin); 39 40 virtual void cancelRecognition(int request_id); 41 virtual void stopRecording(int request_id); 42 43 void OnSpeechRecognitionResults( 44 int request_id, const SpeechRecognitionResults& results); 45 void OnSpeechRecordingComplete(int request_id); 46 void OnSpeechRecognitionComplete(int request_id); 47 void OnSpeechRecognitionToggleSpeechInput(); 48 49 WebKit::WebSpeechInputListener* listener_; 50 51 DISALLOW_COPY_AND_ASSIGN(InputTagSpeechDispatcher); 52 }; 53 54 } // namespace content 55 56 #endif // CONTENT_RENDERER_INPUT_TAG_SPEECH_DISPATCHER_H_ 57