| 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 "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 "third_party/skia/include/core/SkColor.h" | 12 #include "third_party/skia/include/core/SkColor.h" |
| 13 #include "ui/base/l10n/l10n_util.h" | 13 #include "ui/base/l10n/l10n_util.h" |
| 14 #include "ui/base/resource/resource_bundle.h" | 14 #include "ui/base/resource/resource_bundle.h" |
| 15 #include "ui/compositor/layer_animation_observer.h" | 15 #include "ui/compositor/layer_animation_observer.h" |
| 16 #include "ui/display/screen.h" | 16 #include "ui/display/screen.h" |
| 17 #include "ui/events/event_handler.h" | 17 #include "ui/events/event_handler.h" |
| 18 #include "ui/gfx/canvas.h" | 18 #include "ui/gfx/canvas.h" |
| 19 #include "ui/gfx/image/image_skia.h" | 19 #include "ui/gfx/image/image_skia.h" |
| 20 #include "ui/gfx/transform.h" | 20 #include "ui/gfx/transform.h" |
| 21 #include "ui/message_center/message_center_style.h" | 21 #include "ui/message_center/message_center_style.h" |
| 22 #include "ui/message_center/views/custom_notification_view.h" | 22 #include "ui/message_center/views/custom_notification_view.h" |
| 23 #include "ui/message_center/views/padded_button.h" | 23 #include "ui/message_center/views/padded_button.h" |
| 24 #include "ui/message_center/views/toast_contents_view.h" |
| 24 #include "ui/resources/grit/ui_resources.h" | 25 #include "ui/resources/grit/ui_resources.h" |
| 25 #include "ui/strings/grit/ui_strings.h" | 26 #include "ui/strings/grit/ui_strings.h" |
| 26 #include "ui/views/background.h" | 27 #include "ui/views/background.h" |
| 27 #include "ui/views/border.h" | 28 #include "ui/views/border.h" |
| 28 #include "ui/views/controls/button/image_button.h" | 29 #include "ui/views/controls/button/image_button.h" |
| 29 #include "ui/views/focus/focus_manager.h" | 30 #include "ui/views/focus/focus_manager.h" |
| 30 #include "ui/views/layout/box_layout.h" | 31 #include "ui/views/layout/box_layout.h" |
| 31 #include "ui/views/painter.h" | 32 #include "ui/views/painter.h" |
| 32 #include "ui/views/widget/root_view.h" | 33 #include "ui/views/widget/root_view.h" |
| 33 #include "ui/views/widget/widget.h" | 34 #include "ui/views/widget/widget.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 49 owner_->floating_control_buttons_widget_->GetNativeWindow() == | 50 owner_->floating_control_buttons_widget_->GetNativeWindow() == |
| 50 event->target()) { | 51 event->target()) { |
| 51 return; | 52 return; |
| 52 } | 53 } |
| 53 | 54 |
| 54 if (event->IsScrollEvent()) { | 55 if (event->IsScrollEvent()) { |
| 55 ForwardScrollEvent(event->AsScrollEvent()); | 56 ForwardScrollEvent(event->AsScrollEvent()); |
| 56 } else if (event->IsMouseWheelEvent()) { | 57 } else if (event->IsMouseWheelEvent()) { |
| 57 ForwardMouseWheelEvent(event->AsMouseWheelEvent()); | 58 ForwardMouseWheelEvent(event->AsMouseWheelEvent()); |
| 58 } else if (!event->IsTouchEvent()) { | 59 } else if (!event->IsTouchEvent()) { |
| 60 // TODO(yoshiki): Use a better tigger (eg. focusing EditText on |
| 61 // notification) than clicking (crbug.com/697379). |
| 62 if (event->type() == ui::ET_MOUSE_PRESSED) |
| 63 owner_->ActivateToast(); |
| 64 |
| 59 // Forward the rest events to |owner_| except touches because View | 65 // Forward the rest events to |owner_| except touches because View |
| 60 // should no longer receive touch events. See View::OnTouchEvent. | 66 // should no longer receive touch events. See View::OnTouchEvent. |
| 61 owner_->OnEvent(event); | 67 owner_->OnEvent(event); |
| 62 } | 68 } |
| 63 } | 69 } |
| 64 | 70 |
| 65 void ForwardScrollEvent(ui::ScrollEvent* event) { | 71 void ForwardScrollEvent(ui::ScrollEvent* event) { |
| 66 views::Widget* widget = owner_->GetWidget(); | 72 views::Widget* widget = owner_->GetWidget(); |
| 67 if (!widget) | 73 if (!widget) |
| 68 return; | 74 return; |
| (...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 static_cast<message_center::CustomNotificationView*>(parent()) | 496 static_cast<message_center::CustomNotificationView*>(parent()) |
| 491 ->OnContentFocused(); | 497 ->OnContentFocused(); |
| 492 } | 498 } |
| 493 | 499 |
| 494 void ArcCustomNotificationView::OnBlur() { | 500 void ArcCustomNotificationView::OnBlur() { |
| 495 NativeViewHost::OnBlur(); | 501 NativeViewHost::OnBlur(); |
| 496 static_cast<message_center::CustomNotificationView*>(parent()) | 502 static_cast<message_center::CustomNotificationView*>(parent()) |
| 497 ->OnContentBlured(); | 503 ->OnContentBlured(); |
| 498 } | 504 } |
| 499 | 505 |
| 506 void ArcCustomNotificationView::ActivateToast() { |
| 507 if (message_center::ToastContentsView::kViewClassName == |
| 508 parent()->parent()->GetClassName()) { |
| 509 static_cast<message_center::ToastContentsView*>(parent()->parent()) |
| 510 ->ActivateToast(); |
| 511 } |
| 512 } |
| 513 |
| 500 views::FocusTraversable* ArcCustomNotificationView::GetFocusTraversable() { | 514 views::FocusTraversable* ArcCustomNotificationView::GetFocusTraversable() { |
| 501 if (floating_control_buttons_widget_) | 515 if (floating_control_buttons_widget_) |
| 502 return static_cast<views::internal::RootView*>( | 516 return static_cast<views::internal::RootView*>( |
| 503 floating_control_buttons_widget_->GetRootView()); | 517 floating_control_buttons_widget_->GetRootView()); |
| 504 return nullptr; | 518 return nullptr; |
| 505 } | 519 } |
| 506 | 520 |
| 507 void ArcCustomNotificationView::ButtonPressed(views::Button* sender, | 521 void ArcCustomNotificationView::ButtonPressed(views::Button* sender, |
| 508 const ui::Event& event) { | 522 const ui::Event& event) { |
| 509 if (item_ && !item_->pinned() && sender == close_button_) { | 523 if (item_ && !item_->pinned() && sender == close_button_) { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 553 | 567 |
| 554 void ArcCustomNotificationView::OnNotificationSurfaceRemoved( | 568 void ArcCustomNotificationView::OnNotificationSurfaceRemoved( |
| 555 exo::NotificationSurface* surface) { | 569 exo::NotificationSurface* surface) { |
| 556 if (surface->notification_id() != notification_key_) | 570 if (surface->notification_id() != notification_key_) |
| 557 return; | 571 return; |
| 558 | 572 |
| 559 SetSurface(nullptr); | 573 SetSurface(nullptr); |
| 560 } | 574 } |
| 561 | 575 |
| 562 } // namespace arc | 576 } // namespace arc |
| OLD | NEW |