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

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

Issue 2941703002: Detach notification surface (Closed)
Patch Set: Created 3 years, 6 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_notification_content_view.h" 5 #include "ui/arc/notification/arc_notification_content_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 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 353
354 // Reset |floating_control_buttons_widget_| when |surface_| is changed. 354 // Reset |floating_control_buttons_widget_| when |surface_| is changed.
355 floating_control_buttons_widget_.reset(); 355 floating_control_buttons_widget_.reset();
356 control_buttons_view_ = nullptr; 356 control_buttons_view_ = nullptr;
357 settings_button_ = nullptr; 357 settings_button_ = nullptr;
358 close_button_.reset(); 358 close_button_.reset();
359 359
360 if (surface_ && surface_->window()) { 360 if (surface_ && surface_->window()) {
361 surface_->window()->RemoveObserver(this); 361 surface_->window()->RemoveObserver(this);
362 surface_->window()->RemovePreTargetHandler(event_forwarder_.get()); 362 surface_->window()->RemovePreTargetHandler(event_forwarder_.get());
363
364 if (GetWidget())
365 Detach();
363 } 366 }
364 367
365 surface_ = surface; 368 surface_ = surface;
366 369
367 if (surface_ && surface_->window()) { 370 if (surface_ && surface_->window()) {
368 surface_->window()->AddObserver(this); 371 surface_->window()->AddObserver(this);
369 surface_->window()->AddPreTargetHandler(event_forwarder_.get()); 372 surface_->window()->AddPreTargetHandler(event_forwarder_.get());
370 373
371 if (GetWidget()) 374 if (GetWidget())
372 AttachSurface(); 375 AttachSurface();
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 void ArcNotificationContentView::UpdateSnapshot() { 433 void ArcNotificationContentView::UpdateSnapshot() {
431 // Bail if we have a |surface_| because it controls the sizes and paints UI. 434 // Bail if we have a |surface_| because it controls the sizes and paints UI.
432 if (surface_) 435 if (surface_)
433 return; 436 return;
434 437
435 UpdatePreferredSize(); 438 UpdatePreferredSize();
436 SchedulePaint(); 439 SchedulePaint();
437 } 440 }
438 441
439 void ArcNotificationContentView::AttachSurface() { 442 void ArcNotificationContentView::AttachSurface() {
443 DCHECK(!native_view());
444
440 if (!GetWidget()) 445 if (!GetWidget())
441 return; 446 return;
442 447
443 UpdatePreferredSize(); 448 UpdatePreferredSize();
444 Attach(surface_->window()); 449 Attach(surface_->window());
445 450
446 // The texture for this window can be placed at subpixel position 451 // The texture for this window can be placed at subpixel position
447 // with fractional scale factor. Force to align it at the pixel 452 // with fractional scale factor. Force to align it at the pixel
448 // boundary here, and when layout is updated in Layout(). 453 // boundary here, and when layout is updated in Layout().
449 ash::wm::SnapWindowToPixelBoundary(surface_->window()); 454 ash::wm::SnapWindowToPixelBoundary(surface_->window());
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 native_view()) != widget)) { 510 native_view()) != widget)) {
506 return; 511 return;
507 } 512 }
508 } 513 }
509 514
510 views::NativeViewHost::ViewHierarchyChanged(details); 515 views::NativeViewHost::ViewHierarchyChanged(details);
511 516
512 if (!widget || !surface_ || !details.is_add) 517 if (!widget || !surface_ || !details.is_add)
513 return; 518 return;
514 519
520 if (native_view())
521 Detach();
515 AttachSurface(); 522 AttachSurface();
516 } 523 }
517 524
518 void ArcNotificationContentView::Layout() { 525 void ArcNotificationContentView::Layout() {
519 base::AutoReset<bool> auto_reset_in_layout(&in_layout_, true); 526 base::AutoReset<bool> auto_reset_in_layout(&in_layout_, true);
520 527
521 views::NativeViewHost::Layout(); 528 views::NativeViewHost::Layout();
522 529
523 if (!surface_ || !GetWidget()) 530 if (!surface_ || !GetWidget())
524 return; 531 return;
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
720 settings_button_->SchedulePaint(); 727 settings_button_->SchedulePaint();
721 } 728 }
722 if (close_button_) { 729 if (close_button_) {
723 close_button_->SetBackground(views::CreateSolidBackground(current_color)); 730 close_button_->SetBackground(views::CreateSolidBackground(current_color));
724 close_button_->SchedulePaint(); 731 close_button_->SchedulePaint();
725 } 732 }
726 } 733 }
727 } 734 }
728 735
729 } // namespace arc 736 } // 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