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