1 // Copyright 2013 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.
5 #include "ash/metrics/user_metrics_recorder.h"
7 #include "ash/shelf/shelf_layout_manager.h"
8 #include "ash/shelf/shelf_view.h"
9 #include "ash/shelf/shelf_widget.h"
10 #include "ash/shell.h"
11 #include "ash/wm/window_state.h"
12 #include "base/metrics/histogram.h"
13 #include "base/metrics/user_metrics.h"
17 // Time in seconds between calls to "RecordPeriodicMetrics".
18 const int kAshPeriodicMetricsTimeInSeconds
= 30 * 60;
20 UserMetricsRecorder::UserMetricsRecorder() {
21 timer_
.Start(FROM_HERE
,
22 base::TimeDelta::FromSeconds(kAshPeriodicMetricsTimeInSeconds
),
24 &UserMetricsRecorder::RecordPeriodicMetrics
);
27 UserMetricsRecorder::~UserMetricsRecorder() {
31 void UserMetricsRecorder::RecordUserMetricsAction(UserMetricsAction action
) {
33 case ash::UMA_ACCEL_KEYBOARD_BRIGHTNESS_DOWN_F6
:
35 base::UserMetricsAction("Accel_KeyboardBrightnessDown_F6"));
37 case ash::UMA_ACCEL_KEYBOARD_BRIGHTNESS_UP_F7
:
39 base::UserMetricsAction("Accel_KeyboardBrightnessUp_F7"));
41 case ash::UMA_ACCEL_LOCK_SCREEN_LOCK_BUTTON
:
43 base::UserMetricsAction("Accel_LockScreen_LockButton"));
45 case ash::UMA_ACCEL_LOCK_SCREEN_POWER_BUTTON
:
47 base::UserMetricsAction("Accel_LockScreen_PowerButton"));
49 case ash::UMA_ACCEL_MAXIMIZE_RESTORE_F4
:
51 base::UserMetricsAction("Accel_Maximize_Restore_F4"));
53 case ash::UMA_ACCEL_PREVWINDOW_F5
:
54 base::RecordAction(base::UserMetricsAction("Accel_PrevWindow_F5"));
56 case ash::UMA_ACCEL_EXIT_FIRST_Q
:
57 base::RecordAction(base::UserMetricsAction("Accel_Exit_First_Q"));
59 case ash::UMA_ACCEL_EXIT_SECOND_Q
:
60 base::RecordAction(base::UserMetricsAction("Accel_Exit_Second_Q"));
62 case ash::UMA_ACCEL_SHUT_DOWN_POWER_BUTTON
:
64 base::UserMetricsAction("Accel_ShutDown_PowerButton"));
66 case ash::UMA_CLOSE_THROUGH_CONTEXT_MENU
:
67 base::RecordAction(base::UserMetricsAction("CloseFromContextMenu"));
69 case ash::UMA_DRAG_MAXIMIZE_LEFT
:
70 base::RecordAction(base::UserMetricsAction("WindowDrag_MaximizeLeft"));
72 case ash::UMA_DRAG_MAXIMIZE_RIGHT
:
73 base::RecordAction(base::UserMetricsAction("WindowDrag_MaximizeRight"));
75 case ash::UMA_GESTURE_OVERVIEW
:
76 base::RecordAction(base::UserMetricsAction("Gesture_Overview"));
78 case ash::UMA_LAUNCHER_CLICK_ON_APP
:
79 base::RecordAction(base::UserMetricsAction("Launcher_ClickOnApp"));
81 case ash::UMA_LAUNCHER_CLICK_ON_APPLIST_BUTTON
:
83 base::UserMetricsAction("Launcher_ClickOnApplistButton"));
85 case ash::UMA_MOUSE_DOWN
:
86 base::RecordAction(base::UserMetricsAction("Mouse_Down"));
88 case ash::UMA_PANEL_MINIMIZE_CAPTION_CLICK
:
90 base::UserMetricsAction("Panel_Minimize_Caption_Click"));
92 case ash::UMA_PANEL_MINIMIZE_CAPTION_GESTURE
:
94 base::UserMetricsAction("Panel_Minimize_Caption_Gesture"));
96 case ash::UMA_SHELF_ALIGNMENT_SET_BOTTOM
:
98 base::UserMetricsAction("Shelf_AlignmentSetBottom"));
100 case ash::UMA_SHELF_ALIGNMENT_SET_LEFT
:
102 base::UserMetricsAction("Shelf_AlignmentSetLeft"));
104 case ash::UMA_SHELF_ALIGNMENT_SET_RIGHT
:
106 base::UserMetricsAction("Shelf_AlignmentSetRight"));
108 case ash::UMA_STATUS_AREA_AUDIO_CURRENT_INPUT_DEVICE
:
110 base::UserMetricsAction("StatusArea_Audio_CurrentInputDevice"));
112 case ash::UMA_STATUS_AREA_AUDIO_CURRENT_OUTPUT_DEVICE
:
114 base::UserMetricsAction("StatusArea_Audio_CurrentOutputDevice"));
116 case ash::UMA_STATUS_AREA_AUDIO_SWITCH_INPUT_DEVICE
:
118 base::UserMetricsAction("StatusArea_Audio_SwitchInputDevice"));
120 case ash::UMA_STATUS_AREA_AUDIO_SWITCH_OUTPUT_DEVICE
:
122 base::UserMetricsAction("StatusArea_Audio_SwitchOutputDevice"));
124 case ash::UMA_STATUS_AREA_BRIGHTNESS_CHANGED
:
126 base::UserMetricsAction("StatusArea_BrightnessChanged"));
128 case ash::UMA_STATUS_AREA_BLUETOOTH_CONNECT_KNOWN_DEVICE
:
130 base::UserMetricsAction("StatusArea_Bluetooth_Connect_Known"));
132 case ash::UMA_STATUS_AREA_BLUETOOTH_CONNECT_UNKNOWN_DEVICE
:
134 base::UserMetricsAction("StatusArea_Bluetooth_Connect_Unknown"));
136 case ash::UMA_STATUS_AREA_BLUETOOTH_DISABLED
:
138 base::UserMetricsAction("StatusArea_Bluetooth_Disabled"));
140 case ash::UMA_STATUS_AREA_BLUETOOTH_ENABLED
:
142 base::UserMetricsAction("StatusArea_Bluetooth_Enabled"));
144 case ash::UMA_STATUS_AREA_CAPS_LOCK_DETAILED
:
146 base::UserMetricsAction("StatusArea_CapsLock_Detailed"));
148 case ash::UMA_STATUS_AREA_CAPS_LOCK_DISABLED_BY_CLICK
:
150 base::UserMetricsAction("StatusArea_CapsLock_DisabledByClick"));
152 case ash::UMA_STATUS_AREA_CAPS_LOCK_ENABLED_BY_CLICK
:
154 base::UserMetricsAction("StatusArea_CapsLock_EnabledByClick"));
156 case ash::UMA_STATUS_AREA_CAPS_LOCK_POPUP
:
158 base::UserMetricsAction("StatusArea_CapsLock_Popup"));
160 case ash::UMA_STATUS_AREA_CONNECT_TO_CONFIGURED_NETWORK
:
162 base::UserMetricsAction("StatusArea_Network_ConnectConfigured"));
164 case ash::UMA_STATUS_AREA_CONNECT_TO_UNCONFIGURED_NETWORK
:
166 base::UserMetricsAction("StatusArea_Network_ConnectUnconfigured"));
168 case ash::UMA_STATUS_AREA_CONNECT_TO_VPN
:
170 base::UserMetricsAction("StatusArea_VPN_ConnectToNetwork"));
172 case ash::UMA_STATUS_AREA_CHANGED_VOLUME_MENU
:
174 base::UserMetricsAction("StatusArea_Volume_ChangedMenu"));
176 case ash::UMA_STATUS_AREA_CHANGED_VOLUME_POPUP
:
178 base::UserMetricsAction("StatusArea_Volume_ChangedPopup"));
180 case ash::UMA_STATUS_AREA_DETAILED_ACCESSABILITY
:
182 base::UserMetricsAction("StatusArea_Accessability_DetailedView"));
184 case ash::UMA_STATUS_AREA_DETAILED_AUDIO_VIEW
:
186 base::UserMetricsAction("StatusArea_Audio_Detailed"));
188 case ash::UMA_STATUS_AREA_DETAILED_BLUETOOTH_VIEW
:
190 base::UserMetricsAction("StatusArea_Bluetooth_Detailed"));
192 case ash::UMA_STATUS_AREA_DETAILED_BRIGHTNESS_VIEW
:
194 base::UserMetricsAction("StatusArea_Brightness_Detailed"));
196 case ash::UMA_STATUS_AREA_DETAILED_DRIVE_VIEW
:
198 base::UserMetricsAction("StatusArea_Drive_Detailed"));
200 case ash::UMA_STATUS_AREA_DETAILED_NETWORK_VIEW
:
202 base::UserMetricsAction("StatusArea_Network_Detailed"));
204 case ash::UMA_STATUS_AREA_DETAILED_VPN_VIEW
:
206 base::UserMetricsAction("StatusArea_VPN_Detailed"));
208 case ash::UMA_STATUS_AREA_DISABLE_AUTO_CLICK
:
210 base::UserMetricsAction("StatusArea_AutoClickDisabled"));
212 case ash::UMA_STATUS_AREA_DISABLE_HIGH_CONTRAST
:
214 base::UserMetricsAction("StatusArea_HighContrastDisabled"));
216 case ash::UMA_STATUS_AREA_DISABLE_LARGE_CURSOR
:
218 base::UserMetricsAction("StatusArea_LargeCursorDisabled"));
220 case ash::UMA_STATUS_AREA_DISABLE_MAGNIFIER
:
222 base::UserMetricsAction("StatusArea_MagnifierDisabled"));
224 case ash::UMA_STATUS_AREA_DISABLE_SPOKEN_FEEDBACK
:
226 base::UserMetricsAction("StatusArea_SpokenFeedbackDisabled"));
228 case ash::UMA_STATUS_AREA_DISABLE_VIRTUAL_KEYBOARD
:
230 base::UserMetricsAction("StatusArea_VirtualKeyboardDisabled"));
232 case ash::UMA_STATUS_AREA_DISABLE_WIFI
:
234 base::UserMetricsAction("StatusArea_Network_WifiDisabled"));
236 case ash::UMA_STATUS_AREA_DRIVE_CANCEL_OPERATION
:
238 base::UserMetricsAction("StatusArea_Drive_CancelOperation"));
240 case ash::UMA_STATUS_AREA_DRIVE_SETTINGS
:
242 base::UserMetricsAction("StatusArea_Drive_Settings"));
244 case ash::UMA_STATUS_AREA_ENABLE_AUTO_CLICK
:
246 base::UserMetricsAction("StatusArea_AutoClickEnabled"));
248 case ash::UMA_STATUS_AREA_ENABLE_HIGH_CONTRAST
:
250 base::UserMetricsAction("StatusArea_HighContrastEnabled"));
252 case ash::UMA_STATUS_AREA_ENABLE_LARGE_CURSOR
:
254 base::UserMetricsAction("StatusArea_LargeCursorEnabled"));
256 case ash::UMA_STATUS_AREA_ENABLE_MAGNIFIER
:
258 base::UserMetricsAction("StatusArea_MagnifierEnabled"));
260 case ash::UMA_STATUS_AREA_ENABLE_SPOKEN_FEEDBACK
:
262 base::UserMetricsAction("StatusArea_SpokenFeedbackEnabled"));
264 case ash::UMA_STATUS_AREA_ENABLE_VIRTUAL_KEYBOARD
:
266 base::UserMetricsAction("StatusArea_VirtualKeyboardEnabled"));
268 case ash::UMA_STATUS_AREA_ENABLE_WIFI
:
270 base::UserMetricsAction("StatusArea_Network_WifiEnabled"));
272 case ash::UMA_STATUS_AREA_IME_SHOW_DETAILED
:
274 base::UserMetricsAction("StatusArea_IME_Detailed"));
276 case ash::UMA_STATUS_AREA_IME_SWITCH_MODE
:
278 base::UserMetricsAction("StatusArea_IME_SwitchMode"));
280 case ash::UMA_STATUS_AREA_MENU_OPENED
:
282 base::UserMetricsAction("StatusArea_MenuOpened"));
284 case ash::UMA_STATUS_AREA_NETWORK_JOIN_OTHER_CLICKED
:
286 base::UserMetricsAction("StatusArea_Network_JoinOther"));
288 case ash::UMA_STATUS_AREA_NETWORK_SETTINGS_CLICKED
:
290 base::UserMetricsAction("StatusArea_Network_Settings"));
292 case ash::UMA_STATUS_AREA_SHOW_NETWORK_CONNECTION_DETAILS
:
294 base::UserMetricsAction("StatusArea_Network_ConnectionDetails"));
296 case ash::UMA_STATUS_AREA_SHOW_VPN_CONNECTION_DETAILS
:
298 base::UserMetricsAction("StatusArea_VPN_ConnectionDetails"));
300 case ash::UMA_STATUS_AREA_SIGN_OUT
:
302 base::UserMetricsAction("StatusArea_SignOut"));
304 case ash::UMA_STATUS_AREA_VPN_JOIN_OTHER_CLICKED
:
306 base::UserMetricsAction("StatusArea_VPN_JoinOther"));
308 case ash::UMA_STATUS_AREA_VPN_SETTINGS_CLICKED
:
310 base::UserMetricsAction("StatusArea_VPN_Settings"));
312 case ash::UMA_TOGGLE_MAXIMIZE_CAPTION_CLICK
:
314 base::UserMetricsAction("Caption_ClickTogglesMaximize"));
316 case ash::UMA_TOGGLE_MAXIMIZE_CAPTION_GESTURE
:
318 base::UserMetricsAction("Caption_GestureTogglesMaximize"));
320 case ash::UMA_TOGGLE_SINGLE_AXIS_MAXIMIZE_BORDER_CLICK
:
322 base::UserMetricsAction(
323 "WindowBorder_ClickTogglesSingleAxisMaximize"));
325 case ash::UMA_TOUCHPAD_GESTURE_OVERVIEW
:
327 base::UserMetricsAction("Touchpad_Gesture_Overview"));
329 case ash::UMA_TOUCHSCREEN_TAP_DOWN
:
330 base::RecordAction(base::UserMetricsAction("Touchscreen_Down"));
332 case ash::UMA_TRAY_HELP
:
333 base::RecordAction(base::UserMetricsAction("Tray_Help"));
335 case ash::UMA_TRAY_LOCK_SCREEN
:
336 base::RecordAction(base::UserMetricsAction("Tray_LockScreen"));
338 case ash::UMA_TRAY_SHUT_DOWN
:
339 base::RecordAction(base::UserMetricsAction("Tray_ShutDown"));
341 case ash::UMA_WINDOW_APP_CLOSE_BUTTON_CLICK
:
342 base::RecordAction(base::UserMetricsAction("AppCloseButton_Clk"));
344 case ash::UMA_WINDOW_CLOSE_BUTTON_CLICK
:
345 base::RecordAction(base::UserMetricsAction("CloseButton_Clk"));
347 case ash::UMA_WINDOW_MAXIMIZE_BUTTON_CLICK_EXIT_FULLSCREEN
:
348 base::RecordAction(base::UserMetricsAction("MaxButton_Clk_ExitFS"));
350 case ash::UMA_WINDOW_MAXIMIZE_BUTTON_CLICK_RESTORE
:
352 base::UserMetricsAction("MaxButton_Clk_Restore"));
354 case ash::UMA_WINDOW_MAXIMIZE_BUTTON_CLICK_MAXIMIZE
:
356 base::UserMetricsAction("MaxButton_Clk_Maximize"));
358 case ash::UMA_WINDOW_MAXIMIZE_BUTTON_CLICK_MINIMIZE
:
359 base::RecordAction(base::UserMetricsAction("MinButton_Clk"));
361 case ash::UMA_WINDOW_MAXIMIZE_BUTTON_MAXIMIZE_LEFT
:
362 base::RecordAction(base::UserMetricsAction("MaxButton_MaxLeft"));
364 case ash::UMA_WINDOW_MAXIMIZE_BUTTON_MAXIMIZE_RIGHT
:
365 base::RecordAction(base::UserMetricsAction("MaxButton_MaxRight"));
367 case ash::UMA_WINDOW_OVERVIEW
:
369 base::UserMetricsAction("WindowSelector_Overview"));
371 case ash::UMA_WINDOW_OVERVIEW_ENTER_KEY
:
373 base::UserMetricsAction("WindowSelector_OverviewEnterKey"));
375 case ash::UMA_WINDOW_CYCLE
:
377 base::UserMetricsAction("WindowCycleController_Cycle"));
382 void UserMetricsRecorder::RecordPeriodicMetrics() {
383 ShelfLayoutManager
* manager
=
384 ShelfLayoutManager::ForShelf(Shell::GetPrimaryRootWindow());
386 UMA_HISTOGRAM_ENUMERATION("Ash.ShelfAlignmentOverTime",
387 manager
->SelectValueForShelfAlignment(
388 SHELF_ALIGNMENT_UMA_ENUM_VALUE_BOTTOM
,
389 SHELF_ALIGNMENT_UMA_ENUM_VALUE_LEFT
,
390 SHELF_ALIGNMENT_UMA_ENUM_VALUE_RIGHT
,
392 SHELF_ALIGNMENT_UMA_ENUM_VALUE_COUNT
);
395 enum ActiveWindowStateType
{
396 ACTIVE_WINDOW_STATE_TYPE_NO_ACTIVE_WINDOW
,
397 ACTIVE_WINDOW_STATE_TYPE_OTHER
,
398 ACTIVE_WINDOW_STATE_TYPE_MAXIMIZED
,
399 ACTIVE_WINDOW_STATE_TYPE_FULLSCREEN
,
400 ACTIVE_WINDOW_STATE_TYPE_SNAPPED
,
401 ACTIVE_WINDOW_STATE_TYPE_COUNT
404 ActiveWindowStateType active_window_state_type
=
405 ACTIVE_WINDOW_STATE_TYPE_NO_ACTIVE_WINDOW
;
406 wm::WindowState
* active_window_state
= ash::wm::GetActiveWindowState();
407 if (active_window_state
) {
408 switch (active_window_state
->GetStateType()) {
409 case wm::WINDOW_STATE_TYPE_MAXIMIZED
:
410 active_window_state_type
= ACTIVE_WINDOW_STATE_TYPE_MAXIMIZED
;
412 case wm::WINDOW_STATE_TYPE_FULLSCREEN
:
413 active_window_state_type
= ACTIVE_WINDOW_STATE_TYPE_FULLSCREEN
;
415 case wm::WINDOW_STATE_TYPE_LEFT_SNAPPED
:
416 case wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED
:
417 active_window_state_type
= ACTIVE_WINDOW_STATE_TYPE_SNAPPED
;
419 case wm::WINDOW_STATE_TYPE_DEFAULT
:
420 case wm::WINDOW_STATE_TYPE_NORMAL
:
421 case wm::WINDOW_STATE_TYPE_MINIMIZED
:
422 case wm::WINDOW_STATE_TYPE_INACTIVE
:
423 case wm::WINDOW_STATE_TYPE_END
:
424 case wm::WINDOW_STATE_TYPE_AUTO_POSITIONED
:
425 active_window_state_type
= ACTIVE_WINDOW_STATE_TYPE_OTHER
;
429 UMA_HISTOGRAM_ENUMERATION("Ash.ActiveWindowShowTypeOverTime",
430 active_window_state_type
,
431 ACTIVE_WINDOW_STATE_TYPE_COUNT
);