| 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_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" |
| 11 #include "components/exo/surface.h" | 11 #include "components/exo/surface.h" |
| 12 #include "ui/accessibility/ax_action_data.h" | 12 #include "ui/accessibility/ax_action_data.h" |
| 13 #include "ui/accessibility/ax_node_data.h" | 13 #include "ui/accessibility/ax_node_data.h" |
| 14 #include "ui/arc/notification/arc_notification_surface.h" |
| 14 #include "ui/arc/notification/arc_notification_view.h" | 15 #include "ui/arc/notification/arc_notification_view.h" |
| 15 #include "ui/base/l10n/l10n_util.h" | 16 #include "ui/base/l10n/l10n_util.h" |
| 16 #include "ui/base/resource/resource_bundle.h" | 17 #include "ui/base/resource/resource_bundle.h" |
| 17 #include "ui/compositor/layer_animation_observer.h" | 18 #include "ui/compositor/layer_animation_observer.h" |
| 18 #include "ui/events/event_handler.h" | 19 #include "ui/events/event_handler.h" |
| 19 #include "ui/gfx/animation/linear_animation.h" | 20 #include "ui/gfx/animation/linear_animation.h" |
| 20 #include "ui/gfx/animation/tween.h" | 21 #include "ui/gfx/animation/tween.h" |
| 21 #include "ui/gfx/canvas.h" | 22 #include "ui/gfx/canvas.h" |
| 22 #include "ui/gfx/geometry/insets.h" | 23 #include "ui/gfx/geometry/insets.h" |
| 23 #include "ui/gfx/transform.h" | 24 #include "ui/gfx/transform.h" |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 | 112 |
| 112 class ArcNotificationContentView::SlideHelper | 113 class ArcNotificationContentView::SlideHelper |
| 113 : public ui::LayerAnimationObserver { | 114 : public ui::LayerAnimationObserver { |
| 114 public: | 115 public: |
| 115 explicit SlideHelper(ArcNotificationContentView* owner) : owner_(owner) { | 116 explicit SlideHelper(ArcNotificationContentView* owner) : owner_(owner) { |
| 116 GetSlideOutLayer()->GetAnimator()->AddObserver(this); | 117 GetSlideOutLayer()->GetAnimator()->AddObserver(this); |
| 117 | 118 |
| 118 // Reset opacity to 1 to handle to case when the surface is sliding before | 119 // Reset opacity to 1 to handle to case when the surface is sliding before |
| 119 // getting managed by this class, e.g. sliding in a popup before showing | 120 // getting managed by this class, e.g. sliding in a popup before showing |
| 120 // in a message center view. | 121 // in a message center view. |
| 121 if (owner_->surface_ && owner_->surface_->window()) | 122 if (owner_->surface_ && owner_->surface_->GetWindow()) |
| 122 owner_->surface_->window()->layer()->SetOpacity(1.0f); | 123 owner_->surface_->GetWindow()->layer()->SetOpacity(1.0f); |
| 123 } | 124 } |
| 124 ~SlideHelper() override { | 125 ~SlideHelper() override { |
| 125 if (GetSlideOutLayer()) | 126 if (GetSlideOutLayer()) |
| 126 GetSlideOutLayer()->GetAnimator()->RemoveObserver(this); | 127 GetSlideOutLayer()->GetAnimator()->RemoveObserver(this); |
| 127 } | 128 } |
| 128 | 129 |
| 129 void Update() { | 130 void Update() { |
| 130 const bool has_animation = | 131 const bool has_animation = |
| 131 GetSlideOutLayer()->GetAnimator()->is_animating(); | 132 GetSlideOutLayer()->GetAnimator()->is_animating(); |
| 132 const bool has_transform = !GetSlideOutLayer()->transform().IsIdentity(); | 133 const bool has_transform = !GetSlideOutLayer()->transform().IsIdentity(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 143 } | 144 } |
| 144 | 145 |
| 145 private: | 146 private: |
| 146 // This is a temporary hack to address crbug.com/718965 | 147 // This is a temporary hack to address crbug.com/718965 |
| 147 ui::Layer* GetSlideOutLayer() { | 148 ui::Layer* GetSlideOutLayer() { |
| 148 ui::Layer* layer = owner_->parent()->layer(); | 149 ui::Layer* layer = owner_->parent()->layer(); |
| 149 return layer ? layer : owner_->GetWidget()->GetLayer(); | 150 return layer ? layer : owner_->GetWidget()->GetLayer(); |
| 150 } | 151 } |
| 151 | 152 |
| 152 void OnSlideStart() { | 153 void OnSlideStart() { |
| 153 if (!owner_->surface_ || !owner_->surface_->window()) | 154 if (!owner_->surface_ || !owner_->surface_->GetWindow()) |
| 154 return; | 155 return; |
| 155 surface_copy_ = ::wm::RecreateLayers(owner_->surface_->window()); | 156 surface_copy_ = ::wm::RecreateLayers(owner_->surface_->GetWindow()); |
| 156 // |surface_copy_| is at (0, 0) in owner_->layer(). | 157 // |surface_copy_| is at (0, 0) in owner_->layer(). |
| 157 surface_copy_->root()->SetBounds(gfx::Rect(surface_copy_->root()->size())); | 158 surface_copy_->root()->SetBounds(gfx::Rect(surface_copy_->root()->size())); |
| 158 owner_->layer()->Add(surface_copy_->root()); | 159 owner_->layer()->Add(surface_copy_->root()); |
| 159 owner_->surface_->window()->layer()->SetOpacity(0.0f); | 160 owner_->surface_->GetWindow()->layer()->SetOpacity(0.0f); |
| 160 } | 161 } |
| 161 | 162 |
| 162 void OnSlideEnd() { | 163 void OnSlideEnd() { |
| 163 if (!owner_->surface_ || !owner_->surface_->window()) | 164 if (!owner_->surface_ || !owner_->surface_->GetWindow()) |
| 164 return; | 165 return; |
| 165 owner_->surface_->window()->layer()->SetOpacity(1.0f); | 166 owner_->surface_->GetWindow()->layer()->SetOpacity(1.0f); |
| 166 owner_->Layout(); | 167 owner_->Layout(); |
| 167 surface_copy_.reset(); | 168 surface_copy_.reset(); |
| 168 } | 169 } |
| 169 | 170 |
| 170 // ui::LayerAnimationObserver | 171 // ui::LayerAnimationObserver |
| 171 void OnLayerAnimationEnded(ui::LayerAnimationSequence* seq) override { | 172 void OnLayerAnimationEnded(ui::LayerAnimationSequence* seq) override { |
| 172 Update(); | 173 Update(); |
| 173 } | 174 } |
| 174 void OnLayerAnimationAborted(ui::LayerAnimationSequence* seq) override { | 175 void OnLayerAnimationAborted(ui::LayerAnimationSequence* seq) override { |
| 175 Update(); | 176 Update(); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 void ArcNotificationContentView::ControlButton::OnFocus() { | 232 void ArcNotificationContentView::ControlButton::OnFocus() { |
| 232 message_center::PaddedButton::OnFocus(); | 233 message_center::PaddedButton::OnFocus(); |
| 233 owner_->UpdateControlButtonsVisibility(); | 234 owner_->UpdateControlButtonsVisibility(); |
| 234 } | 235 } |
| 235 | 236 |
| 236 void ArcNotificationContentView::ControlButton::OnBlur() { | 237 void ArcNotificationContentView::ControlButton::OnBlur() { |
| 237 message_center::PaddedButton::OnBlur(); | 238 message_center::PaddedButton::OnBlur(); |
| 238 owner_->UpdateControlButtonsVisibility(); | 239 owner_->UpdateControlButtonsVisibility(); |
| 239 } | 240 } |
| 240 | 241 |
| 242 // static, for ArcNotificationContentView::GetClassName(). |
| 243 const char ArcNotificationContentView::kViewClassName[] = |
| 244 "ArcNotificationContentView"; |
| 245 |
| 241 ArcNotificationContentView::ArcNotificationContentView( | 246 ArcNotificationContentView::ArcNotificationContentView( |
| 242 ArcNotificationItem* item) | 247 ArcNotificationItem* item) |
| 243 : item_(item), | 248 : item_(item), |
| 244 notification_key_(item->GetNotificationKey()), | 249 notification_key_(item->GetNotificationKey()), |
| 245 event_forwarder_(new EventForwarder(this)) { | 250 event_forwarder_(new EventForwarder(this)) { |
| 246 SetFocusBehavior(FocusBehavior::ALWAYS); | 251 SetFocusBehavior(FocusBehavior::ALWAYS); |
| 247 set_notify_enter_exit_on_child(true); | 252 set_notify_enter_exit_on_child(true); |
| 248 | 253 |
| 249 item_->IncrementWindowRefCount(); | 254 item_->IncrementWindowRefCount(); |
| 250 item_->AddObserver(this); | 255 item_->AddObserver(this); |
| 251 | 256 |
| 252 auto* surface_manager = ArcNotificationSurfaceManager::Get(); | 257 auto* surface_manager = ArcNotificationSurfaceManager::Get(); |
| 253 if (surface_manager) { | 258 if (surface_manager) { |
| 254 surface_manager->AddObserver(this); | 259 surface_manager->AddObserver(this); |
| 255 exo::NotificationSurface* surface = | 260 ArcNotificationSurface* surface = |
| 256 surface_manager->GetSurface(notification_key_); | 261 surface_manager->GetArcSurface(notification_key_); |
| 257 if (surface) | 262 if (surface) |
| 258 OnNotificationSurfaceAdded(surface); | 263 OnNotificationSurfaceAdded(surface); |
| 259 } | 264 } |
| 260 | 265 |
| 261 // Create a layer as an anchor to insert surface copy during a slide. | 266 // Create a layer as an anchor to insert surface copy during a slide. |
| 262 SetPaintToLayer(); | 267 SetPaintToLayer(); |
| 263 UpdatePreferredSize(); | 268 UpdatePreferredSize(); |
| 264 UpdateAccessibleName(); | 269 UpdateAccessibleName(); |
| 265 } | 270 } |
| 266 | 271 |
| 267 ArcNotificationContentView::~ArcNotificationContentView() { | 272 ArcNotificationContentView::~ArcNotificationContentView() { |
| 268 SetSurface(nullptr); | 273 SetSurface(nullptr); |
| 269 | 274 |
| 270 auto* surface_manager = ArcNotificationSurfaceManager::Get(); | 275 auto* surface_manager = ArcNotificationSurfaceManager::Get(); |
| 271 if (surface_manager) | 276 if (surface_manager) |
| 272 surface_manager->RemoveObserver(this); | 277 surface_manager->RemoveObserver(this); |
| 273 if (item_) { | 278 if (item_) { |
| 274 item_->RemoveObserver(this); | 279 item_->RemoveObserver(this); |
| 275 item_->DecrementWindowRefCount(); | 280 item_->DecrementWindowRefCount(); |
| 276 } | 281 } |
| 277 } | 282 } |
| 278 | 283 |
| 284 const char* ArcNotificationContentView::GetClassName() const { |
| 285 return kViewClassName; |
| 286 } |
| 287 |
| 279 std::unique_ptr<ArcNotificationContentViewDelegate> | 288 std::unique_ptr<ArcNotificationContentViewDelegate> |
| 280 ArcNotificationContentView::CreateContentViewDelegate() { | 289 ArcNotificationContentView::CreateContentViewDelegate() { |
| 281 return base::MakeUnique<ArcNotificationContentView::ContentViewDelegate>( | 290 return base::MakeUnique<ArcNotificationContentView::ContentViewDelegate>( |
| 282 this); | 291 this); |
| 283 } | 292 } |
| 284 | 293 |
| 285 void ArcNotificationContentView::CreateCloseButton() { | 294 void ArcNotificationContentView::CreateCloseButton() { |
| 286 DCHECK(control_buttons_view_); | 295 DCHECK(control_buttons_view_); |
| 287 DCHECK(item_); | 296 DCHECK(item_); |
| 288 | 297 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 new views::BoxLayout(views::BoxLayout::kHorizontal)); | 335 new views::BoxLayout(views::BoxLayout::kHorizontal)); |
| 327 | 336 |
| 328 if (item_->IsOpeningSettingsSupported()) | 337 if (item_->IsOpeningSettingsSupported()) |
| 329 CreateSettingsButton(); | 338 CreateSettingsButton(); |
| 330 if (!item_->GetPinned()) | 339 if (!item_->GetPinned()) |
| 331 CreateCloseButton(); | 340 CreateCloseButton(); |
| 332 | 341 |
| 333 views::Widget::InitParams params(views::Widget::InitParams::TYPE_CONTROL); | 342 views::Widget::InitParams params(views::Widget::InitParams::TYPE_CONTROL); |
| 334 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; | 343 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; |
| 335 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 344 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| 336 params.parent = surface_->window(); | 345 params.parent = surface_->GetWindow(); |
| 337 | 346 |
| 338 floating_control_buttons_widget_.reset(new views::Widget); | 347 floating_control_buttons_widget_.reset(new views::Widget); |
| 339 floating_control_buttons_widget_->Init(params); | 348 floating_control_buttons_widget_->Init(params); |
| 340 floating_control_buttons_widget_->SetContentsView(control_buttons_view_); | 349 floating_control_buttons_widget_->SetContentsView(control_buttons_view_); |
| 341 | 350 |
| 342 // Put the close button into the focus chain. | 351 // Put the close button into the focus chain. |
| 343 floating_control_buttons_widget_->SetFocusTraversableParent( | 352 floating_control_buttons_widget_->SetFocusTraversableParent( |
| 344 GetWidget()->GetFocusTraversable()); | 353 GetWidget()->GetFocusTraversable()); |
| 345 floating_control_buttons_widget_->SetFocusTraversableParentView(this); | 354 floating_control_buttons_widget_->SetFocusTraversableParentView(this); |
| 346 | 355 |
| 347 Layout(); | 356 Layout(); |
| 348 } | 357 } |
| 349 | 358 |
| 350 void ArcNotificationContentView::SetSurface(exo::NotificationSurface* surface) { | 359 void ArcNotificationContentView::SetSurface(ArcNotificationSurface* surface) { |
| 351 if (surface_ == surface) | 360 if (surface_ == surface) |
| 352 return; | 361 return; |
| 353 | 362 |
| 354 // Reset |floating_control_buttons_widget_| when |surface_| is changed. | 363 // Reset |floating_control_buttons_widget_| when |surface_| is changed. |
| 355 floating_control_buttons_widget_.reset(); | 364 floating_control_buttons_widget_.reset(); |
| 356 control_buttons_view_ = nullptr; | 365 control_buttons_view_ = nullptr; |
| 357 settings_button_ = nullptr; | 366 settings_button_ = nullptr; |
| 358 close_button_.reset(); | 367 close_button_.reset(); |
| 359 | 368 |
| 360 if (surface_ && surface_->window()) { | 369 if (surface_ && surface_->GetWindow()) { |
| 361 surface_->window()->RemoveObserver(this); | 370 surface_->GetWindow()->RemoveObserver(this); |
| 362 surface_->window()->RemovePreTargetHandler(event_forwarder_.get()); | 371 surface_->GetWindow()->RemovePreTargetHandler(event_forwarder_.get()); |
| 363 | 372 |
| 364 if (GetWidget()) | 373 if (GetWidget() && surface_->IsAttached()) |
| 365 Detach(); | 374 surface_->Detach(); |
| 366 } | 375 } |
| 367 | 376 |
| 368 surface_ = surface; | 377 surface_ = surface; |
| 369 | 378 |
| 370 if (surface_ && surface_->window()) { | 379 if (surface_ && surface_->GetWindow()) { |
| 371 surface_->window()->AddObserver(this); | 380 surface_->GetWindow()->AddObserver(this); |
| 372 surface_->window()->AddPreTargetHandler(event_forwarder_.get()); | 381 surface_->GetWindow()->AddPreTargetHandler(event_forwarder_.get()); |
| 373 | 382 |
| 374 if (GetWidget()) | 383 if (GetWidget()) |
| 375 AttachSurface(); | 384 AttachSurface(); |
| 376 } | 385 } |
| 377 } | 386 } |
| 378 | 387 |
| 379 void ArcNotificationContentView::UpdatePreferredSize() { | 388 void ArcNotificationContentView::UpdatePreferredSize() { |
| 380 gfx::Size preferred_size; | 389 gfx::Size preferred_size; |
| 381 if (surface_) | 390 if (surface_) |
| 382 preferred_size = surface_->GetSize(); | 391 preferred_size = surface_->GetSize(); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 SchedulePaint(); | 448 SchedulePaint(); |
| 440 } | 449 } |
| 441 | 450 |
| 442 void ArcNotificationContentView::AttachSurface() { | 451 void ArcNotificationContentView::AttachSurface() { |
| 443 DCHECK(!native_view()); | 452 DCHECK(!native_view()); |
| 444 | 453 |
| 445 if (!GetWidget()) | 454 if (!GetWidget()) |
| 446 return; | 455 return; |
| 447 | 456 |
| 448 UpdatePreferredSize(); | 457 UpdatePreferredSize(); |
| 449 Attach(surface_->window()); | 458 surface_->Attach(this); |
| 450 | 459 |
| 451 // The texture for this window can be placed at subpixel position | 460 // The texture for this window can be placed at subpixel position |
| 452 // with fractional scale factor. Force to align it at the pixel | 461 // with fractional scale factor. Force to align it at the pixel |
| 453 // boundary here, and when layout is updated in Layout(). | 462 // boundary here, and when layout is updated in Layout(). |
| 454 ash::wm::SnapWindowToPixelBoundary(surface_->window()); | 463 ash::wm::SnapWindowToPixelBoundary(surface_->GetWindow()); |
| 455 | 464 |
| 456 // Creates slide helper after this view is added to its parent. | 465 // Creates slide helper after this view is added to its parent. |
| 457 slide_helper_.reset(new SlideHelper(this)); | 466 slide_helper_.reset(new SlideHelper(this)); |
| 458 | 467 |
| 459 // Invokes Update() in case surface is attached during a slide. | 468 // Invokes Update() in case surface is attached during a slide. |
| 460 slide_helper_->Update(); | 469 slide_helper_->Update(); |
| 461 | 470 |
| 462 // (Re-)create the floating buttons after |surface_| is attached to a widget. | 471 // (Re-)create the floating buttons after |surface_| is attached to a widget. |
| 463 MaybeCreateFloatingControlButtons(); | 472 MaybeCreateFloatingControlButtons(); |
| 464 } | 473 } |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 510 native_view()) != widget)) { | 519 native_view()) != widget)) { |
| 511 return; | 520 return; |
| 512 } | 521 } |
| 513 } | 522 } |
| 514 | 523 |
| 515 views::NativeViewHost::ViewHierarchyChanged(details); | 524 views::NativeViewHost::ViewHierarchyChanged(details); |
| 516 | 525 |
| 517 if (!widget || !surface_ || !details.is_add) | 526 if (!widget || !surface_ || !details.is_add) |
| 518 return; | 527 return; |
| 519 | 528 |
| 520 if (native_view()) | 529 if (surface_->IsAttached()) |
| 521 Detach(); | 530 surface_->Detach(); |
| 522 AttachSurface(); | 531 AttachSurface(); |
| 523 } | 532 } |
| 524 | 533 |
| 525 void ArcNotificationContentView::Layout() { | 534 void ArcNotificationContentView::Layout() { |
| 526 base::AutoReset<bool> auto_reset_in_layout(&in_layout_, true); | 535 base::AutoReset<bool> auto_reset_in_layout(&in_layout_, true); |
| 527 | 536 |
| 528 views::NativeViewHost::Layout(); | 537 views::NativeViewHost::Layout(); |
| 529 | 538 |
| 530 if (!surface_ || !GetWidget()) | 539 if (!surface_ || !GetWidget()) |
| 531 return; | 540 return; |
| 532 | 541 |
| 533 const gfx::Rect contents_bounds = GetContentsBounds(); | 542 const gfx::Rect contents_bounds = GetContentsBounds(); |
| 534 | 543 |
| 535 // Scale notification surface if necessary. | 544 // Scale notification surface if necessary. |
| 536 gfx::Transform transform; | 545 gfx::Transform transform; |
| 537 const gfx::Size surface_size = surface_->GetSize(); | 546 const gfx::Size surface_size = surface_->GetSize(); |
| 538 const gfx::Size contents_size = contents_bounds.size(); | 547 const gfx::Size contents_size = contents_bounds.size(); |
| 539 if (!surface_size.IsEmpty() && !contents_size.IsEmpty()) { | 548 if (!surface_size.IsEmpty() && !contents_size.IsEmpty()) { |
| 540 transform.Scale( | 549 transform.Scale( |
| 541 static_cast<float>(contents_size.width()) / surface_size.width(), | 550 static_cast<float>(contents_size.width()) / surface_size.width(), |
| 542 static_cast<float>(contents_size.height()) / surface_size.height()); | 551 static_cast<float>(contents_size.height()) / surface_size.height()); |
| 543 } | 552 } |
| 544 | 553 |
| 545 // Apply the transform to the surface content so that close button can | 554 // Apply the transform to the surface content so that close button can |
| 546 // be positioned without the need to consider the transform. | 555 // be positioned without the need to consider the transform. |
| 547 surface_->window()->children()[0]->SetTransform(transform); | 556 surface_->GetContentWindow()->SetTransform(transform); |
| 548 | 557 |
| 549 if (!floating_control_buttons_widget_) | 558 if (!floating_control_buttons_widget_) |
| 550 return; | 559 return; |
| 551 | 560 |
| 552 gfx::Rect control_buttons_bounds(contents_bounds); | 561 gfx::Rect control_buttons_bounds(contents_bounds); |
| 553 int buttons_width = 0; | 562 int buttons_width = 0; |
| 554 int buttons_height = 0; | 563 int buttons_height = 0; |
| 555 if (close_button_) { | 564 if (close_button_) { |
| 556 buttons_width += close_button_->GetPreferredSize().width(); | 565 buttons_width += close_button_->GetPreferredSize().width(); |
| 557 buttons_height = close_button_->GetPreferredSize().height(); | 566 buttons_height = close_button_->GetPreferredSize().height(); |
| 558 } | 567 } |
| 559 if (settings_button_) { | 568 if (settings_button_) { |
| 560 buttons_width += settings_button_->GetPreferredSize().width(); | 569 buttons_width += settings_button_->GetPreferredSize().width(); |
| 561 buttons_height = settings_button_->GetPreferredSize().height(); | 570 buttons_height = settings_button_->GetPreferredSize().height(); |
| 562 } | 571 } |
| 563 control_buttons_bounds.set_x(control_buttons_bounds.right() - buttons_width - | 572 control_buttons_bounds.set_x(control_buttons_bounds.right() - buttons_width - |
| 564 message_center::kControlButtonPadding); | 573 message_center::kControlButtonPadding); |
| 565 control_buttons_bounds.set_y(control_buttons_bounds.y() + | 574 control_buttons_bounds.set_y(control_buttons_bounds.y() + |
| 566 message_center::kControlButtonPadding); | 575 message_center::kControlButtonPadding); |
| 567 control_buttons_bounds.set_width(buttons_width); | 576 control_buttons_bounds.set_width(buttons_width); |
| 568 control_buttons_bounds.set_height(buttons_height); | 577 control_buttons_bounds.set_height(buttons_height); |
| 569 floating_control_buttons_widget_->SetBounds(control_buttons_bounds); | 578 floating_control_buttons_widget_->SetBounds(control_buttons_bounds); |
| 570 | 579 |
| 571 UpdateControlButtonsVisibility(); | 580 UpdateControlButtonsVisibility(); |
| 572 | 581 |
| 573 ash::wm::SnapWindowToPixelBoundary(surface_->window()); | 582 ash::wm::SnapWindowToPixelBoundary(surface_->GetWindow()); |
| 574 } | 583 } |
| 575 | 584 |
| 576 void ArcNotificationContentView::OnPaint(gfx::Canvas* canvas) { | 585 void ArcNotificationContentView::OnPaint(gfx::Canvas* canvas) { |
| 577 views::NativeViewHost::OnPaint(canvas); | 586 views::NativeViewHost::OnPaint(canvas); |
| 578 | 587 |
| 579 // Bail if there is a |surface_| or no item or no snapshot image. | 588 // Bail if there is a |surface_| or no item or no snapshot image. |
| 580 if (surface_ || !item_ || item_->GetSnapshot().isNull()) | 589 if (surface_ || !item_ || item_->GetSnapshot().isNull()) |
| 581 return; | 590 return; |
| 582 const gfx::Rect contents_bounds = GetContentsBounds(); | 591 const gfx::Rect contents_bounds = GetContentsBounds(); |
| 583 canvas->DrawImageInt(item_->GetSnapshot(), 0, 0, item_->GetSnapshot().width(), | 592 canvas->DrawImageInt(item_->GetSnapshot(), 0, 0, item_->GetSnapshot().width(), |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 680 | 689 |
| 681 void ArcNotificationContentView::OnItemUpdated() { | 690 void ArcNotificationContentView::OnItemUpdated() { |
| 682 UpdateAccessibleName(); | 691 UpdateAccessibleName(); |
| 683 UpdatePinnedState(); | 692 UpdatePinnedState(); |
| 684 UpdateSnapshot(); | 693 UpdateSnapshot(); |
| 685 if (ShouldUpdateControlButtonsColor()) | 694 if (ShouldUpdateControlButtonsColor()) |
| 686 StartControlButtonsColorAnimation(); | 695 StartControlButtonsColorAnimation(); |
| 687 } | 696 } |
| 688 | 697 |
| 689 void ArcNotificationContentView::OnNotificationSurfaceAdded( | 698 void ArcNotificationContentView::OnNotificationSurfaceAdded( |
| 690 exo::NotificationSurface* surface) { | 699 ArcNotificationSurface* surface) { |
| 691 if (surface->notification_key() != notification_key_) | 700 if (surface->GetNotificationKey() != notification_key_) |
| 692 return; | 701 return; |
| 693 | 702 |
| 694 SetSurface(surface); | 703 SetSurface(surface); |
| 695 } | 704 } |
| 696 | 705 |
| 697 void ArcNotificationContentView::OnNotificationSurfaceRemoved( | 706 void ArcNotificationContentView::OnNotificationSurfaceRemoved( |
| 698 exo::NotificationSurface* surface) { | 707 ArcNotificationSurface* surface) { |
| 699 if (surface->notification_key() != notification_key_) | 708 if (surface->GetNotificationKey() != notification_key_) |
| 700 return; | 709 return; |
| 701 | 710 |
| 702 SetSurface(nullptr); | 711 SetSurface(nullptr); |
| 703 } | 712 } |
| 704 | 713 |
| 705 void ArcNotificationContentView::AnimationEnded( | 714 void ArcNotificationContentView::AnimationEnded( |
| 706 const gfx::Animation* animation) { | 715 const gfx::Animation* animation) { |
| 707 DCHECK_EQ(animation, control_button_color_animation_.get()); | 716 DCHECK_EQ(animation, control_button_color_animation_.get()); |
| 708 control_button_color_animation_.reset(); | 717 control_button_color_animation_.reset(); |
| 709 } | 718 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 727 settings_button_->SchedulePaint(); | 736 settings_button_->SchedulePaint(); |
| 728 } | 737 } |
| 729 if (close_button_) { | 738 if (close_button_) { |
| 730 close_button_->SetBackground(views::CreateSolidBackground(current_color)); | 739 close_button_->SetBackground(views::CreateSolidBackground(current_color)); |
| 731 close_button_->SchedulePaint(); | 740 close_button_->SchedulePaint(); |
| 732 } | 741 } |
| 733 } | 742 } |
| 734 } | 743 } |
| 735 | 744 |
| 736 } // namespace arc | 745 } // namespace arc |
| OLD | NEW |