| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 #include "chrome/browser/chromeos/login/user_manager.h" | 45 #include "chrome/browser/chromeos/login/user_manager.h" |
| 46 #include "chrome/browser/chromeos/settings/cros_settings.h" | 46 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 47 #include "chrome/browser/chromeos/settings/cros_settings_names.h" | 47 #include "chrome/browser/chromeos/settings/cros_settings_names.h" |
| 48 #include "chrome/browser/extensions/extension_service.h" | 48 #include "chrome/browser/extensions/extension_service.h" |
| 49 #include "chrome/browser/first_run/first_run.h" | 49 #include "chrome/browser/first_run/first_run.h" |
| 50 #include "chrome/browser/net/chrome_url_request_context.h" | 50 #include "chrome/browser/net/chrome_url_request_context.h" |
| 51 #include "chrome/browser/net/preconnect.h" | 51 #include "chrome/browser/net/preconnect.h" |
| 52 #include "chrome/browser/policy/browser_policy_connector.h" | 52 #include "chrome/browser/policy/browser_policy_connector.h" |
| 53 #include "chrome/browser/policy/cloud_policy_client.h" | 53 #include "chrome/browser/policy/cloud_policy_client.h" |
| 54 #include "chrome/browser/policy/cloud_policy_service.h" | 54 #include "chrome/browser/policy/cloud_policy_service.h" |
| 55 #include "chrome/browser/policy/user_cloud_policy_manager.h" | |
| 56 #include "chrome/browser/prefs/pref_service.h" | 55 #include "chrome/browser/prefs/pref_service.h" |
| 57 #include "chrome/browser/profiles/profile.h" | 56 #include "chrome/browser/profiles/profile.h" |
| 58 #include "chrome/browser/profiles/profile_manager.h" | 57 #include "chrome/browser/profiles/profile_manager.h" |
| 59 #include "chrome/browser/signin/signin_manager.h" | 58 #include "chrome/browser/signin/signin_manager.h" |
| 60 #include "chrome/browser/signin/signin_manager_factory.h" | 59 #include "chrome/browser/signin/signin_manager_factory.h" |
| 61 #include "chrome/browser/signin/token_service.h" | 60 #include "chrome/browser/signin/token_service.h" |
| 62 #include "chrome/browser/signin/token_service_factory.h" | 61 #include "chrome/browser/signin/token_service_factory.h" |
| 63 #include "chrome/browser/sync/profile_sync_service.h" | 62 #include "chrome/browser/sync/profile_sync_service.h" |
| 64 #include "chrome/browser/sync/profile_sync_service_factory.h" | 63 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 65 #include "chrome/browser/ui/startup/startup_browser_creator.h" | 64 #include "chrome/browser/ui/startup/startup_browser_creator.h" |
| (...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 | 490 |
| 492 // Initialize user policy before the profile is created so the profile | 491 // Initialize user policy before the profile is created so the profile |
| 493 // initialization code sees the cached policy settings. | 492 // initialization code sees the cached policy settings. |
| 494 connector->InitializeUserPolicy(username, wait_for_policy_fetch); | 493 connector->InitializeUserPolicy(username, wait_for_policy_fetch); |
| 495 | 494 |
| 496 // The default profile will have been changed because the ProfileManager | 495 // The default profile will have been changed because the ProfileManager |
| 497 // will process the notification that the UserManager sends out. | 496 // will process the notification that the UserManager sends out. |
| 498 ProfileManager::CreateDefaultProfileAsync( | 497 ProfileManager::CreateDefaultProfileAsync( |
| 499 base::Bind(&LoginUtilsImpl::OnProfileCreated, AsWeakPtr())); | 498 base::Bind(&LoginUtilsImpl::OnProfileCreated, AsWeakPtr())); |
| 500 | 499 |
| 501 // The default profile is only partially initialized at this point. | |
| 502 // Setup the UserCloudPolicyManager so profile initialization can complete. | |
| 503 Profile* user_profile = ProfileManager::GetDefaultProfile(); | |
| 504 | |
| 505 // Initialize the new cloud policy framework, if enabled. | |
| 506 if (user_profile->GetUserCloudPolicyManager()) { | |
| 507 user_profile->GetUserCloudPolicyManager()->Initialize( | |
| 508 g_browser_process->local_state(), | |
| 509 connector->device_management_service(), | |
| 510 connector->GetUserAffiliation(username)); | |
| 511 } | |
| 512 | |
| 513 if (wait_for_policy_fetch) { | 500 if (wait_for_policy_fetch) { |
| 514 // Profile creation will block until user policy is fetched, which | 501 // Profile creation will block until user policy is fetched, which |
| 515 // requires the DeviceManagement token. Try to fetch it now. | 502 // requires the DeviceManagement token. Try to fetch it now. |
| 516 // TODO(atwilson): This is somewhat racy, as we are trying to fetch a | 503 // TODO(atwilson): This is somewhat racy, as we are trying to fetch a |
| 517 // DMToken in parallel with loading the cached policy blob (there could | 504 // DMToken in parallel with loading the cached policy blob (there could |
| 518 // already be a DMToken in the cached policy). Once the legacy policy | 505 // already be a DMToken in the cached policy). Once the legacy policy |
| 519 // framework is removed, this code can register a | 506 // framework is removed, this code can register a |
| 520 // CloudPolicyService::Observer to check whether the CloudPolicyClient was | 507 // CloudPolicyService::Observer to check whether the CloudPolicyClient was |
| 521 // able to register itself using the cached policy data, and then only | 508 // able to register itself using the cached policy data, and then only |
| 522 // create a PolicyOAuthFetcher if the client is still unregistered | 509 // create a PolicyOAuthFetcher if the client is still unregistered |
| (...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1241 bool LoginUtils::IsWhitelisted(const std::string& username) { | 1228 bool LoginUtils::IsWhitelisted(const std::string& username) { |
| 1242 CrosSettings* cros_settings = CrosSettings::Get(); | 1229 CrosSettings* cros_settings = CrosSettings::Get(); |
| 1243 bool allow_new_user = false; | 1230 bool allow_new_user = false; |
| 1244 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); | 1231 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); |
| 1245 if (allow_new_user) | 1232 if (allow_new_user) |
| 1246 return true; | 1233 return true; |
| 1247 return cros_settings->FindEmailInList(kAccountsPrefUsers, username); | 1234 return cros_settings->FindEmailInList(kAccountsPrefUsers, username); |
| 1248 } | 1235 } |
| 1249 | 1236 |
| 1250 } // namespace chromeos | 1237 } // namespace chromeos |
| OLD | NEW |