| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/user.h" | 5 #include "chrome/browser/chromeos/login/user.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "base/threading/thread_restrictions.h" | 10 #include "base/threading/thread_restrictions.h" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 explicit PublicAccountUser(const std::string& email); | 101 explicit PublicAccountUser(const std::string& email); |
| 102 virtual ~PublicAccountUser(); | 102 virtual ~PublicAccountUser(); |
| 103 | 103 |
| 104 // Overridden from User: | 104 // Overridden from User: |
| 105 virtual UserType GetType() const OVERRIDE; | 105 virtual UserType GetType() const OVERRIDE; |
| 106 | 106 |
| 107 private: | 107 private: |
| 108 DISALLOW_COPY_AND_ASSIGN(PublicAccountUser); | 108 DISALLOW_COPY_AND_ASSIGN(PublicAccountUser); |
| 109 }; | 109 }; |
| 110 | 110 |
| 111 UserContext::UserContext() : using_oauth(true), auth_flow(AUTH_FLOW_OFFLINE) { | 111 UserContext::UserContext() : using_oauth(true) { |
| 112 } | 112 } |
| 113 | 113 |
| 114 UserContext::UserContext(const std::string& username, | 114 UserContext::UserContext(const std::string& username, |
| 115 const std::string& password, | 115 const std::string& password, |
| 116 const std::string& auth_code) | 116 const std::string& auth_code) |
| 117 : username(username), | 117 : username(username), |
| 118 password(password), | 118 password(password), |
| 119 auth_code(auth_code), | 119 auth_code(auth_code), |
| 120 using_oauth(true), | 120 using_oauth(true) { |
| 121 auth_flow(AUTH_FLOW_OFFLINE) { | |
| 122 } | 121 } |
| 123 | 122 |
| 124 UserContext::UserContext(const std::string& username, | 123 UserContext::UserContext(const std::string& username, |
| 125 const std::string& password, | 124 const std::string& password, |
| 126 const std::string& auth_code, | 125 const std::string& auth_code, |
| 127 const std::string& username_hash) | 126 const std::string& username_hash) |
| 128 : username(username), | 127 : username(username), |
| 129 password(password), | 128 password(password), |
| 130 auth_code(auth_code), | 129 auth_code(auth_code), |
| 131 username_hash(username_hash), | 130 username_hash(username_hash), |
| 132 using_oauth(true), | 131 using_oauth(true) { |
| 133 auth_flow(AUTH_FLOW_OFFLINE) { | |
| 134 } | 132 } |
| 135 | 133 |
| 136 UserContext::UserContext(const std::string& username, | 134 UserContext::UserContext(const std::string& username, |
| 137 const std::string& password, | 135 const std::string& password, |
| 138 const std::string& auth_code, | 136 const std::string& auth_code, |
| 139 const std::string& username_hash, | 137 const std::string& username_hash, |
| 140 bool using_oauth, | 138 bool using_oauth) |
| 141 AuthFlow auth_flow) | |
| 142 : username(username), | 139 : username(username), |
| 143 password(password), | 140 password(password), |
| 144 auth_code(auth_code), | 141 auth_code(auth_code), |
| 145 username_hash(username_hash), | 142 username_hash(username_hash), |
| 146 using_oauth(using_oauth), | 143 using_oauth(using_oauth) { |
| 147 auth_flow(auth_flow) { | |
| 148 } | 144 } |
| 149 | 145 |
| 150 UserContext::~UserContext() { | 146 UserContext::~UserContext() { |
| 151 } | 147 } |
| 152 | 148 |
| 153 bool UserContext::operator==(const UserContext& context) const { | 149 bool UserContext::operator==(const UserContext& context) const { |
| 154 return context.username == username && | 150 return context.username == username && |
| 155 context.password == password && | 151 context.password == password && |
| 156 context.auth_code == auth_code && | 152 context.auth_code == auth_code && |
| 157 context.username_hash == username_hash && | 153 context.username_hash == username_hash && |
| 158 context.using_oauth == using_oauth && | 154 context.using_oauth == using_oauth; |
| 159 context.auth_flow == auth_flow; | |
| 160 } | 155 } |
| 161 | 156 |
| 162 base::string16 User::GetDisplayName() const { | 157 base::string16 User::GetDisplayName() const { |
| 163 // Fallback to the email account name in case display name haven't been set. | 158 // Fallback to the email account name in case display name haven't been set. |
| 164 return display_name_.empty() ? | 159 return display_name_.empty() ? |
| 165 base::UTF8ToUTF16(GetAccountName(true)) : | 160 base::UTF8ToUTF16(GetAccountName(true)) : |
| 166 display_name_; | 161 display_name_; |
| 167 } | 162 } |
| 168 | 163 |
| 169 std::string User::GetAccountName(bool use_display_email) const { | 164 std::string User::GetAccountName(bool use_display_email) const { |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 case USER_TYPE_LOCALLY_MANAGED: | 345 case USER_TYPE_LOCALLY_MANAGED: |
| 351 case USER_TYPE_KIOSK_APP: | 346 case USER_TYPE_KIOSK_APP: |
| 352 return false; | 347 return false; |
| 353 default: | 348 default: |
| 354 NOTREACHED(); | 349 NOTREACHED(); |
| 355 } | 350 } |
| 356 return false; | 351 return false; |
| 357 } | 352 } |
| 358 | 353 |
| 359 } // namespace chromeos | 354 } // namespace chromeos |
| OLD | NEW |