Chromium Code Reviews| 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_SPEECH_RECOGNITION_BUBBLE_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_SPEECH_SPEECH_RECOGNITION_BUBBLE_CONTROLLER_H_ |
| 6 #define CHROME_BROWSER_SPEECH_SPEECH_RECOGNITION_BUBBLE_CONTROLLER_H_ | 6 #define CHROME_BROWSER_SPEECH_SPEECH_RECOGNITION_BUBBLE_CONTROLLER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 28 int session_id, SpeechRecognitionBubble::Button button) = 0; | 28 int session_id, SpeechRecognitionBubble::Button button) = 0; |
| 29 | 29 |
| 30 // Invoked when the user clicks outside the speech recognition info bubble | 30 // Invoked when the user clicks outside the speech recognition info bubble |
| 31 // causing it to close and input focus to change. | 31 // causing it to close and input focus to change. |
| 32 virtual void InfoBubbleFocusChanged(int session_id) = 0; | 32 virtual void InfoBubbleFocusChanged(int session_id) = 0; |
| 33 | 33 |
| 34 protected: | 34 protected: |
| 35 virtual ~Delegate() {} | 35 virtual ~Delegate() {} |
| 36 }; | 36 }; |
| 37 | 37 |
| 38 // All methods of this delegate are called on the UI thread. | |
| 39 class DelegateForTests { | |
|
jam
2012/07/11 15:59:04
I haven't seen this pattern before. it seems unfor
Primiano Tucci (use gerrit)
2012/07/11 16:15:49
Unfortunately, I have no other idea on how to chec
| |
| 40 public: | |
| 41 virtual void BubbleCreated() = 0; | |
| 42 virtual void BubbleSwitchedToRecordingMode() = 0; | |
| 43 virtual void BubbleSwitchedToRecognizingMode() = 0; | |
| 44 virtual void BubbleMessageDisplayed() = 0; | |
| 45 virtual void BubbleClosed() = 0; | |
| 46 }; | |
| 47 | |
| 48 static void SetDelegateForTests(DelegateForTests* delegate_for_tests); | |
| 49 static SpeechRecognitionBubbleController* GetInstanceForTests(); | |
| 50 | |
| 38 explicit SpeechRecognitionBubbleController(Delegate* delegate); | 51 explicit SpeechRecognitionBubbleController(Delegate* delegate); |
| 39 | 52 |
| 40 // Creates and shows a new speech recognition UI bubble in warmup mode. | 53 // Creates and shows a new speech recognition UI bubble in warmup mode. |
| 41 void CreateBubble(int session_id, | 54 void CreateBubble(int session_id, |
| 42 int render_process_id, | 55 int render_process_id, |
| 43 int render_view_id, | 56 int render_view_id, |
| 44 const gfx::Rect& element_rect); | 57 const gfx::Rect& element_rect); |
| 45 | 58 |
| 46 // Indicates to the user that audio recording is in progress. | 59 // Indicates to the user that audio recording is in progress. |
| 47 void SetBubbleRecordingMode(); | 60 void SetBubbleRecordingMode(); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 98 explicit UIRequest(RequestType type_value); | 111 explicit UIRequest(RequestType type_value); |
| 99 ~UIRequest(); | 112 ~UIRequest(); |
| 100 }; | 113 }; |
| 101 | 114 |
| 102 virtual ~SpeechRecognitionBubbleController(); | 115 virtual ~SpeechRecognitionBubbleController(); |
| 103 | 116 |
| 104 void InvokeDelegateButtonClicked(SpeechRecognitionBubble::Button button); | 117 void InvokeDelegateButtonClicked(SpeechRecognitionBubble::Button button); |
| 105 void InvokeDelegateFocusChanged(); | 118 void InvokeDelegateFocusChanged(); |
| 106 void ProcessRequestInUiThread(const UIRequest& request); | 119 void ProcessRequestInUiThread(const UIRequest& request); |
| 107 | 120 |
| 121 // Instance getter for simulating button presses during tests. | |
| 122 static SpeechRecognitionBubbleController* instance_for_tests_; | |
| 123 | |
| 124 // Delegate for receiving events on the UI thread during tests. | |
| 125 static DelegateForTests* delegate_for_tests_; | |
| 126 | |
| 108 // *** The following are accessed only on the IO thread. | 127 // *** The following are accessed only on the IO thread. |
| 109 Delegate* delegate_; | 128 Delegate* delegate_; |
| 110 | 129 |
| 111 // The session id for currently visible bubble. | 130 // The session id for currently visible bubble. |
| 112 int current_bubble_session_id_; | 131 int current_bubble_session_id_; |
| 113 | 132 |
| 114 // The render process and view ids for the currently visible bubble. | 133 // The render process and view ids for the currently visible bubble. |
| 115 int current_bubble_render_process_id_; | 134 int current_bubble_render_process_id_; |
| 116 int current_bubble_render_view_id_; | 135 int current_bubble_render_view_id_; |
| 117 | 136 |
| 118 RequestType last_request_issued_; | 137 RequestType last_request_issued_; |
| 119 | 138 |
| 120 // *** The following are accessed only on the UI thread. | 139 // *** The following are accessed only on the UI thread. |
| 121 scoped_ptr<SpeechRecognitionBubble> bubble_; | 140 scoped_ptr<SpeechRecognitionBubble> bubble_; |
| 122 }; | 141 }; |
| 123 | 142 |
| 124 // This typedef is to workaround the issue with certain versions of | 143 // This typedef is to workaround the issue with certain versions of |
| 125 // Visual Studio where it gets confused between multiple Delegate | 144 // Visual Studio where it gets confused between multiple Delegate |
| 126 // classes and gives a C2500 error. (I saw this error on the try bots - | 145 // classes and gives a C2500 error. (I saw this error on the try bots - |
| 127 // the workaround was not needed for my machine). | 146 // the workaround was not needed for my machine). |
| 128 typedef SpeechRecognitionBubbleController::Delegate | 147 typedef SpeechRecognitionBubbleController::Delegate |
| 129 SpeechRecognitionBubbleControllerDelegate; | 148 SpeechRecognitionBubbleControllerDelegate; |
| 130 | 149 |
| 150 typedef SpeechRecognitionBubbleController::DelegateForTests | |
| 151 SpeechRecognitionBubbleControllerDelegateForTests; | |
| 152 | |
| 131 } // namespace speech | 153 } // namespace speech |
| 132 | 154 |
| 133 #endif // CHROME_BROWSER_SPEECH_SPEECH_RECOGNITION_BUBBLE_CONTROLLER_H_ | 155 #endif // CHROME_BROWSER_SPEECH_SPEECH_RECOGNITION_BUBBLE_CONTROLLER_H_ |
| OLD | NEW |