| 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 "chrome/browser/chromeos/login/default_user_images.h" | 10 #include "chrome/browser/chromeos/login/default_user_images.h" |
| 11 #include "chrome/browser/chromeos/login/user_manager.h" | 11 #include "chrome/browser/chromeos/login/user_manager.h" |
| 12 #include "grit/theme_resources.h" | 12 #include "grit/theme_resources.h" |
| 13 #include "ui/base/l10n/l10n_util.h" |
| 13 #include "ui/base/resource/resource_bundle.h" | 14 #include "ui/base/resource/resource_bundle.h" |
| 14 | 15 |
| 15 namespace chromeos { | 16 namespace chromeos { |
| 16 | 17 |
| 17 namespace { | 18 namespace { |
| 18 | 19 |
| 19 // Returns account name portion of an email. | 20 // Returns account name portion of an email. |
| 20 std::string GetUserName(const std::string& email) { | 21 std::string GetUserName(const std::string& email) { |
| 21 std::string::size_type i = email.find('@'); | 22 std::string::size_type i = email.find('@'); |
| 22 if (i == 0 || i == std::string::npos) { | 23 if (i == 0 || i == std::string::npos) { |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 return new PublicAccountUser(email); | 201 return new PublicAccountUser(email); |
| 201 } | 202 } |
| 202 | 203 |
| 203 User::User(const std::string& email) | 204 User::User(const std::string& email) |
| 204 : email_(email), | 205 : email_(email), |
| 205 oauth_token_status_(OAUTH_TOKEN_STATUS_UNKNOWN), | 206 oauth_token_status_(OAUTH_TOKEN_STATUS_UNKNOWN), |
| 206 image_index_(kInvalidImageIndex), | 207 image_index_(kInvalidImageIndex), |
| 207 image_is_stub_(false), | 208 image_is_stub_(false), |
| 208 image_is_loading_(false), | 209 image_is_loading_(false), |
| 209 is_logged_in_(false), | 210 is_logged_in_(false), |
| 210 is_active_(false) { | 211 is_active_(false), |
| 212 profile_is_created_(false) { |
| 211 } | 213 } |
| 212 | 214 |
| 213 User::~User() {} | 215 User::~User() {} |
| 214 | 216 |
| 217 void User::SetAccountLocale(const std::string& raw_account_locale) { |
| 218 account_locale_.reset(new std::string); |
| 219 // Ignore result |
| 220 l10n_util::CheckAndResolveLocale(raw_account_locale, account_locale_.get()); |
| 221 } |
| 222 |
| 215 void User::SetImage(const UserImage& user_image, int image_index) { | 223 void User::SetImage(const UserImage& user_image, int image_index) { |
| 216 user_image_ = user_image; | 224 user_image_ = user_image; |
| 217 image_index_ = image_index; | 225 image_index_ = image_index; |
| 218 image_is_stub_ = false; | 226 image_is_stub_ = false; |
| 219 image_is_loading_ = false; | 227 image_is_loading_ = false; |
| 220 DCHECK(HasDefaultImage() || user_image.has_raw_image()); | 228 DCHECK(HasDefaultImage() || user_image.has_raw_image()); |
| 221 } | 229 } |
| 222 | 230 |
| 223 void User::SetImageURL(const GURL& image_url) { | 231 void User::SetImageURL(const GURL& image_url) { |
| 224 user_image_.set_url(image_url); | 232 user_image_.set_url(image_url); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 | 310 |
| 303 PublicAccountUser::PublicAccountUser(const std::string& email) : User(email) { | 311 PublicAccountUser::PublicAccountUser(const std::string& email) : User(email) { |
| 304 } | 312 } |
| 305 | 313 |
| 306 PublicAccountUser::~PublicAccountUser() {} | 314 PublicAccountUser::~PublicAccountUser() {} |
| 307 | 315 |
| 308 User::UserType PublicAccountUser::GetType() const { | 316 User::UserType PublicAccountUser::GetType() const { |
| 309 return USER_TYPE_PUBLIC_ACCOUNT; | 317 return USER_TYPE_PUBLIC_ACCOUNT; |
| 310 } | 318 } |
| 311 | 319 |
| 320 bool User::has_gaia_account() const { |
| 321 COMPILE_ASSERT(NUM_USER_TYPES == 6, num_user_types_unexpected); |
| 322 switch (GetType()) { |
| 323 case USER_TYPE_REGULAR: |
| 324 return true; |
| 325 case USER_TYPE_GUEST: |
| 326 case USER_TYPE_RETAIL_MODE: |
| 327 case USER_TYPE_PUBLIC_ACCOUNT: |
| 328 case USER_TYPE_LOCALLY_MANAGED: |
| 329 case USER_TYPE_KIOSK_APP: |
| 330 return false; |
| 331 default: |
| 332 NOTREACHED(); |
| 333 } |
| 334 return false; |
| 335 } |
| 336 |
| 312 } // namespace chromeos | 337 } // namespace chromeos |
| OLD | NEW |