OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "ash/wm/stylus_metrics_recorder.h" | |
6 | |
7 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" | |
8 #include "ash/common/wm_shell.h" | |
9 #include "ash/shell.h" | |
10 #include "base/metrics/histogram.h" | |
11 #include "ui/events/event.h" | |
12 #include "ui/events/event_constants.h" | |
13 #include "ui/events/event_utils.h" | |
14 | |
15 namespace ash { | |
16 | |
17 // Form factor of the down event. This enum is used to back an UMA histogram | |
18 // and should be treated as append-only. | |
19 enum DownEventFormFactor { | |
20 DOWN_EVENT_FORMFACTOR_CLAMSHELL = 0, | |
21 DOWN_EVENT_FORMFACTOR_TOUCHVIEW, | |
22 DOWN_EVENT_FORMFACTOR_COUNT | |
23 }; | |
24 | |
25 // Input type of the down event. This enum is used to back an UMA histogram | |
26 // and should be treated as append-only. | |
27 enum DownEventSource { | |
28 DOWN_EVENT_SOURCE_UNKNOWN = 0, | |
29 DOWN_EVENT_SOURCE_MOUSE, | |
30 DOWN_EVENT_SOURCE_STYLUS, | |
31 DOWN_EVENT_SOURCE_TOUCH, | |
32 DOWN_EVENT_SOURCE_COUNT | |
33 }; | |
34 | |
35 StylusMetricsRecorder::StylusMetricsRecorder() {} | |
36 | |
37 StylusMetricsRecorder::~StylusMetricsRecorder() {} | |
38 | |
39 void StylusMetricsRecorder::OnMouseEvent(ui::MouseEvent* event) { | |
40 if (event->type() != ui::ET_MOUSE_PRESSED) | |
41 return; | |
42 RecordUMA(event->pointer_details().pointer_type); | |
43 } | |
44 | |
45 void StylusMetricsRecorder::OnTouchEvent(ui::TouchEvent* event) { | |
46 if (event->type() != ui::ET_TOUCH_PRESSED) | |
47 return; | |
48 RecordUMA(event->pointer_details().pointer_type); | |
49 } | |
50 | |
51 void StylusMetricsRecorder::RecordUMA(ui::EventPointerType type) { | |
52 DownEventFormFactor form_factor = DOWN_EVENT_FORMFACTOR_CLAMSHELL; | |
53 if (WmShell::Get() | |
54 ->maximize_mode_controller() | |
55 ->IsMaximizeModeWindowManagerEnabled()) { | |
56 form_factor = DOWN_EVENT_FORMFACTOR_TOUCHVIEW; | |
57 } | |
58 UMA_HISTOGRAM_ENUMERATION("Event.DownEventCount.PerFormFactor", form_factor, | |
59 DOWN_EVENT_FORMFACTOR_COUNT); | |
60 | |
61 DownEventSource input_type = DOWN_EVENT_SOURCE_UNKNOWN; | |
62 switch (type) { | |
63 case ui::EventPointerType::POINTER_TYPE_UNKNOWN: | |
64 input_type = DOWN_EVENT_SOURCE_UNKNOWN; | |
65 break; | |
66 case ui::EventPointerType::POINTER_TYPE_MOUSE: | |
67 input_type = DOWN_EVENT_SOURCE_MOUSE; | |
68 break; | |
69 case ui::EventPointerType::POINTER_TYPE_PEN: | |
70 input_type = DOWN_EVENT_SOURCE_STYLUS; | |
71 break; | |
72 case ui::EventPointerType::POINTER_TYPE_TOUCH: | |
73 input_type = DOWN_EVENT_SOURCE_TOUCH; | |
74 break; | |
75 case ui::EventPointerType::POINTER_TYPE_ERASER: | |
76 input_type = DOWN_EVENT_SOURCE_STYLUS; | |
77 break; | |
78 } | |
79 | |
80 UMA_HISTOGRAM_ENUMERATION("Event.DownEventCount.PerInput", input_type, | |
81 DOWN_EVENT_SOURCE_COUNT); | |
82 } | |
83 | |
84 } // namespace ash | |
OLD | NEW |