| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |