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

Side by Side Diff: chrome/browser/chromeos/login/user.cc

Issue 23095006: If user profile doesn't contain language setting, default to his Google account settings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added comment on "list of preferred languages". Created 7 years, 3 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
OLDNEW
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 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 return new PublicAccountUser(email); 196 return new PublicAccountUser(email);
196 } 197 }
197 198
198 User::User(const std::string& email) 199 User::User(const std::string& email)
199 : email_(email), 200 : email_(email),
200 oauth_token_status_(OAUTH_TOKEN_STATUS_UNKNOWN), 201 oauth_token_status_(OAUTH_TOKEN_STATUS_UNKNOWN),
201 image_index_(kInvalidImageIndex), 202 image_index_(kInvalidImageIndex),
202 image_is_stub_(false), 203 image_is_stub_(false),
203 image_is_loading_(false), 204 image_is_loading_(false),
204 is_logged_in_(false), 205 is_logged_in_(false),
205 is_active_(false) { 206 is_active_(false),
207 profile_is_created_(false) {
206 } 208 }
207 209
208 User::~User() {} 210 User::~User() {}
209 211
212 void User::SetAccountLocale(const std::string& raw_account_locale) {
213 account_locale_.reset(new std::string);
214 // Ignore result
215 l10n_util::CheckAndResolveLocale(raw_account_locale, account_locale_.get());
216 }
217
210 void User::SetImage(const UserImage& user_image, int image_index) { 218 void User::SetImage(const UserImage& user_image, int image_index) {
211 user_image_ = user_image; 219 user_image_ = user_image;
212 image_index_ = image_index; 220 image_index_ = image_index;
213 image_is_stub_ = false; 221 image_is_stub_ = false;
214 image_is_loading_ = false; 222 image_is_loading_ = false;
215 DCHECK(HasDefaultImage() || user_image.has_raw_image()); 223 DCHECK(HasDefaultImage() || user_image.has_raw_image());
216 } 224 }
217 225
218 void User::SetImageURL(const GURL& image_url) { 226 void User::SetImageURL(const GURL& image_url) {
219 user_image_.set_url(image_url); 227 user_image_.set_url(image_url);
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 301
294 PublicAccountUser::PublicAccountUser(const std::string& email) : User(email) { 302 PublicAccountUser::PublicAccountUser(const std::string& email) : User(email) {
295 } 303 }
296 304
297 PublicAccountUser::~PublicAccountUser() {} 305 PublicAccountUser::~PublicAccountUser() {}
298 306
299 User::UserType PublicAccountUser::GetType() const { 307 User::UserType PublicAccountUser::GetType() const {
300 return USER_TYPE_PUBLIC_ACCOUNT; 308 return USER_TYPE_PUBLIC_ACCOUNT;
301 } 309 }
302 310
311 bool User::has_account() const {
312 COMPILE_ASSERT(NUM_USER_TYPES == 6, num_user_types_unexpected);
313 switch (GetType()) {
314 case USER_TYPE_REGULAR:
315 return true;
316 case USER_TYPE_GUEST:
317 case USER_TYPE_RETAIL_MODE:
318 case USER_TYPE_PUBLIC_ACCOUNT:
319 case USER_TYPE_LOCALLY_MANAGED:
320 case USER_TYPE_KIOSK_APP:
321 return false;
322 default:
323 NOTREACHED();
324 }
325 return false;
326 }
327
303 } // namespace chromeos 328 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698