Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(239)

Side by Side Diff: chrome/browser/speech/speech_input_bubble.h

Issue 6115001: Listen for tab close notifications and cancel active speech sessions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/speech/speech_input_bubble.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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_INPUT_BUBBLE_H_ 5 #ifndef CHROME_BROWSER_SPEECH_SPEECH_INPUT_BUBBLE_H_
6 #define CHROME_BROWSER_SPEECH_SPEECH_INPUT_BUBBLE_H_ 6 #define CHROME_BROWSER_SPEECH_SPEECH_INPUT_BUBBLE_H_
7 #pragma once 7 #pragma once
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 // Brings up the bubble on screen. 92 // Brings up the bubble on screen.
93 virtual void Show() = 0; 93 virtual void Show() = 0;
94 94
95 // Hides the info bubble, resulting in a call to 95 // Hides the info bubble, resulting in a call to
96 // |Delegate::InfoBubbleFocusChanged| as well. 96 // |Delegate::InfoBubbleFocusChanged| as well.
97 virtual void Hide() = 0; 97 virtual void Hide() = 0;
98 98
99 // Updates the current captured audio volume displayed on screen. 99 // Updates the current captured audio volume displayed on screen.
100 virtual void SetInputVolume(float volume) = 0; 100 virtual void SetInputVolume(float volume) = 0;
101 101
102 // Returns the TabContents for which this bubble gets displayed.
103 virtual TabContents* tab_contents() = 0;
104
102 // The horizontal distance between the start of the html widget and the speech 105 // The horizontal distance between the start of the html widget and the speech
103 // bubble's arrow. 106 // bubble's arrow.
104 static const int kBubbleTargetOffsetX; 107 static const int kBubbleTargetOffsetX;
105 108
106 private: 109 private:
107 static FactoryMethod factory_; 110 static FactoryMethod factory_;
108 }; 111 };
109 112
110 // Base class for the platform specific bubble implementations, this contains 113 // Base class for the platform specific bubble implementations, this contains
111 // the platform independent code for SpeechInputBubble. 114 // the platform independent code for SpeechInputBubble.
112 class SpeechInputBubbleBase : public SpeechInputBubble { 115 class SpeechInputBubbleBase : public SpeechInputBubble {
113 public: 116 public:
114 // The current display mode of the bubble, useful only for the platform 117 // The current display mode of the bubble, useful only for the platform
115 // specific implementation. 118 // specific implementation.
116 enum DisplayMode { 119 enum DisplayMode {
117 DISPLAY_MODE_RECORDING, 120 DISPLAY_MODE_RECORDING,
118 DISPLAY_MODE_RECOGNIZING, 121 DISPLAY_MODE_RECOGNIZING,
119 DISPLAY_MODE_MESSAGE 122 DISPLAY_MODE_MESSAGE
120 }; 123 };
121 124
122 SpeechInputBubbleBase(); 125 explicit SpeechInputBubbleBase(TabContents* tab_contents);
123 virtual ~SpeechInputBubbleBase(); 126 virtual ~SpeechInputBubbleBase();
124 127
125 // SpeechInputBubble methods 128 // SpeechInputBubble methods
126 virtual void SetRecordingMode(); 129 virtual void SetRecordingMode();
127 virtual void SetRecognizingMode(); 130 virtual void SetRecognizingMode();
128 virtual void SetMessage(const string16& text); 131 virtual void SetMessage(const string16& text);
129 virtual void SetInputVolume(float volume); 132 virtual void SetInputVolume(float volume);
133 virtual TabContents* tab_contents() { return tab_contents_; }
130 134
131 protected: 135 protected:
132 // Updates the platform specific UI layout for the current display mode. 136 // Updates the platform specific UI layout for the current display mode.
133 virtual void UpdateLayout() = 0; 137 virtual void UpdateLayout() = 0;
134 138
135 // Sets the given image as the image to display in the speech bubble. 139 // Sets the given image as the image to display in the speech bubble.
136 // TODO(satish): Make the SetRecognizingMode call use this to show an 140 // TODO(satish): Make the SetRecognizingMode call use this to show an
137 // animation while waiting for results. 141 // animation while waiting for results.
138 virtual void SetImage(const SkBitmap& image) = 0; 142 virtual void SetImage(const SkBitmap& image) = 0;
139 143
(...skipping 12 matching lines...) Expand all
152 ScopedRunnableMethodFactory<SpeechInputBubbleBase> task_factory_; 156 ScopedRunnableMethodFactory<SpeechInputBubbleBase> task_factory_;
153 int animation_step_; // Current index/step of the animation. 157 int animation_step_; // Current index/step of the animation.
154 std::vector<SkBitmap> animation_frames_; 158 std::vector<SkBitmap> animation_frames_;
155 159
156 DisplayMode display_mode_; 160 DisplayMode display_mode_;
157 string16 message_text_; // Text displayed in DISPLAY_MODE_MESSAGE 161 string16 message_text_; // Text displayed in DISPLAY_MODE_MESSAGE
158 // The current microphone image with volume level indication. 162 // The current microphone image with volume level indication.
159 scoped_ptr<SkBitmap> mic_image_; 163 scoped_ptr<SkBitmap> mic_image_;
160 // A temporary buffer image used in creating the above mic image. 164 // A temporary buffer image used in creating the above mic image.
161 scoped_ptr<SkBitmap> buffer_image_; 165 scoped_ptr<SkBitmap> buffer_image_;
166 // TabContents in which this this bubble gets displayed.
167 TabContents* tab_contents_;
162 168
163 static SkBitmap* mic_full_; // Mic image with full volume. 169 static SkBitmap* mic_full_; // Mic image with full volume.
164 static SkBitmap* mic_empty_; // Mic image with zero volume. 170 static SkBitmap* mic_empty_; // Mic image with zero volume.
165 static SkBitmap* mic_mask_; // Gradient mask used by the volume indicator. 171 static SkBitmap* mic_mask_; // Gradient mask used by the volume indicator.
166 static SkBitmap* spinner_; // Spinner image for the progress animation. 172 static SkBitmap* spinner_; // Spinner image for the progress animation.
167 static const int kRecognizingAnimationStepMs; 173 static const int kRecognizingAnimationStepMs;
168 }; 174 };
169 175
170 // This typedef is to workaround the issue with certain versions of 176 // This typedef is to workaround the issue with certain versions of
171 // Visual Studio where it gets confused between multiple Delegate 177 // Visual Studio where it gets confused between multiple Delegate
172 // classes and gives a C2500 error. (I saw this error on the try bots - 178 // classes and gives a C2500 error. (I saw this error on the try bots -
173 // the workaround was not needed for my machine). 179 // the workaround was not needed for my machine).
174 typedef SpeechInputBubble::Delegate SpeechInputBubbleDelegate; 180 typedef SpeechInputBubble::Delegate SpeechInputBubbleDelegate;
175 181
176 #endif // CHROME_BROWSER_SPEECH_SPEECH_INPUT_BUBBLE_H_ 182 #endif // CHROME_BROWSER_SPEECH_SPEECH_INPUT_BUBBLE_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/speech/speech_input_bubble.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698