| 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 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 // got closed because the object was destroyed by the caller. | 50 // got closed because the object was destroyed by the caller. |
| 51 virtual void InfoBubbleFocusChanged() = 0; | 51 virtual void InfoBubbleFocusChanged() = 0; |
| 52 | 52 |
| 53 protected: | 53 protected: |
| 54 virtual ~Delegate() { | 54 virtual ~Delegate() { |
| 55 } | 55 } |
| 56 }; | 56 }; |
| 57 | 57 |
| 58 // Factory method to create new instances. | 58 // Factory method to create new instances. |
| 59 // Creates the bubble, call |Show| to display it on screen. | 59 // Creates the bubble, call |Show| to display it on screen. |
| 60 // |web_contents| is the WebContents hosting the page. | 60 // |render_process_id| and |render_view_id| is used to extract the |
| 61 // correct WebContents. |
| 61 // |element_rect| is the display bounds of the html element requesting speech | 62 // |element_rect| is the display bounds of the html element requesting speech |
| 62 // recognition (in page coordinates). | 63 // recognition (in page coordinates). |
| 63 static SpeechRecognitionBubble* Create(content::WebContents* web_contents, | 64 static SpeechRecognitionBubble* Create( |
| 64 Delegate* delegate, | 65 int render_process_id, |
| 65 const gfx::Rect& element_rect); | 66 int render_view_id, |
| 67 Delegate* delegate, |
| 68 const gfx::Rect& element_rect); |
| 66 | 69 |
| 67 // This is implemented by platform specific code to create the underlying | 70 // This is implemented by platform specific code to create the underlying |
| 68 // bubble window. Not to be called directly by users of this class. | 71 // bubble window. Not to be called directly by users of this class. |
| 69 static SpeechRecognitionBubble* CreateNativeBubble( | 72 static SpeechRecognitionBubble* CreateNativeBubble( |
| 70 content::WebContents* web_contents, | 73 int render_process_id, |
| 74 int render_view_id, |
| 71 Delegate* delegate, | 75 Delegate* delegate, |
| 72 const gfx::Rect& element_rect); | 76 const gfx::Rect& element_rect); |
| 73 | 77 |
| 74 // |Create| uses the currently registered FactoryMethod to create the | 78 // |Create| uses the currently registered FactoryMethod to create the |
| 75 // SpeechRecognitionBubble instances. FactoryMethod is intended for testing. | 79 // SpeechRecognitionBubble instances. FactoryMethod is intended for testing. |
| 76 typedef SpeechRecognitionBubble* (*FactoryMethod)(content::WebContents*, | 80 typedef SpeechRecognitionBubble* (*FactoryMethod)(content::WebContents*, |
| 77 Delegate*, | 81 Delegate*, |
| 78 const gfx::Rect&); | 82 const gfx::Rect&); |
| 79 // Sets the factory used by the static method Create. SpeechRecognitionBubble | 83 // Sets the factory used by the static method Create. SpeechRecognitionBubble |
| 80 // does not take ownership of |factory|. A value of NULL results in a | 84 // does not take ownership of |factory|. A value of NULL results in a |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 public: | 132 public: |
| 129 // The current display mode of the bubble, useful only for the platform | 133 // The current display mode of the bubble, useful only for the platform |
| 130 // specific implementation. | 134 // specific implementation. |
| 131 enum DisplayMode { | 135 enum DisplayMode { |
| 132 DISPLAY_MODE_WARM_UP, | 136 DISPLAY_MODE_WARM_UP, |
| 133 DISPLAY_MODE_RECORDING, | 137 DISPLAY_MODE_RECORDING, |
| 134 DISPLAY_MODE_RECOGNIZING, | 138 DISPLAY_MODE_RECOGNIZING, |
| 135 DISPLAY_MODE_MESSAGE | 139 DISPLAY_MODE_MESSAGE |
| 136 }; | 140 }; |
| 137 | 141 |
| 138 explicit SpeechRecognitionBubbleBase(content::WebContents* web_contents); | 142 SpeechRecognitionBubbleBase(int render_process_id, int render_view_id); |
| 139 virtual ~SpeechRecognitionBubbleBase(); | 143 virtual ~SpeechRecognitionBubbleBase(); |
| 140 | 144 |
| 141 // SpeechRecognitionBubble methods | 145 // SpeechRecognitionBubble methods |
| 142 virtual void SetWarmUpMode() OVERRIDE; | 146 virtual void SetWarmUpMode() OVERRIDE; |
| 143 virtual void SetRecordingMode() OVERRIDE; | 147 virtual void SetRecordingMode() OVERRIDE; |
| 144 virtual void SetRecognizingMode() OVERRIDE; | 148 virtual void SetRecognizingMode() OVERRIDE; |
| 145 virtual void SetMessage(const base::string16& text) OVERRIDE; | 149 virtual void SetMessage(const base::string16& text) OVERRIDE; |
| 146 virtual void SetInputVolume(float volume, float noise_volume) OVERRIDE; | 150 virtual void SetInputVolume(float volume, float noise_volume) OVERRIDE; |
| 147 virtual content::WebContents* GetWebContents() OVERRIDE; | 151 virtual content::WebContents* GetWebContents() OVERRIDE; |
| 148 | 152 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 172 base::WeakPtrFactory<SpeechRecognitionBubbleBase> weak_factory_; | 176 base::WeakPtrFactory<SpeechRecognitionBubbleBase> weak_factory_; |
| 173 int animation_step_; // Current index/step of the animation. | 177 int animation_step_; // Current index/step of the animation. |
| 174 | 178 |
| 175 DisplayMode display_mode_; | 179 DisplayMode display_mode_; |
| 176 base::string16 message_text_; // Text displayed in DISPLAY_MODE_MESSAGE | 180 base::string16 message_text_; // Text displayed in DISPLAY_MODE_MESSAGE |
| 177 | 181 |
| 178 // The current microphone image with volume level indication. | 182 // The current microphone image with volume level indication. |
| 179 scoped_ptr<SkBitmap> mic_image_; | 183 scoped_ptr<SkBitmap> mic_image_; |
| 180 // A temporary buffer image used in creating the above mic image. | 184 // A temporary buffer image used in creating the above mic image. |
| 181 scoped_ptr<SkBitmap> buffer_image_; | 185 scoped_ptr<SkBitmap> buffer_image_; |
| 182 // WebContents in which this this bubble gets displayed. | 186 |
| 183 content::WebContents* web_contents_; | 187 // Content in which this bubble gets displayed. |
| 188 int render_process_id_; |
| 189 int render_view_id_; |
| 190 |
| 184 // The current image displayed in the bubble's icon widget. | 191 // The current image displayed in the bubble's icon widget. |
| 185 gfx::ImageSkia icon_image_; | 192 gfx::ImageSkia icon_image_; |
| 186 // The scale factor used for the web-contents. | 193 // The scale factor used for the web-contents. |
| 187 float scale_; | 194 float scale_; |
| 188 | 195 |
| 189 DISALLOW_COPY_AND_ASSIGN(SpeechRecognitionBubbleBase); | 196 DISALLOW_COPY_AND_ASSIGN(SpeechRecognitionBubbleBase); |
| 190 }; | 197 }; |
| 191 | 198 |
| 192 // This typedef is to workaround the issue with certain versions of | 199 // This typedef is to workaround the issue with certain versions of |
| 193 // Visual Studio where it gets confused between multiple Delegate | 200 // Visual Studio where it gets confused between multiple Delegate |
| 194 // classes and gives a C2500 error. (I saw this error on the try bots - | 201 // classes and gives a C2500 error. (I saw this error on the try bots - |
| 195 // the workaround was not needed for my machine). | 202 // the workaround was not needed for my machine). |
| 196 typedef SpeechRecognitionBubble::Delegate SpeechRecognitionBubbleDelegate; | 203 typedef SpeechRecognitionBubble::Delegate SpeechRecognitionBubbleDelegate; |
| 197 | 204 |
| 198 #endif // CHROME_BROWSER_SPEECH_SPEECH_RECOGNITION_BUBBLE_H_ | 205 #endif // CHROME_BROWSER_SPEECH_SPEECH_RECOGNITION_BUBBLE_H_ |
| OLD | NEW |