Chromium Code Reviews| Index: content/browser/speech/speech_recognition_manager_impl.h |
| diff --git a/content/browser/speech/speech_recognition_manager_impl.h b/content/browser/speech/speech_recognition_manager_impl.h |
| index 0cd91051b842ebcc69b4543bbf146507d471ed45..58f62dbc7eddda5fa91847c4b20926de139c0e7e 100644 |
| --- a/content/browser/speech/speech_recognition_manager_impl.h |
| +++ b/content/browser/speech/speech_recognition_manager_impl.h |
| @@ -12,6 +12,7 @@ |
| #include "base/callback.h" |
| #include "base/compiler_specific.h" |
| #include "base/memory/weak_ptr.h" |
| +#include "content/browser/renderer_host/media/media_stream_requester.h" |
| #include "content/public/browser/speech_recognition_event_listener.h" |
| #include "content/public/browser/speech_recognition_manager.h" |
| #include "content/public/browser/speech_recognition_session_config.h" |
| @@ -23,6 +24,10 @@ class BrowserMainLoop; |
| class SpeechRecognitionManagerDelegate; |
| } |
| +namespace media_stream { |
| +class MediaStreamManager; |
| +} |
| + |
| namespace speech { |
| class SpeechRecognizer; |
| @@ -30,13 +35,12 @@ class SpeechRecognizer; |
| // This is the manager for speech recognition. It is a single instance in |
| // the browser process and can serve several requests. Each recognition request |
| // corresponds to a session, initiated via |CreateSession|. |
| -// In every moment the manager has at most one session capturing audio, which |
| -// is identified by |session_id_capturing_audio_|. However, multiple sessions |
| -// can live in parallel in respect of the aforementioned constraint, i.e. while |
| -// waiting for results. |
| -// This class does not handle user interface objects (bubbles, tray icon). |
| -// Those are managed by the delegate, which receives a copy of all sessions |
| -// events. |
| +// |
| +// In any moment, the manager has a single session known as the primary session, |
| +// |primary_session_id_|. |
| +// This is the session that is capturing audio, waiting for user permission, |
| +// etc. There may also be other, non-primary, sessions living in parallel that |
| +// are waiting for results but not recording audio. |
| // |
| // The SpeechRecognitionManager has the following responsibilities: |
| // - Handles requests received from various render views and makes sure only |
| @@ -123,6 +127,7 @@ class CONTENT_EXPORT SpeechRecognitionManagerImpl : |
| int id; |
| bool listener_is_active; |
| + bool is_waiting_for_permission; |
|
Satish
2012/09/12 06:15:09
instead of this flag in each Session object, how a
hans
2012/09/12 09:46:58
Done.
|
| content::SpeechRecognitionSessionConfig config; |
| content::SpeechRecognitionSessionContext context; |
| scoped_refptr<SpeechRecognizer> recognizer; |
| @@ -130,7 +135,9 @@ class CONTENT_EXPORT SpeechRecognitionManagerImpl : |
| // Callback issued by the SpeechRecognitionManagerDelegate for reporting |
| // asynchronously the result of the CheckRecognitionIsAllowed call. |
| - void RecognitionAllowedCallback(int session_id, bool is_allowed); |
| + void RecognitionAllowedCallback(int session_id, |
| + bool ask_user, |
| + bool is_allowed); |
| // Entry point for pushing any external event into the session handling FSM. |
| void DispatchEvent(int session_id, FSMEvent event); |
| @@ -159,7 +166,7 @@ class CONTENT_EXPORT SpeechRecognitionManagerImpl : |
| typedef std::map<int, Session> SessionsTable; |
| SessionsTable sessions_; |
| - int session_id_capturing_audio_; |
| + int primary_session_id_; |
| int last_session_id_; |
| bool is_dispatching_event_; |
| scoped_ptr<content::SpeechRecognitionManagerDelegate> delegate_; |
| @@ -168,6 +175,41 @@ class CONTENT_EXPORT SpeechRecognitionManagerImpl : |
| // about this class being destroyed in the meanwhile (due to browser shutdown) |
| // since tasks pending on a destroyed WeakPtr are automatically discarded. |
| base::WeakPtrFactory<SpeechRecognitionManagerImpl> weak_factory_; |
| + |
| + class PermissionRequest : public media_stream::MediaStreamRequester { |
|
Satish
2012/09/12 06:15:09
can this be forward declared in this header and th
hans
2012/09/12 09:46:58
No, because it inherits from another class it can'
hans
2012/09/12 09:46:58
Done.
|
| + public: |
| + PermissionRequest(media_stream::MediaStreamManager* media_stream_manager, |
| + const base::Callback<void(bool is_allowed)>& callback); |
| + virtual ~PermissionRequest(); |
| + |
| + void Start(int render_process_id, int render_view_id, const GURL& origin); |
| + void Abort(); |
| + |
| + // MediaStreamRequester methods. |
| + virtual void StreamGenerated( |
| + const std::string& label, |
| + const media_stream::StreamDeviceInfoArray& audio_devices, |
| + const media_stream::StreamDeviceInfoArray& video_devices) OVERRIDE; |
| + virtual void StreamGenerationFailed(const std::string& label) OVERRIDE; |
| + |
| + // The callbacks below are ignored. |
| + virtual void AudioDeviceFailed(const std::string& label, |
| + int index) OVERRIDE {} |
| + virtual void VideoDeviceFailed(const std::string& label, |
| + int index) OVERRIDE {} |
| + virtual void DevicesEnumerated( |
| + const std::string& label, |
| + const media_stream::StreamDeviceInfoArray& devices) OVERRIDE {} |
| + virtual void DeviceOpened( |
| + const std::string& label, |
| + const media_stream::StreamDeviceInfo& device_info) OVERRIDE {} |
| + |
| + private: |
| + media_stream::MediaStreamManager* media_stream_manager_; |
| + base::Callback<void(bool is_allowed)> callback_; |
| + std::string label_; |
| + }; |
| + scoped_ptr<PermissionRequest> permission_request_; |
| }; |
| } // namespace speech |