OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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/metrics/pointer_metrics_recorder.h" | 5 #include "ash/metrics/pointer_metrics_recorder.h" |
6 | 6 |
7 #include "ash/shared/app_types.h" | 7 #include "ash/shared/app_types.h" |
8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
9 #include "ash/shell_port.h" | 9 #include "ash/shell_port.h" |
10 #include "ash/wm/maximize_mode/maximize_mode_controller.h" | 10 #include "ash/wm/maximize_mode/maximize_mode_controller.h" |
11 #include "ash/wm_window.h" | |
12 #include "base/metrics/histogram_macros.h" | 11 #include "base/metrics/histogram_macros.h" |
| 12 #include "ui/aura/client/aura_constants.h" |
| 13 #include "ui/aura/window.h" |
13 #include "ui/events/event_constants.h" | 14 #include "ui/events/event_constants.h" |
14 #include "ui/views/widget/widget.h" | 15 #include "ui/views/widget/widget.h" |
15 | 16 |
16 namespace ash { | 17 namespace ash { |
17 | 18 |
18 namespace { | 19 namespace { |
19 | 20 |
20 // Form factor of the down event. This enum is used to back an UMA histogram | 21 // Form factor of the down event. This enum is used to back an UMA histogram |
21 // and new values should be inserted immediately above FORM_FACTOR_COUNT. | 22 // and new values should be inserted immediately above FORM_FACTOR_COUNT. |
22 enum class DownEventFormFactor { | 23 enum class DownEventFormFactor { |
23 CLAMSHELL = 0, | 24 CLAMSHELL = 0, |
24 TOUCH_VIEW, | 25 TOUCH_VIEW, |
25 FORM_FACTOR_COUNT, | 26 FORM_FACTOR_COUNT, |
26 }; | 27 }; |
27 | 28 |
28 // Input type of the down event. This enum is used to back an UMA | 29 // Input type of the down event. This enum is used to back an UMA |
29 // histogram and new values should be inserted immediately above SOURCE_COUNT. | 30 // histogram and new values should be inserted immediately above SOURCE_COUNT. |
30 enum class DownEventSource { | 31 enum class DownEventSource { |
31 UNKNOWN = 0, | 32 UNKNOWN = 0, |
32 MOUSE, | 33 MOUSE, |
33 STYLUS, | 34 STYLUS, |
34 TOUCH, | 35 TOUCH, |
35 SOURCE_COUNT, | 36 SOURCE_COUNT, |
36 }; | 37 }; |
37 | 38 |
38 int GetDestination(views::Widget* target) { | 39 int GetDestination(views::Widget* target) { |
39 if (!target) | 40 if (!target) |
40 return static_cast<int>(AppType::OTHERS); | 41 return static_cast<int>(AppType::OTHERS); |
41 | 42 |
42 WmWindow* window = WmWindow::Get(target->GetNativeWindow()); | 43 aura::Window* window = target->GetNativeWindow(); |
43 DCHECK(window); | 44 DCHECK(window); |
44 return window->GetAppType(); | 45 return window->GetProperty(aura::client::kAppType); |
45 } | 46 } |
46 | 47 |
47 void RecordUMA(ui::EventPointerType type, views::Widget* target) { | 48 void RecordUMA(ui::EventPointerType type, views::Widget* target) { |
48 DownEventFormFactor form_factor = DownEventFormFactor::CLAMSHELL; | 49 DownEventFormFactor form_factor = DownEventFormFactor::CLAMSHELL; |
49 if (Shell::Get() | 50 if (Shell::Get() |
50 ->maximize_mode_controller() | 51 ->maximize_mode_controller() |
51 ->IsMaximizeModeWindowManagerEnabled()) { | 52 ->IsMaximizeModeWindowManagerEnabled()) { |
52 form_factor = DownEventFormFactor::TOUCH_VIEW; | 53 form_factor = DownEventFormFactor::TOUCH_VIEW; |
53 } | 54 } |
54 UMA_HISTOGRAM_ENUMERATION( | 55 UMA_HISTOGRAM_ENUMERATION( |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 | 99 |
99 void PointerMetricsRecorder::OnPointerEventObserved( | 100 void PointerMetricsRecorder::OnPointerEventObserved( |
100 const ui::PointerEvent& event, | 101 const ui::PointerEvent& event, |
101 const gfx::Point& location_in_screen, | 102 const gfx::Point& location_in_screen, |
102 views::Widget* target) { | 103 views::Widget* target) { |
103 if (event.type() == ui::ET_POINTER_DOWN) | 104 if (event.type() == ui::ET_POINTER_DOWN) |
104 RecordUMA(event.pointer_details().pointer_type, target); | 105 RecordUMA(event.pointer_details().pointer_type, target); |
105 } | 106 } |
106 | 107 |
107 } // namespace ash | 108 } // namespace ash |
OLD | NEW |