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

Side by Side Diff: chromeos/login/auth/user_context.cc

Issue 1412813003: This CL replaces user_manager::UserID with AccountId. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@468875--Chrome-OS-handles-deletion-of-Gmail-account-poorly--Create-AccountID-structure-part2--user_names
Patch Set: Fix Win GN build. Created 5 years, 1 month 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 | « chromeos/login/auth/user_context.h ('k') | components/user_manager.gypi » ('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 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() : account_id_(EmptyAccountId()) {}
11 : is_using_oauth_(true),
12 auth_flow_(AUTH_FLOW_OFFLINE),
13 user_type_(user_manager::USER_TYPE_REGULAR) {
14 }
15 11
16 UserContext::UserContext(const UserContext& other) 12 UserContext::UserContext(const UserContext& other)
17 : user_id_(other.user_id_), 13 : account_id_(other.account_id_),
18 gaia_id_(other.gaia_id_), 14 gaia_id_(other.gaia_id_),
19 key_(other.key_), 15 key_(other.key_),
20 auth_code_(other.auth_code_), 16 auth_code_(other.auth_code_),
21 refresh_token_(other.refresh_token_), 17 refresh_token_(other.refresh_token_),
22 access_token_(other.access_token_), 18 access_token_(other.access_token_),
23 user_id_hash_(other.user_id_hash_), 19 user_id_hash_(other.user_id_hash_),
24 is_using_oauth_(other.is_using_oauth_), 20 is_using_oauth_(other.is_using_oauth_),
25 auth_flow_(other.auth_flow_), 21 auth_flow_(other.auth_flow_),
26 user_type_(other.user_type_), 22 user_type_(other.user_type_),
27 public_session_locale_(other.public_session_locale_), 23 public_session_locale_(other.public_session_locale_),
28 public_session_input_method_(other.public_session_input_method_), 24 public_session_input_method_(other.public_session_input_method_),
29 device_id_(other.device_id_), 25 device_id_(other.device_id_),
30 gaps_cookie_(other.gaps_cookie_) { 26 gaps_cookie_(other.gaps_cookie_) {}
31 }
32 27
33 UserContext::UserContext(const std::string& user_id) 28 UserContext::UserContext(const AccountId& account_id)
34 : user_id_(login::CanonicalizeUserID(user_id)), 29 : account_id_(account_id) {
35 is_using_oauth_(true), 30 account_id_.SetUserEmail(
36 auth_flow_(AUTH_FLOW_OFFLINE), 31 login::CanonicalizeUserID(account_id.GetUserEmail()));
37 user_type_(user_manager::USER_TYPE_REGULAR) {
38 } 32 }
39 33
40 UserContext::UserContext(user_manager::UserType user_type, 34 UserContext::UserContext(user_manager::UserType user_type,
41 const std::string& user_id) 35 const std::string& user_id)
42 : is_using_oauth_(true), 36 : account_id_(EmptyAccountId()), user_type_(user_type) {
43 auth_flow_(AUTH_FLOW_OFFLINE),
44 user_type_(user_type) {
45 if (user_type_ == user_manager::USER_TYPE_REGULAR) 37 if (user_type_ == user_manager::USER_TYPE_REGULAR)
46 user_id_ = login::CanonicalizeUserID(user_id); 38 account_id_ = AccountId::FromUserEmail(login::CanonicalizeUserID(user_id));
47 else 39 else
48 user_id_ = user_id; 40 account_id_ = AccountId::FromUserEmail(user_id);
49 } 41 }
50 42
51 UserContext::~UserContext() { 43 UserContext::~UserContext() {
52 } 44 }
53 45
54 bool UserContext::operator==(const UserContext& context) const { 46 bool UserContext::operator==(const UserContext& context) const {
55 return context.user_id_ == user_id_ && context.gaia_id_ == gaia_id_ && 47 return context.account_id_ == account_id_ && context.gaia_id_ == gaia_id_ &&
56 context.key_ == key_ && context.auth_code_ == auth_code_ && 48 context.key_ == key_ && context.auth_code_ == auth_code_ &&
57 context.refresh_token_ == refresh_token_ && 49 context.refresh_token_ == refresh_token_ &&
58 context.access_token_ == access_token_ && 50 context.access_token_ == access_token_ &&
59 context.user_id_hash_ == user_id_hash_ && 51 context.user_id_hash_ == user_id_hash_ &&
60 context.is_using_oauth_ == is_using_oauth_ && 52 context.is_using_oauth_ == is_using_oauth_ &&
61 context.auth_flow_ == auth_flow_ && context.user_type_ == user_type_ && 53 context.auth_flow_ == auth_flow_ && context.user_type_ == user_type_ &&
62 context.public_session_locale_ == public_session_locale_ && 54 context.public_session_locale_ == public_session_locale_ &&
63 context.public_session_input_method_ == public_session_input_method_; 55 context.public_session_input_method_ == public_session_input_method_;
64 } 56 }
65 57
66 bool UserContext::operator!=(const UserContext& context) const { 58 bool UserContext::operator!=(const UserContext& context) const {
67 return !(*this == context); 59 return !(*this == context);
68 } 60 }
69 61
70 const std::string& UserContext::GetUserID() const { 62 const AccountId& UserContext::GetAccountId() const {
71 return user_id_; 63 return account_id_;
72 } 64 }
73 65
74 const std::string& UserContext::GetGaiaID() const { 66 const std::string& UserContext::GetGaiaID() const {
75 return gaia_id_; 67 return gaia_id_;
76 } 68 }
77 69
78 const Key* UserContext::GetKey() const { 70 const Key* UserContext::GetKey() const {
79 return &key_; 71 return &key_;
80 } 72 }
81 73
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 113
122 const std::string& UserContext::GetDeviceId() const { 114 const std::string& UserContext::GetDeviceId() const {
123 return device_id_; 115 return device_id_;
124 } 116 }
125 117
126 const std::string& UserContext::GetGAPSCookie() const { 118 const std::string& UserContext::GetGAPSCookie() const {
127 return gaps_cookie_; 119 return gaps_cookie_;
128 } 120 }
129 121
130 bool UserContext::HasCredentials() const { 122 bool UserContext::HasCredentials() const {
131 return (!user_id_.empty() && !key_.GetSecret().empty()) || 123 return (account_id_.is_valid() && !key_.GetSecret().empty()) ||
132 !auth_code_.empty(); 124 !auth_code_.empty();
133 } 125 }
134 126
135 void UserContext::SetUserID(const std::string& user_id) { 127 void UserContext::SetUserID(const std::string& user_id) {
136 user_id_ = login::CanonicalizeUserID(user_id); 128 account_id_ = AccountId::FromUserEmail(login::CanonicalizeUserID(user_id));
137 } 129 }
138 130
139 void UserContext::SetGaiaID(const std::string& gaia_id) { 131 void UserContext::SetGaiaID(const std::string& gaia_id) {
140 gaia_id_ = gaia_id; 132 gaia_id_ = gaia_id;
141 } 133 }
142 134
143 void UserContext::SetKey(const Key& key) { 135 void UserContext::SetKey(const Key& key) {
144 key_ = key; 136 key_ = key;
145 } 137 }
146 138
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 gaps_cookie_ = gaps_cookie; 180 gaps_cookie_ = gaps_cookie;
189 } 181 }
190 182
191 void UserContext::ClearSecrets() { 183 void UserContext::ClearSecrets() {
192 key_.ClearSecret(); 184 key_.ClearSecret();
193 auth_code_.clear(); 185 auth_code_.clear();
194 refresh_token_.clear(); 186 refresh_token_.clear();
195 } 187 }
196 188
197 } // namespace chromeos 189 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/login/auth/user_context.h ('k') | components/user_manager.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698