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

Side by Side Diff: ui/arc/notification/arc_custom_notification_view.cc

Issue 2863163002: Fix ARC notification crash. (Closed)
Patch Set: Created 3 years, 7 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 | 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 "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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 103
104 ArcCustomNotificationView* const owner_; 104 ArcCustomNotificationView* const owner_;
105 105
106 DISALLOW_COPY_AND_ASSIGN(EventForwarder); 106 DISALLOW_COPY_AND_ASSIGN(EventForwarder);
107 }; 107 };
108 108
109 class ArcCustomNotificationView::SlideHelper 109 class ArcCustomNotificationView::SlideHelper
110 : public ui::LayerAnimationObserver { 110 : public ui::LayerAnimationObserver {
111 public: 111 public:
112 explicit SlideHelper(ArcCustomNotificationView* owner) : owner_(owner) { 112 explicit SlideHelper(ArcCustomNotificationView* owner) : owner_(owner) {
113 owner_->parent()->layer()->GetAnimator()->AddObserver(this); 113 GetSlideOutLayer()->GetAnimator()->AddObserver(this);
114 114
115 // Reset opacity to 1 to handle to case when the surface is sliding before 115 // Reset opacity to 1 to handle to case when the surface is sliding before
116 // getting managed by this class, e.g. sliding in a popup before showing 116 // getting managed by this class, e.g. sliding in a popup before showing
117 // in a message center view. 117 // in a message center view.
118 if (owner_->surface_ && owner_->surface_->window()) 118 if (owner_->surface_ && owner_->surface_->window())
119 owner_->surface_->window()->layer()->SetOpacity(1.0f); 119 owner_->surface_->window()->layer()->SetOpacity(1.0f);
120 } 120 }
121 ~SlideHelper() override { 121 ~SlideHelper() override {
122 owner_->parent()->layer()->GetAnimator()->RemoveObserver(this); 122 GetSlideOutLayer()->GetAnimator()->RemoveObserver(this);
123 } 123 }
124 124
125 void Update() { 125 void Update() {
126 const bool has_animation = 126 const bool has_animation =
127 owner_->parent()->layer()->GetAnimator()->is_animating(); 127 GetSlideOutLayer()->GetAnimator()->is_animating();
128 const bool has_transform = !owner_->parent()->GetTransform().IsIdentity(); 128 const bool has_transform = !GetSlideOutLayer()->transform().IsIdentity();
129 const bool sliding = has_transform || has_animation; 129 const bool sliding = has_transform || has_animation;
130 if (sliding_ == sliding) 130 if (sliding_ == sliding)
131 return; 131 return;
132 132
133 sliding_ = sliding; 133 sliding_ = sliding;
134 134
135 if (sliding_) 135 if (sliding_)
136 OnSlideStart(); 136 OnSlideStart();
137 else 137 else
138 OnSlideEnd(); 138 OnSlideEnd();
139 } 139 }
140 140
141 private: 141 private:
142 // This is a temporary hack to address crbug.com/718965
143 ui::Layer* GetSlideOutLayer() {
144 ui::Layer* layer = owner_->parent()->layer();
145 return layer ? layer : owner_->GetWidget()->GetLayer();
146 }
147
142 void OnSlideStart() { 148 void OnSlideStart() {
143 if (!owner_->surface_ || !owner_->surface_->window()) 149 if (!owner_->surface_ || !owner_->surface_->window())
144 return; 150 return;
145 surface_copy_ = ::wm::RecreateLayers(owner_->surface_->window()); 151 surface_copy_ = ::wm::RecreateLayers(owner_->surface_->window());
146 // |surface_copy_| is at (0, 0) in owner_->layer(). 152 // |surface_copy_| is at (0, 0) in owner_->layer().
147 surface_copy_->root()->SetBounds(gfx::Rect(surface_copy_->root()->size())); 153 surface_copy_->root()->SetBounds(gfx::Rect(surface_copy_->root()->size()));
148 owner_->layer()->Add(surface_copy_->root()); 154 owner_->layer()->Add(surface_copy_->root());
149 owner_->surface_->window()->layer()->SetOpacity(0.0f); 155 owner_->surface_->window()->layer()->SetOpacity(0.0f);
150 } 156 }
151 157
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after
720 } 726 }
721 if (close_button_) { 727 if (close_button_) {
722 close_button_->set_background( 728 close_button_->set_background(
723 views::Background::CreateSolidBackground(current_color)); 729 views::Background::CreateSolidBackground(current_color));
724 close_button_->SchedulePaint(); 730 close_button_->SchedulePaint();
725 } 731 }
726 } 732 }
727 } 733 }
728 734
729 } // namespace arc 735 } // namespace arc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698