Chromium Code Reviews| Index: chrome/browser/chromeos/login/auth/user_context.cc |
| diff --git a/chrome/browser/chromeos/login/auth/user_context.cc b/chrome/browser/chromeos/login/auth/user_context.cc |
| index 8236565101217e3f864bc16f19b18810ee7d4298..f5d763f00cce981d6666f4deeda506ad7a4917ae 100644 |
| --- a/chrome/browser/chromeos/login/auth/user_context.cc |
| +++ b/chrome/browser/chromeos/login/auth/user_context.cc |
| @@ -9,8 +9,10 @@ |
| namespace chromeos { |
| -UserContext::UserContext() : is_using_oauth_(true), |
| - auth_flow_(AUTH_FLOW_OFFLINE) { |
| +UserContext::UserContext() |
| + : is_using_oauth_(true), |
| + auth_flow_(AUTH_FLOW_OFFLINE), |
| + user_type_(User::USER_TYPE_REGULAR) { |
| } |
| UserContext::UserContext(const UserContext& other) |
| @@ -19,25 +21,39 @@ UserContext::UserContext(const UserContext& other) |
| auth_code_(other.auth_code_), |
| user_id_hash_(other.user_id_hash_), |
| is_using_oauth_(other.is_using_oauth_), |
| - auth_flow_(other.auth_flow_) { |
| + auth_flow_(other.auth_flow_), |
| + user_type_(other.user_type_) { |
| } |
| UserContext::UserContext(const std::string& user_id) |
| : user_id_(login::CanonicalizeUserID(user_id)), |
| is_using_oauth_(true), |
| - auth_flow_(AUTH_FLOW_OFFLINE) { |
| + auth_flow_(AUTH_FLOW_OFFLINE), |
| + user_type_(User::USER_TYPE_REGULAR) { |
| +} |
| + |
| +UserContext::UserContext(User::UserType user_type, const std::string& user_id) |
| + : is_using_oauth_(true), |
| + auth_flow_(AUTH_FLOW_OFFLINE), |
| + user_type_(user_type) { |
| + if (user_type_ == User::USER_TYPE_GUEST || |
| + user_type_ == User::USER_TYPE_RETAIL_MODE || |
| + user_type_ == User::USER_TYPE_KIOSK_APP) { |
|
Nikita (slow)
2014/06/11 14:05:14
nit: I think SUPERVISED user should be here as wel
|
| + user_id_ = user_id; |
| + } else { |
| + user_id_ = login::CanonicalizeUserID(user_id); |
| + } |
| } |
| UserContext::~UserContext() { |
| } |
| bool UserContext::operator==(const UserContext& context) const { |
| - return context.user_id_ == user_id_ && |
| - context.key_ == key_ && |
| + return context.user_id_ == user_id_ && context.key_ == key_ && |
| context.auth_code_ == auth_code_ && |
| context.user_id_hash_ == user_id_hash_ && |
| context.is_using_oauth_ == is_using_oauth_ && |
| - context.auth_flow_ == auth_flow_; |
| + context.auth_flow_ == auth_flow_ && context.user_type_ == user_type_; |
| } |
| bool UserContext::operator!=(const UserContext& context) const { |
| @@ -72,6 +88,10 @@ UserContext::AuthFlow UserContext::GetAuthFlow() const { |
| return auth_flow_; |
| } |
| +User::UserType UserContext::GetUserType() const { |
| + return user_type_; |
| +} |
| + |
| bool UserContext::HasCredentials() const { |
| return (!user_id_.empty() && !key_.GetSecret().empty()) || |
| !auth_code_.empty(); |
| @@ -101,6 +121,10 @@ void UserContext::SetAuthFlow(AuthFlow auth_flow) { |
| auth_flow_ = auth_flow; |
| } |
| +void UserContext::SetUserType(User::UserType user_type) { |
| + user_type_ = user_type; |
| +} |
| + |
| void UserContext::ClearSecrets() { |
| key_.ClearSecret(); |
| auth_code_.clear(); |