| 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_PUBLIC_BROWSER_SPEECH_RECOGNITION_MANAGER_H_ | 5 #ifndef CONTENT_PUBLIC_BROWSER_SPEECH_RECOGNITION_MANAGER_H_ |
| 6 #define CONTENT_PUBLIC_BROWSER_SPEECH_RECOGNITION_MANAGER_H_ | 6 #define CONTENT_PUBLIC_BROWSER_SPEECH_RECOGNITION_MANAGER_H_ |
| 7 | 7 |
| 8 #include "base/string16.h" | 8 #include "base/string16.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "content/common/content_export.h" | 10 #include "content/common/content_export.h" |
| 11 #include "content/public/common/speech_recognition_result.h" | 11 #include "content/public/common/speech_recognition_result.h" |
| 12 | 12 |
| 13 namespace media { |
| 14 class AudioManager; |
| 15 } |
| 16 |
| 13 namespace content { | 17 namespace content { |
| 14 | 18 |
| 15 class SpeechRecognitionEventListener; | 19 class SpeechRecognitionEventListener; |
| 16 struct SpeechRecognitionSessionConfig; | 20 struct SpeechRecognitionSessionConfig; |
| 17 struct SpeechRecognitionSessionContext; | 21 struct SpeechRecognitionSessionContext; |
| 18 | 22 |
| 19 // The SpeechRecognitionManager (SRM) is a singleton class that handles SR | 23 // The SpeechRecognitionManager (SRM) is a singleton class that handles SR |
| 20 // functionalities within Chrome. Everyone that needs to perform SR should | 24 // functionalities within Chrome. Everyone that needs to perform SR should |
| 21 // interface exclusively with the SRM, receiving events through the callback | 25 // interface exclusively with the SRM, receiving events through the callback |
| 22 // interface SpeechRecognitionEventListener. | 26 // interface SpeechRecognitionEventListener. |
| 23 // Since many different sources can use SR in different times (some overlapping | 27 // Since many different sources can use SR in different times (some overlapping |
| 24 // is allowed while waiting for results), the SRM has the further responsibility | 28 // is allowed while waiting for results), the SRM has the further responsibility |
| 25 // of handling separately and reliably (taking into account also call sequences | 29 // of handling separately and reliably (taking into account also call sequences |
| 26 // that might not make sense, e.g., two subsequent AbortSession calls). | 30 // that might not make sense, e.g., two subsequent AbortSession calls). |
| 27 // In this sense a session, within the SRM, models the ongoing evolution of a | 31 // In this sense a session, within the SRM, models the ongoing evolution of a |
| 28 // SR request from the viewpoint of the end-user, abstracting all the concrete | 32 // SR request from the viewpoint of the end-user, abstracting all the concrete |
| 29 // operations that must be carried out, that will be handled by inner classes. | 33 // operations that must be carried out, that will be handled by inner classes. |
| 30 class SpeechRecognitionManager { | 34 class SpeechRecognitionManager { |
| 31 public: | 35 public: |
| 32 enum { kSessionIDInvalid = 0 }; | 36 enum { kSessionIDInvalid = 0 }; |
| 33 | 37 |
| 34 // Returns the singleton instance. | 38 // Returns the singleton instance. |
| 35 static CONTENT_EXPORT SpeechRecognitionManager* GetInstance(); | 39 static CONTENT_EXPORT SpeechRecognitionManager* GetInstance(); |
| 36 | 40 |
| 41 // Overrides the AudioManager that will be used for tests. |
| 42 static CONTENT_EXPORT void SetAudioManagerForTests( |
| 43 media::AudioManager* audio_manager); |
| 44 |
| 45 // Sets the ID that will be used by URLFetcher requests. |
| 46 static CONTENT_EXPORT void SetURLFetcherIDForTests(int url_fetcher_id); |
| 47 |
| 37 // Creates a new recognition session. | 48 // Creates a new recognition session. |
| 38 virtual int CreateSession(const SpeechRecognitionSessionConfig& config) = 0; | 49 virtual int CreateSession(const SpeechRecognitionSessionConfig& config) = 0; |
| 39 | 50 |
| 40 // Starts/restarts recognition for an existing session, after performing a | 51 // Starts/restarts recognition for an existing session, after performing a |
| 41 // premilinary check on the delegate (CheckRecognitionIsAllowed). | 52 // premilinary check on the delegate (CheckRecognitionIsAllowed). |
| 42 virtual void StartSession(int session_id) = 0; | 53 virtual void StartSession(int session_id) = 0; |
| 43 | 54 |
| 44 // Aborts recognition for an existing session, without providing any result. | 55 // Aborts recognition for an existing session, without providing any result. |
| 45 virtual void AbortSession(int session_id) = 0; | 56 virtual void AbortSession(int session_id) = 0; |
| 46 | 57 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 // via the BrowserThread::FILE thread. | 96 // via the BrowserThread::FILE thread. |
| 86 virtual void ShowAudioInputSettings() = 0; | 97 virtual void ShowAudioInputSettings() = 0; |
| 87 | 98 |
| 88 protected: | 99 protected: |
| 89 virtual ~SpeechRecognitionManager() {} | 100 virtual ~SpeechRecognitionManager() {} |
| 90 }; | 101 }; |
| 91 | 102 |
| 92 } // namespace content | 103 } // namespace content |
| 93 | 104 |
| 94 #endif // CONTENT_PUBLIC_BROWSER_SPEECH_RECOGNITION_MANAGER_H_ | 105 #endif // CONTENT_PUBLIC_BROWSER_SPEECH_RECOGNITION_MANAGER_H_ |
| OLD | NEW |