| 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 "ui/arc/notification/arc_custom_notification_view.h" | 5 #include "ui/arc/notification/arc_custom_notification_view.h" |
| 6 | 6 |
| 7 #include "ash/wm/window_util.h" | 7 #include "ash/wm/window_util.h" |
| 8 #include "base/auto_reset.h" | 8 #include "base/auto_reset.h" |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "components/exo/notification_surface.h" | 10 #include "components/exo/notification_surface.h" |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 | 102 |
| 103 ArcCustomNotificationView* const owner_; | 103 ArcCustomNotificationView* const owner_; |
| 104 | 104 |
| 105 DISALLOW_COPY_AND_ASSIGN(EventForwarder); | 105 DISALLOW_COPY_AND_ASSIGN(EventForwarder); |
| 106 }; | 106 }; |
| 107 | 107 |
| 108 class ArcCustomNotificationView::SlideHelper | 108 class ArcCustomNotificationView::SlideHelper |
| 109 : public ui::LayerAnimationObserver { | 109 : public ui::LayerAnimationObserver { |
| 110 public: | 110 public: |
| 111 explicit SlideHelper(ArcCustomNotificationView* owner) : owner_(owner) { | 111 explicit SlideHelper(ArcCustomNotificationView* owner) : owner_(owner) { |
| 112 owner_->parent()->layer()->GetAnimator()->AddObserver(this); | 112 GetSlideOutLayer()->GetAnimator()->AddObserver(this); |
| 113 | 113 |
| 114 // Reset opacity to 1 to handle to case when the surface is sliding before | 114 // Reset opacity to 1 to handle to case when the surface is sliding before |
| 115 // getting managed by this class, e.g. sliding in a popup before showing | 115 // getting managed by this class, e.g. sliding in a popup before showing |
| 116 // in a message center view. | 116 // in a message center view. |
| 117 if (owner_->surface_ && owner_->surface_->window()) | 117 if (owner_->surface_ && owner_->surface_->window()) |
| 118 owner_->surface_->window()->layer()->SetOpacity(1.0f); | 118 owner_->surface_->window()->layer()->SetOpacity(1.0f); |
| 119 } | 119 } |
| 120 ~SlideHelper() override { | 120 ~SlideHelper() override { |
| 121 owner_->parent()->layer()->GetAnimator()->RemoveObserver(this); | 121 GetSlideOutLayer()->GetAnimator()->RemoveObserver(this); |
| 122 } | 122 } |
| 123 | 123 |
| 124 void Update() { | 124 void Update() { |
| 125 const bool has_animation = | 125 const bool has_animation = |
| 126 owner_->parent()->layer()->GetAnimator()->is_animating(); | 126 GetSlideOutLayer()->GetAnimator()->is_animating(); |
| 127 const bool has_transform = !owner_->parent()->GetTransform().IsIdentity(); | 127 const bool has_transform = !GetSlideOutLayer()->transform().IsIdentity(); |
| 128 const bool sliding = has_transform || has_animation; | 128 const bool sliding = has_transform || has_animation; |
| 129 if (sliding_ == sliding) | 129 if (sliding_ == sliding) |
| 130 return; | 130 return; |
| 131 | 131 |
| 132 sliding_ = sliding; | 132 sliding_ = sliding; |
| 133 | 133 |
| 134 if (sliding_) | 134 if (sliding_) |
| 135 OnSlideStart(); | 135 OnSlideStart(); |
| 136 else | 136 else |
| 137 OnSlideEnd(); | 137 OnSlideEnd(); |
| 138 } | 138 } |
| 139 | 139 |
| 140 private: | 140 private: |
| 141 // This is a temporary hack to address crbug.com/718965 |
| 142 ui::Layer* GetSlideOutLayer() { |
| 143 ui::Layer* layer = owner_->parent()->layer(); |
| 144 return layer ? layer : owner_->GetWidget()->GetLayer(); |
| 145 } |
| 146 |
| 141 void OnSlideStart() { | 147 void OnSlideStart() { |
| 142 if (!owner_->surface_ || !owner_->surface_->window()) | 148 if (!owner_->surface_ || !owner_->surface_->window()) |
| 143 return; | 149 return; |
| 144 surface_copy_ = ::wm::RecreateLayers(owner_->surface_->window()); | 150 surface_copy_ = ::wm::RecreateLayers(owner_->surface_->window()); |
| 145 // |surface_copy_| is at (0, 0) in owner_->layer(). | 151 // |surface_copy_| is at (0, 0) in owner_->layer(). |
| 146 surface_copy_->root()->SetBounds(gfx::Rect(surface_copy_->root()->size())); | 152 surface_copy_->root()->SetBounds(gfx::Rect(surface_copy_->root()->size())); |
| 147 owner_->layer()->Add(surface_copy_->root()); | 153 owner_->layer()->Add(surface_copy_->root()); |
| 148 owner_->surface_->window()->layer()->SetOpacity(0.0f); | 154 owner_->surface_->window()->layer()->SetOpacity(0.0f); |
| 149 } | 155 } |
| 150 | 156 |
| (...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 728 } | 734 } |
| 729 if (close_button_) { | 735 if (close_button_) { |
| 730 close_button_->set_background( | 736 close_button_->set_background( |
| 731 views::Background::CreateSolidBackground(current_color)); | 737 views::Background::CreateSolidBackground(current_color)); |
| 732 close_button_->SchedulePaint(); | 738 close_button_->SchedulePaint(); |
| 733 } | 739 } |
| 734 } | 740 } |
| 735 } | 741 } |
| 736 | 742 |
| 737 } // namespace arc | 743 } // namespace arc |
| OLD | NEW |