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

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

Issue 12225046: [cros] Set profile pref for locally managed users (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: initialize pref on Profile::CREATE_STATUS_CREATED cb Created 7 years, 10 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 (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/login_utils.h" 5 #include "chrome/browser/chromeos/login/login_utils.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "ash/ash_switches.h" 10 #include "ash/ash_switches.h"
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 420
421 // Initialize user policy before the profile is created so the profile 421 // Initialize user policy before the profile is created so the profile
422 // initialization code sees the cached policy settings. 422 // initialization code sees the cached policy settings.
423 connector->InitializeUserPolicy(username, 423 connector->InitializeUserPolicy(username,
424 user_manager->IsLoggedInAsPublicAccount(), 424 user_manager->IsLoggedInAsPublicAccount(),
425 wait_for_policy_fetch); 425 wait_for_policy_fetch);
426 426
427 // The default profile will have been changed because the ProfileManager 427 // The default profile will have been changed because the ProfileManager
428 // will process the notification that the UserManager sends out. 428 // will process the notification that the UserManager sends out.
429 ProfileManager::CreateDefaultProfileAsync( 429 ProfileManager::CreateDefaultProfileAsync(
430 base::Bind(&LoginUtilsImpl::OnProfileCreated, AsWeakPtr())); 430 base::Bind(&LoginUtilsImpl::OnProfileCreated, AsWeakPtr()),
431 UserManager::Get()->IsLoggedInAsLocallyManagedUser());
431 432
432 if (wait_for_policy_fetch) { 433 if (wait_for_policy_fetch) {
433 // Profile creation will block until user policy is fetched, which 434 // Profile creation will block until user policy is fetched, which
434 // requires the DeviceManagement token. Try to fetch it now. 435 // requires the DeviceManagement token. Try to fetch it now.
435 // TODO(atwilson): This is somewhat racy, as we are trying to fetch a 436 // TODO(atwilson): This is somewhat racy, as we are trying to fetch a
436 // DMToken in parallel with loading the cached policy blob (there could 437 // DMToken in parallel with loading the cached policy blob (there could
437 // already be a DMToken in the cached policy). Once the legacy policy 438 // already be a DMToken in the cached policy). Once the legacy policy
438 // framework is removed, this code can register a 439 // framework is removed, this code can register a
439 // CloudPolicyService::Observer to check whether the CloudPolicyClient was 440 // CloudPolicyService::Observer to check whether the CloudPolicyClient was
440 // able to register itself using the cached policy data, and then only 441 // able to register itself using the cached policy data, and then only
441 // create a PolicyOAuthFetcher if the client is still unregistered 442 // create a PolicyOAuthFetcher if the client is still unregistered
442 // (http://crbug.com/143187). 443 // (http://crbug.com/143187).
443 VLOG(1) << "Profile creation requires policy token, fetching now"; 444 VLOG(1) << "Profile creation requires policy token, fetching now";
444 login_manager_->RestorePolicyTokens( 445 login_manager_->RestorePolicyTokens(
445 authenticator_->authentication_profile()->GetRequestContext()); 446 authenticator_->authentication_profile()->GetRequestContext());
446 } 447 }
447 } 448 }
448 449
449 void LoginUtilsImpl::DelegateDeleted(LoginUtils::Delegate* delegate) { 450 void LoginUtilsImpl::DelegateDeleted(LoginUtils::Delegate* delegate) {
450 if (delegate_ == delegate) 451 if (delegate_ == delegate)
451 delegate_ = NULL; 452 delegate_ = NULL;
452 } 453 }
453 454
454 void LoginUtilsImpl::InitProfilePreferences(Profile* user_profile) { 455 void LoginUtilsImpl::InitProfilePreferences(Profile* user_profile) {
455 if (UserManager::Get()->IsCurrentUserNew()) 456 if (UserManager::Get()->IsCurrentUserNew())
456 SetFirstLoginPrefs(user_profile->GetPrefs()); 457 SetFirstLoginPrefs(user_profile->GetPrefs());
457 458
458 if (!UserManager::Get()->IsLoggedInAsLocallyManagedUser()) { 459 if (UserManager::Get()->IsLoggedInAsLocallyManagedUser()) {
460 user_profile->GetPrefs()->SetBoolean(prefs::kProfileIsManaged, true);
461 } else {
459 // Make sure that the google service username is properly set (we do this 462 // Make sure that the google service username is properly set (we do this
460 // on every sign in, not just the first login, to deal with existing 463 // on every sign in, not just the first login, to deal with existing
461 // profiles that might not have it set yet). 464 // profiles that might not have it set yet).
462 StringPrefMember google_services_username; 465 StringPrefMember google_services_username;
463 google_services_username.Init(prefs::kGoogleServicesUsername, 466 google_services_username.Init(prefs::kGoogleServicesUsername,
464 user_profile->GetPrefs()); 467 user_profile->GetPrefs());
465 google_services_username.SetValue( 468 google_services_username.SetValue(
466 UserManager::Get()->GetLoggedInUser()->display_email()); 469 UserManager::Get()->GetLoggedInUser()->display_email());
467 } 470 }
468 471
(...skipping 27 matching lines...) Expand all
496 case Profile::CREATE_STATUS_CREATED: { 499 case Profile::CREATE_STATUS_CREATED: {
497 InitProfilePreferences(user_profile); 500 InitProfilePreferences(user_profile);
498 return; 501 return;
499 } 502 }
500 case Profile::CREATE_STATUS_FAIL: 503 case Profile::CREATE_STATUS_FAIL:
501 default: 504 default:
502 NOTREACHED(); 505 NOTREACHED();
503 return; 506 return;
504 } 507 }
505 508
509 // Processing Profile::CREATE_STATUS_INITIALIZED notification.
Dmitry Polukhin 2013/02/08 17:26:53 Could you please remove this comment and make it c
Nikita (slow) 2013/02/11 09:42:12 Done.
506 BootTimesLoader* btl = BootTimesLoader::Get(); 510 BootTimesLoader* btl = BootTimesLoader::Get();
507 btl->AddLoginTimeMarker("UserProfileGotten", false); 511 btl->AddLoginTimeMarker("UserProfileGotten", false);
508 512
509 if (using_oauth_) { 513 if (using_oauth_) {
510 // Transfer proxy authentication cache, cookies (optionally) and server 514 // Transfer proxy authentication cache, cookies (optionally) and server
511 // bound certs from the profile that was used for authentication. This 515 // bound certs from the profile that was used for authentication. This
512 // profile contains cookies that auth extension should have already put in 516 // profile contains cookies that auth extension should have already put in
513 // place that will ensure that the newly created session is authenticated 517 // place that will ensure that the newly created session is authenticated
514 // for the websites that work with the used authentication schema. 518 // for the websites that work with the used authentication schema.
515 ProfileAuthData::Transfer(authenticator_->authentication_profile(), 519 ProfileAuthData::Transfer(authenticator_->authentication_profile(),
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after
1044 bool LoginUtils::IsWhitelisted(const std::string& username) { 1048 bool LoginUtils::IsWhitelisted(const std::string& username) {
1045 CrosSettings* cros_settings = CrosSettings::Get(); 1049 CrosSettings* cros_settings = CrosSettings::Get();
1046 bool allow_new_user = false; 1050 bool allow_new_user = false;
1047 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); 1051 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user);
1048 if (allow_new_user) 1052 if (allow_new_user)
1049 return true; 1053 return true;
1050 return cros_settings->FindEmailInList(kAccountsPrefUsers, username); 1054 return cros_settings->FindEmailInList(kAccountsPrefUsers, username);
1051 } 1055 }
1052 1056
1053 } // namespace chromeos 1057 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/profiles/profile_manager.h » ('j') | chrome/browser/profiles/profile_manager.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698