| 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_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 "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "components/exo/notification_surface.h" | 9 #include "components/exo/notification_surface.h" |
| 10 #include "components/exo/surface.h" | 10 #include "components/exo/surface.h" |
| 11 #include "third_party/skia/include/core/SkColor.h" | 11 #include "third_party/skia/include/core/SkColor.h" |
| 12 #include "ui/base/l10n/l10n_util.h" | 12 #include "ui/base/l10n/l10n_util.h" |
| 13 #include "ui/base/resource/resource_bundle.h" | 13 #include "ui/base/resource/resource_bundle.h" |
| 14 #include "ui/compositor/layer_animation_observer.h" | 14 #include "ui/compositor/layer_animation_observer.h" |
| 15 #include "ui/display/screen.h" | 15 #include "ui/display/screen.h" |
| 16 #include "ui/events/event_handler.h" | 16 #include "ui/events/event_handler.h" |
| 17 #include "ui/gfx/canvas.h" | 17 #include "ui/gfx/canvas.h" |
| 18 #include "ui/gfx/image/image_skia.h" | 18 #include "ui/gfx/image/image_skia.h" |
| 19 #include "ui/gfx/transform.h" | 19 #include "ui/gfx/transform.h" |
| 20 #include "ui/message_center/message_center_style.h" | 20 #include "ui/message_center/message_center_style.h" |
| 21 #include "ui/message_center/views/custom_notification_view.h" |
| 21 #include "ui/resources/grit/ui_resources.h" | 22 #include "ui/resources/grit/ui_resources.h" |
| 22 #include "ui/strings/grit/ui_strings.h" | 23 #include "ui/strings/grit/ui_strings.h" |
| 23 #include "ui/views/background.h" | 24 #include "ui/views/background.h" |
| 24 #include "ui/views/border.h" | 25 #include "ui/views/border.h" |
| 25 #include "ui/views/controls/button/image_button.h" | 26 #include "ui/views/controls/button/image_button.h" |
| 26 #include "ui/views/painter.h" | 27 #include "ui/views/painter.h" |
| 27 #include "ui/views/widget/widget.h" | 28 #include "ui/views/widget/widget.h" |
| 28 #include "ui/wm/core/window_util.h" | 29 #include "ui/wm/core/window_util.h" |
| 29 | 30 |
| 30 namespace arc { | 31 namespace arc { |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 ArcCustomNotificationView* const owner_; | 173 ArcCustomNotificationView* const owner_; |
| 173 | 174 |
| 174 DISALLOW_COPY_AND_ASSIGN(ContentViewDelegate); | 175 DISALLOW_COPY_AND_ASSIGN(ContentViewDelegate); |
| 175 }; | 176 }; |
| 176 | 177 |
| 177 ArcCustomNotificationView::ArcCustomNotificationView( | 178 ArcCustomNotificationView::ArcCustomNotificationView( |
| 178 ArcCustomNotificationItem* item) | 179 ArcCustomNotificationItem* item) |
| 179 : item_(item), | 180 : item_(item), |
| 180 notification_key_(item->notification_key()), | 181 notification_key_(item->notification_key()), |
| 181 event_forwarder_(new EventForwarder(this)) { | 182 event_forwarder_(new EventForwarder(this)) { |
| 183 SetFocusBehavior(FocusBehavior::ALWAYS); |
| 184 |
| 182 item_->IncrementWindowRefCount(); | 185 item_->IncrementWindowRefCount(); |
| 183 item_->AddObserver(this); | 186 item_->AddObserver(this); |
| 184 | 187 |
| 185 ArcNotificationSurfaceManager::Get()->AddObserver(this); | 188 ArcNotificationSurfaceManager::Get()->AddObserver(this); |
| 186 exo::NotificationSurface* surface = | 189 exo::NotificationSurface* surface = |
| 187 ArcNotificationSurfaceManager::Get()->GetSurface(notification_key_); | 190 ArcNotificationSurfaceManager::Get()->GetSurface(notification_key_); |
| 188 if (surface) | 191 if (surface) |
| 189 OnNotificationSurfaceAdded(surface); | 192 OnNotificationSurfaceAdded(surface); |
| 190 | 193 |
| 191 // Create a layer as an anchor to insert surface copy during a slide. | 194 // Create a layer as an anchor to insert surface copy during a slide. |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 } | 439 } |
| 437 | 440 |
| 438 void ArcCustomNotificationView::OnMouseEntered(const ui::MouseEvent&) { | 441 void ArcCustomNotificationView::OnMouseEntered(const ui::MouseEvent&) { |
| 439 UpdateCloseButtonVisiblity(); | 442 UpdateCloseButtonVisiblity(); |
| 440 } | 443 } |
| 441 | 444 |
| 442 void ArcCustomNotificationView::OnMouseExited(const ui::MouseEvent&) { | 445 void ArcCustomNotificationView::OnMouseExited(const ui::MouseEvent&) { |
| 443 UpdateCloseButtonVisiblity(); | 446 UpdateCloseButtonVisiblity(); |
| 444 } | 447 } |
| 445 | 448 |
| 449 void ArcCustomNotificationView::OnFocus() { |
| 450 NativeViewHost::OnFocus(); |
| 451 static_cast<message_center::CustomNotificationView*>(parent()) |
| 452 ->OnContentFocused(); |
| 453 } |
| 454 |
| 455 void ArcCustomNotificationView::OnBlur() { |
| 456 NativeViewHost::OnBlur(); |
| 457 static_cast<message_center::CustomNotificationView*>(parent()) |
| 458 ->OnContentBlured(); |
| 459 } |
| 460 |
| 446 void ArcCustomNotificationView::ButtonPressed(views::Button* sender, | 461 void ArcCustomNotificationView::ButtonPressed(views::Button* sender, |
| 447 const ui::Event& event) { | 462 const ui::Event& event) { |
| 448 if (item_ && !item_->pinned() && sender == floating_close_button_) { | 463 if (item_ && !item_->pinned() && sender == floating_close_button_) { |
| 449 item_->CloseFromCloseButton(); | 464 item_->CloseFromCloseButton(); |
| 450 } | 465 } |
| 451 } | 466 } |
| 452 | 467 |
| 453 void ArcCustomNotificationView::OnWindowBoundsChanged( | 468 void ArcCustomNotificationView::OnWindowBoundsChanged( |
| 454 aura::Window* window, | 469 aura::Window* window, |
| 455 const gfx::Rect& old_bounds, | 470 const gfx::Rect& old_bounds, |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 | 504 |
| 490 void ArcCustomNotificationView::OnNotificationSurfaceRemoved( | 505 void ArcCustomNotificationView::OnNotificationSurfaceRemoved( |
| 491 exo::NotificationSurface* surface) { | 506 exo::NotificationSurface* surface) { |
| 492 if (surface->notification_id() != notification_key_) | 507 if (surface->notification_id() != notification_key_) |
| 493 return; | 508 return; |
| 494 | 509 |
| 495 SetSurface(nullptr); | 510 SetSurface(nullptr); |
| 496 } | 511 } |
| 497 | 512 |
| 498 } // namespace arc | 513 } // namespace arc |
| OLD | NEW |