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

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

Issue 1097663003: Fetch OAuth2 tokens prior to profile creation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: set up default networks Created 5 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
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()
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 gaia_id_(other.gaia_id_),
19 key_(other.key_), 19 key_(other.key_),
20 auth_code_(other.auth_code_), 20 auth_code_(other.auth_code_),
21 refresh_token_(other.refresh_token_), 21 refresh_token_(other.refresh_token_),
22 access_token_(other.access_token_),
22 user_id_hash_(other.user_id_hash_), 23 user_id_hash_(other.user_id_hash_),
23 is_using_oauth_(other.is_using_oauth_), 24 is_using_oauth_(other.is_using_oauth_),
24 auth_flow_(other.auth_flow_), 25 auth_flow_(other.auth_flow_),
25 user_type_(other.user_type_), 26 user_type_(other.user_type_),
26 public_session_locale_(other.public_session_locale_), 27 public_session_locale_(other.public_session_locale_),
27 public_session_input_method_(other.public_session_input_method_) { 28 public_session_input_method_(other.public_session_input_method_) {
28 } 29 }
29 30
30 UserContext::UserContext(const std::string& user_id) 31 UserContext::UserContext(const std::string& user_id)
31 : user_id_(login::CanonicalizeUserID(user_id)), 32 : user_id_(login::CanonicalizeUserID(user_id)),
(...skipping 19 matching lines...) Expand all
51 bool UserContext::operator==(const UserContext& context) const { 52 bool UserContext::operator==(const UserContext& context) const {
52 return context.user_id_ == user_id_ && 53 return context.user_id_ == user_id_ &&
53 context.gaia_id_ == gaia_id_ && 54 context.gaia_id_ == gaia_id_ &&
54 context.key_ == key_ && 55 context.key_ == key_ &&
55 context.auth_code_ == auth_code_ && 56 context.auth_code_ == auth_code_ &&
56 context.user_id_hash_ == user_id_hash_ && 57 context.user_id_hash_ == user_id_hash_ &&
57 context.is_using_oauth_ == is_using_oauth_ && 58 context.is_using_oauth_ == is_using_oauth_ &&
58 context.auth_flow_ == auth_flow_ && 59 context.auth_flow_ == auth_flow_ &&
59 context.user_type_ == user_type_ && 60 context.user_type_ == user_type_ &&
60 context.public_session_locale_ == public_session_locale_ && 61 context.public_session_locale_ == public_session_locale_ &&
61 context.public_session_input_method_ == public_session_input_method_; 62 context.public_session_input_method_ == public_session_input_method_;
xiyuan 2015/04/23 16:09:23 nit: Update this to include access_token_ and refr
achuithb 2015/04/23 22:11:16 Done. Sorry for the oversight!
62 } 63 }
63 64
64 bool UserContext::operator!=(const UserContext& context) const { 65 bool UserContext::operator!=(const UserContext& context) const {
65 return !(*this == context); 66 return !(*this == context);
66 } 67 }
67 68
68 const std::string& UserContext::GetUserID() const { 69 const std::string& UserContext::GetUserID() const {
69 return user_id_; 70 return user_id_;
70 } 71 }
71 72
(...skipping 10 matching lines...) Expand all
82 } 83 }
83 84
84 const std::string& UserContext::GetAuthCode() const { 85 const std::string& UserContext::GetAuthCode() const {
85 return auth_code_; 86 return auth_code_;
86 } 87 }
87 88
88 const std::string& UserContext::GetRefreshToken() const { 89 const std::string& UserContext::GetRefreshToken() const {
89 return refresh_token_; 90 return refresh_token_;
90 } 91 }
91 92
93 const std::string& UserContext::GetAccessToken() const {
94 return access_token_;
95 }
96
92 const std::string& UserContext::GetUserIDHash() const { 97 const std::string& UserContext::GetUserIDHash() const {
93 return user_id_hash_; 98 return user_id_hash_;
94 } 99 }
95 100
96 bool UserContext::IsUsingOAuth() const { 101 bool UserContext::IsUsingOAuth() const {
97 return is_using_oauth_; 102 return is_using_oauth_;
98 } 103 }
99 104
100 UserContext::AuthFlow UserContext::GetAuthFlow() const { 105 UserContext::AuthFlow UserContext::GetAuthFlow() const {
101 return auth_flow_; 106 return auth_flow_;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 } 140 }
136 141
137 void UserContext::SetAuthCode(const std::string& auth_code) { 142 void UserContext::SetAuthCode(const std::string& auth_code) {
138 auth_code_ = auth_code; 143 auth_code_ = auth_code;
139 } 144 }
140 145
141 void UserContext::SetRefreshToken(const std::string& refresh_token) { 146 void UserContext::SetRefreshToken(const std::string& refresh_token) {
142 refresh_token_ = refresh_token; 147 refresh_token_ = refresh_token;
143 } 148 }
144 149
150 void UserContext::SetAccessToken(const std::string& access_token) {
151 access_token_ = access_token;
152 }
153
145 void UserContext::SetUserIDHash(const std::string& user_id_hash) { 154 void UserContext::SetUserIDHash(const std::string& user_id_hash) {
146 user_id_hash_ = user_id_hash; 155 user_id_hash_ = user_id_hash;
147 } 156 }
148 157
149 void UserContext::SetIsUsingOAuth(bool is_using_oauth) { 158 void UserContext::SetIsUsingOAuth(bool is_using_oauth) {
150 is_using_oauth_ = is_using_oauth; 159 is_using_oauth_ = is_using_oauth;
151 } 160 }
152 161
153 void UserContext::SetAuthFlow(AuthFlow auth_flow) { 162 void UserContext::SetAuthFlow(AuthFlow auth_flow) {
154 auth_flow_ = auth_flow; 163 auth_flow_ = auth_flow;
(...skipping 15 matching lines...) Expand all
170 device_id_ = device_id; 179 device_id_ = device_id;
171 } 180 }
172 181
173 void UserContext::ClearSecrets() { 182 void UserContext::ClearSecrets() {
174 key_.ClearSecret(); 183 key_.ClearSecret();
175 auth_code_.clear(); 184 auth_code_.clear();
176 refresh_token_.clear(); 185 refresh_token_.clear();
177 } 186 }
178 187
179 } // namespace chromeos 188 } // namespace chromeos
OLDNEW
« chromeos/login/auth/user_context.h ('K') | « chromeos/login/auth/user_context.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698