1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_SPEECH_CHROME_SPEECH_RECOGNITION_MANAGER_DELEGATE_BUBBLE_UI_H_
6 #define CHROME_BROWSER_SPEECH_CHROME_SPEECH_RECOGNITION_MANAGER_DELEGATE_BUBBLE_UI_H_
8 #include "base/compiler_specific.h"
9 #include "chrome/browser/speech/chrome_speech_recognition_manager_delegate.h"
10 #include "chrome/browser/speech/speech_recognition_bubble_controller.h"
14 // This class extends ChromeSpeechRecognitionManagerDelegate to add the behavior
15 // required to handle the (bubble) UI for speech recognition sessions initiated
16 // by input elements with a x-webkit-speech attribute. This extended behavior is
17 // achieved by means of overriding some SpeechRecognitionEventListener methods
18 // and intercepting the calls required to show, animate and hide the bubble UI.
19 class ChromeSpeechRecognitionManagerDelegateBubbleUI
20 : public ChromeSpeechRecognitionManagerDelegate
,
21 public SpeechRecognitionBubbleControllerDelegate
{
23 ChromeSpeechRecognitionManagerDelegateBubbleUI();
24 virtual ~ChromeSpeechRecognitionManagerDelegateBubbleUI();
27 // SpeechRecognitionBubbleControllerDelegate methods.
28 virtual void InfoBubbleButtonClicked(
29 int session_id
, SpeechRecognitionBubble::Button button
) OVERRIDE
;
30 virtual void InfoBubbleFocusChanged(int session_id
) OVERRIDE
;
32 // Overridden base class SpeechRecognitionEventListener methods.
33 virtual void OnRecognitionStart(int session_id
) OVERRIDE
;
34 virtual void OnAudioStart(int session_id
) OVERRIDE
;
35 virtual void OnAudioEnd(int session_id
) OVERRIDE
;
36 virtual void OnRecognitionEnd(int session_id
) OVERRIDE
;
37 virtual void OnRecognitionError(
38 int session_id
, const content::SpeechRecognitionError
& error
) OVERRIDE
;
39 virtual void OnAudioLevelsChange(
40 int session_id
, float volume
, float noise_volume
) OVERRIDE
;
42 // Starts a new recognition session, using the config of the last one
43 // (which is copied into |last_session_config_|). Used for "try again".
44 void RestartLastSession();
46 // Called on the UI thread by the base class when tab closure was detected.
47 virtual void TabClosedCallback(
48 int render_process_id
, int render_view_id
) OVERRIDE
;
51 // Lazy initializer for bubble controller.
52 SpeechRecognitionBubbleController
* GetBubbleController();
54 scoped_refptr
<SpeechRecognitionBubbleController
> bubble_controller_
;
55 scoped_ptr
<content::SpeechRecognitionSessionConfig
> last_session_config_
;
57 DISALLOW_COPY_AND_ASSIGN(ChromeSpeechRecognitionManagerDelegateBubbleUI
);
62 #endif // CHROME_BROWSER_SPEECH_CHROME_SPEECH_RECOGNITION_MANAGER_DELEGATE_BUBBLE_UI_H_