Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1829)

Side by Side Diff: ash/metrics/user_metrics_recorder.cc

Issue 2826313002: cros: Use SessionController in UserMetricsRecorder to get login status (Closed)
Patch Set: review comments Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | ash/metrics/user_metrics_recorder_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 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/user_metrics_recorder.h" 5 #include "ash/metrics/user_metrics_recorder.h"
6 6
7 #include "ash/metrics/desktop_task_switch_metric_recorder.h" 7 #include "ash/metrics/desktop_task_switch_metric_recorder.h"
8 #include "ash/metrics/pointer_metrics_recorder.h" 8 #include "ash/metrics/pointer_metrics_recorder.h"
9 #include "ash/public/cpp/shelf_item.h" 9 #include "ash/public/cpp/shelf_item.h"
10 #include "ash/public/cpp/shell_window_ids.h" 10 #include "ash/public/cpp/shell_window_ids.h"
11 #include "ash/session/session_controller.h"
11 #include "ash/session/session_state_delegate.h" 12 #include "ash/session/session_state_delegate.h"
12 #include "ash/shelf/shelf_model.h" 13 #include "ash/shelf/shelf_model.h"
13 #include "ash/shelf/shelf_view.h" 14 #include "ash/shelf/shelf_view.h"
14 #include "ash/shelf/wm_shelf.h" 15 #include "ash/shelf/wm_shelf.h"
15 #include "ash/shell.h" 16 #include "ash/shell.h"
16 #include "ash/shell_port.h" 17 #include "ash/shell_port.h"
17 #include "ash/system/tray/system_tray_delegate.h"
18 #include "ash/wm/window_state.h" 18 #include "ash/wm/window_state.h"
19 #include "ash/wm/window_state_aura.h" 19 #include "ash/wm/window_state_aura.h"
20 #include "ash/wm_window.h" 20 #include "ash/wm_window.h"
21 #include "base/memory/ptr_util.h" 21 #include "base/memory/ptr_util.h"
22 #include "base/metrics/histogram_macros.h" 22 #include "base/metrics/histogram_macros.h"
23 #include "base/metrics/user_metrics.h" 23 #include "base/metrics/user_metrics.h"
24 #include "ui/aura/window.h" 24 #include "ui/aura/window.h"
25 25
26 namespace ash { 26 namespace ash {
27 27
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 // TODO: We probably want to recorde PINNED state. 72 // TODO: We probably want to recorde PINNED state.
73 active_window_state_type = ACTIVE_WINDOW_STATE_TYPE_OTHER; 73 active_window_state_type = ACTIVE_WINDOW_STATE_TYPE_OTHER;
74 break; 74 break;
75 } 75 }
76 } 76 }
77 return active_window_state_type; 77 return active_window_state_type;
78 } 78 }
79 79
80 // Returns true if kiosk mode is active. 80 // Returns true if kiosk mode is active.
81 bool IsKioskModeActive() { 81 bool IsKioskModeActive() {
82 return Shell::Get()->system_tray_delegate()->GetUserLoginStatus() == 82 return Shell::Get()->session_controller()->login_status() ==
83 LoginStatus::KIOSK_APP; 83 LoginStatus::KIOSK_APP;
84 } 84 }
85 85
86 // Returns true if ARC kiosk mode is active. 86 // Returns true if ARC kiosk mode is active.
87 bool IsArcKioskModeActive() { 87 bool IsArcKioskModeActive() {
88 return Shell::Get()->system_tray_delegate()->GetUserLoginStatus() == 88 return Shell::Get()->session_controller()->login_status() ==
89 LoginStatus::ARC_KIOSK_APP; 89 LoginStatus::ARC_KIOSK_APP;
90 } 90 }
91 91
92 // Returns true if there is an active user and their session isn't currently 92 // Returns true if there is an active user and their session isn't currently
93 // locked. 93 // locked.
94 bool IsUserActive() { 94 bool IsUserActive() {
95 switch (Shell::Get()->system_tray_delegate()->GetUserLoginStatus()) { 95 SessionController* session = Shell::Get()->session_controller();
96 case LoginStatus::NOT_LOGGED_IN: 96 return session->IsActiveUserSessionStarted() && !session->IsScreenLocked();
97 case LoginStatus::LOCKED:
98 return false;
99 case LoginStatus::USER:
100 case LoginStatus::OWNER:
101 case LoginStatus::GUEST:
102 case LoginStatus::PUBLIC:
103 case LoginStatus::SUPERVISED:
104 case LoginStatus::KIOSK_APP:
105 case LoginStatus::ARC_KIOSK_APP:
106 return true;
107 }
108 NOTREACHED();
109 return false;
110 } 97 }
111 98
112 // Array of window container ids that contain visible windows to be counted for 99 // Array of window container ids that contain visible windows to be counted for
113 // UMA statistics. Note the containers are ordered from top most visible 100 // UMA statistics. Note the containers are ordered from top most visible
114 // container to the lowest to allow the |GetNumVisibleWindows| method to short 101 // container to the lowest to allow the |GetNumVisibleWindows| method to short
115 // circuit when processing a maximized or fullscreen window. 102 // circuit when processing a maximized or fullscreen window.
116 int kVisibleWindowContainerIds[] = { 103 int kVisibleWindowContainerIds[] = {
117 kShellWindowId_PanelContainer, 104 kShellWindowId_PanelContainer,
118 kShellWindowId_AlwaysOnTopContainer, 105 kShellWindowId_AlwaysOnTopContainer,
119 kShellWindowId_DefaultContainer 106 kShellWindowId_DefaultContainer
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after
668 return IsUserActive() && !IsKioskModeActive() && !IsArcKioskModeActive(); 655 return IsUserActive() && !IsKioskModeActive() && !IsArcKioskModeActive();
669 } 656 }
670 657
671 void UserMetricsRecorder::StartTimer() { 658 void UserMetricsRecorder::StartTimer() {
672 timer_.Start(FROM_HERE, 659 timer_.Start(FROM_HERE,
673 base::TimeDelta::FromSeconds(kAshPeriodicMetricsTimeInSeconds), 660 base::TimeDelta::FromSeconds(kAshPeriodicMetricsTimeInSeconds),
674 this, &UserMetricsRecorder::RecordPeriodicMetrics); 661 this, &UserMetricsRecorder::RecordPeriodicMetrics);
675 } 662 }
676 663
677 } // namespace ash 664 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/metrics/user_metrics_recorder_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698