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/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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 #include "chrome/browser/chromeos/login/screen_locker.h" | 42 #include "chrome/browser/chromeos/login/screen_locker.h" |
43 #include "chrome/browser/chromeos/login/user_manager.h" | 43 #include "chrome/browser/chromeos/login/user_manager.h" |
44 #include "chrome/browser/chromeos/settings/cros_settings.h" | 44 #include "chrome/browser/chromeos/settings/cros_settings.h" |
45 #include "chrome/browser/chromeos/settings/cros_settings_names.h" | 45 #include "chrome/browser/chromeos/settings/cros_settings_names.h" |
46 #include "chrome/browser/chromeos/settings/ownership_service.h" | 46 #include "chrome/browser/chromeos/settings/ownership_service.h" |
47 #include "chrome/browser/extensions/extension_service.h" | 47 #include "chrome/browser/extensions/extension_service.h" |
48 #include "chrome/browser/first_run/first_run.h" | 48 #include "chrome/browser/first_run/first_run.h" |
49 #include "chrome/browser/net/chrome_url_request_context.h" | 49 #include "chrome/browser/net/chrome_url_request_context.h" |
50 #include "chrome/browser/net/preconnect.h" | 50 #include "chrome/browser/net/preconnect.h" |
51 #include "chrome/browser/policy/browser_policy_connector.h" | 51 #include "chrome/browser/policy/browser_policy_connector.h" |
| 52 #include "chrome/browser/policy/cloud_policy_client.h" |
| 53 #include "chrome/browser/policy/cloud_policy_service.h" |
| 54 #include "chrome/browser/policy/user_cloud_policy_manager.h" |
52 #include "chrome/browser/prefs/pref_member.h" | 55 #include "chrome/browser/prefs/pref_member.h" |
53 #include "chrome/browser/prefs/pref_service.h" | 56 #include "chrome/browser/prefs/pref_service.h" |
54 #include "chrome/browser/profiles/profile.h" | 57 #include "chrome/browser/profiles/profile.h" |
55 #include "chrome/browser/profiles/profile_manager.h" | 58 #include "chrome/browser/profiles/profile_manager.h" |
56 #include "chrome/browser/signin/signin_manager.h" | 59 #include "chrome/browser/signin/signin_manager.h" |
57 #include "chrome/browser/signin/signin_manager_factory.h" | 60 #include "chrome/browser/signin/signin_manager_factory.h" |
58 #include "chrome/browser/signin/token_service.h" | 61 #include "chrome/browser/signin/token_service.h" |
59 #include "chrome/browser/signin/token_service_factory.h" | 62 #include "chrome/browser/signin/token_service_factory.h" |
60 #include "chrome/browser/sync/profile_sync_service.h" | 63 #include "chrome/browser/sync/profile_sync_service.h" |
61 #include "chrome/browser/sync/profile_sync_service_factory.h" | 64 #include "chrome/browser/sync/profile_sync_service_factory.h" |
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 bool wait_for_policy_fetch = | 483 bool wait_for_policy_fetch = |
481 using_oauth_ && | 484 using_oauth_ && |
482 authenticator_.get() && | 485 authenticator_.get() && |
483 (connector->GetUserAffiliation(username) == | 486 (connector->GetUserAffiliation(username) == |
484 policy::USER_AFFILIATION_MANAGED); | 487 policy::USER_AFFILIATION_MANAGED); |
485 | 488 |
486 // Initialize user policy before the profile is created so the profile | 489 // Initialize user policy before the profile is created so the profile |
487 // initialization code sees the cached policy settings. | 490 // initialization code sees the cached policy settings. |
488 connector->InitializeUserPolicy(username, wait_for_policy_fetch); | 491 connector->InitializeUserPolicy(username, wait_for_policy_fetch); |
489 | 492 |
| 493 // The default profile will have been changed because the ProfileManager |
| 494 // will process the notification that the UserManager sends out. |
| 495 ProfileManager::CreateDefaultProfileAsync( |
| 496 base::Bind(&LoginUtilsImpl::OnProfileCreated, AsWeakPtr())); |
| 497 |
| 498 // The default profile is only partially initialized at this point. |
| 499 // Setup the UserCloudPolicyManager so profile initialization can complete. |
| 500 Profile* user_profile = ProfileManager::GetDefaultProfile(); |
| 501 |
| 502 // Initialize the new cloud policy framework, if enabled. |
| 503 if (user_profile->GetUserCloudPolicyManager()) { |
| 504 user_profile->GetUserCloudPolicyManager()->Initialize( |
| 505 g_browser_process->local_state(), |
| 506 connector->device_management_service(), |
| 507 connector->GetUserAffiliation(username)); |
| 508 } |
| 509 |
490 if (wait_for_policy_fetch) { | 510 if (wait_for_policy_fetch) { |
491 // Profile creation will block until user policy is fetched, which | 511 // Profile creation will block until user policy is fetched, which |
492 // requires the DeviceManagement token. Try to fetch it now. | 512 // requires the DeviceManagement token. Try to fetch it now. |
493 VLOG(1) << "Profile creation requires policy token, fetching now"; | 513 VLOG(1) << "Profile creation requires policy token, fetching now"; |
494 policy_oauth_fetcher_.reset( | 514 policy_oauth_fetcher_.reset( |
495 new PolicyOAuthFetcher(authenticator_->authentication_profile())); | 515 new PolicyOAuthFetcher(authenticator_->authentication_profile())); |
496 policy_oauth_fetcher_->Start(); | 516 policy_oauth_fetcher_->Start(); |
497 } | 517 } |
498 | |
499 // The default profile will have been changed because the ProfileManager | |
500 // will process the notification that the UserManager sends out. | |
501 ProfileManager::CreateDefaultProfileAsync( | |
502 base::Bind(&LoginUtilsImpl::OnProfileCreated, AsWeakPtr())); | |
503 } | 518 } |
504 | 519 |
505 void LoginUtilsImpl::DelegateDeleted(LoginUtils::Delegate* delegate) { | 520 void LoginUtilsImpl::DelegateDeleted(LoginUtils::Delegate* delegate) { |
506 if (delegate_ == delegate) | 521 if (delegate_ == delegate) |
507 delegate_ = NULL; | 522 delegate_ = NULL; |
508 } | 523 } |
509 | 524 |
510 void LoginUtilsImpl::OnProfileCreated( | 525 void LoginUtilsImpl::OnProfileCreated( |
511 Profile* user_profile, | 526 Profile* user_profile, |
512 Profile::CreateStatus status) { | 527 Profile::CreateStatus status) { |
(...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1189 bool LoginUtils::IsWhitelisted(const std::string& username) { | 1204 bool LoginUtils::IsWhitelisted(const std::string& username) { |
1190 CrosSettings* cros_settings = CrosSettings::Get(); | 1205 CrosSettings* cros_settings = CrosSettings::Get(); |
1191 bool allow_new_user = false; | 1206 bool allow_new_user = false; |
1192 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); | 1207 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); |
1193 if (allow_new_user) | 1208 if (allow_new_user) |
1194 return true; | 1209 return true; |
1195 return cros_settings->FindEmailInList(kAccountsPrefUsers, username); | 1210 return cros_settings->FindEmailInList(kAccountsPrefUsers, username); |
1196 } | 1211 } |
1197 | 1212 |
1198 } // namespace chromeos | 1213 } // namespace chromeos |
OLD | NEW |