Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(330)

Side by Side Diff: content/browser/speech/speech_input_manager.h

Issue 9433006: Remove GetAudioManager and GetMediaStreamManager from ResourceContext. The reason is the content mo… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: sync to head Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_MANAGER_H_ 5 #ifndef CONTENT_BROWSER_SPEECH_SPEECH_INPUT_MANAGER_H_
6 #define CONTENT_BROWSER_SPEECH_SPEECH_INPUT_MANAGER_H_ 6 #define CONTENT_BROWSER_SPEECH_SPEECH_INPUT_MANAGER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 // Describes the microphone errors that are reported via ShowMicError. 42 // Describes the microphone errors that are reported via ShowMicError.
43 enum MicError { 43 enum MicError {
44 kNoDeviceAvailable = 0, 44 kNoDeviceAvailable = 0,
45 kDeviceInUse 45 kDeviceInUse
46 }; 46 };
47 47
48 SpeechInputManager(); 48 SpeechInputManager();
49 49
50 // Invokes the platform provided microphone settings UI in a non-blocking way, 50 // Invokes the platform provided microphone settings UI in a non-blocking way,
51 // via the BrowserThread::FILE thread. 51 // via the BrowserThread::FILE thread.
52 static void ShowAudioInputSettings(AudioManager* audio_manager); 52 static void ShowAudioInputSettings();
53
54 // Same as ShowAudioInputSettings above but can be called from the UI thread
55 // where the caller has a pointer to a resource context, but due to not
56 // running on the IO thread, cannot access its properties.
57 static void ShowAudioInputSettingsFromUI(
58 content::ResourceContext* resource_context);
59 53
60 virtual ~SpeechInputManager(); 54 virtual ~SpeechInputManager();
61 55
56 // These are wrappers around AudioManager.
tommi (sloooow) - chröme 2012/02/23 07:50:59 much nicer!
57 bool HasAudioInputDevices();
58 bool IsRecordingInProcess();
59 string16 GetAudioInputDeviceModel();
60
62 // Handlers for requests from render views. 61 // Handlers for requests from render views.
63 62
64 // |delegate| is a weak pointer and should remain valid until 63 // |delegate| is a weak pointer and should remain valid until
65 // its |DidCompleteRecognition| method is called or recognition is cancelled. 64 // its |DidCompleteRecognition| method is called or recognition is cancelled.
66 // |render_process_id| is the ID of the renderer process initiating the 65 // |render_process_id| is the ID of the renderer process initiating the
67 // request. 66 // request.
68 // |element_rect| is the display bounds of the html element requesting speech 67 // |element_rect| is the display bounds of the html element requesting speech
69 // input (in page coordinates). 68 // input (in page coordinates).
70 virtual void StartRecognition( 69 virtual void StartRecognition(
71 content::SpeechInputManagerDelegate* delegate, 70 content::SpeechInputManagerDelegate* delegate,
72 int caller_id, 71 int caller_id,
73 int render_process_id, 72 int render_process_id,
74 int render_view_id, 73 int render_view_id,
75 const gfx::Rect& element_rect, 74 const gfx::Rect& element_rect,
76 const std::string& language, 75 const std::string& language,
77 const std::string& grammar, 76 const std::string& grammar,
78 const std::string& origin_url, 77 const std::string& origin_url,
79 net::URLRequestContextGetter* context_getter, 78 net::URLRequestContextGetter* context_getter,
80 content::SpeechInputPreferences* speech_input_prefs, 79 content::SpeechInputPreferences* speech_input_prefs);
81 AudioManager* audio_manager);
82 virtual void CancelRecognition(int caller_id); 80 virtual void CancelRecognition(int caller_id);
83 virtual void CancelAllRequestsWithDelegate( 81 virtual void CancelAllRequestsWithDelegate(
84 content::SpeechInputManagerDelegate* delegate); 82 content::SpeechInputManagerDelegate* delegate);
85 virtual void StopRecording(int caller_id); 83 virtual void StopRecording(int caller_id);
86 84
87 // Overridden from content::SpeechRecognizerDelegate: 85 // Overridden from content::SpeechRecognizerDelegate:
88 virtual void DidStartReceivingAudio(int caller_id) OVERRIDE; 86 virtual void DidStartReceivingAudio(int caller_id) OVERRIDE;
89 virtual void SetRecognitionResult( 87 virtual void SetRecognitionResult(
90 int caller_id, 88 int caller_id,
91 const content::SpeechInputResult& result) OVERRIDE; 89 const content::SpeechInputResult& result) OVERRIDE;
92 virtual void DidCompleteRecording(int caller_id) OVERRIDE; 90 virtual void DidCompleteRecording(int caller_id) OVERRIDE;
93 virtual void DidCompleteRecognition(int caller_id) OVERRIDE; 91 virtual void DidCompleteRecognition(int caller_id) OVERRIDE;
94 virtual void DidStartReceivingSpeech(int caller_id) OVERRIDE; 92 virtual void DidStartReceivingSpeech(int caller_id) OVERRIDE;
95 virtual void DidStopReceivingSpeech(int caller_id) OVERRIDE; 93 virtual void DidStopReceivingSpeech(int caller_id) OVERRIDE;
96 94
97 virtual void OnRecognizerError(int caller_id, 95 virtual void OnRecognizerError(int caller_id,
98 content::SpeechInputError error) OVERRIDE; 96 content::SpeechInputError error) OVERRIDE;
99 virtual void DidCompleteEnvironmentEstimation(int caller_id) OVERRIDE; 97 virtual void DidCompleteEnvironmentEstimation(int caller_id) OVERRIDE;
100 virtual void SetInputVolume(int caller_id, float volume, 98 virtual void SetInputVolume(int caller_id, float volume,
101 float noise_volume) OVERRIDE; 99 float noise_volume) OVERRIDE;
102 100
103 protected: 101 protected:
104 // The pure virtual methods are used for displaying the current state of 102 // The pure virtual methods are used for displaying the current state of
105 // recognition and for fetching optional request information. 103 // recognition and for fetching optional request information.
106 104
107 // Get the optional request information if available. 105 // Get the optional request information if available.
108 virtual void GetRequestInfo(AudioManager* audio_manager, 106 virtual void GetRequestInfo(bool* can_report_metrics,
109 bool* can_report_metrics,
110 std::string* request_info) = 0; 107 std::string* request_info) = 0;
111 108
112 // Called when recognition has been requested from point |element_rect_| on 109 // Called when recognition has been requested from point |element_rect_| on
113 // the view port for the given caller. 110 // the view port for the given caller.
114 virtual void ShowRecognitionRequested(int caller_id, 111 virtual void ShowRecognitionRequested(int caller_id,
115 int render_process_id, 112 int render_process_id,
116 int render_view_id, 113 int render_view_id,
117 const gfx::Rect& element_rect) = 0; 114 const gfx::Rect& element_rect) = 0;
118 115
119 // Called when recognition is starting up. 116 // Called when recognition is starting up.
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 typedef std::map<int, SpeechInputRequest> SpeechRecognizerMap; 167 typedef std::map<int, SpeechInputRequest> SpeechRecognizerMap;
171 SpeechRecognizerMap requests_; 168 SpeechRecognizerMap requests_;
172 std::string request_info_; 169 std::string request_info_;
173 bool can_report_metrics_; 170 bool can_report_metrics_;
174 int recording_caller_id_; 171 int recording_caller_id_;
175 }; 172 };
176 173
177 } // namespace speech_input 174 } // namespace speech_input
178 175
179 #endif // CONTENT_BROWSER_SPEECH_SPEECH_INPUT_MANAGER_H_ 176 #endif // CONTENT_BROWSER_SPEECH_SPEECH_INPUT_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698