| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_BROWSER_SPEECH_SPEECH_INPUT_DISPATCHER_HOST_H_ | 5 #ifndef CONTENT_BROWSER_SPEECH_SPEECH_RECOGNITION_DISPATCHER_HOST_H_ |
| 6 #define CONTENT_BROWSER_SPEECH_SPEECH_INPUT_DISPATCHER_HOST_H_ | 6 #define CONTENT_BROWSER_SPEECH_SPEECH_RECOGNITION_DISPATCHER_HOST_H_ |
| 7 | 7 |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "content/common/content_export.h" | 9 #include "content/common/content_export.h" |
| 10 #include "content/public/browser/browser_message_filter.h" | 10 #include "content/public/browser/browser_message_filter.h" |
| 11 #include "net/url_request/url_request_context_getter.h" | 11 #include "net/url_request/url_request_context_getter.h" |
| 12 | 12 |
| 13 class AudioManager; | 13 class AudioManager; |
| 14 struct SpeechInputHostMsg_StartRecognition_Params; | 14 struct SpeechRecognitionHostMsg_StartRequest_Params; |
| 15 | 15 |
| 16 namespace content { | 16 namespace content { |
| 17 class SpeechInputPreferences; | 17 class SpeechRecognitionPreferences; |
| 18 struct SpeechInputResult; | 18 struct SpeechInputResult; |
| 19 } | 19 } |
| 20 | 20 |
| 21 namespace speech_input { | 21 namespace speech { |
| 22 | 22 |
| 23 class SpeechInputManagerImpl; | 23 class SpeechRecognitionManagerImpl; |
| 24 | 24 |
| 25 // SpeechInputDispatcherHost is a delegate for Speech API messages used by | 25 // SpeechRecognitionDispatcherHost is a delegate for Speech API messages used by |
| 26 // RenderMessageFilter. | 26 // RenderMessageFilter. |
| 27 // It's the complement of SpeechInputDispatcher (owned by RenderView). | 27 // It's the complement of SpeechRecognitionDispatcher (owned by RenderView). |
| 28 class CONTENT_EXPORT SpeechInputDispatcherHost | 28 class CONTENT_EXPORT SpeechRecognitionDispatcherHost |
| 29 : public content::BrowserMessageFilter { | 29 : public content::BrowserMessageFilter { |
| 30 public: | 30 public: |
| 31 class SpeechInputCallers; | 31 class Callers; |
| 32 | 32 |
| 33 SpeechInputDispatcherHost( | 33 SpeechRecognitionDispatcherHost( |
| 34 int render_process_id, | 34 int render_process_id, |
| 35 net::URLRequestContextGetter* context_getter, | 35 net::URLRequestContextGetter* context_getter, |
| 36 content::SpeechInputPreferences* speech_input_preferences, | 36 content::SpeechRecognitionPreferences* recognition_preferences, |
| 37 AudioManager* audio_manager); | 37 AudioManager* audio_manager); |
| 38 | 38 |
| 39 // Methods called by SpeechInputManagerImpl. | 39 // Methods called by SpeechRecognitionManagerImpl. |
| 40 void SetRecognitionResult(int caller_id, | 40 void SetRecognitionResult(int caller_id, |
| 41 const content::SpeechInputResult& result); | 41 const content::SpeechInputResult& result); |
| 42 void DidCompleteRecording(int caller_id); | 42 void DidCompleteRecording(int caller_id); |
| 43 void DidCompleteRecognition(int caller_id); | 43 void DidCompleteRecognition(int caller_id); |
| 44 | 44 |
| 45 // content::BrowserMessageFilter implementation. | 45 // content::BrowserMessageFilter implementation. |
| 46 virtual bool OnMessageReceived(const IPC::Message& message, | 46 virtual bool OnMessageReceived(const IPC::Message& message, |
| 47 bool* message_was_ok) OVERRIDE; | 47 bool* message_was_ok) OVERRIDE; |
| 48 | 48 |
| 49 // Singleton manager setter useful for tests. | 49 // Singleton manager setter useful for tests. |
| 50 static void set_manager(SpeechInputManagerImpl* manager); | 50 static void set_manager(SpeechRecognitionManagerImpl* manager); |
| 51 | 51 |
| 52 private: | 52 private: |
| 53 virtual ~SpeechInputDispatcherHost(); | 53 virtual ~SpeechRecognitionDispatcherHost(); |
| 54 | 54 |
| 55 void OnStartRecognition( | 55 void OnStartRecognition( |
| 56 const SpeechInputHostMsg_StartRecognition_Params ¶ms); | 56 const SpeechRecognitionHostMsg_StartRequest_Params ¶ms); |
| 57 void OnCancelRecognition(int render_view_id, int request_id); | 57 void OnCancelRecognition(int render_view_id, int request_id); |
| 58 void OnStopRecording(int render_view_id, int request_id); | 58 void OnStopRecording(int render_view_id, int request_id); |
| 59 | 59 |
| 60 // Returns the speech input manager to forward events to, creating one if | 60 // Returns the speech recognition manager to forward events to, creating one |
| 61 // needed. | 61 // if needed. |
| 62 SpeechInputManagerImpl* manager(); | 62 SpeechRecognitionManagerImpl* manager(); |
| 63 | 63 |
| 64 int render_process_id_; | 64 int render_process_id_; |
| 65 bool may_have_pending_requests_; // Set if we received any speech IPC request | 65 bool may_have_pending_requests_; // Set if we received any speech IPC request |
| 66 | 66 |
| 67 scoped_refptr<net::URLRequestContextGetter> context_getter_; | 67 scoped_refptr<net::URLRequestContextGetter> context_getter_; |
| 68 scoped_refptr<content::SpeechInputPreferences> speech_input_preferences_; | 68 scoped_refptr<content::SpeechRecognitionPreferences> recognition_preferences_; |
| 69 AudioManager* audio_manager_; | 69 AudioManager* audio_manager_; |
| 70 | 70 |
| 71 static SpeechInputManagerImpl* manager_; | 71 static SpeechRecognitionManagerImpl* manager_; |
| 72 | 72 |
| 73 DISALLOW_COPY_AND_ASSIGN(SpeechInputDispatcherHost); | 73 DISALLOW_COPY_AND_ASSIGN(SpeechRecognitionDispatcherHost); |
| 74 }; | 74 }; |
| 75 | 75 |
| 76 } // namespace speech_input | 76 } // namespace speech |
| 77 | 77 |
| 78 #endif // CONTENT_BROWSER_SPEECH_SPEECH_INPUT_DISPATCHER_HOST_H_ | 78 #endif // CONTENT_BROWSER_SPEECH_SPEECH_RECOGNITION_DISPATCHER_HOST_H_ |
| OLD | NEW |