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 "ui/accessibility/ax_action_data.h" |
12 #include "ui/base/l10n/l10n_util.h" | 13 #include "ui/base/l10n/l10n_util.h" |
13 #include "ui/base/resource/resource_bundle.h" | 14 #include "ui/base/resource/resource_bundle.h" |
14 #include "ui/compositor/layer_animation_observer.h" | 15 #include "ui/compositor/layer_animation_observer.h" |
15 #include "ui/events/event_handler.h" | 16 #include "ui/events/event_handler.h" |
16 #include "ui/gfx/animation/linear_animation.h" | 17 #include "ui/gfx/animation/linear_animation.h" |
17 #include "ui/gfx/animation/tween.h" | 18 #include "ui/gfx/animation/tween.h" |
18 #include "ui/gfx/canvas.h" | 19 #include "ui/gfx/canvas.h" |
19 #include "ui/gfx/transform.h" | 20 #include "ui/gfx/transform.h" |
20 #include "ui/message_center/message_center_style.h" | 21 #include "ui/message_center/message_center_style.h" |
21 #include "ui/message_center/views/custom_notification_view.h" | 22 #include "ui/message_center/views/custom_notification_view.h" |
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
617 } | 618 } |
618 } | 619 } |
619 | 620 |
620 views::FocusTraversable* ArcCustomNotificationView::GetFocusTraversable() { | 621 views::FocusTraversable* ArcCustomNotificationView::GetFocusTraversable() { |
621 if (floating_control_buttons_widget_) | 622 if (floating_control_buttons_widget_) |
622 return static_cast<views::internal::RootView*>( | 623 return static_cast<views::internal::RootView*>( |
623 floating_control_buttons_widget_->GetRootView()); | 624 floating_control_buttons_widget_->GetRootView()); |
624 return nullptr; | 625 return nullptr; |
625 } | 626 } |
626 | 627 |
627 bool ArcCustomNotificationView::OnMousePressed(const ui::MouseEvent& event) { | 628 bool ArcCustomNotificationView::HandleAccessibleAction( |
628 // TODO(yhanada): Remove this hack as soon as possible after letting | 629 const ui::AXActionData& action_data) { |
629 // accessible actions be delivered to this view. | 630 if (item_ && action_data.action == ui::AX_ACTION_DO_DEFAULT) { |
630 // All mouse clicks or touches should be sent to corresponding Android view | |
631 // because the surface is on this view, so receiving a mouse pressed event | |
632 // means the event is generated by automation API. | |
633 // We can distinguish events from automation API by checking the target of the | |
634 // event because the target of all events generated by automation API is set | |
635 // to nullptr. | |
636 if (event.IsOnlyLeftMouseButton() && item_ && | |
637 item_->expand_state() != mojom::ArcNotificationExpandState::FIXED_SIZE && | |
638 event.target() == nullptr) { | |
639 item_->ToggleExpansion(); | 631 item_->ToggleExpansion(); |
640 return true; | 632 return true; |
641 } | 633 } |
642 return false; | 634 return false; |
643 } | 635 } |
644 | 636 |
645 void ArcCustomNotificationView::ButtonPressed(views::Button* sender, | 637 void ArcCustomNotificationView::ButtonPressed(views::Button* sender, |
646 const ui::Event& event) { | 638 const ui::Event& event) { |
647 if (item_ && !item_->pinned() && sender == close_button_.get()) { | 639 if (item_ && !item_->pinned() && sender == close_button_.get()) { |
648 CHECK_EQ(message_center::CustomNotificationView::kViewClassName, | 640 CHECK_EQ(message_center::CustomNotificationView::kViewClassName, |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
728 } | 720 } |
729 if (close_button_) { | 721 if (close_button_) { |
730 close_button_->set_background( | 722 close_button_->set_background( |
731 views::Background::CreateSolidBackground(current_color)); | 723 views::Background::CreateSolidBackground(current_color)); |
732 close_button_->SchedulePaint(); | 724 close_button_->SchedulePaint(); |
733 } | 725 } |
734 } | 726 } |
735 } | 727 } |
736 | 728 |
737 } // namespace arc | 729 } // namespace arc |
OLD | NEW |