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

Side by Side Diff: ash/system/toast/toast_overlay.cc

Issue 2204113002: Prevent hiding a toast during animation Base URL: https://chromium.googlesource.com/chromium/src.git@2785
Patch Set: Created 4 years, 4 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
« no previous file with comments | « ash/system/toast/toast_manager_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "ash/system/toast/toast_overlay.h" 5 #include "ash/system/toast/toast_overlay.h"
6 6
7 #include "ash/common/shelf/wm_shelf.h" 7 #include "ash/common/shelf/wm_shelf.h"
8 #include "ash/common/shell_window_ids.h" 8 #include "ash/common/shell_window_ids.h"
9 #include "ash/common/wm_root_window_controller.h" 9 #include "ash/common/wm_root_window_controller.h"
10 #include "ash/common/wm_shell.h" 10 #include "ash/common/wm_shell.h"
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 ToastOverlay::~ToastOverlay() { 244 ToastOverlay::~ToastOverlay() {
245 overlay_widget_->Close(); 245 overlay_widget_->Close();
246 } 246 }
247 247
248 void ToastOverlay::Show(bool visible) { 248 void ToastOverlay::Show(bool visible) {
249 if (overlay_widget_->GetLayer()->GetTargetVisibility() == visible) 249 if (overlay_widget_->GetLayer()->GetTargetVisibility() == visible)
250 return; 250 return;
251 251
252 ui::LayerAnimator* animator = overlay_widget_->GetLayer()->GetAnimator(); 252 ui::LayerAnimator* animator = overlay_widget_->GetLayer()->GetAnimator();
253 DCHECK(animator); 253 DCHECK(animator);
254 if (animator->is_animating()) {
255 // Showing during hiding animation doesn't happen since, ToastOverlay should
256 // be one-time-use and not be reused.
257 DCHECK(!visible);
258
259 return;
260 }
254 261
255 base::TimeDelta original_duration = animator->GetTransitionDuration(); 262 base::TimeDelta original_duration = animator->GetTransitionDuration();
256 ui::ScopedLayerAnimationSettings animation_settings(animator); 263 ui::ScopedLayerAnimationSettings animation_settings(animator);
257 // ScopedLayerAnimationSettings ctor chanes the transition duration, so change 264 // ScopedLayerAnimationSettings ctor chanes the transition duration, so change
258 // back it to the original value (should be zero). 265 // back it to the original value (should be zero).
259 animation_settings.SetTransitionDuration(original_duration); 266 animation_settings.SetTransitionDuration(original_duration);
260 267
261 animation_settings.AddObserver(this); 268 animation_settings.AddObserver(this);
262 269
263 if (visible) { 270 if (visible) {
(...skipping 23 matching lines...) Expand all
287 294
288 views::Widget* ToastOverlay::widget_for_testing() { 295 views::Widget* ToastOverlay::widget_for_testing() {
289 return overlay_widget_.get(); 296 return overlay_widget_.get();
290 } 297 }
291 298
292 void ToastOverlay::ClickDismissButtonForTesting(const ui::Event& event) { 299 void ToastOverlay::ClickDismissButtonForTesting(const ui::Event& event) {
293 overlay_view_->button()->NotifyClick(event); 300 overlay_view_->button()->NotifyClick(event);
294 } 301 }
295 302
296 } // namespace ash 303 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/toast/toast_manager_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698