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

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

Issue 2150603003: Prevent hiding a toast during animation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix test failures Created 4 years, 5 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 | « no previous file | ash/system/toast/toast_manager_unittest.cc » ('j') | 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/common/system/toast/toast_overlay.h" 5 #include "ash/common/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_lookup.h" 9 #include "ash/common/wm_lookup.h"
10 #include "ash/common/wm_root_window_controller.h" 10 #include "ash/common/wm_root_window_controller.h"
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 ToastOverlay::~ToastOverlay() { 246 ToastOverlay::~ToastOverlay() {
247 overlay_widget_->Close(); 247 overlay_widget_->Close();
248 } 248 }
249 249
250 void ToastOverlay::Show(bool visible) { 250 void ToastOverlay::Show(bool visible) {
251 if (overlay_widget_->GetLayer()->GetTargetVisibility() == visible) 251 if (overlay_widget_->GetLayer()->GetTargetVisibility() == visible)
252 return; 252 return;
253 253
254 ui::LayerAnimator* animator = overlay_widget_->GetLayer()->GetAnimator(); 254 ui::LayerAnimator* animator = overlay_widget_->GetLayer()->GetAnimator();
255 DCHECK(animator); 255 DCHECK(animator);
256 if (animator->is_animating()) {
257 // Showing during hiding animation doesn't happen since, ToastOverlay should
258 // be one-time-use and not be reused.
259 DCHECK(!visible);
260
261 return;
262 }
256 263
257 base::TimeDelta original_duration = animator->GetTransitionDuration(); 264 base::TimeDelta original_duration = animator->GetTransitionDuration();
258 ui::ScopedLayerAnimationSettings animation_settings(animator); 265 ui::ScopedLayerAnimationSettings animation_settings(animator);
259 // ScopedLayerAnimationSettings ctor chanes the transition duration, so change 266 // ScopedLayerAnimationSettings ctor chanes the transition duration, so change
260 // back it to the original value (should be zero). 267 // back it to the original value (should be zero).
261 animation_settings.SetTransitionDuration(original_duration); 268 animation_settings.SetTransitionDuration(original_duration);
262 269
263 animation_settings.AddObserver(this); 270 animation_settings.AddObserver(this);
264 271
265 if (visible) { 272 if (visible) {
(...skipping 23 matching lines...) Expand all
289 296
290 views::Widget* ToastOverlay::widget_for_testing() { 297 views::Widget* ToastOverlay::widget_for_testing() {
291 return overlay_widget_.get(); 298 return overlay_widget_.get();
292 } 299 }
293 300
294 void ToastOverlay::ClickDismissButtonForTesting(const ui::Event& event) { 301 void ToastOverlay::ClickDismissButtonForTesting(const ui::Event& event) {
295 overlay_view_->button()->NotifyClick(event); 302 overlay_view_->button()->NotifyClick(event);
296 } 303 }
297 304
298 } // namespace ash 305 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/system/toast/toast_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698