| 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 "chrome/browser/speech/speech_recognition_bubble_controller.h" | 10 #include "chrome/browser/speech/speech_recognition_bubble_controller.h" |
| 11 #include "content/public/browser/speech_recognition_manager_delegate.h" | 11 #include "content/public/browser/speech_recognition_manager_delegate.h" |
| 12 | 12 |
| 13 namespace base { |
| 14 class WaitableEvent; |
| 15 } |
| 16 |
| 13 namespace speech { | 17 namespace speech { |
| 14 | 18 |
| 15 // This is Chrome's implementation of the SpeechRecognitionManager interface. | 19 // This is Chrome's implementation of the SpeechRecognitionManagerDelegate |
| 16 // This class is a singleton and accessed via the Get method. | 20 // interface. |
| 17 class ChromeSpeechRecognitionManagerDelegate | 21 class ChromeSpeechRecognitionManagerDelegate |
| 18 : NON_EXPORTED_BASE(public content::SpeechRecognitionManagerDelegate), | 22 : NON_EXPORTED_BASE(public content::SpeechRecognitionManagerDelegate), |
| 19 public SpeechRecognitionBubbleControllerDelegate { | 23 public SpeechRecognitionBubbleControllerDelegate { |
| 20 public: | 24 public: |
| 21 ChromeSpeechRecognitionManagerDelegate(); | 25 ChromeSpeechRecognitionManagerDelegate(); |
| 22 virtual ~ChromeSpeechRecognitionManagerDelegate(); | 26 virtual ~ChromeSpeechRecognitionManagerDelegate(); |
| 23 | 27 |
| 24 // SpeechRecognitionBubbleControllerDelegate methods. | 28 // SpeechRecognitionBubbleControllerDelegate methods. |
| 25 virtual void InfoBubbleButtonClicked( | 29 virtual void InfoBubbleButtonClicked( |
| 26 int session_id, SpeechRecognitionBubble::Button button) OVERRIDE; | 30 int session_id, SpeechRecognitionBubble::Button button) OVERRIDE; |
| 27 virtual void InfoBubbleFocusChanged(int session_id) OVERRIDE; | 31 virtual void InfoBubbleFocusChanged(int session_id) OVERRIDE; |
| 28 | 32 |
| 29 protected: | 33 protected: |
| 30 // SpeechRecognitionManagerDelegate methods. | 34 // SpeechRecognitionManagerDelegate methods. |
| 31 virtual void GetRequestInfo(bool* can_report_metrics, | 35 virtual void GetDiagnosticInformation(bool* can_report_metrics, |
| 32 std::string* request_info) OVERRIDE; | 36 std::string* hardware_info) OVERRIDE; |
| 33 virtual void ShowRecognitionRequested(int session_id, | 37 virtual bool IsRecognitionAllowed(int session_id) OVERRIDE; |
| 34 int render_process_id, | 38 virtual void ShowRecognitionRequested(int session_id) OVERRIDE; |
| 35 int render_view_id, | |
| 36 const gfx::Rect& element_rect) OVERRIDE; | |
| 37 virtual void ShowWarmUp(int session_id) OVERRIDE; | 39 virtual void ShowWarmUp(int session_id) OVERRIDE; |
| 38 virtual void ShowRecognizing(int session_id) OVERRIDE; | 40 virtual void ShowRecognizing(int session_id) OVERRIDE; |
| 39 virtual void ShowRecording(int session_id) OVERRIDE; | 41 virtual void ShowRecording(int session_id) OVERRIDE; |
| 40 virtual void ShowInputVolume(int session_id, | 42 virtual void ShowInputVolume(int session_id, |
| 41 float volume, | 43 float volume, |
| 42 float noise_volume) OVERRIDE; | 44 float noise_volume) OVERRIDE; |
| 43 virtual void ShowMicError(int session_id, | 45 virtual void ShowError(int session_id, |
| 44 MicError error) OVERRIDE; | 46 const content::SpeechRecognitionError& error) OVERRIDE; |
| 45 virtual void ShowRecognizerError( | |
| 46 int session_id, content::SpeechRecognitionErrorCode error) OVERRIDE; | |
| 47 virtual void DoClose(int session_id) OVERRIDE; | 47 virtual void DoClose(int session_id) OVERRIDE; |
| 48 | 48 |
| 49 private: | 49 private: |
| 50 class OptionalRequestInfo; | 50 class OptionalRequestInfo; |
| 51 | 51 |
| 52 // Checks for VIEW_TYPE_WEB_CONTENTS host in the UI thread and notifies back |
| 53 // completion through |event| (to IsRecognitionAllowed in the IO thread). |
| 54 static void CheckRenderViewType(int render_process_id, |
| 55 int render_view_id, |
| 56 bool* result, |
| 57 base::WaitableEvent* event); |
| 58 |
| 52 scoped_refptr<SpeechRecognitionBubbleController> bubble_controller_; | 59 scoped_refptr<SpeechRecognitionBubbleController> bubble_controller_; |
| 53 scoped_refptr<OptionalRequestInfo> optional_request_info_; | 60 scoped_refptr<OptionalRequestInfo> optional_request_info_; |
| 54 | 61 |
| 55 DISALLOW_COPY_AND_ASSIGN(ChromeSpeechRecognitionManagerDelegate); | 62 DISALLOW_COPY_AND_ASSIGN(ChromeSpeechRecognitionManagerDelegate); |
| 56 }; | 63 }; |
| 57 | 64 |
| 58 } // namespace speech | 65 } // namespace speech |
| 59 | 66 |
| 60 #endif // CHROME_BROWSER_SPEECH_CHROME_SPEECH_RECOGNITION_MANAGER_DELEGATE_H_ | 67 #endif // CHROME_BROWSER_SPEECH_CHROME_SPEECH_RECOGNITION_MANAGER_DELEGATE_H_ |
| OLD | NEW |