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

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

Issue 324463003: ChromeOS login webui refactoring : Simplify login methods. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 | Annotate | Revision Log
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 "chrome/browser/chromeos/login/auth/user_context.h" 5 #include "chrome/browser/chromeos/login/auth/user_context.h"
6 6
7 #include "chrome/browser/chromeos/login/helper.h" 7 #include "chrome/browser/chromeos/login/helper.h"
8 #include "chrome/browser/chromeos/login/users/user_manager.h" 8 #include "chrome/browser/chromeos/login/users/user_manager.h"
9 9
10 namespace chromeos { 10 namespace chromeos {
11 11
12 UserContext::UserContext() : is_using_oauth_(true), 12 UserContext::UserContext()
13 auth_flow_(AUTH_FLOW_OFFLINE) { 13 : is_using_oauth_(true),
14 auth_flow_(AUTH_FLOW_OFFLINE),
15 user_type_(User::USER_TYPE_REGULAR) {
14 } 16 }
15 17
16 UserContext::UserContext(const UserContext& other) 18 UserContext::UserContext(const UserContext& other)
17 : user_id_(other.user_id_), 19 : user_id_(other.user_id_),
18 key_(other.key_), 20 key_(other.key_),
19 auth_code_(other.auth_code_), 21 auth_code_(other.auth_code_),
20 user_id_hash_(other.user_id_hash_), 22 user_id_hash_(other.user_id_hash_),
21 is_using_oauth_(other.is_using_oauth_), 23 is_using_oauth_(other.is_using_oauth_),
22 auth_flow_(other.auth_flow_) { 24 auth_flow_(other.auth_flow_),
25 user_type_(other.user_type_) {
23 } 26 }
24 27
25 UserContext::UserContext(const std::string& user_id) 28 UserContext::UserContext(const std::string& user_id)
26 : user_id_(login::CanonicalizeUserID(user_id)), 29 : user_id_(login::CanonicalizeUserID(user_id)),
27 is_using_oauth_(true), 30 is_using_oauth_(true),
28 auth_flow_(AUTH_FLOW_OFFLINE) { 31 auth_flow_(AUTH_FLOW_OFFLINE),
32 user_type_(User::USER_TYPE_REGULAR) {
29 } 33 }
30 34
31 UserContext::~UserContext() { 35 UserContext::~UserContext() {
32 } 36 }
33 37
34 bool UserContext::operator==(const UserContext& context) const { 38 bool UserContext::operator==(const UserContext& context) const {
35 return context.user_id_ == user_id_ && 39 return context.user_id_ == user_id_ && context.key_ == key_ &&
36 context.key_ == key_ &&
37 context.auth_code_ == auth_code_ && 40 context.auth_code_ == auth_code_ &&
38 context.user_id_hash_ == user_id_hash_ && 41 context.user_id_hash_ == user_id_hash_ &&
39 context.is_using_oauth_ == is_using_oauth_ && 42 context.is_using_oauth_ == is_using_oauth_ &&
40 context.auth_flow_ == auth_flow_; 43 context.auth_flow_ == auth_flow_ && context.user_type_ == user_type_;
41 } 44 }
42 45
43 bool UserContext::operator!=(const UserContext& context) const { 46 bool UserContext::operator!=(const UserContext& context) const {
44 return !(*this == context); 47 return !(*this == context);
45 } 48 }
46 49
47 const std::string& UserContext::GetUserID() const { 50 const std::string& UserContext::GetUserID() const {
48 return user_id_; 51 return user_id_;
49 } 52 }
50 53
(...skipping 14 matching lines...) Expand all
65 } 68 }
66 69
67 bool UserContext::IsUsingOAuth() const { 70 bool UserContext::IsUsingOAuth() const {
68 return is_using_oauth_; 71 return is_using_oauth_;
69 } 72 }
70 73
71 UserContext::AuthFlow UserContext::GetAuthFlow() const { 74 UserContext::AuthFlow UserContext::GetAuthFlow() const {
72 return auth_flow_; 75 return auth_flow_;
73 } 76 }
74 77
78 User::UserType UserContext::GetUserType() const {
79 return user_type_;
80 }
81
75 bool UserContext::HasCredentials() const { 82 bool UserContext::HasCredentials() const {
76 return (!user_id_.empty() && !key_.GetSecret().empty()) || 83 return (!user_id_.empty() && !key_.GetSecret().empty()) ||
77 !auth_code_.empty(); 84 !auth_code_.empty();
78 } 85 }
79 86
80 void UserContext::SetUserID(const std::string& user_id) { 87 void UserContext::SetUserID(const std::string& user_id) {
81 user_id_ = login::CanonicalizeUserID(user_id); 88 user_id_ = login::CanonicalizeUserID(user_id);
82 } 89 }
83 90
84 void UserContext::SetKey(const Key& key) { 91 void UserContext::SetKey(const Key& key) {
85 key_ = key; 92 key_ = key;
86 } 93 }
87 94
88 void UserContext::SetAuthCode(const std::string& auth_code) { 95 void UserContext::SetAuthCode(const std::string& auth_code) {
89 auth_code_ = auth_code; 96 auth_code_ = auth_code;
90 } 97 }
91 98
92 void UserContext::SetUserIDHash(const std::string& user_id_hash) { 99 void UserContext::SetUserIDHash(const std::string& user_id_hash) {
93 user_id_hash_ = user_id_hash; 100 user_id_hash_ = user_id_hash;
94 } 101 }
95 102
96 void UserContext::SetIsUsingOAuth(bool is_using_oauth) { 103 void UserContext::SetIsUsingOAuth(bool is_using_oauth) {
97 is_using_oauth_ = is_using_oauth; 104 is_using_oauth_ = is_using_oauth;
98 } 105 }
99 106
100 void UserContext::SetAuthFlow(AuthFlow auth_flow) { 107 void UserContext::SetAuthFlow(AuthFlow auth_flow) {
101 auth_flow_ = auth_flow; 108 auth_flow_ = auth_flow;
102 } 109 }
103 110
111 void UserContext::SetUserType(User::UserType user_type) {
112 user_type_ = user_type;
113 }
114
104 void UserContext::ClearSecrets() { 115 void UserContext::ClearSecrets() {
105 key_.ClearSecret(); 116 key_.ClearSecret();
106 auth_code_.clear(); 117 auth_code_.clear();
107 } 118 }
108 119
109 } // namespace chromeos 120 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698