| 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_H_ | 5 #ifndef CHROME_BROWSER_SPEECH_SPEECH_RECOGNITION_BUBBLE_H_ |
| 6 #define CHROME_BROWSER_SPEECH_SPEECH_RECOGNITION_BUBBLE_H_ | 6 #define CHROME_BROWSER_SPEECH_SPEECH_RECOGNITION_BUBBLE_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "base/string16.h" | 13 #include "base/string16.h" |
| 14 | 14 |
| 15 class SkBitmap; | 15 class SkBitmap; |
| 16 class SkCanvas; | 16 class SkCanvas; |
| 17 | 17 |
| 18 namespace content { | 18 namespace content { |
| 19 class WebContents; | 19 class WebContents; |
| 20 } | 20 } |
| 21 | 21 |
| 22 namespace gfx { | 22 namespace gfx { |
| 23 class Canvas; | 23 class Canvas; |
| 24 class ImageSkia; |
| 24 class Rect; | 25 class Rect; |
| 25 } | 26 } |
| 26 | 27 |
| 27 // SpeechRecognitionBubble displays a popup info bubble during speech | 28 // SpeechRecognitionBubble displays a popup info bubble during speech |
| 28 // recognition, points to the html element which requested speech recognition | 29 // recognition, points to the html element which requested speech recognition |
| 29 // and shows progress events. The popup is closed by the user clicking anywhere | 30 // and shows progress events. The popup is closed by the user clicking anywhere |
| 30 // outside the popup window, or by the caller destroying this object. | 31 // outside the popup window, or by the caller destroying this object. |
| 31 class SpeechRecognitionBubble { | 32 class SpeechRecognitionBubble { |
| 32 public: | 33 public: |
| 33 // The various buttons which may be part of the bubble. | 34 // The various buttons which may be part of the bubble. |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 // Updates the platform specific UI layout for the current display mode. | 150 // Updates the platform specific UI layout for the current display mode. |
| 150 virtual void UpdateLayout() = 0; | 151 virtual void UpdateLayout() = 0; |
| 151 | 152 |
| 152 // Overridden by subclasses to copy |icon_image()| to the screen. | 153 // Overridden by subclasses to copy |icon_image()| to the screen. |
| 153 virtual void UpdateImage() = 0; | 154 virtual void UpdateImage() = 0; |
| 154 | 155 |
| 155 DisplayMode display_mode() const { return display_mode_; } | 156 DisplayMode display_mode() const { return display_mode_; } |
| 156 | 157 |
| 157 const string16& message_text() const { return message_text_; } | 158 const string16& message_text() const { return message_text_; } |
| 158 | 159 |
| 159 SkBitmap icon_image(); | 160 gfx::ImageSkia icon_image(); |
| 160 | 161 |
| 161 private: | 162 private: |
| 162 void DoRecognizingAnimationStep(); | 163 void DoRecognizingAnimationStep(); |
| 163 void DoWarmingUpAnimationStep(); | 164 void DoWarmingUpAnimationStep(); |
| 164 void SetImage(const SkBitmap& image); | 165 void SetImage(const gfx::ImageSkia& image); |
| 165 | 166 |
| 166 void DrawVolumeOverlay(SkCanvas* canvas, | 167 void DrawVolumeOverlay(SkCanvas* canvas, |
| 167 const SkBitmap& bitmap, | 168 const gfx::ImageSkia& image_skia, |
| 168 float volume); | 169 float volume); |
| 169 | 170 |
| 170 // Task factory used for animation timer. | 171 // Task factory used for animation timer. |
| 171 base::WeakPtrFactory<SpeechRecognitionBubbleBase> weak_factory_; | 172 base::WeakPtrFactory<SpeechRecognitionBubbleBase> weak_factory_; |
| 172 int animation_step_; // Current index/step of the animation. | 173 int animation_step_; // Current index/step of the animation. |
| 173 std::vector<SkBitmap> animation_frames_; | 174 std::vector<gfx::ImageSkia> animation_frames_; |
| 174 std::vector<SkBitmap> warming_up_frames_; | 175 std::vector<gfx::ImageSkia> warming_up_frames_; |
| 175 | 176 |
| 176 DisplayMode display_mode_; | 177 DisplayMode display_mode_; |
| 177 string16 message_text_; // Text displayed in DISPLAY_MODE_MESSAGE | 178 string16 message_text_; // Text displayed in DISPLAY_MODE_MESSAGE |
| 178 // The current microphone image with volume level indication. | 179 // The current microphone image with volume level indication. |
| 179 scoped_ptr<SkBitmap> mic_image_; | 180 scoped_ptr<SkBitmap> mic_image_; |
| 180 // A temporary buffer image used in creating the above mic image. | 181 // A temporary buffer image used in creating the above mic image. |
| 181 scoped_ptr<SkBitmap> buffer_image_; | 182 scoped_ptr<SkBitmap> buffer_image_; |
| 182 // WebContents in which this this bubble gets displayed. | 183 // WebContents in which this this bubble gets displayed. |
| 183 content::WebContents* web_contents_; | 184 content::WebContents* web_contents_; |
| 184 // The current image displayed in the bubble's icon widget. | 185 // The current image displayed in the bubble's icon widget. |
| 185 scoped_ptr<SkBitmap> icon_image_; | 186 scoped_ptr<gfx::ImageSkia> icon_image_; |
| 186 }; | 187 }; |
| 187 | 188 |
| 188 // This typedef is to workaround the issue with certain versions of | 189 // This typedef is to workaround the issue with certain versions of |
| 189 // Visual Studio where it gets confused between multiple Delegate | 190 // Visual Studio where it gets confused between multiple Delegate |
| 190 // classes and gives a C2500 error. (I saw this error on the try bots - | 191 // classes and gives a C2500 error. (I saw this error on the try bots - |
| 191 // the workaround was not needed for my machine). | 192 // the workaround was not needed for my machine). |
| 192 typedef SpeechRecognitionBubble::Delegate SpeechRecognitionBubbleDelegate; | 193 typedef SpeechRecognitionBubble::Delegate SpeechRecognitionBubbleDelegate; |
| 193 | 194 |
| 194 #endif // CHROME_BROWSER_SPEECH_SPEECH_RECOGNITION_BUBBLE_H_ | 195 #endif // CHROME_BROWSER_SPEECH_SPEECH_RECOGNITION_BUBBLE_H_ |
| OLD | NEW |