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; | |
53 if (WmShell::Get() | |
54 ->maximize_mode_controller() | |
55 ->IsMaximizeModeWindowManagerEnabled()) { | |
56 form_factor = DOWN_EVENT_FORMFACTOR_TOUCHVIEW; | |
57 } else { | |
58 form_factor = DOWN_EVENT_FORMFACTOR_CLAMSHELL; | |
59 } | |
60 UMA_HISTOGRAM_ENUMERATION("Event.DownEventCount.PerFormFactor", form_factor, | |
61 DOWN_EVENT_FORMFACTOR_COUNT); | |
62 | |
63 DownEventSource input_type; | |
Ilya Sherman
2016/08/24 00:48:01
nit: I think the Visual Studio compiler isn't clev
xiaoyinh(OOO Sep 11-29)
2016/08/24 16:51:51
Done.
| |
64 switch (type) { | |
65 case ui::EventPointerType::POINTER_TYPE_UNKNOWN: | |
66 input_type = DOWN_EVENT_SOURCE_UNKNOWN; | |
67 break; | |
68 case ui::EventPointerType::POINTER_TYPE_MOUSE: | |
69 input_type = DOWN_EVENT_SOURCE_MOUSE; | |
70 break; | |
71 case ui::EventPointerType::POINTER_TYPE_PEN: | |
72 input_type = DOWN_EVENT_SOURCE_STYLUS; | |
73 break; | |
74 case ui::EventPointerType::POINTER_TYPE_TOUCH: | |
75 input_type = DOWN_EVENT_SOURCE_TOUCH; | |
76 break; | |
77 } | |
78 | |
79 UMA_HISTOGRAM_ENUMERATION("Event.DownEventCount.PerInput", input_type, | |
80 DOWN_EVENT_SOURCE_COUNT); | |
81 } | |
82 | |
83 } // namespace ash | |
OLD | NEW |