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

Side by Side Diff: chromeos/login/login_state.cc

Issue 23684033: Fix device policy recovery on CrOS login (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « chromeos/login/login_state.h ('k') | chromeos/login/login_state_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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "chromeos/login/login_state.h" 5 #include "chromeos/login/login_state.h"
6 6
7 #include "base/chromeos/chromeos_version.h" 7 #include "base/chromeos/chromeos_version.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "chromeos/chromeos_switches.h" 10 #include "chromeos/chromeos_switches.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 void LoginState::SetLoggedInState(LoggedInState state, 60 void LoginState::SetLoggedInState(LoggedInState state,
61 LoggedInUserType type) { 61 LoggedInUserType type) {
62 if (state == logged_in_state_ && type == logged_in_user_type_) 62 if (state == logged_in_state_ && type == logged_in_user_type_)
63 return; 63 return;
64 VLOG(1) << "LoggedInState: " << state << " UserType: " << type; 64 VLOG(1) << "LoggedInState: " << state << " UserType: " << type;
65 logged_in_state_ = state; 65 logged_in_state_ = state;
66 logged_in_user_type_ = type; 66 logged_in_user_type_ = type;
67 NotifyObservers(); 67 NotifyObservers();
68 } 68 }
69 69
70 LoginState::LoggedInState LoginState::GetLoggedInState() const {
71 if (AlwaysLoggedIn())
72 return LOGGED_IN_ACTIVE;
73 return logged_in_state_;
74 }
75
76 LoginState::LoggedInUserType LoginState::GetLoggedInUserType() const { 70 LoginState::LoggedInUserType LoginState::GetLoggedInUserType() const {
77 return logged_in_user_type_; 71 return logged_in_user_type_;
78 } 72 }
79 73
80 bool LoginState::IsUserLoggedIn() const { 74 bool LoginState::IsUserLoggedIn() const {
81 return GetLoggedInState() == LOGGED_IN_ACTIVE; 75 if (AlwaysLoggedIn())
76 return true;
77 return logged_in_state_ == LOGGED_IN_ACTIVE;
78 }
79
80 bool LoginState::IsInSafeMode() const {
81 DCHECK(!AlwaysLoggedIn() || logged_in_state_ != LOGGED_IN_SAFE_MODE);
82 return logged_in_state_ == LOGGED_IN_SAFE_MODE;
82 } 83 }
83 84
84 bool LoginState::IsGuestUser() const { 85 bool LoginState::IsGuestUser() const {
85 if (GetLoggedInState() != LOGGED_IN_ACTIVE) 86 if (!IsUserLoggedIn())
86 return false; 87 return false;
87 switch (logged_in_user_type_) { 88 switch (logged_in_user_type_) {
88 case LOGGED_IN_USER_NONE: 89 case LOGGED_IN_USER_NONE:
89 case LOGGED_IN_USER_REGULAR: 90 case LOGGED_IN_USER_REGULAR:
90 case LOGGED_IN_USER_OWNER: 91 case LOGGED_IN_USER_OWNER:
91 case LOGGED_IN_USER_LOCALLY_MANAGED: 92 case LOGGED_IN_USER_LOCALLY_MANAGED:
92 case LOGGED_IN_USER_KIOSK_APP: 93 case LOGGED_IN_USER_KIOSK_APP:
93 return false; 94 return false;
94 case LOGGED_IN_USER_GUEST: 95 case LOGGED_IN_USER_GUEST:
95 case LOGGED_IN_USER_RETAIL_MODE: 96 case LOGGED_IN_USER_RETAIL_MODE:
(...skipping 21 matching lines...) Expand all
117 118
118 LoginState::LoginState() : logged_in_state_(LOGGED_IN_OOBE), 119 LoginState::LoginState() : logged_in_state_(LOGGED_IN_OOBE),
119 logged_in_user_type_(LOGGED_IN_USER_NONE) { 120 logged_in_user_type_(LOGGED_IN_USER_NONE) {
120 } 121 }
121 122
122 LoginState::~LoginState() { 123 LoginState::~LoginState() {
123 } 124 }
124 125
125 void LoginState::NotifyObservers() { 126 void LoginState::NotifyObservers() {
126 FOR_EACH_OBSERVER(LoginState::Observer, observer_list_, 127 FOR_EACH_OBSERVER(LoginState::Observer, observer_list_,
127 LoggedInStateChanged(GetLoggedInState())); 128 LoggedInStateChanged());
128 } 129 }
129 130
130 } // namespace chromeos 131 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/login/login_state.h ('k') | chromeos/login/login_state_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698