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/session/session_state_delegate.h"
8 #include "ash/shelf/shelf_delegate.h"
9 #include "ash/shelf/shelf_item_types.h"
10 #include "ash/shelf/shelf_layout_manager.h"
11 #include "ash/shelf/shelf_model.h"
12 #include "ash/shelf/shelf_view.h"
13 #include "ash/shelf/shelf_widget.h"
14 #include "ash/shell.h"
15 #include "ash/shell_window_ids.h"
16 #include "ash/system/tray/system_tray_delegate.h"
17 #include "ash/wm/window_state.h"
18 #include "base/metrics/histogram.h"
19 #include "base/metrics/user_metrics.h"
20 #include "ui/aura/window.h"
26 // Time in seconds between calls to "RecordPeriodicMetrics".
27 const int kAshPeriodicMetricsTimeInSeconds
= 30 * 60;
29 enum ActiveWindowStateType
{
30 ACTIVE_WINDOW_STATE_TYPE_NO_ACTIVE_WINDOW
,
31 ACTIVE_WINDOW_STATE_TYPE_OTHER
,
32 ACTIVE_WINDOW_STATE_TYPE_MAXIMIZED
,
33 ACTIVE_WINDOW_STATE_TYPE_FULLSCREEN
,
34 ACTIVE_WINDOW_STATE_TYPE_SNAPPED
,
35 ACTIVE_WINDOW_STATE_TYPE_DOCKED
,
36 ACTIVE_WINDOW_STATE_TYPE_COUNT
39 ActiveWindowStateType
GetActiveWindowState() {
40 ActiveWindowStateType active_window_state_type
=
41 ACTIVE_WINDOW_STATE_TYPE_NO_ACTIVE_WINDOW
;
42 wm::WindowState
* active_window_state
= ash::wm::GetActiveWindowState();
43 if (active_window_state
) {
44 switch (active_window_state
->GetStateType()) {
45 case wm::WINDOW_STATE_TYPE_MAXIMIZED
:
46 active_window_state_type
= ACTIVE_WINDOW_STATE_TYPE_MAXIMIZED
;
48 case wm::WINDOW_STATE_TYPE_FULLSCREEN
:
49 active_window_state_type
= ACTIVE_WINDOW_STATE_TYPE_FULLSCREEN
;
51 case wm::WINDOW_STATE_TYPE_LEFT_SNAPPED
:
52 case wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED
:
53 active_window_state_type
= ACTIVE_WINDOW_STATE_TYPE_SNAPPED
;
55 case wm::WINDOW_STATE_TYPE_DOCKED
:
56 case wm::WINDOW_STATE_TYPE_DOCKED_MINIMIZED
:
57 active_window_state_type
= ACTIVE_WINDOW_STATE_TYPE_DOCKED
;
59 case wm::WINDOW_STATE_TYPE_DEFAULT
:
60 case wm::WINDOW_STATE_TYPE_NORMAL
:
61 case wm::WINDOW_STATE_TYPE_MINIMIZED
:
62 case wm::WINDOW_STATE_TYPE_INACTIVE
:
63 case wm::WINDOW_STATE_TYPE_END
:
64 case wm::WINDOW_STATE_TYPE_AUTO_POSITIONED
:
65 active_window_state_type
= ACTIVE_WINDOW_STATE_TYPE_OTHER
;
69 return active_window_state_type
;
72 // Returns true if kiosk mode is active.
73 bool IsKioskModeActive() {
74 return Shell::GetInstance()->system_tray_delegate()->GetUserLoginStatus() ==
75 user::LOGGED_IN_KIOSK_APP
;
78 // Returns true if there is an active user and their session isn't currently
81 switch (Shell::GetInstance()->system_tray_delegate()->GetUserLoginStatus()) {
82 case user::LOGGED_IN_NONE
:
83 case user::LOGGED_IN_LOCKED
:
85 case user::LOGGED_IN_USER
:
86 case user::LOGGED_IN_OWNER
:
87 case user::LOGGED_IN_GUEST
:
88 case user::LOGGED_IN_PUBLIC
:
89 case user::LOGGED_IN_SUPERVISED
:
90 case user::LOGGED_IN_KIOSK_APP
:
97 // Array of window container ids that contain visible windows to be counted for
98 // UMA statistics. Note the containers are ordered from top most visible
99 // container to the lowest to allow the |GetNumVisibleWindows| method to short
100 // circuit when processing a maximized or fullscreen window.
101 int kVisibleWindowContainerIds
[] = {kShellWindowId_PanelContainer
,
102 kShellWindowId_DockedContainer
,
103 kShellWindowId_AlwaysOnTopContainer
,
104 kShellWindowId_DefaultContainer
};
106 // Returns an approximate count of how many windows are currently visible in the
107 // primary root window.
108 int GetNumVisibleWindowsInPrimaryDisplay() {
109 int visible_window_count
= 0;
110 bool maximized_or_fullscreen_window_present
= false;
112 for (const int& current_container_id
: kVisibleWindowContainerIds
) {
113 if (maximized_or_fullscreen_window_present
)
116 const aura::Window::Windows
& children
=
117 Shell::GetContainer(Shell::GetInstance()->GetPrimaryRootWindow(),
118 current_container_id
)->children();
119 // Reverse iterate over the child windows so that they are processed in
120 // visible stacking order.
121 for (aura::Window::Windows::const_reverse_iterator it
= children
.rbegin(),
122 rend
= children
.rend();
124 const aura::Window
* child_window
= *it
;
125 const wm::WindowState
* child_window_state
=
126 wm::GetWindowState(child_window
);
128 if (!child_window
->IsVisible() || child_window_state
->IsMinimized())
131 // Only count activatable windows for 2 reasons:
132 // 1. Ensures that a browser window and its transient, modal child will
133 // only count as 1 visible window.
134 // 2. Prevents counting some windows in the
135 // kShellWindowId_DockedContainer that were not opened by the user.
136 if (child_window_state
->CanActivate())
137 ++visible_window_count
;
139 // Stop counting windows that will be hidden by maximized or fullscreen
140 // windows. Only windows in the kShellWindowId_DefaultContainer and
141 // kShellWindowId_AlwaysOnTopContainer can be maximized or fullscreened
142 // and completely obscure windows beneath them.
143 if ((kShellWindowId_DefaultContainer
== current_container_id
||
144 kShellWindowId_AlwaysOnTopContainer
== current_container_id
) &&
145 child_window_state
->IsMaximizedOrFullscreen()) {
146 maximized_or_fullscreen_window_present
= true;
151 return visible_window_count
;
154 // Records the number of items in the shelf as an UMA statistic.
155 void RecordShelfItemCounts() {
156 ShelfDelegate
* shelf_delegate
= Shell::GetInstance()->GetShelfDelegate();
157 int pinned_item_count
= 0;
158 int unpinned_item_count
= 0;
160 for (const ShelfItem
& shelf_item
:
161 Shell::GetInstance()->shelf_model()->items()) {
162 if (shelf_item
.type
!= TYPE_APP_LIST
) {
163 // Internal ash apps do not have an app id and thus will always be counted
165 if (shelf_delegate
->HasShelfIDToAppIDMapping(shelf_item
.id
) &&
166 shelf_delegate
->IsAppPinned(
167 shelf_delegate
->GetAppIDForShelfID(shelf_item
.id
))) {
170 ++unpinned_item_count
;
175 UMA_HISTOGRAM_COUNTS_100("Ash.Shelf.NumberOfItems",
176 pinned_item_count
+ unpinned_item_count
);
177 UMA_HISTOGRAM_COUNTS_100("Ash.Shelf.NumberOfPinnedItems", pinned_item_count
);
178 UMA_HISTOGRAM_COUNTS_100("Ash.Shelf.NumberOfUnpinnedItems",
179 unpinned_item_count
);
184 UserMetricsRecorder::UserMetricsRecorder() {
188 UserMetricsRecorder::UserMetricsRecorder(bool record_periodic_metrics
) {
189 if (record_periodic_metrics
)
193 UserMetricsRecorder::~UserMetricsRecorder() {
197 void UserMetricsRecorder::RecordUserMetricsAction(UserMetricsAction action
) {
199 case ash::UMA_ACCEL_KEYBOARD_BRIGHTNESS_DOWN_F6
:
201 base::UserMetricsAction("Accel_KeyboardBrightnessDown_F6"));
203 case ash::UMA_ACCEL_KEYBOARD_BRIGHTNESS_UP_F7
:
205 base::UserMetricsAction("Accel_KeyboardBrightnessUp_F7"));
207 case ash::UMA_ACCEL_LOCK_SCREEN_LOCK_BUTTON
:
209 base::UserMetricsAction("Accel_LockScreen_LockButton"));
211 case ash::UMA_ACCEL_LOCK_SCREEN_POWER_BUTTON
:
213 base::UserMetricsAction("Accel_LockScreen_PowerButton"));
215 case ash::UMA_ACCEL_MAXIMIZE_RESTORE_F4
:
217 base::UserMetricsAction("Accel_Maximize_Restore_F4"));
219 case ash::UMA_ACCEL_PREVWINDOW_F5
:
220 base::RecordAction(base::UserMetricsAction("Accel_PrevWindow_F5"));
222 case ash::UMA_ACCEL_EXIT_FIRST_Q
:
223 base::RecordAction(base::UserMetricsAction("Accel_Exit_First_Q"));
225 case ash::UMA_ACCEL_EXIT_SECOND_Q
:
226 base::RecordAction(base::UserMetricsAction("Accel_Exit_Second_Q"));
228 case ash::UMA_ACCEL_RESTART_POWER_BUTTON
:
230 base::UserMetricsAction("Accel_Restart_PowerButton"));
232 case ash::UMA_ACCEL_SHUT_DOWN_POWER_BUTTON
:
234 base::UserMetricsAction("Accel_ShutDown_PowerButton"));
236 case ash::UMA_CLOSE_THROUGH_CONTEXT_MENU
:
237 base::RecordAction(base::UserMetricsAction("CloseFromContextMenu"));
239 case ash::UMA_DRAG_MAXIMIZE_LEFT
:
240 base::RecordAction(base::UserMetricsAction("WindowDrag_MaximizeLeft"));
242 case ash::UMA_DRAG_MAXIMIZE_RIGHT
:
243 base::RecordAction(base::UserMetricsAction("WindowDrag_MaximizeRight"));
245 case ash::UMA_GESTURE_OVERVIEW
:
246 base::RecordAction(base::UserMetricsAction("Gesture_Overview"));
248 case ash::UMA_LAUNCHER_BUTTON_PRESSED_WITH_MOUSE
:
250 base::UserMetricsAction("Launcher_ButtonPressed_Mouse"));
252 case ash::UMA_LAUNCHER_BUTTON_PRESSED_WITH_TOUCH
:
254 base::UserMetricsAction("Launcher_ButtonPressed_Touch"));
256 case ash::UMA_LAUNCHER_CLICK_ON_APP
:
257 base::RecordAction(base::UserMetricsAction("Launcher_ClickOnApp"));
259 case ash::UMA_LAUNCHER_CLICK_ON_APPLIST_BUTTON
:
261 base::UserMetricsAction("Launcher_ClickOnApplistButton"));
263 case ash::UMA_LAUNCHER_LAUNCH_TASK
:
264 base::RecordAction(base::UserMetricsAction("Launcher_LaunchTask"));
265 task_switch_metrics_recorder_
.OnTaskSwitch(
266 TaskSwitchMetricsRecorder::kShelf
);
268 case ash::UMA_LAUNCHER_MINIMIZE_TASK
:
269 base::RecordAction(base::UserMetricsAction("Launcher_MinimizeTask"));
271 case ash::UMA_LAUNCHER_SWITCH_TASK
:
272 base::RecordAction(base::UserMetricsAction("Launcher_SwitchTask"));
273 task_switch_metrics_recorder_
.OnTaskSwitch(
274 TaskSwitchMetricsRecorder::kShelf
);
276 case UMA_MAXIMIZE_MODE_DISABLED
:
277 base::RecordAction(base::UserMetricsAction("Touchview_Disabled"));
279 case UMA_MAXIMIZE_MODE_ENABLED
:
280 base::RecordAction(base::UserMetricsAction("Touchview_Enabled"));
282 case UMA_MAXIMIZE_MODE_INITIALLY_DISABLED
:
284 base::UserMetricsAction("Touchview_Initially_Disabled"));
286 case ash::UMA_MOUSE_DOWN
:
287 base::RecordAction(base::UserMetricsAction("Mouse_Down"));
289 case ash::UMA_PANEL_MINIMIZE_CAPTION_CLICK
:
291 base::UserMetricsAction("Panel_Minimize_Caption_Click"));
293 case ash::UMA_PANEL_MINIMIZE_CAPTION_GESTURE
:
295 base::UserMetricsAction("Panel_Minimize_Caption_Gesture"));
297 case ash::UMA_SHELF_ALIGNMENT_SET_BOTTOM
:
299 base::UserMetricsAction("Shelf_AlignmentSetBottom"));
301 case ash::UMA_SHELF_ALIGNMENT_SET_LEFT
:
303 base::UserMetricsAction("Shelf_AlignmentSetLeft"));
305 case ash::UMA_SHELF_ALIGNMENT_SET_RIGHT
:
307 base::UserMetricsAction("Shelf_AlignmentSetRight"));
309 case ash::UMA_STATUS_AREA_AUDIO_CURRENT_INPUT_DEVICE
:
311 base::UserMetricsAction("StatusArea_Audio_CurrentInputDevice"));
313 case ash::UMA_STATUS_AREA_AUDIO_CURRENT_OUTPUT_DEVICE
:
315 base::UserMetricsAction("StatusArea_Audio_CurrentOutputDevice"));
317 case ash::UMA_STATUS_AREA_AUDIO_SWITCH_INPUT_DEVICE
:
319 base::UserMetricsAction("StatusArea_Audio_SwitchInputDevice"));
321 case ash::UMA_STATUS_AREA_AUDIO_SWITCH_OUTPUT_DEVICE
:
323 base::UserMetricsAction("StatusArea_Audio_SwitchOutputDevice"));
325 case ash::UMA_STATUS_AREA_BRIGHTNESS_CHANGED
:
327 base::UserMetricsAction("StatusArea_BrightnessChanged"));
329 case ash::UMA_STATUS_AREA_BLUETOOTH_CONNECT_KNOWN_DEVICE
:
331 base::UserMetricsAction("StatusArea_Bluetooth_Connect_Known"));
333 case ash::UMA_STATUS_AREA_BLUETOOTH_CONNECT_UNKNOWN_DEVICE
:
335 base::UserMetricsAction("StatusArea_Bluetooth_Connect_Unknown"));
337 case ash::UMA_STATUS_AREA_BLUETOOTH_DISABLED
:
339 base::UserMetricsAction("StatusArea_Bluetooth_Disabled"));
341 case ash::UMA_STATUS_AREA_BLUETOOTH_ENABLED
:
343 base::UserMetricsAction("StatusArea_Bluetooth_Enabled"));
345 case ash::UMA_STATUS_AREA_CAPS_LOCK_DETAILED
:
347 base::UserMetricsAction("StatusArea_CapsLock_Detailed"));
349 case ash::UMA_STATUS_AREA_CAPS_LOCK_DISABLED_BY_CLICK
:
351 base::UserMetricsAction("StatusArea_CapsLock_DisabledByClick"));
353 case ash::UMA_STATUS_AREA_CAPS_LOCK_ENABLED_BY_CLICK
:
355 base::UserMetricsAction("StatusArea_CapsLock_EnabledByClick"));
357 case ash::UMA_STATUS_AREA_CAPS_LOCK_POPUP
:
359 base::UserMetricsAction("StatusArea_CapsLock_Popup"));
361 case ash::UMA_STATUS_AREA_CONNECT_TO_CONFIGURED_NETWORK
:
363 base::UserMetricsAction("StatusArea_Network_ConnectConfigured"));
365 case ash::UMA_STATUS_AREA_CONNECT_TO_UNCONFIGURED_NETWORK
:
367 base::UserMetricsAction("StatusArea_Network_ConnectUnconfigured"));
369 case ash::UMA_STATUS_AREA_CONNECT_TO_VPN
:
371 base::UserMetricsAction("StatusArea_VPN_ConnectToNetwork"));
373 case ash::UMA_STATUS_AREA_CHANGED_VOLUME_MENU
:
375 base::UserMetricsAction("StatusArea_Volume_ChangedMenu"));
377 case ash::UMA_STATUS_AREA_CHANGED_VOLUME_POPUP
:
379 base::UserMetricsAction("StatusArea_Volume_ChangedPopup"));
381 case ash::UMA_STATUS_AREA_DETAILED_ACCESSABILITY
:
383 base::UserMetricsAction("StatusArea_Accessability_DetailedView"));
385 case ash::UMA_STATUS_AREA_DETAILED_AUDIO_VIEW
:
387 base::UserMetricsAction("StatusArea_Audio_Detailed"));
389 case ash::UMA_STATUS_AREA_DETAILED_BLUETOOTH_VIEW
:
391 base::UserMetricsAction("StatusArea_Bluetooth_Detailed"));
393 case ash::UMA_STATUS_AREA_DETAILED_BRIGHTNESS_VIEW
:
395 base::UserMetricsAction("StatusArea_Brightness_Detailed"));
397 case ash::UMA_STATUS_AREA_DETAILED_CAST_VIEW
:
398 base::RecordAction(base::UserMetricsAction("StatusArea_Cast_Detailed"));
400 case ash::UMA_STATUS_AREA_DETAILED_DRIVE_VIEW
:
402 base::UserMetricsAction("StatusArea_Drive_Detailed"));
404 case ash::UMA_STATUS_AREA_DETAILED_NETWORK_VIEW
:
406 base::UserMetricsAction("StatusArea_Network_Detailed"));
408 case ash::UMA_STATUS_AREA_DETAILED_VPN_VIEW
:
410 base::UserMetricsAction("StatusArea_VPN_Detailed"));
412 case ash::UMA_STATUS_AREA_DISABLE_AUTO_CLICK
:
414 base::UserMetricsAction("StatusArea_AutoClickDisabled"));
416 case ash::UMA_STATUS_AREA_DISABLE_HIGH_CONTRAST
:
418 base::UserMetricsAction("StatusArea_HighContrastDisabled"));
420 case ash::UMA_STATUS_AREA_DISABLE_LARGE_CURSOR
:
422 base::UserMetricsAction("StatusArea_LargeCursorDisabled"));
424 case ash::UMA_STATUS_AREA_DISABLE_MAGNIFIER
:
426 base::UserMetricsAction("StatusArea_MagnifierDisabled"));
428 case ash::UMA_STATUS_AREA_DISABLE_SPOKEN_FEEDBACK
:
430 base::UserMetricsAction("StatusArea_SpokenFeedbackDisabled"));
432 case ash::UMA_STATUS_AREA_DISABLE_VIRTUAL_KEYBOARD
:
434 base::UserMetricsAction("StatusArea_VirtualKeyboardDisabled"));
436 case ash::UMA_STATUS_AREA_DISABLE_WIFI
:
438 base::UserMetricsAction("StatusArea_Network_WifiDisabled"));
440 case ash::UMA_STATUS_AREA_DRIVE_CANCEL_OPERATION
:
442 base::UserMetricsAction("StatusArea_Drive_CancelOperation"));
444 case ash::UMA_STATUS_AREA_DRIVE_SETTINGS
:
446 base::UserMetricsAction("StatusArea_Drive_Settings"));
448 case ash::UMA_STATUS_AREA_ENABLE_AUTO_CLICK
:
450 base::UserMetricsAction("StatusArea_AutoClickEnabled"));
452 case ash::UMA_STATUS_AREA_ENABLE_HIGH_CONTRAST
:
454 base::UserMetricsAction("StatusArea_HighContrastEnabled"));
456 case ash::UMA_STATUS_AREA_ENABLE_LARGE_CURSOR
:
458 base::UserMetricsAction("StatusArea_LargeCursorEnabled"));
460 case ash::UMA_STATUS_AREA_ENABLE_MAGNIFIER
:
462 base::UserMetricsAction("StatusArea_MagnifierEnabled"));
464 case ash::UMA_STATUS_AREA_ENABLE_SPOKEN_FEEDBACK
:
466 base::UserMetricsAction("StatusArea_SpokenFeedbackEnabled"));
468 case ash::UMA_STATUS_AREA_ENABLE_VIRTUAL_KEYBOARD
:
470 base::UserMetricsAction("StatusArea_VirtualKeyboardEnabled"));
472 case ash::UMA_STATUS_AREA_ENABLE_WIFI
:
474 base::UserMetricsAction("StatusArea_Network_WifiEnabled"));
476 case ash::UMA_STATUS_AREA_IME_SHOW_DETAILED
:
478 base::UserMetricsAction("StatusArea_IME_Detailed"));
480 case ash::UMA_STATUS_AREA_IME_SWITCH_MODE
:
482 base::UserMetricsAction("StatusArea_IME_SwitchMode"));
484 case ash::UMA_STATUS_AREA_MENU_OPENED
:
486 base::UserMetricsAction("StatusArea_MenuOpened"));
488 case ash::UMA_STATUS_AREA_NETWORK_JOIN_OTHER_CLICKED
:
490 base::UserMetricsAction("StatusArea_Network_JoinOther"));
492 case ash::UMA_STATUS_AREA_NETWORK_SETTINGS_CLICKED
:
494 base::UserMetricsAction("StatusArea_Network_Settings"));
496 case ash::UMA_STATUS_AREA_SHOW_NETWORK_CONNECTION_DETAILS
:
498 base::UserMetricsAction("StatusArea_Network_ConnectionDetails"));
500 case ash::UMA_STATUS_AREA_SHOW_VPN_CONNECTION_DETAILS
:
502 base::UserMetricsAction("StatusArea_VPN_ConnectionDetails"));
504 case ash::UMA_STATUS_AREA_SIGN_OUT
:
506 base::UserMetricsAction("StatusArea_SignOut"));
508 case ash::UMA_STATUS_AREA_VPN_ADD_BUILT_IN_CLICKED
:
509 base::RecordAction(base::UserMetricsAction("StatusArea_VPN_AddBuiltIn"));
511 case ash::UMA_STATUS_AREA_VPN_ADD_THIRD_PARTY_CLICKED
:
513 base::UserMetricsAction("StatusArea_VPN_AddThirdParty"));
515 case ash::UMA_STATUS_AREA_VPN_DISCONNECT_CLICKED
:
516 base::RecordAction(base::UserMetricsAction("StatusArea_VPN_Disconnect"));
518 case ash::UMA_STATUS_AREA_VPN_SETTINGS_CLICKED
:
520 base::UserMetricsAction("StatusArea_VPN_Settings"));
522 case ash::UMA_TOGGLE_MAXIMIZE_CAPTION_CLICK
:
524 base::UserMetricsAction("Caption_ClickTogglesMaximize"));
526 case ash::UMA_TOGGLE_MAXIMIZE_CAPTION_GESTURE
:
528 base::UserMetricsAction("Caption_GestureTogglesMaximize"));
530 case ash::UMA_TOGGLE_SINGLE_AXIS_MAXIMIZE_BORDER_CLICK
:
532 base::UserMetricsAction(
533 "WindowBorder_ClickTogglesSingleAxisMaximize"));
535 case ash::UMA_TOUCHPAD_GESTURE_OVERVIEW
:
537 base::UserMetricsAction("Touchpad_Gesture_Overview"));
539 case ash::UMA_TOUCHSCREEN_TAP_DOWN
:
540 base::RecordAction(base::UserMetricsAction("Touchscreen_Down"));
542 case ash::UMA_TRAY_HELP
:
543 base::RecordAction(base::UserMetricsAction("Tray_Help"));
545 case ash::UMA_TRAY_LOCK_SCREEN
:
546 base::RecordAction(base::UserMetricsAction("Tray_LockScreen"));
548 case ash::UMA_TRAY_OVERVIEW
:
549 base::RecordAction(base::UserMetricsAction("Tray_Overview"));
551 case ash::UMA_TRAY_SHUT_DOWN
:
552 base::RecordAction(base::UserMetricsAction("Tray_ShutDown"));
554 case ash::UMA_WINDOW_APP_CLOSE_BUTTON_CLICK
:
555 base::RecordAction(base::UserMetricsAction("AppCloseButton_Clk"));
557 case ash::UMA_WINDOW_CLOSE_BUTTON_CLICK
:
558 base::RecordAction(base::UserMetricsAction("CloseButton_Clk"));
560 case ash::UMA_WINDOW_MAXIMIZE_BUTTON_CLICK_EXIT_FULLSCREEN
:
561 base::RecordAction(base::UserMetricsAction("MaxButton_Clk_ExitFS"));
563 case ash::UMA_WINDOW_MAXIMIZE_BUTTON_CLICK_RESTORE
:
565 base::UserMetricsAction("MaxButton_Clk_Restore"));
567 case ash::UMA_WINDOW_MAXIMIZE_BUTTON_CLICK_MAXIMIZE
:
569 base::UserMetricsAction("MaxButton_Clk_Maximize"));
571 case ash::UMA_WINDOW_MAXIMIZE_BUTTON_CLICK_MINIMIZE
:
572 base::RecordAction(base::UserMetricsAction("MinButton_Clk"));
574 case ash::UMA_WINDOW_MAXIMIZE_BUTTON_MAXIMIZE_LEFT
:
575 base::RecordAction(base::UserMetricsAction("MaxButton_MaxLeft"));
577 case ash::UMA_WINDOW_MAXIMIZE_BUTTON_MAXIMIZE_RIGHT
:
578 base::RecordAction(base::UserMetricsAction("MaxButton_MaxRight"));
580 case ash::UMA_WINDOW_OVERVIEW
:
582 base::UserMetricsAction("WindowSelector_Overview"));
584 case ash::UMA_WINDOW_OVERVIEW_ACTIVE_WINDOW_CHANGED
:
586 base::UserMetricsAction("WindowSelector_ActiveWindowChanged"));
587 task_switch_metrics_recorder_
.OnTaskSwitch(
588 TaskSwitchMetricsRecorder::kOverviewMode
);
590 case ash::UMA_WINDOW_OVERVIEW_ENTER_KEY
:
592 base::UserMetricsAction("WindowSelector_OverviewEnterKey"));
594 case ash::UMA_WINDOW_CYCLE
:
596 base::UserMetricsAction("WindowCycleController_Cycle"));
601 void UserMetricsRecorder::RecordPeriodicMetrics() {
602 ShelfLayoutManager
* manager
=
603 ShelfLayoutManager::ForShelf(Shell::GetPrimaryRootWindow());
604 // TODO(bruthig): Investigating whether the check for |manager| is necessary
605 // and add tests if it is.
607 // TODO(bruthig): Consider tracking the time spent in each alignment.
608 UMA_HISTOGRAM_ENUMERATION("Ash.ShelfAlignmentOverTime",
609 manager
->SelectValueForShelfAlignment(
610 SHELF_ALIGNMENT_UMA_ENUM_VALUE_BOTTOM
,
611 SHELF_ALIGNMENT_UMA_ENUM_VALUE_LEFT
,
612 SHELF_ALIGNMENT_UMA_ENUM_VALUE_RIGHT
,
614 SHELF_ALIGNMENT_UMA_ENUM_VALUE_COUNT
);
617 if (IsUserInActiveDesktopEnvironment()) {
618 RecordShelfItemCounts();
619 UMA_HISTOGRAM_COUNTS_100("Ash.NumberOfVisibleWindowsInPrimaryDisplay",
620 GetNumVisibleWindowsInPrimaryDisplay());
623 // TODO(bruthig): Find out if this should only be logged when the user is
625 // TODO(bruthig): Consider tracking how long a particular type of window is
627 UMA_HISTOGRAM_ENUMERATION("Ash.ActiveWindowShowTypeOverTime",
628 GetActiveWindowState(),
629 ACTIVE_WINDOW_STATE_TYPE_COUNT
);
632 bool UserMetricsRecorder::IsUserInActiveDesktopEnvironment() const {
633 return IsUserActive() && !IsKioskModeActive();
636 void UserMetricsRecorder::StartTimer() {
637 timer_
.Start(FROM_HERE
,
638 base::TimeDelta::FromSeconds(kAshPeriodicMetricsTimeInSeconds
),
639 this, &UserMetricsRecorder::RecordPeriodicMetrics
);