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

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

Issue 148343008: Speech Recognition API: Safeguarding against page closes during startup (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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
OLDNEW
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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 // |web_contents| is the WebContents hosting the page.
61 // |element_rect| is the display bounds of the html element requesting speech 61 // |element_rect| is the display bounds of the html element requesting speech
62 // recognition (in page coordinates). 62 // recognition (in page coordinates).
63 static SpeechRecognitionBubble* Create(content::WebContents* web_contents, 63 static SpeechRecognitionBubble* Create(
64 Delegate* delegate, 64 int render_process_id,
65 const gfx::Rect& element_rect); 65 int render_view_id,
66 Delegate* delegate,
67 const gfx::Rect& element_rect);
66 68
67 // This is implemented by platform specific code to create the underlying 69 // This is implemented by platform specific code to create the underlying
68 // bubble window. Not to be called directly by users of this class. 70 // bubble window. Not to be called directly by users of this class.
69 static SpeechRecognitionBubble* CreateNativeBubble( 71 static SpeechRecognitionBubble* CreateNativeBubble(
70 content::WebContents* web_contents, 72 int render_process_id,
73 int render_view_id,
71 Delegate* delegate, 74 Delegate* delegate,
72 const gfx::Rect& element_rect); 75 const gfx::Rect& element_rect);
73 76
74 // |Create| uses the currently registered FactoryMethod to create the 77 // |Create| uses the currently registered FactoryMethod to create the
75 // SpeechRecognitionBubble instances. FactoryMethod is intended for testing. 78 // SpeechRecognitionBubble instances. FactoryMethod is intended for testing.
76 typedef SpeechRecognitionBubble* (*FactoryMethod)(content::WebContents*, 79 typedef SpeechRecognitionBubble* (*FactoryMethod)(content::WebContents*,
77 Delegate*, 80 Delegate*,
78 const gfx::Rect&); 81 const gfx::Rect&);
79 // Sets the factory used by the static method Create. SpeechRecognitionBubble 82 // Sets the factory used by the static method Create. SpeechRecognitionBubble
80 // does not take ownership of |factory|. A value of NULL results in a 83 // 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
128 public: 131 public:
129 // The current display mode of the bubble, useful only for the platform 132 // The current display mode of the bubble, useful only for the platform
130 // specific implementation. 133 // specific implementation.
131 enum DisplayMode { 134 enum DisplayMode {
132 DISPLAY_MODE_WARM_UP, 135 DISPLAY_MODE_WARM_UP,
133 DISPLAY_MODE_RECORDING, 136 DISPLAY_MODE_RECORDING,
134 DISPLAY_MODE_RECOGNIZING, 137 DISPLAY_MODE_RECOGNIZING,
135 DISPLAY_MODE_MESSAGE 138 DISPLAY_MODE_MESSAGE
136 }; 139 };
137 140
138 explicit SpeechRecognitionBubbleBase(content::WebContents* web_contents); 141 SpeechRecognitionBubbleBase(int render_process_id, int render_view_id);
139 virtual ~SpeechRecognitionBubbleBase(); 142 virtual ~SpeechRecognitionBubbleBase();
140 143
141 // SpeechRecognitionBubble methods 144 // SpeechRecognitionBubble methods
142 virtual void SetWarmUpMode() OVERRIDE; 145 virtual void SetWarmUpMode() OVERRIDE;
143 virtual void SetRecordingMode() OVERRIDE; 146 virtual void SetRecordingMode() OVERRIDE;
144 virtual void SetRecognizingMode() OVERRIDE; 147 virtual void SetRecognizingMode() OVERRIDE;
145 virtual void SetMessage(const base::string16& text) OVERRIDE; 148 virtual void SetMessage(const base::string16& text) OVERRIDE;
146 virtual void SetInputVolume(float volume, float noise_volume) OVERRIDE; 149 virtual void SetInputVolume(float volume, float noise_volume) OVERRIDE;
147 virtual content::WebContents* GetWebContents() OVERRIDE; 150 virtual content::WebContents* GetWebContents() OVERRIDE;
148 151
(...skipping 23 matching lines...) Expand all
172 base::WeakPtrFactory<SpeechRecognitionBubbleBase> weak_factory_; 175 base::WeakPtrFactory<SpeechRecognitionBubbleBase> weak_factory_;
173 int animation_step_; // Current index/step of the animation. 176 int animation_step_; // Current index/step of the animation.
174 177
175 DisplayMode display_mode_; 178 DisplayMode display_mode_;
176 base::string16 message_text_; // Text displayed in DISPLAY_MODE_MESSAGE 179 base::string16 message_text_; // Text displayed in DISPLAY_MODE_MESSAGE
177 180
178 // The current microphone image with volume level indication. 181 // The current microphone image with volume level indication.
179 scoped_ptr<SkBitmap> mic_image_; 182 scoped_ptr<SkBitmap> mic_image_;
180 // A temporary buffer image used in creating the above mic image. 183 // A temporary buffer image used in creating the above mic image.
181 scoped_ptr<SkBitmap> buffer_image_; 184 scoped_ptr<SkBitmap> buffer_image_;
185
182 // WebContents in which this this bubble gets displayed. 186 // WebContents in which this this bubble gets displayed.
183 content::WebContents* web_contents_; 187 int render_process_id_;
188 int render_view_id_;
189
184 // The current image displayed in the bubble's icon widget. 190 // The current image displayed in the bubble's icon widget.
185 gfx::ImageSkia icon_image_; 191 gfx::ImageSkia icon_image_;
186 // The scale factor used for the web-contents. 192 // The scale factor used for the web-contents.
187 float scale_; 193 float scale_;
188 194
189 DISALLOW_COPY_AND_ASSIGN(SpeechRecognitionBubbleBase); 195 DISALLOW_COPY_AND_ASSIGN(SpeechRecognitionBubbleBase);
190 }; 196 };
191 197
192 // This typedef is to workaround the issue with certain versions of 198 // This typedef is to workaround the issue with certain versions of
193 // Visual Studio where it gets confused between multiple Delegate 199 // Visual Studio where it gets confused between multiple Delegate
194 // classes and gives a C2500 error. (I saw this error on the try bots - 200 // classes and gives a C2500 error. (I saw this error on the try bots -
195 // the workaround was not needed for my machine). 201 // the workaround was not needed for my machine).
196 typedef SpeechRecognitionBubble::Delegate SpeechRecognitionBubbleDelegate; 202 typedef SpeechRecognitionBubble::Delegate SpeechRecognitionBubbleDelegate;
197 203
198 #endif // CHROME_BROWSER_SPEECH_SPEECH_RECOGNITION_BUBBLE_H_ 204 #endif // CHROME_BROWSER_SPEECH_SPEECH_RECOGNITION_BUBBLE_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/speech/speech_recognition_bubble.cc » ('j') | chrome/browser/speech/speech_recognition_bubble.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698