| 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_SPEECH_INPUT_DISPATCHER_HOST_H_ | |
| 6 #define CONTENT_BROWSER_SPEECH_SPEECH_INPUT_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 SpeechInputHostMsg_StartRecognition_Params; | |
| 15 | |
| 16 namespace content { | |
| 17 class SpeechInputPreferences; | |
| 18 struct SpeechInputResult; | |
| 19 } | |
| 20 | |
| 21 namespace speech_input { | |
| 22 | |
| 23 class SpeechInputManagerImpl; | |
| 24 | |
| 25 // SpeechInputDispatcherHost is a delegate for Speech API messages used by | |
| 26 // RenderMessageFilter. | |
| 27 // It's the complement of SpeechInputDispatcher (owned by RenderView). | |
| 28 class CONTENT_EXPORT SpeechInputDispatcherHost | |
| 29 : public content::BrowserMessageFilter { | |
| 30 public: | |
| 31 class SpeechInputCallers; | |
| 32 | |
| 33 SpeechInputDispatcherHost( | |
| 34 int render_process_id, | |
| 35 net::URLRequestContextGetter* context_getter, | |
| 36 content::SpeechInputPreferences* speech_input_preferences, | |
| 37 AudioManager* audio_manager); | |
| 38 | |
| 39 // Methods called by SpeechInputManagerImpl. | |
| 40 void SetRecognitionResult(int caller_id, | |
| 41 const content::SpeechInputResult& 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(SpeechInputManagerImpl* manager); | |
| 51 | |
| 52 private: | |
| 53 virtual ~SpeechInputDispatcherHost(); | |
| 54 | |
| 55 void OnStartRecognition( | |
| 56 const SpeechInputHostMsg_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 input manager to forward events to, creating one if | |
| 61 // needed. | |
| 62 SpeechInputManagerImpl* 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::SpeechInputPreferences> speech_input_preferences_; | |
| 69 AudioManager* audio_manager_; | |
| 70 | |
| 71 static SpeechInputManagerImpl* manager_; | |
| 72 | |
| 73 DISALLOW_COPY_AND_ASSIGN(SpeechInputDispatcherHost); | |
| 74 }; | |
| 75 | |
| 76 } // namespace speech_input | |
| 77 | |
| 78 #endif // CONTENT_BROWSER_SPEECH_SPEECH_INPUT_DISPATCHER_HOST_H_ | |
| OLD | NEW |