OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ash/wm/system_gesture_event_filter.h" | 5 #include "ash/wm/system_gesture_event_filter.h" |
6 | 6 |
7 #include "ash/metrics/user_metrics_recorder.h" | 7 #include "ash/metrics/user_metrics_recorder.h" |
| 8 #include "ash/public/cpp/config.h" |
8 #include "ash/shell.h" | 9 #include "ash/shell.h" |
9 #include "ash/touch/touch_uma.h" | 10 #include "ash/touch/touch_uma.h" |
10 #include "ash/wm/gestures/overview_gesture_handler.h" | 11 #include "ash/wm/gestures/overview_gesture_handler.h" |
11 #include "ui/base/touch/touch_device.h" | 12 #include "ui/base/touch/touch_device.h" |
12 #include "ui/events/event.h" | 13 #include "ui/events/event.h" |
13 #include "ui/events/event_constants.h" | 14 #include "ui/events/event_constants.h" |
14 | 15 |
15 namespace ash { | 16 namespace ash { |
16 | 17 |
17 SystemGestureEventFilter::SystemGestureEventFilter() | 18 SystemGestureEventFilter::SystemGestureEventFilter() |
18 : overview_gesture_handler_(new OverviewGestureHandler) {} | 19 : overview_gesture_handler_(new OverviewGestureHandler) {} |
19 | 20 |
20 SystemGestureEventFilter::~SystemGestureEventFilter() {} | 21 SystemGestureEventFilter::~SystemGestureEventFilter() {} |
21 | 22 |
22 void SystemGestureEventFilter::OnMouseEvent(ui::MouseEvent* event) { | 23 void SystemGestureEventFilter::OnMouseEvent(ui::MouseEvent* event) { |
| 24 // ui::GetTouchScreensAvailability() uses InputDeviceManager, which is |
| 25 // not created in mash. Figure out! |
23 if (event->type() == ui::ET_MOUSE_PRESSED && | 26 if (event->type() == ui::ET_MOUSE_PRESSED && |
| 27 Shell::GetAshConfig() == Config::CLASSIC && |
24 ui::GetTouchScreensAvailability() == | 28 ui::GetTouchScreensAvailability() == |
25 ui::TouchScreensAvailability::ENABLED) { | 29 ui::TouchScreensAvailability::ENABLED) { |
26 Shell::Get()->metrics()->RecordUserMetricsAction(UMA_MOUSE_DOWN); | 30 Shell::Get()->metrics()->RecordUserMetricsAction(UMA_MOUSE_DOWN); |
27 } | 31 } |
28 } | 32 } |
29 | 33 |
30 void SystemGestureEventFilter::OnScrollEvent(ui::ScrollEvent* event) { | 34 void SystemGestureEventFilter::OnScrollEvent(ui::ScrollEvent* event) { |
31 if (overview_gesture_handler_ && | 35 if (overview_gesture_handler_ && |
32 overview_gesture_handler_->ProcessScrollEvent(*event)) { | 36 overview_gesture_handler_->ProcessScrollEvent(*event)) { |
33 event->StopPropagation(); | 37 event->StopPropagation(); |
34 } | 38 } |
35 } | 39 } |
36 | 40 |
37 void SystemGestureEventFilter::OnTouchEvent(ui::TouchEvent* event) { | 41 void SystemGestureEventFilter::OnTouchEvent(ui::TouchEvent* event) { |
38 aura::Window* target = static_cast<aura::Window*>(event->target()); | 42 aura::Window* target = static_cast<aura::Window*>(event->target()); |
39 ash::TouchUMA::GetInstance()->RecordTouchEvent(target, *event); | 43 ash::TouchUMA::GetInstance()->RecordTouchEvent(target, *event); |
40 } | 44 } |
41 | 45 |
42 void SystemGestureEventFilter::OnGestureEvent(ui::GestureEvent* event) { | 46 void SystemGestureEventFilter::OnGestureEvent(ui::GestureEvent* event) { |
43 aura::Window* target = static_cast<aura::Window*>(event->target()); | 47 aura::Window* target = static_cast<aura::Window*>(event->target()); |
44 ash::TouchUMA::GetInstance()->RecordGestureEvent(target, *event); | 48 ash::TouchUMA::GetInstance()->RecordGestureEvent(target, *event); |
45 } | 49 } |
46 | 50 |
47 } // namespace ash | 51 } // namespace ash |
OLD | NEW |