| 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 CHROME_BROWSER_SPEECH_CHROME_SPEECH_RECOGNITION_MANAGER_DELEGATE_H_ | 5 #ifndef CHROME_BROWSER_SPEECH_CHROME_SPEECH_RECOGNITION_MANAGER_DELEGATE_H_ |
| 6 #define CHROME_BROWSER_SPEECH_CHROME_SPEECH_RECOGNITION_MANAGER_DELEGATE_H_ | 6 #define CHROME_BROWSER_SPEECH_CHROME_SPEECH_RECOGNITION_MANAGER_DELEGATE_H_ |
| 7 | 7 |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "content/public/browser/speech_recognition_event_listener.h" | 10 #include "content/public/browser/speech_recognition_event_listener.h" |
| 11 #include "content/public/browser/speech_recognition_manager_delegate.h" | 11 #include "content/public/browser/speech_recognition_manager_delegate.h" |
| 12 #include "content/public/browser/speech_recognition_session_config.h" | 12 #include "content/public/browser/speech_recognition_session_config.h" |
| 13 | 13 |
| 14 namespace speech { | 14 namespace speech { |
| 15 | 15 |
| 16 // This is Chrome's implementation of the SpeechRecognitionManagerDelegate | 16 // This is Chrome's implementation of the SpeechRecognitionManagerDelegate |
| 17 // interface. | 17 // interface. |
| 18 class ChromeSpeechRecognitionManagerDelegate | 18 class ChromeSpeechRecognitionManagerDelegate |
| 19 : public content::SpeechRecognitionManagerDelegate, | 19 : public content::SpeechRecognitionManagerDelegate, |
| 20 public content::SpeechRecognitionEventListener { | 20 public content::SpeechRecognitionEventListener { |
| 21 public: | 21 public: |
| 22 ChromeSpeechRecognitionManagerDelegate(); | 22 ChromeSpeechRecognitionManagerDelegate(); |
| 23 virtual ~ChromeSpeechRecognitionManagerDelegate(); | 23 virtual ~ChromeSpeechRecognitionManagerDelegate(); |
| 24 | 24 |
| 25 protected: | 25 protected: |
| 26 // SpeechRecognitionEventListener methods. | 26 // SpeechRecognitionEventListener methods. |
| 27 virtual void OnRecognitionStart(int session_id) OVERRIDE; | 27 virtual void OnRecognitionStart(int session_id) override; |
| 28 virtual void OnAudioStart(int session_id) OVERRIDE; | 28 virtual void OnAudioStart(int session_id) override; |
| 29 virtual void OnEnvironmentEstimationComplete(int session_id) OVERRIDE; | 29 virtual void OnEnvironmentEstimationComplete(int session_id) override; |
| 30 virtual void OnSoundStart(int session_id) OVERRIDE; | 30 virtual void OnSoundStart(int session_id) override; |
| 31 virtual void OnSoundEnd(int session_id) OVERRIDE; | 31 virtual void OnSoundEnd(int session_id) override; |
| 32 virtual void OnAudioEnd(int session_id) OVERRIDE; | 32 virtual void OnAudioEnd(int session_id) override; |
| 33 virtual void OnRecognitionEnd(int session_id) OVERRIDE; | 33 virtual void OnRecognitionEnd(int session_id) override; |
| 34 virtual void OnRecognitionResults( | 34 virtual void OnRecognitionResults( |
| 35 int session_id, const content::SpeechRecognitionResults& result) OVERRIDE; | 35 int session_id, const content::SpeechRecognitionResults& result) override; |
| 36 virtual void OnRecognitionError( | 36 virtual void OnRecognitionError( |
| 37 int session_id, const content::SpeechRecognitionError& error) OVERRIDE; | 37 int session_id, const content::SpeechRecognitionError& error) override; |
| 38 virtual void OnAudioLevelsChange(int session_id, float volume, | 38 virtual void OnAudioLevelsChange(int session_id, float volume, |
| 39 float noise_volume) OVERRIDE; | 39 float noise_volume) override; |
| 40 | 40 |
| 41 // SpeechRecognitionManagerDelegate methods. | 41 // SpeechRecognitionManagerDelegate methods. |
| 42 virtual void GetDiagnosticInformation(bool* can_report_metrics, | 42 virtual void GetDiagnosticInformation(bool* can_report_metrics, |
| 43 std::string* hardware_info) OVERRIDE; | 43 std::string* hardware_info) override; |
| 44 virtual void CheckRecognitionIsAllowed( | 44 virtual void CheckRecognitionIsAllowed( |
| 45 int session_id, | 45 int session_id, |
| 46 base::Callback<void(bool ask_user, bool is_allowed)> callback) OVERRIDE; | 46 base::Callback<void(bool ask_user, bool is_allowed)> callback) override; |
| 47 virtual content::SpeechRecognitionEventListener* GetEventListener() OVERRIDE; | 47 virtual content::SpeechRecognitionEventListener* GetEventListener() override; |
| 48 virtual bool FilterProfanities(int render_process_id) OVERRIDE; | 48 virtual bool FilterProfanities(int render_process_id) override; |
| 49 | 49 |
| 50 // Callback called by |tab_watcher_| on the IO thread to signal tab closure. | 50 // Callback called by |tab_watcher_| on the IO thread to signal tab closure. |
| 51 virtual void TabClosedCallback(int render_process_id, int render_view_id); | 51 virtual void TabClosedCallback(int render_process_id, int render_view_id); |
| 52 | 52 |
| 53 private: | 53 private: |
| 54 class OptionalRequestInfo; | 54 class OptionalRequestInfo; |
| 55 class TabWatcher; | 55 class TabWatcher; |
| 56 | 56 |
| 57 // Checks for VIEW_TYPE_TAB_CONTENTS host in the UI thread and notifies back | 57 // Checks for VIEW_TYPE_TAB_CONTENTS host in the UI thread and notifies back |
| 58 // the result in the IO thread through |callback|. | 58 // the result in the IO thread through |callback|. |
| 59 static void CheckRenderViewType( | 59 static void CheckRenderViewType( |
| 60 base::Callback<void(bool ask_user, bool is_allowed)> callback, | 60 base::Callback<void(bool ask_user, bool is_allowed)> callback, |
| 61 int render_process_id, | 61 int render_process_id, |
| 62 int render_view_id); | 62 int render_view_id); |
| 63 | 63 |
| 64 scoped_refptr<OptionalRequestInfo> optional_request_info_; | 64 scoped_refptr<OptionalRequestInfo> optional_request_info_; |
| 65 scoped_refptr<TabWatcher> tab_watcher_; | 65 scoped_refptr<TabWatcher> tab_watcher_; |
| 66 | 66 |
| 67 DISALLOW_COPY_AND_ASSIGN(ChromeSpeechRecognitionManagerDelegate); | 67 DISALLOW_COPY_AND_ASSIGN(ChromeSpeechRecognitionManagerDelegate); |
| 68 }; | 68 }; |
| 69 | 69 |
| 70 } // namespace speech | 70 } // namespace speech |
| 71 | 71 |
| 72 #endif // CHROME_BROWSER_SPEECH_CHROME_SPEECH_RECOGNITION_MANAGER_DELEGATE_H_ | 72 #endif // CHROME_BROWSER_SPEECH_CHROME_SPEECH_RECOGNITION_MANAGER_DELEGATE_H_ |
| OLD | NEW |