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

Unified Diff: ui/arc/notification/arc_notification_content_view.cc

Issue 2918763002: Fix crash on updating notification before attaching (Closed)
Patch Set: addressed comment 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/arc/notification/arc_notification_content_view.cc
diff --git a/ui/arc/notification/arc_notification_content_view.cc b/ui/arc/notification/arc_notification_content_view.cc
index 312dcb97f903e63d66ce622d45743429f8169721..3f99033c95edca5245a674300edab2df34067175 100644
--- a/ui/arc/notification/arc_notification_content_view.cc
+++ b/ui/arc/notification/arc_notification_content_view.cc
@@ -360,8 +360,6 @@ void ArcNotificationContentView::SetSurface(exo::NotificationSurface* surface) {
surface_->window()->AddObserver(this);
surface_->window()->AddPreTargetHandler(event_forwarder_.get());
- MaybeCreateFloatingControlButtons();
-
if (GetWidget())
AttachSurface();
}
@@ -388,22 +386,9 @@ void ArcNotificationContentView::UpdatePreferredSize() {
}
void ArcNotificationContentView::UpdateControlButtonsVisibility() {
- if (!surface_)
+ if (!floating_control_buttons_widget_)
return;
- // TODO(edcourtney, yhanada): Creating the floating control widget here is not
- // correct. This function may be called during the destruction of
- // |floating_control_buttons_widget_|. This can lead to memory corruption.
- // Rather than creating it here, we should fix the behaviour of OnMouseExited
- // and OnMouseEntered for ARC notifications in MessageCenterView. See
- // crbug.com/714587 and crbug.com/709862.
- if (!floating_control_buttons_widget_) {
- // This may update |floating_control_buttons_widget_|.
- MaybeCreateFloatingControlButtons();
- if (!floating_control_buttons_widget_)
- return;
- }
-
const bool target_visiblity =
IsMouseHovered() || (close_button_ && close_button_->HasFocus()) ||
(settings_button_ && settings_button_->HasFocus());
@@ -420,6 +405,10 @@ void ArcNotificationContentView::UpdatePinnedState() {
if (!item_)
return;
+ // Surface is not attached yet.
+ if (!control_buttons_view_)
+ return;
+
if (item_->GetPinned() && close_button_) {
control_buttons_view_->RemoveChildView(close_button_.get());
close_button_.reset();
@@ -457,10 +446,8 @@ void ArcNotificationContentView::AttachSurface() {
// Invokes Update() in case surface is attached during a slide.
slide_helper_->Update();
- // Updates pinned state to create or destroy the floating close button
- // after |surface_| is attached to a widget.
- if (item_)
- UpdatePinnedState();
+ // (Re-)create the floating buttons after |surface_| is attached to a widget.
+ MaybeCreateFloatingControlButtons();
}
void ArcNotificationContentView::StartControlButtonsColorAnimation() {
« 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