| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/auth/user_context.h" | 5 #include "chromeos/login/auth/user_context.h" |
| 6 #include "chromeos/login/user_names.h" | 6 #include "chromeos/login/user_names.h" |
| 7 | 7 |
| 8 namespace chromeos { | 8 namespace chromeos { |
| 9 | 9 |
| 10 UserContext::UserContext() | 10 UserContext::UserContext() |
| 11 : is_using_oauth_(true), | 11 : is_using_oauth_(true), |
| 12 auth_flow_(AUTH_FLOW_OFFLINE), | 12 auth_flow_(AUTH_FLOW_OFFLINE), |
| 13 user_type_(user_manager::USER_TYPE_REGULAR) { | 13 user_type_(user_manager::USER_TYPE_REGULAR) { |
| 14 } | 14 } |
| 15 | 15 |
| 16 UserContext::UserContext(const UserContext& other) | 16 UserContext::UserContext(const UserContext& other) |
| 17 : user_id_(other.user_id_), | 17 : user_id_(other.user_id_), |
| 18 gaia_id_(other.gaia_id_), |
| 18 key_(other.key_), | 19 key_(other.key_), |
| 19 auth_code_(other.auth_code_), | 20 auth_code_(other.auth_code_), |
| 20 user_id_hash_(other.user_id_hash_), | 21 user_id_hash_(other.user_id_hash_), |
| 21 is_using_oauth_(other.is_using_oauth_), | 22 is_using_oauth_(other.is_using_oauth_), |
| 22 auth_flow_(other.auth_flow_), | 23 auth_flow_(other.auth_flow_), |
| 23 user_type_(other.user_type_), | 24 user_type_(other.user_type_), |
| 24 public_session_locale_(other.public_session_locale_), | 25 public_session_locale_(other.public_session_locale_), |
| 25 public_session_input_method_(other.public_session_input_method_) { | 26 public_session_input_method_(other.public_session_input_method_) { |
| 26 } | 27 } |
| 27 | 28 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 41 user_id_ = login::CanonicalizeUserID(user_id); | 42 user_id_ = login::CanonicalizeUserID(user_id); |
| 42 else | 43 else |
| 43 user_id_ = user_id; | 44 user_id_ = user_id; |
| 44 } | 45 } |
| 45 | 46 |
| 46 UserContext::~UserContext() { | 47 UserContext::~UserContext() { |
| 47 } | 48 } |
| 48 | 49 |
| 49 bool UserContext::operator==(const UserContext& context) const { | 50 bool UserContext::operator==(const UserContext& context) const { |
| 50 return context.user_id_ == user_id_ && | 51 return context.user_id_ == user_id_ && |
| 52 context.gaia_id_ == gaia_id_ && |
| 51 context.key_ == key_ && | 53 context.key_ == key_ && |
| 52 context.auth_code_ == auth_code_ && | 54 context.auth_code_ == auth_code_ && |
| 53 context.user_id_hash_ == user_id_hash_ && | 55 context.user_id_hash_ == user_id_hash_ && |
| 54 context.is_using_oauth_ == is_using_oauth_ && | 56 context.is_using_oauth_ == is_using_oauth_ && |
| 55 context.auth_flow_ == auth_flow_ && | 57 context.auth_flow_ == auth_flow_ && |
| 56 context.user_type_ == user_type_ && | 58 context.user_type_ == user_type_ && |
| 57 context.public_session_locale_ == public_session_locale_ && | 59 context.public_session_locale_ == public_session_locale_ && |
| 58 context.public_session_input_method_ == public_session_input_method_; | 60 context.public_session_input_method_ == public_session_input_method_; |
| 59 } | 61 } |
| 60 | 62 |
| 61 bool UserContext::operator!=(const UserContext& context) const { | 63 bool UserContext::operator!=(const UserContext& context) const { |
| 62 return !(*this == context); | 64 return !(*this == context); |
| 63 } | 65 } |
| 64 | 66 |
| 65 const std::string& UserContext::GetUserID() const { | 67 const std::string& UserContext::GetUserID() const { |
| 66 return user_id_; | 68 return user_id_; |
| 67 } | 69 } |
| 68 | 70 |
| 71 const std::string& UserContext::GetGaiaID() const { |
| 72 return gaia_id_; |
| 73 } |
| 74 |
| 69 const Key* UserContext::GetKey() const { | 75 const Key* UserContext::GetKey() const { |
| 70 return &key_; | 76 return &key_; |
| 71 } | 77 } |
| 72 | 78 |
| 73 Key* UserContext::GetKey() { | 79 Key* UserContext::GetKey() { |
| 74 return &key_; | 80 return &key_; |
| 75 } | 81 } |
| 76 | 82 |
| 77 const std::string& UserContext::GetAuthCode() const { | 83 const std::string& UserContext::GetAuthCode() const { |
| 78 return auth_code_; | 84 return auth_code_; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 104 | 110 |
| 105 bool UserContext::HasCredentials() const { | 111 bool UserContext::HasCredentials() const { |
| 106 return (!user_id_.empty() && !key_.GetSecret().empty()) || | 112 return (!user_id_.empty() && !key_.GetSecret().empty()) || |
| 107 !auth_code_.empty(); | 113 !auth_code_.empty(); |
| 108 } | 114 } |
| 109 | 115 |
| 110 void UserContext::SetUserID(const std::string& user_id) { | 116 void UserContext::SetUserID(const std::string& user_id) { |
| 111 user_id_ = login::CanonicalizeUserID(user_id); | 117 user_id_ = login::CanonicalizeUserID(user_id); |
| 112 } | 118 } |
| 113 | 119 |
| 120 void UserContext::SetGaiaID(const std::string& gaia_id) { |
| 121 gaia_id_ = gaia_id; |
| 122 } |
| 123 |
| 114 void UserContext::SetKey(const Key& key) { | 124 void UserContext::SetKey(const Key& key) { |
| 115 key_ = key; | 125 key_ = key; |
| 116 } | 126 } |
| 117 | 127 |
| 118 void UserContext::SetAuthCode(const std::string& auth_code) { | 128 void UserContext::SetAuthCode(const std::string& auth_code) { |
| 119 auth_code_ = auth_code; | 129 auth_code_ = auth_code; |
| 120 } | 130 } |
| 121 | 131 |
| 122 void UserContext::SetUserIDHash(const std::string& user_id_hash) { | 132 void UserContext::SetUserIDHash(const std::string& user_id_hash) { |
| 123 user_id_hash_ = user_id_hash; | 133 user_id_hash_ = user_id_hash; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 142 void UserContext::SetPublicSessionInputMethod(const std::string& input_method) { | 152 void UserContext::SetPublicSessionInputMethod(const std::string& input_method) { |
| 143 public_session_input_method_ = input_method; | 153 public_session_input_method_ = input_method; |
| 144 } | 154 } |
| 145 | 155 |
| 146 void UserContext::ClearSecrets() { | 156 void UserContext::ClearSecrets() { |
| 147 key_.ClearSecret(); | 157 key_.ClearSecret(); |
| 148 auth_code_.clear(); | 158 auth_code_.clear(); |
| 149 } | 159 } |
| 150 | 160 |
| 151 } // namespace chromeos | 161 } // namespace chromeos |
| OLD | NEW |