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

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

Issue 290513003: Move UserContext to its own file (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased. Created 6 years, 7 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/chromeos/login/auth/user_context.h"
6
7 #include "chrome/browser/chromeos/login/helper.h"
8 #include "chrome/browser/chromeos/login/users/user_manager.h"
9
10 namespace chromeos {
11
12 UserContext::UserContext() : does_need_password_hashing_(true),
13 is_using_oauth_(true),
14 auth_flow_(AUTH_FLOW_OFFLINE) {
15 }
16
17 UserContext::UserContext(const UserContext& other)
18 : user_id_(other.user_id_),
19 password_(other.password_),
20 does_need_password_hashing_(other.does_need_password_hashing_),
21 key_label_(other.key_label_),
22 auth_code_(other.auth_code_),
23 user_id_hash_(other.user_id_hash_),
24 is_using_oauth_(other.is_using_oauth_),
25 auth_flow_(other.auth_flow_) {
26 }
27
28 UserContext::UserContext(const std::string& user_id)
29 : user_id_(login::CanonicalizeUserID(user_id)),
30 does_need_password_hashing_(true),
31 is_using_oauth_(true),
32 auth_flow_(AUTH_FLOW_OFFLINE) {
33 }
34
35 UserContext::~UserContext() {
36 }
37
38 bool UserContext::operator==(const UserContext& context) const {
39 return context.user_id_ == user_id_ &&
40 context.password_ == password_ &&
41 context.does_need_password_hashing_ == does_need_password_hashing_ &&
42 context.key_label_ == key_label_ &&
43 context.auth_code_ == auth_code_ &&
44 context.user_id_hash_ == user_id_hash_ &&
45 context.is_using_oauth_ == is_using_oauth_ &&
46 context.auth_flow_ == auth_flow_;
47 }
48
49 const std::string& UserContext::GetUserID() const {
50 return user_id_;
51 }
52
53 const std::string& UserContext::GetPassword() const {
54 return password_;
55 }
56
57 bool UserContext::DoesNeedPasswordHashing() const {
58 return does_need_password_hashing_;
59 }
60
61 const std::string& UserContext::GetKeyLabel() const {
62 return key_label_;
63 }
64
65 const std::string& UserContext::GetAuthCode() const {
66 return auth_code_;
67 }
68
69 const std::string& UserContext::GetUserIDHash() const {
70 return user_id_hash_;
71 }
72
73 bool UserContext::IsUsingOAuth() const {
74 return is_using_oauth_;
75 }
76
77 UserContext::AuthFlow UserContext::GetAuthFlow() const {
78 return auth_flow_;
79 }
80
81 bool UserContext::HasCredentials() const {
82 return (!user_id_.empty() && !password_.empty()) || !auth_code_.empty();
83 }
84
85 void UserContext::SetUserID(const std::string& user_id) {
86 user_id_ = login::CanonicalizeUserID(user_id);
87 }
88
89 void UserContext::SetPassword(const std::string& password) {
90 password_ = password;
91 }
92
93 void UserContext::SetDoesNeedPasswordHashing(bool does_need_password_hashing) {
94 does_need_password_hashing_ = does_need_password_hashing;
95 }
96
97 void UserContext::SetKeyLabel(const std::string& key_label) {
98 key_label_ = key_label;
99 }
100
101 void UserContext::SetAuthCode(const std::string& auth_code) {
102 auth_code_ = auth_code;
103 }
104
105 void UserContext::SetUserIDHash(const std::string& user_id_hash) {
106 user_id_hash_ = user_id_hash;
107 }
108
109 void UserContext::SetIsUsingOAuth(bool is_using_oauth) {
110 is_using_oauth_ = is_using_oauth;
111 }
112
113 void UserContext::SetAuthFlow(AuthFlow auth_flow) {
114 auth_flow_ = auth_flow;
115 }
116
117 void UserContext::ClearSecrets() {
118 password_.clear();
119 auth_code_.clear();
120 }
121
122 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/auth/user_context.h ('k') | chrome/browser/chromeos/login/existing_user_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698