Use "= delete" for DISALLOW_COPY and DISALLOW_ASSIGN.
[chromium-blink-merge.git] / ash / metrics / user_metrics_recorder.cc
blobcfc4d8ee16d4a79a28fe463ce86ff38e8f60b497
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"
22 namespace ash {
24 namespace {
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;
47 break;
48 case wm::WINDOW_STATE_TYPE_FULLSCREEN:
49 active_window_state_type = ACTIVE_WINDOW_STATE_TYPE_FULLSCREEN;
50 break;
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;
54 break;
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;
58 break;
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;
66 break;
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
79 // locked.
80 bool IsUserActive() {
81 switch (Shell::GetInstance()->system_tray_delegate()->GetUserLoginStatus()) {
82 case user::LOGGED_IN_NONE:
83 case user::LOGGED_IN_LOCKED:
84 return false;
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:
91 return true;
93 NOTREACHED();
94 return false;
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)
114 break;
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();
123 it != rend; ++it) {
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())
129 continue;
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;
147 break;
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
164 // as unpinned.
165 if (shelf_delegate->HasShelfIDToAppIDMapping(shelf_item.id) &&
166 shelf_delegate->IsAppPinned(
167 shelf_delegate->GetAppIDForShelfID(shelf_item.id))) {
168 ++pinned_item_count;
169 } else {
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);
182 } // namespace
184 UserMetricsRecorder::UserMetricsRecorder() {
185 StartTimer();
188 UserMetricsRecorder::UserMetricsRecorder(bool record_periodic_metrics) {
189 if (record_periodic_metrics)
190 StartTimer();
193 UserMetricsRecorder::~UserMetricsRecorder() {
194 timer_.Stop();
197 void UserMetricsRecorder::RecordUserMetricsAction(UserMetricsAction action) {
198 switch (action) {
199 case ash::UMA_ACCEL_KEYBOARD_BRIGHTNESS_DOWN_F6:
200 base::RecordAction(
201 base::UserMetricsAction("Accel_KeyboardBrightnessDown_F6"));
202 break;
203 case ash::UMA_ACCEL_KEYBOARD_BRIGHTNESS_UP_F7:
204 base::RecordAction(
205 base::UserMetricsAction("Accel_KeyboardBrightnessUp_F7"));
206 break;
207 case ash::UMA_ACCEL_LOCK_SCREEN_LOCK_BUTTON:
208 base::RecordAction(
209 base::UserMetricsAction("Accel_LockScreen_LockButton"));
210 break;
211 case ash::UMA_ACCEL_LOCK_SCREEN_POWER_BUTTON:
212 base::RecordAction(
213 base::UserMetricsAction("Accel_LockScreen_PowerButton"));
214 break;
215 case ash::UMA_ACCEL_MAXIMIZE_RESTORE_F4:
216 base::RecordAction(
217 base::UserMetricsAction("Accel_Maximize_Restore_F4"));
218 break;
219 case ash::UMA_ACCEL_PREVWINDOW_F5:
220 base::RecordAction(base::UserMetricsAction("Accel_PrevWindow_F5"));
221 break;
222 case ash::UMA_ACCEL_EXIT_FIRST_Q:
223 base::RecordAction(base::UserMetricsAction("Accel_Exit_First_Q"));
224 break;
225 case ash::UMA_ACCEL_EXIT_SECOND_Q:
226 base::RecordAction(base::UserMetricsAction("Accel_Exit_Second_Q"));
227 break;
228 case ash::UMA_ACCEL_RESTART_POWER_BUTTON:
229 base::RecordAction(
230 base::UserMetricsAction("Accel_Restart_PowerButton"));
231 break;
232 case ash::UMA_ACCEL_SHUT_DOWN_POWER_BUTTON:
233 base::RecordAction(
234 base::UserMetricsAction("Accel_ShutDown_PowerButton"));
235 break;
236 case ash::UMA_CLOSE_THROUGH_CONTEXT_MENU:
237 base::RecordAction(base::UserMetricsAction("CloseFromContextMenu"));
238 break;
239 case ash::UMA_DRAG_MAXIMIZE_LEFT:
240 base::RecordAction(base::UserMetricsAction("WindowDrag_MaximizeLeft"));
241 break;
242 case ash::UMA_DRAG_MAXIMIZE_RIGHT:
243 base::RecordAction(base::UserMetricsAction("WindowDrag_MaximizeRight"));
244 break;
245 case ash::UMA_GESTURE_OVERVIEW:
246 base::RecordAction(base::UserMetricsAction("Gesture_Overview"));
247 break;
248 case ash::UMA_LAUNCHER_BUTTON_PRESSED_WITH_MOUSE:
249 base::RecordAction(
250 base::UserMetricsAction("Launcher_ButtonPressed_Mouse"));
251 break;
252 case ash::UMA_LAUNCHER_BUTTON_PRESSED_WITH_TOUCH:
253 base::RecordAction(
254 base::UserMetricsAction("Launcher_ButtonPressed_Touch"));
255 break;
256 case ash::UMA_LAUNCHER_CLICK_ON_APP:
257 base::RecordAction(base::UserMetricsAction("Launcher_ClickOnApp"));
258 break;
259 case ash::UMA_LAUNCHER_CLICK_ON_APPLIST_BUTTON:
260 base::RecordAction(
261 base::UserMetricsAction("Launcher_ClickOnApplistButton"));
262 break;
263 case ash::UMA_LAUNCHER_LAUNCH_TASK:
264 base::RecordAction(base::UserMetricsAction("Launcher_LaunchTask"));
265 task_switch_metrics_recorder_.OnTaskSwitch(
266 TaskSwitchMetricsRecorder::kShelf);
267 break;
268 case ash::UMA_LAUNCHER_MINIMIZE_TASK:
269 base::RecordAction(base::UserMetricsAction("Launcher_MinimizeTask"));
270 break;
271 case ash::UMA_LAUNCHER_SWITCH_TASK:
272 base::RecordAction(base::UserMetricsAction("Launcher_SwitchTask"));
273 task_switch_metrics_recorder_.OnTaskSwitch(
274 TaskSwitchMetricsRecorder::kShelf);
275 break;
276 case UMA_MAXIMIZE_MODE_DISABLED:
277 base::RecordAction(base::UserMetricsAction("Touchview_Disabled"));
278 break;
279 case UMA_MAXIMIZE_MODE_ENABLED:
280 base::RecordAction(base::UserMetricsAction("Touchview_Enabled"));
281 break;
282 case UMA_MAXIMIZE_MODE_INITIALLY_DISABLED:
283 base::RecordAction(
284 base::UserMetricsAction("Touchview_Initially_Disabled"));
285 break;
286 case ash::UMA_MOUSE_DOWN:
287 base::RecordAction(base::UserMetricsAction("Mouse_Down"));
288 break;
289 case ash::UMA_PANEL_MINIMIZE_CAPTION_CLICK:
290 base::RecordAction(
291 base::UserMetricsAction("Panel_Minimize_Caption_Click"));
292 break;
293 case ash::UMA_PANEL_MINIMIZE_CAPTION_GESTURE:
294 base::RecordAction(
295 base::UserMetricsAction("Panel_Minimize_Caption_Gesture"));
296 break;
297 case ash::UMA_SHELF_ALIGNMENT_SET_BOTTOM:
298 base::RecordAction(
299 base::UserMetricsAction("Shelf_AlignmentSetBottom"));
300 break;
301 case ash::UMA_SHELF_ALIGNMENT_SET_LEFT:
302 base::RecordAction(
303 base::UserMetricsAction("Shelf_AlignmentSetLeft"));
304 break;
305 case ash::UMA_SHELF_ALIGNMENT_SET_RIGHT:
306 base::RecordAction(
307 base::UserMetricsAction("Shelf_AlignmentSetRight"));
308 break;
309 case ash::UMA_STATUS_AREA_AUDIO_CURRENT_INPUT_DEVICE:
310 base::RecordAction(
311 base::UserMetricsAction("StatusArea_Audio_CurrentInputDevice"));
312 break;
313 case ash::UMA_STATUS_AREA_AUDIO_CURRENT_OUTPUT_DEVICE:
314 base::RecordAction(
315 base::UserMetricsAction("StatusArea_Audio_CurrentOutputDevice"));
316 break;
317 case ash::UMA_STATUS_AREA_AUDIO_SWITCH_INPUT_DEVICE:
318 base::RecordAction(
319 base::UserMetricsAction("StatusArea_Audio_SwitchInputDevice"));
320 break;
321 case ash::UMA_STATUS_AREA_AUDIO_SWITCH_OUTPUT_DEVICE:
322 base::RecordAction(
323 base::UserMetricsAction("StatusArea_Audio_SwitchOutputDevice"));
324 break;
325 case ash::UMA_STATUS_AREA_BRIGHTNESS_CHANGED:
326 base::RecordAction(
327 base::UserMetricsAction("StatusArea_BrightnessChanged"));
328 break;
329 case ash::UMA_STATUS_AREA_BLUETOOTH_CONNECT_KNOWN_DEVICE:
330 base::RecordAction(
331 base::UserMetricsAction("StatusArea_Bluetooth_Connect_Known"));
332 break;
333 case ash::UMA_STATUS_AREA_BLUETOOTH_CONNECT_UNKNOWN_DEVICE:
334 base::RecordAction(
335 base::UserMetricsAction("StatusArea_Bluetooth_Connect_Unknown"));
336 break;
337 case ash::UMA_STATUS_AREA_BLUETOOTH_DISABLED:
338 base::RecordAction(
339 base::UserMetricsAction("StatusArea_Bluetooth_Disabled"));
340 break;
341 case ash::UMA_STATUS_AREA_BLUETOOTH_ENABLED:
342 base::RecordAction(
343 base::UserMetricsAction("StatusArea_Bluetooth_Enabled"));
344 break;
345 case ash::UMA_STATUS_AREA_CAPS_LOCK_DETAILED:
346 base::RecordAction(
347 base::UserMetricsAction("StatusArea_CapsLock_Detailed"));
348 break;
349 case ash::UMA_STATUS_AREA_CAPS_LOCK_DISABLED_BY_CLICK:
350 base::RecordAction(
351 base::UserMetricsAction("StatusArea_CapsLock_DisabledByClick"));
352 break;
353 case ash::UMA_STATUS_AREA_CAPS_LOCK_ENABLED_BY_CLICK:
354 base::RecordAction(
355 base::UserMetricsAction("StatusArea_CapsLock_EnabledByClick"));
356 break;
357 case ash::UMA_STATUS_AREA_CAPS_LOCK_POPUP:
358 base::RecordAction(
359 base::UserMetricsAction("StatusArea_CapsLock_Popup"));
360 break;
361 case ash::UMA_STATUS_AREA_CONNECT_TO_CONFIGURED_NETWORK:
362 base::RecordAction(
363 base::UserMetricsAction("StatusArea_Network_ConnectConfigured"));
364 break;
365 case ash::UMA_STATUS_AREA_CONNECT_TO_UNCONFIGURED_NETWORK:
366 base::RecordAction(
367 base::UserMetricsAction("StatusArea_Network_ConnectUnconfigured"));
368 break;
369 case ash::UMA_STATUS_AREA_CONNECT_TO_VPN:
370 base::RecordAction(
371 base::UserMetricsAction("StatusArea_VPN_ConnectToNetwork"));
372 break;
373 case ash::UMA_STATUS_AREA_CHANGED_VOLUME_MENU:
374 base::RecordAction(
375 base::UserMetricsAction("StatusArea_Volume_ChangedMenu"));
376 break;
377 case ash::UMA_STATUS_AREA_CHANGED_VOLUME_POPUP:
378 base::RecordAction(
379 base::UserMetricsAction("StatusArea_Volume_ChangedPopup"));
380 break;
381 case ash::UMA_STATUS_AREA_DETAILED_ACCESSABILITY:
382 base::RecordAction(
383 base::UserMetricsAction("StatusArea_Accessability_DetailedView"));
384 break;
385 case ash::UMA_STATUS_AREA_DETAILED_AUDIO_VIEW:
386 base::RecordAction(
387 base::UserMetricsAction("StatusArea_Audio_Detailed"));
388 break;
389 case ash::UMA_STATUS_AREA_DETAILED_BLUETOOTH_VIEW:
390 base::RecordAction(
391 base::UserMetricsAction("StatusArea_Bluetooth_Detailed"));
392 break;
393 case ash::UMA_STATUS_AREA_DETAILED_BRIGHTNESS_VIEW:
394 base::RecordAction(
395 base::UserMetricsAction("StatusArea_Brightness_Detailed"));
396 break;
397 case ash::UMA_STATUS_AREA_DETAILED_CAST_VIEW:
398 base::RecordAction(base::UserMetricsAction("StatusArea_Cast_Detailed"));
399 break;
400 case ash::UMA_STATUS_AREA_DETAILED_DRIVE_VIEW:
401 base::RecordAction(
402 base::UserMetricsAction("StatusArea_Drive_Detailed"));
403 break;
404 case ash::UMA_STATUS_AREA_DETAILED_NETWORK_VIEW:
405 base::RecordAction(
406 base::UserMetricsAction("StatusArea_Network_Detailed"));
407 break;
408 case ash::UMA_STATUS_AREA_DETAILED_VPN_VIEW:
409 base::RecordAction(
410 base::UserMetricsAction("StatusArea_VPN_Detailed"));
411 break;
412 case ash::UMA_STATUS_AREA_DISABLE_AUTO_CLICK:
413 base::RecordAction(
414 base::UserMetricsAction("StatusArea_AutoClickDisabled"));
415 break;
416 case ash::UMA_STATUS_AREA_DISABLE_HIGH_CONTRAST:
417 base::RecordAction(
418 base::UserMetricsAction("StatusArea_HighContrastDisabled"));
419 break;
420 case ash::UMA_STATUS_AREA_DISABLE_LARGE_CURSOR:
421 base::RecordAction(
422 base::UserMetricsAction("StatusArea_LargeCursorDisabled"));
423 break;
424 case ash::UMA_STATUS_AREA_DISABLE_MAGNIFIER:
425 base::RecordAction(
426 base::UserMetricsAction("StatusArea_MagnifierDisabled"));
427 break;
428 case ash::UMA_STATUS_AREA_DISABLE_SPOKEN_FEEDBACK:
429 base::RecordAction(
430 base::UserMetricsAction("StatusArea_SpokenFeedbackDisabled"));
431 break;
432 case ash::UMA_STATUS_AREA_DISABLE_VIRTUAL_KEYBOARD:
433 base::RecordAction(
434 base::UserMetricsAction("StatusArea_VirtualKeyboardDisabled"));
435 break;
436 case ash::UMA_STATUS_AREA_DISABLE_WIFI:
437 base::RecordAction(
438 base::UserMetricsAction("StatusArea_Network_WifiDisabled"));
439 break;
440 case ash::UMA_STATUS_AREA_DRIVE_CANCEL_OPERATION:
441 base::RecordAction(
442 base::UserMetricsAction("StatusArea_Drive_CancelOperation"));
443 break;
444 case ash::UMA_STATUS_AREA_DRIVE_SETTINGS:
445 base::RecordAction(
446 base::UserMetricsAction("StatusArea_Drive_Settings"));
447 break;
448 case ash::UMA_STATUS_AREA_ENABLE_AUTO_CLICK:
449 base::RecordAction(
450 base::UserMetricsAction("StatusArea_AutoClickEnabled"));
451 break;
452 case ash::UMA_STATUS_AREA_ENABLE_HIGH_CONTRAST:
453 base::RecordAction(
454 base::UserMetricsAction("StatusArea_HighContrastEnabled"));
455 break;
456 case ash::UMA_STATUS_AREA_ENABLE_LARGE_CURSOR:
457 base::RecordAction(
458 base::UserMetricsAction("StatusArea_LargeCursorEnabled"));
459 break;
460 case ash::UMA_STATUS_AREA_ENABLE_MAGNIFIER:
461 base::RecordAction(
462 base::UserMetricsAction("StatusArea_MagnifierEnabled"));
463 break;
464 case ash::UMA_STATUS_AREA_ENABLE_SPOKEN_FEEDBACK:
465 base::RecordAction(
466 base::UserMetricsAction("StatusArea_SpokenFeedbackEnabled"));
467 break;
468 case ash::UMA_STATUS_AREA_ENABLE_VIRTUAL_KEYBOARD:
469 base::RecordAction(
470 base::UserMetricsAction("StatusArea_VirtualKeyboardEnabled"));
471 break;
472 case ash::UMA_STATUS_AREA_ENABLE_WIFI:
473 base::RecordAction(
474 base::UserMetricsAction("StatusArea_Network_WifiEnabled"));
475 break;
476 case ash::UMA_STATUS_AREA_IME_SHOW_DETAILED:
477 base::RecordAction(
478 base::UserMetricsAction("StatusArea_IME_Detailed"));
479 break;
480 case ash::UMA_STATUS_AREA_IME_SWITCH_MODE:
481 base::RecordAction(
482 base::UserMetricsAction("StatusArea_IME_SwitchMode"));
483 break;
484 case ash::UMA_STATUS_AREA_MENU_OPENED:
485 base::RecordAction(
486 base::UserMetricsAction("StatusArea_MenuOpened"));
487 break;
488 case ash::UMA_STATUS_AREA_NETWORK_JOIN_OTHER_CLICKED:
489 base::RecordAction(
490 base::UserMetricsAction("StatusArea_Network_JoinOther"));
491 break;
492 case ash::UMA_STATUS_AREA_NETWORK_SETTINGS_CLICKED:
493 base::RecordAction(
494 base::UserMetricsAction("StatusArea_Network_Settings"));
495 break;
496 case ash::UMA_STATUS_AREA_SHOW_NETWORK_CONNECTION_DETAILS:
497 base::RecordAction(
498 base::UserMetricsAction("StatusArea_Network_ConnectionDetails"));
499 break;
500 case ash::UMA_STATUS_AREA_SHOW_VPN_CONNECTION_DETAILS:
501 base::RecordAction(
502 base::UserMetricsAction("StatusArea_VPN_ConnectionDetails"));
503 break;
504 case ash::UMA_STATUS_AREA_SIGN_OUT:
505 base::RecordAction(
506 base::UserMetricsAction("StatusArea_SignOut"));
507 break;
508 case ash::UMA_STATUS_AREA_VPN_ADD_BUILT_IN_CLICKED:
509 base::RecordAction(base::UserMetricsAction("StatusArea_VPN_AddBuiltIn"));
510 break;
511 case ash::UMA_STATUS_AREA_VPN_ADD_THIRD_PARTY_CLICKED:
512 base::RecordAction(
513 base::UserMetricsAction("StatusArea_VPN_AddThirdParty"));
514 break;
515 case ash::UMA_STATUS_AREA_VPN_DISCONNECT_CLICKED:
516 base::RecordAction(base::UserMetricsAction("StatusArea_VPN_Disconnect"));
517 break;
518 case ash::UMA_STATUS_AREA_VPN_SETTINGS_CLICKED:
519 base::RecordAction(
520 base::UserMetricsAction("StatusArea_VPN_Settings"));
521 break;
522 case ash::UMA_TOGGLE_MAXIMIZE_CAPTION_CLICK:
523 base::RecordAction(
524 base::UserMetricsAction("Caption_ClickTogglesMaximize"));
525 break;
526 case ash::UMA_TOGGLE_MAXIMIZE_CAPTION_GESTURE:
527 base::RecordAction(
528 base::UserMetricsAction("Caption_GestureTogglesMaximize"));
529 break;
530 case ash::UMA_TOGGLE_SINGLE_AXIS_MAXIMIZE_BORDER_CLICK:
531 base::RecordAction(
532 base::UserMetricsAction(
533 "WindowBorder_ClickTogglesSingleAxisMaximize"));
534 break;
535 case ash::UMA_TOUCHPAD_GESTURE_OVERVIEW:
536 base::RecordAction(
537 base::UserMetricsAction("Touchpad_Gesture_Overview"));
538 break;
539 case ash::UMA_TOUCHSCREEN_TAP_DOWN:
540 base::RecordAction(base::UserMetricsAction("Touchscreen_Down"));
541 break;
542 case ash::UMA_TRAY_HELP:
543 base::RecordAction(base::UserMetricsAction("Tray_Help"));
544 break;
545 case ash::UMA_TRAY_LOCK_SCREEN:
546 base::RecordAction(base::UserMetricsAction("Tray_LockScreen"));
547 break;
548 case ash::UMA_TRAY_OVERVIEW:
549 base::RecordAction(base::UserMetricsAction("Tray_Overview"));
550 break;
551 case ash::UMA_TRAY_SHUT_DOWN:
552 base::RecordAction(base::UserMetricsAction("Tray_ShutDown"));
553 break;
554 case ash::UMA_WINDOW_APP_CLOSE_BUTTON_CLICK:
555 base::RecordAction(base::UserMetricsAction("AppCloseButton_Clk"));
556 break;
557 case ash::UMA_WINDOW_CLOSE_BUTTON_CLICK:
558 base::RecordAction(base::UserMetricsAction("CloseButton_Clk"));
559 break;
560 case ash::UMA_WINDOW_MAXIMIZE_BUTTON_CLICK_EXIT_FULLSCREEN:
561 base::RecordAction(base::UserMetricsAction("MaxButton_Clk_ExitFS"));
562 break;
563 case ash::UMA_WINDOW_MAXIMIZE_BUTTON_CLICK_RESTORE:
564 base::RecordAction(
565 base::UserMetricsAction("MaxButton_Clk_Restore"));
566 break;
567 case ash::UMA_WINDOW_MAXIMIZE_BUTTON_CLICK_MAXIMIZE:
568 base::RecordAction(
569 base::UserMetricsAction("MaxButton_Clk_Maximize"));
570 break;
571 case ash::UMA_WINDOW_MAXIMIZE_BUTTON_CLICK_MINIMIZE:
572 base::RecordAction(base::UserMetricsAction("MinButton_Clk"));
573 break;
574 case ash::UMA_WINDOW_MAXIMIZE_BUTTON_MAXIMIZE_LEFT:
575 base::RecordAction(base::UserMetricsAction("MaxButton_MaxLeft"));
576 break;
577 case ash::UMA_WINDOW_MAXIMIZE_BUTTON_MAXIMIZE_RIGHT:
578 base::RecordAction(base::UserMetricsAction("MaxButton_MaxRight"));
579 break;
580 case ash::UMA_WINDOW_OVERVIEW:
581 base::RecordAction(
582 base::UserMetricsAction("WindowSelector_Overview"));
583 break;
584 case ash::UMA_WINDOW_OVERVIEW_ACTIVE_WINDOW_CHANGED:
585 base::RecordAction(
586 base::UserMetricsAction("WindowSelector_ActiveWindowChanged"));
587 task_switch_metrics_recorder_.OnTaskSwitch(
588 TaskSwitchMetricsRecorder::kOverviewMode);
589 break;
590 case ash::UMA_WINDOW_OVERVIEW_ENTER_KEY:
591 base::RecordAction(
592 base::UserMetricsAction("WindowSelector_OverviewEnterKey"));
593 break;
594 case ash::UMA_WINDOW_CYCLE:
595 base::RecordAction(
596 base::UserMetricsAction("WindowCycleController_Cycle"));
597 break;
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.
606 if (manager) {
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,
613 -1),
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
624 // active.
625 // TODO(bruthig): Consider tracking how long a particular type of window is
626 // active at a time.
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);
642 } // namespace ash