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