Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(242)

Unified Diff: ui/arc/notification/arc_custom_notification_view.cc

Issue 2873553002: [Notifications] Fix swipe to close for ARC notifications. (Closed)
Patch Set: Address comments. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/arc/notification/arc_custom_notification_view.cc
diff --git a/ui/arc/notification/arc_custom_notification_view.cc b/ui/arc/notification/arc_custom_notification_view.cc
index b3f1259860239a647c0826374c8c8bb7a35de6e8..3a8d99ee08a8bb26c39da6a620514703eb059f5a 100644
--- a/ui/arc/notification/arc_custom_notification_view.cc
+++ b/ui/arc/notification/arc_custom_notification_view.cc
@@ -64,41 +64,35 @@ class ArcCustomNotificationView::EventForwarder : public ui::EventHandler {
return;
}
- if (event->IsScrollEvent()) {
- ForwardScrollEvent(event->AsScrollEvent());
- } else if (event->IsMouseWheelEvent()) {
- ForwardMouseWheelEvent(event->AsMouseWheelEvent());
- } else if (!event->IsTouchEvent() && event->type() != ui::ET_GESTURE_TAP) {
- // TODO(yoshiki): Use a better tigger (eg. focusing EditText on
- // notification) than clicking (crbug.com/697379).
- if (event->type() == ui::ET_MOUSE_PRESSED)
- owner_->ActivateToast();
-
- // Forward the rest events to |owner_| except for:
- // 1. Touches, because View should no longer receive touch events.
- // See View::OnTouchEvent.
- // 2. Tap gestures are handled on the Android side, so ignore them.
- // See crbug.com/709911.
- owner_->OnEvent(event);
- }
- }
-
- void ForwardScrollEvent(ui::ScrollEvent* event) {
- views::Widget* widget = owner_->GetWidget();
- if (!widget)
- return;
-
- event->target()->ConvertEventToTarget(widget->GetNativeWindow(), event);
- widget->OnScrollEvent(event);
- }
+ // TODO(yoshiki): Use a better tigger (eg. focusing EditText on
+ // notification) than clicking (crbug.com/697379).
+ if (event->type() == ui::ET_MOUSE_PRESSED)
+ owner_->ActivateToast();
- void ForwardMouseWheelEvent(ui::MouseWheelEvent* event) {
views::Widget* widget = owner_->GetWidget();
if (!widget)
return;
- event->target()->ConvertEventToTarget(widget->GetNativeWindow(), event);
- widget->OnMouseEvent(event);
+ // Forward the events to the containing widget, except for:
+ // 1. Touches, because View should no longer receive touch events.
+ // See View::OnTouchEvent.
+ // 2. Tap gestures are handled on the Android side, so ignore them.
+ // See crbug.com/709911.
+ // 3. Key events. These are already forwarded by NotificationSurface's
+ // WindowDelegate.
+ if (event->IsLocatedEvent()) {
+ ui::LocatedEvent* located_event = event->AsLocatedEvent();
+ located_event->target()->ConvertEventToTarget(widget->GetNativeWindow(),
+ located_event);
+ if (located_event->type() == ui::ET_MOUSE_MOVED) {
+ widget->OnMouseEvent(located_event->AsMouseEvent());
+ } else if (located_event->IsScrollEvent()) {
+ widget->OnScrollEvent(located_event->AsScrollEvent());
+ } else if (located_event->IsGestureEvent() &&
+ event->type() != ui::ET_GESTURE_TAP) {
+ widget->OnGestureEvent(located_event->AsGestureEvent());
+ }
+ }
}
ArcCustomNotificationView* const owner_;
@@ -202,6 +196,11 @@ class ArcCustomNotificationView::ContentViewDelegate
owner_->UpdateControlButtonsVisibility();
}
+ void OnSlideChanged() override {
+ if (owner_->slide_helper_)
+ owner_->slide_helper_->Update();
+ }
+
private:
ArcCustomNotificationView* const owner_;
@@ -572,20 +571,6 @@ void ArcCustomNotificationView::OnPaint(gfx::Canvas* canvas) {
contents_bounds.height(), false);
}
-void ArcCustomNotificationView::OnKeyEvent(ui::KeyEvent* event) {
- // Forward to parent CustomNotificationView to handle keyboard dismissal.
- parent()->OnKeyEvent(event);
-}
-
-void ArcCustomNotificationView::OnGestureEvent(ui::GestureEvent* event) {
- // Forward to parent CustomNotificationView to handle sliding out.
- parent()->OnGestureEvent(event);
-
- // |slide_helper_| could be null before |surface_| is attached.
- if (slide_helper_)
- slide_helper_->Update();
-}
-
void ArcCustomNotificationView::OnMouseEntered(const ui::MouseEvent&) {
UpdateControlButtonsVisibility();
}

Powered by Google App Engine
This is Rietveld 408576698