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