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

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

Issue 2345373002: arc: Fix UpdatePinnedState crash (Closed)
Patch Set: Created 4 years, 3 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 "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "components/exo/notification_surface.h" 8 #include "components/exo/notification_surface.h"
9 #include "components/exo/surface.h" 9 #include "components/exo/surface.h"
10 #include "third_party/skia/include/core/SkColor.h" 10 #include "third_party/skia/include/core/SkColor.h"
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 223
224 surface_ = surface; 224 surface_ = surface;
225 225
226 if (surface_ && surface_->window()) { 226 if (surface_ && surface_->window()) {
227 surface_->window()->AddObserver(this); 227 surface_->window()->AddObserver(this);
228 surface_->window()->AddPreTargetHandler(event_forwarder_.get()); 228 surface_->window()->AddPreTargetHandler(event_forwarder_.get());
229 229
230 if (GetWidget()) 230 if (GetWidget())
231 AttachSurface(); 231 AttachSurface();
232 232
233 UpdatePinnedState(); 233 if (item_)
yoshiki 2016/09/20 03:43:06 The patch itself lgtm, but why item is null here?
xiyuan 2016/09/20 15:58:16 There is a racing between ArcNotificationService a
234 UpdatePinnedState();
234 } 235 }
235 } 236 }
236 237
237 void ArcCustomNotificationView::UpdatePreferredSize() { 238 void ArcCustomNotificationView::UpdatePreferredSize() {
238 gfx::Size preferred_size = 239 gfx::Size preferred_size =
239 surface_ ? surface_->GetSize() : item_ ? item_->snapshot().size() 240 surface_ ? surface_->GetSize() : item_ ? item_->snapshot().size()
240 : gfx::Size(); 241 : gfx::Size();
241 if (preferred_size.IsEmpty()) 242 if (preferred_size.IsEmpty())
242 return; 243 return;
243 244
(...skipping 17 matching lines...) Expand all
261 if (target_visiblity == floating_close_button_widget_->IsVisible()) 262 if (target_visiblity == floating_close_button_widget_->IsVisible())
262 return; 263 return;
263 264
264 if (target_visiblity) 265 if (target_visiblity)
265 floating_close_button_widget_->Show(); 266 floating_close_button_widget_->Show();
266 else 267 else
267 floating_close_button_widget_->Hide(); 268 floating_close_button_widget_->Hide();
268 } 269 }
269 270
270 void ArcCustomNotificationView::UpdatePinnedState() { 271 void ArcCustomNotificationView::UpdatePinnedState() {
272 DCHECK(item_);
273
271 if (item_->pinned() && floating_close_button_widget_) { 274 if (item_->pinned() && floating_close_button_widget_) {
272 floating_close_button_widget_.reset(); 275 floating_close_button_widget_.reset();
273 } else if (!item_->pinned() && !floating_close_button_widget_) { 276 } else if (!item_->pinned() && !floating_close_button_widget_) {
274 CreateFloatingCloseButton(); 277 CreateFloatingCloseButton();
275 } 278 }
276 } 279 }
277 280
278 void ArcCustomNotificationView::UpdateSnapshot() { 281 void ArcCustomNotificationView::UpdateSnapshot() {
279 // Bail if we have a |surface_| because it controls the sizes and paints UI. 282 // Bail if we have a |surface_| because it controls the sizes and paints UI.
280 if (surface_) 283 if (surface_)
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 435
433 void ArcCustomNotificationView::OnNotificationSurfaceRemoved( 436 void ArcCustomNotificationView::OnNotificationSurfaceRemoved(
434 exo::NotificationSurface* surface) { 437 exo::NotificationSurface* surface) {
435 if (surface->notification_id() != notification_key_) 438 if (surface->notification_id() != notification_key_)
436 return; 439 return;
437 440
438 SetSurface(nullptr); 441 SetSurface(nullptr);
439 } 442 }
440 443
441 } // namespace arc 444 } // 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