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 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 10 matching lines...) Expand all Loading... |
42 if (user_type_ == user_manager::USER_TYPE_REGULAR) | 43 if (user_type_ == user_manager::USER_TYPE_REGULAR) |
43 user_id_ = login::CanonicalizeUserID(user_id); | 44 user_id_ = login::CanonicalizeUserID(user_id); |
44 else | 45 else |
45 user_id_ = user_id; | 46 user_id_ = user_id; |
46 } | 47 } |
47 | 48 |
48 UserContext::~UserContext() { | 49 UserContext::~UserContext() { |
49 } | 50 } |
50 | 51 |
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_ && context.gaia_id_ == gaia_id_ && |
53 context.gaia_id_ == gaia_id_ && | 54 context.key_ == key_ && context.auth_code_ == auth_code_ && |
54 context.key_ == key_ && | 55 context.refresh_token_ == refresh_token_ && |
55 context.auth_code_ == auth_code_ && | 56 context.access_token_ == access_token_ && |
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_ && context.user_type_ == user_type_ && |
59 context.user_type_ == user_type_ && | |
60 context.public_session_locale_ == public_session_locale_ && | 60 context.public_session_locale_ == public_session_locale_ && |
61 context.public_session_input_method_ == public_session_input_method_; | 61 context.public_session_input_method_ == public_session_input_method_; |
62 } | 62 } |
63 | 63 |
64 bool UserContext::operator!=(const UserContext& context) const { | 64 bool UserContext::operator!=(const UserContext& context) const { |
65 return !(*this == context); | 65 return !(*this == context); |
66 } | 66 } |
67 | 67 |
68 const std::string& UserContext::GetUserID() const { | 68 const std::string& UserContext::GetUserID() const { |
69 return user_id_; | 69 return user_id_; |
(...skipping 12 matching lines...) Expand all Loading... |
82 } | 82 } |
83 | 83 |
84 const std::string& UserContext::GetAuthCode() const { | 84 const std::string& UserContext::GetAuthCode() const { |
85 return auth_code_; | 85 return auth_code_; |
86 } | 86 } |
87 | 87 |
88 const std::string& UserContext::GetRefreshToken() const { | 88 const std::string& UserContext::GetRefreshToken() const { |
89 return refresh_token_; | 89 return refresh_token_; |
90 } | 90 } |
91 | 91 |
| 92 const std::string& UserContext::GetAccessToken() const { |
| 93 return access_token_; |
| 94 } |
| 95 |
92 const std::string& UserContext::GetUserIDHash() const { | 96 const std::string& UserContext::GetUserIDHash() const { |
93 return user_id_hash_; | 97 return user_id_hash_; |
94 } | 98 } |
95 | 99 |
96 bool UserContext::IsUsingOAuth() const { | 100 bool UserContext::IsUsingOAuth() const { |
97 return is_using_oauth_; | 101 return is_using_oauth_; |
98 } | 102 } |
99 | 103 |
100 UserContext::AuthFlow UserContext::GetAuthFlow() const { | 104 UserContext::AuthFlow UserContext::GetAuthFlow() const { |
101 return auth_flow_; | 105 return auth_flow_; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 } | 139 } |
136 | 140 |
137 void UserContext::SetAuthCode(const std::string& auth_code) { | 141 void UserContext::SetAuthCode(const std::string& auth_code) { |
138 auth_code_ = auth_code; | 142 auth_code_ = auth_code; |
139 } | 143 } |
140 | 144 |
141 void UserContext::SetRefreshToken(const std::string& refresh_token) { | 145 void UserContext::SetRefreshToken(const std::string& refresh_token) { |
142 refresh_token_ = refresh_token; | 146 refresh_token_ = refresh_token; |
143 } | 147 } |
144 | 148 |
| 149 void UserContext::SetAccessToken(const std::string& access_token) { |
| 150 access_token_ = access_token; |
| 151 } |
| 152 |
145 void UserContext::SetUserIDHash(const std::string& user_id_hash) { | 153 void UserContext::SetUserIDHash(const std::string& user_id_hash) { |
146 user_id_hash_ = user_id_hash; | 154 user_id_hash_ = user_id_hash; |
147 } | 155 } |
148 | 156 |
149 void UserContext::SetIsUsingOAuth(bool is_using_oauth) { | 157 void UserContext::SetIsUsingOAuth(bool is_using_oauth) { |
150 is_using_oauth_ = is_using_oauth; | 158 is_using_oauth_ = is_using_oauth; |
151 } | 159 } |
152 | 160 |
153 void UserContext::SetAuthFlow(AuthFlow auth_flow) { | 161 void UserContext::SetAuthFlow(AuthFlow auth_flow) { |
154 auth_flow_ = auth_flow; | 162 auth_flow_ = auth_flow; |
(...skipping 15 matching lines...) Expand all Loading... |
170 device_id_ = device_id; | 178 device_id_ = device_id; |
171 } | 179 } |
172 | 180 |
173 void UserContext::ClearSecrets() { | 181 void UserContext::ClearSecrets() { |
174 key_.ClearSecret(); | 182 key_.ClearSecret(); |
175 auth_code_.clear(); | 183 auth_code_.clear(); |
176 refresh_token_.clear(); | 184 refresh_token_.clear(); |
177 } | 185 } |
178 | 186 |
179 } // namespace chromeos | 187 } // namespace chromeos |
OLD | NEW |