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. | |
jdufault
2016/08/23 23:09:53
Continue comment on the same line.
xiaoyinh(OOO Sep 11-29)
2016/08/23 23:45:41
Done.
| |
18 // This enum is used to back an UMA histogram and should be treated as | |
19 // append-only. | |
20 enum DownEventFormFactor { | |
21 DOWN_EVENT_FORMFACTOR_CLAMSHELL = 0, | |
22 DOWN_EVENT_FORMFACTOR_TOUCHVIEW, | |
23 DOWN_EVENT_FORMFACTOR_COUNT | |
24 }; | |
25 | |
26 // Input type of the down event. | |
jdufault
2016/08/23 23:09:53
Continue comment on the same line.
xiaoyinh(OOO Sep 11-29)
2016/08/23 23:45:41
Done.
| |
27 // This enum is used to back an UMA histogram and should be treated as | |
28 // append-only. | |
29 enum DownEventSource { | |
30 DOWN_EVENT_SOURCE_UNKNOWN = 0, | |
31 DOWN_EVENT_SOURCE_MOUSE, | |
32 DOWN_EVENT_SOURCE_STYLUS, | |
33 DOWN_EVENT_SOURCE_TOUCH, | |
34 DOWN_EVENT_SOURCE_COUNT | |
35 }; | |
36 | |
37 StylusMetricsRecorder::StylusMetricsRecorder() {} | |
38 | |
39 StylusMetricsRecorder::~StylusMetricsRecorder() {} | |
40 | |
41 void StylusMetricsRecorder::OnMouseEvent(ui::MouseEvent* event) { | |
42 if (event->type() != ui::ET_MOUSE_PRESSED) | |
43 return; | |
44 RecordUMA(event->pointer_details().pointer_type); | |
45 } | |
46 | |
47 void StylusMetricsRecorder::OnTouchEvent(ui::TouchEvent* event) { | |
48 if (event->type() != ui::ET_TOUCH_PRESSED) | |
49 return; | |
50 RecordUMA(event->pointer_details().pointer_type); | |
51 } | |
52 | |
53 void StylusMetricsRecorder::RecordUMA(ui::EventPointerType type) { | |
54 DownEventFormFactor form_factor; | |
55 if (WmShell::Get() | |
56 ->maximize_mode_controller() | |
57 ->IsMaximizeModeWindowManagerEnabled()) { | |
58 form_factor = DOWN_EVENT_FORMFACTOR_TOUCHVIEW; | |
59 } else { | |
60 form_factor = DOWN_EVENT_FORMFACTOR_CLAMSHELL; | |
61 } | |
62 UMA_HISTOGRAM_ENUMERATION("Event.DownEventCount.PerFormFactor", form_factor, | |
63 DOWN_EVENT_FORMFACTOR_COUNT); | |
64 | |
65 DownEventSource input_type; | |
66 switch (type) { | |
67 case ui::EventPointerType::POINTER_TYPE_UNKNOWN: | |
68 input_type = DOWN_EVENT_SOURCE_UNKNOWN; | |
69 break; | |
70 case ui::EventPointerType::POINTER_TYPE_MOUSE: | |
71 input_type = DOWN_EVENT_SOURCE_MOUSE; | |
72 break; | |
73 case ui::EventPointerType::POINTER_TYPE_PEN: | |
74 input_type = DOWN_EVENT_SOURCE_STYLUS; | |
75 break; | |
76 case ui::EventPointerType::POINTER_TYPE_TOUCH: | |
77 input_type = DOWN_EVENT_SOURCE_TOUCH; | |
78 break; | |
79 } | |
80 | |
81 UMA_HISTOGRAM_ENUMERATION("Event.DownEventCount.PerInput", input_type, | |
82 DOWN_EVENT_SOURCE_COUNT); | |
83 } | |
84 | |
85 } // namespace ash | |
OLD | NEW |