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

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

Issue 14113053: chrome: Use base::MessageLoop. (Part 3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase again Created 7 years, 6 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 #include "chrome/browser/speech/speech_recognition_bubble.h" 5 #include "chrome/browser/speech/speech_recognition_bubble.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/lazy_instance.h" 8 #include "base/lazy_instance.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "content/public/browser/web_contents.h" 10 #include "content/public/browser/web_contents.h"
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 void SpeechRecognitionBubbleBase::SetWarmUpMode() { 170 void SpeechRecognitionBubbleBase::SetWarmUpMode() {
171 weak_factory_.InvalidateWeakPtrs(); 171 weak_factory_.InvalidateWeakPtrs();
172 display_mode_ = DISPLAY_MODE_WARM_UP; 172 display_mode_ = DISPLAY_MODE_WARM_UP;
173 animation_step_ = 0; 173 animation_step_ = 0;
174 DoWarmingUpAnimationStep(); 174 DoWarmingUpAnimationStep();
175 UpdateLayout(); 175 UpdateLayout();
176 } 176 }
177 177
178 void SpeechRecognitionBubbleBase::DoWarmingUpAnimationStep() { 178 void SpeechRecognitionBubbleBase::DoWarmingUpAnimationStep() {
179 SetImage(g_images.Get().warm_up()[animation_step_]); 179 SetImage(g_images.Get().warm_up()[animation_step_]);
180 MessageLoop::current()->PostDelayedTask( 180 base::MessageLoop::current()->PostDelayedTask(
181 FROM_HERE, 181 FROM_HERE,
182 base::Bind(&SpeechRecognitionBubbleBase::DoWarmingUpAnimationStep, 182 base::Bind(&SpeechRecognitionBubbleBase::DoWarmingUpAnimationStep,
183 weak_factory_.GetWeakPtr()), 183 weak_factory_.GetWeakPtr()),
184 base::TimeDelta::FromMilliseconds( 184 base::TimeDelta::FromMilliseconds(
185 animation_step_ == 0 ? kWarmingUpAnimationStartMs 185 animation_step_ == 0 ? kWarmingUpAnimationStartMs
186 : kWarmingUpAnimationStepMs)); 186 : kWarmingUpAnimationStepMs));
187 if (++animation_step_ >= static_cast<int>(g_images.Get().warm_up().size())) 187 if (++animation_step_ >= static_cast<int>(g_images.Get().warm_up().size()))
188 animation_step_ = 1; // Frame 0 is skipped during the animation. 188 animation_step_ = 1; // Frame 0 is skipped during the animation.
189 } 189 }
190 190
191 void SpeechRecognitionBubbleBase::SetRecordingMode() { 191 void SpeechRecognitionBubbleBase::SetRecordingMode() {
192 weak_factory_.InvalidateWeakPtrs(); 192 weak_factory_.InvalidateWeakPtrs();
193 display_mode_ = DISPLAY_MODE_RECORDING; 193 display_mode_ = DISPLAY_MODE_RECORDING;
194 SetInputVolume(0, 0); 194 SetInputVolume(0, 0);
195 UpdateLayout(); 195 UpdateLayout();
196 } 196 }
197 197
198 void SpeechRecognitionBubbleBase::SetRecognizingMode() { 198 void SpeechRecognitionBubbleBase::SetRecognizingMode() {
199 display_mode_ = DISPLAY_MODE_RECOGNIZING; 199 display_mode_ = DISPLAY_MODE_RECOGNIZING;
200 animation_step_ = 0; 200 animation_step_ = 0;
201 DoRecognizingAnimationStep(); 201 DoRecognizingAnimationStep();
202 UpdateLayout(); 202 UpdateLayout();
203 } 203 }
204 204
205 void SpeechRecognitionBubbleBase::DoRecognizingAnimationStep() { 205 void SpeechRecognitionBubbleBase::DoRecognizingAnimationStep() {
206 SetImage(g_images.Get().spinner()[animation_step_]); 206 SetImage(g_images.Get().spinner()[animation_step_]);
207 if (++animation_step_ >= static_cast<int>(g_images.Get().spinner().size())) 207 if (++animation_step_ >= static_cast<int>(g_images.Get().spinner().size()))
208 animation_step_ = 0; 208 animation_step_ = 0;
209 MessageLoop::current()->PostDelayedTask( 209 base::MessageLoop::current()->PostDelayedTask(
210 FROM_HERE, 210 FROM_HERE,
211 base::Bind(&SpeechRecognitionBubbleBase::DoRecognizingAnimationStep, 211 base::Bind(&SpeechRecognitionBubbleBase::DoRecognizingAnimationStep,
212 weak_factory_.GetWeakPtr()), 212 weak_factory_.GetWeakPtr()),
213 base::TimeDelta::FromMilliseconds(kRecognizingAnimationStepMs)); 213 base::TimeDelta::FromMilliseconds(kRecognizingAnimationStepMs));
214 } 214 }
215 215
216 void SpeechRecognitionBubbleBase::SetMessage(const string16& text) { 216 void SpeechRecognitionBubbleBase::SetMessage(const string16& text) {
217 weak_factory_.InvalidateWeakPtrs(); 217 weak_factory_.InvalidateWeakPtrs();
218 message_text_ = text; 218 message_text_ = text;
219 display_mode_ = DISPLAY_MODE_MESSAGE; 219 display_mode_ = DISPLAY_MODE_MESSAGE;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 } 269 }
270 270
271 void SpeechRecognitionBubbleBase::SetImage(const gfx::ImageSkia& image) { 271 void SpeechRecognitionBubbleBase::SetImage(const gfx::ImageSkia& image) {
272 icon_image_ = image; 272 icon_image_ = image;
273 UpdateImage(); 273 UpdateImage();
274 } 274 }
275 275
276 gfx::ImageSkia SpeechRecognitionBubbleBase::icon_image() { 276 gfx::ImageSkia SpeechRecognitionBubbleBase::icon_image() {
277 return icon_image_; 277 return icon_image_;
278 } 278 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698