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_BROWSER_SPEECH_INPUT_TAG_SPEECH_DISPATCHER_HOST_H_ |
| 6 #define CONTENT_BROWSER_SPEECH_INPUT_TAG_SPEECH_DISPATCHER_HOST_H_ |
| 7 |
| 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "content/common/content_export.h" |
| 10 #include "content/public/browser/browser_message_filter.h" |
| 11 #include "net/url_request/url_request_context_getter.h" |
| 12 |
| 13 class AudioManager; |
| 14 struct InputTagSpeechHostMsg_StartRecognition_Params; |
| 15 |
| 16 namespace content { |
| 17 class SpeechRecognitionPreferences; |
| 18 struct SpeechRecognitionResult; |
| 19 } |
| 20 |
| 21 namespace speech { |
| 22 |
| 23 class SpeechRecognitionManagerImpl; |
| 24 |
| 25 // InputTagSpeechDispatcherHost is a delegate for Speech API messages used by |
| 26 // RenderMessageFilter. |
| 27 // It's the complement of InputTagSpeechDispatcher (owned by RenderView). |
| 28 class CONTENT_EXPORT InputTagSpeechDispatcherHost |
| 29 : public content::BrowserMessageFilter { |
| 30 public: |
| 31 class Callers; |
| 32 |
| 33 InputTagSpeechDispatcherHost( |
| 34 int render_process_id, |
| 35 net::URLRequestContextGetter* context_getter, |
| 36 content::SpeechRecognitionPreferences* recognition_preferences, |
| 37 AudioManager* audio_manager); |
| 38 |
| 39 // Methods called by SpeechRecognitionManagerImpl. |
| 40 void SetRecognitionResult(int caller_id, |
| 41 const content::SpeechRecognitionResult& result); |
| 42 void DidCompleteRecording(int caller_id); |
| 43 void DidCompleteRecognition(int caller_id); |
| 44 |
| 45 // content::BrowserMessageFilter implementation. |
| 46 virtual bool OnMessageReceived(const IPC::Message& message, |
| 47 bool* message_was_ok) OVERRIDE; |
| 48 |
| 49 // Singleton manager setter useful for tests. |
| 50 static void set_manager(SpeechRecognitionManagerImpl* manager); |
| 51 |
| 52 private: |
| 53 virtual ~InputTagSpeechDispatcherHost(); |
| 54 |
| 55 void OnStartRecognition( |
| 56 const InputTagSpeechHostMsg_StartRecognition_Params ¶ms); |
| 57 void OnCancelRecognition(int render_view_id, int request_id); |
| 58 void OnStopRecording(int render_view_id, int request_id); |
| 59 |
| 60 // Returns the speech recognition manager to forward events to, creating one |
| 61 // if needed. |
| 62 SpeechRecognitionManagerImpl* manager(); |
| 63 |
| 64 int render_process_id_; |
| 65 bool may_have_pending_requests_; // Set if we received any speech IPC request |
| 66 |
| 67 scoped_refptr<net::URLRequestContextGetter> context_getter_; |
| 68 scoped_refptr<content::SpeechRecognitionPreferences> recognition_preferences_; |
| 69 AudioManager* audio_manager_; |
| 70 |
| 71 static SpeechRecognitionManagerImpl* manager_; |
| 72 |
| 73 DISALLOW_COPY_AND_ASSIGN(InputTagSpeechDispatcherHost); |
| 74 }; |
| 75 |
| 76 } // namespace speech |
| 77 |
| 78 #endif // CONTENT_BROWSER_SPEECH_INPUT_TAG_SPEECH_DISPATCHER_HOST_H_ |
OLD | NEW |