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" | 55 #include "chrome/browser/policy/user_cloud_policy_manager.h" |
Joao da Silva
2012/11/21 17:06:34
nit: not needed
Mattias Nissler (ping if slow)
2012/11/22 20:51:59
Done.
| |
56 #include "chrome/browser/prefs/pref_service.h" | 56 #include "chrome/browser/prefs/pref_service.h" |
57 #include "chrome/browser/profiles/profile.h" | 57 #include "chrome/browser/profiles/profile.h" |
58 #include "chrome/browser/profiles/profile_manager.h" | 58 #include "chrome/browser/profiles/profile_manager.h" |
59 #include "chrome/browser/signin/signin_manager.h" | 59 #include "chrome/browser/signin/signin_manager.h" |
60 #include "chrome/browser/signin/signin_manager_factory.h" | 60 #include "chrome/browser/signin/signin_manager_factory.h" |
61 #include "chrome/browser/signin/token_service.h" | 61 #include "chrome/browser/signin/token_service.h" |
62 #include "chrome/browser/signin/token_service_factory.h" | 62 #include "chrome/browser/signin/token_service_factory.h" |
63 #include "chrome/browser/sync/profile_sync_service.h" | 63 #include "chrome/browser/sync/profile_sync_service.h" |
64 #include "chrome/browser/sync/profile_sync_service_factory.h" | 64 #include "chrome/browser/sync/profile_sync_service_factory.h" |
65 #include "chrome/browser/ui/startup/startup_browser_creator.h" | 65 #include "chrome/browser/ui/startup/startup_browser_creator.h" |
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
491 | 491 |
492 // Initialize user policy before the profile is created so the profile | 492 // Initialize user policy before the profile is created so the profile |
493 // initialization code sees the cached policy settings. | 493 // initialization code sees the cached policy settings. |
494 connector->InitializeUserPolicy(username, wait_for_policy_fetch); | 494 connector->InitializeUserPolicy(username, wait_for_policy_fetch); |
495 | 495 |
496 // The default profile will have been changed because the ProfileManager | 496 // The default profile will have been changed because the ProfileManager |
497 // will process the notification that the UserManager sends out. | 497 // will process the notification that the UserManager sends out. |
498 ProfileManager::CreateDefaultProfileAsync( | 498 ProfileManager::CreateDefaultProfileAsync( |
499 base::Bind(&LoginUtilsImpl::OnProfileCreated, AsWeakPtr())); | 499 base::Bind(&LoginUtilsImpl::OnProfileCreated, AsWeakPtr())); |
500 | 500 |
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) { | 501 if (wait_for_policy_fetch) { |
514 // Profile creation will block until user policy is fetched, which | 502 // Profile creation will block until user policy is fetched, which |
515 // requires the DeviceManagement token. Try to fetch it now. | 503 // requires the DeviceManagement token. Try to fetch it now. |
516 // TODO(atwilson): This is somewhat racy, as we are trying to fetch a | 504 // 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 | 505 // DMToken in parallel with loading the cached policy blob (there could |
518 // already be a DMToken in the cached policy). Once the legacy policy | 506 // already be a DMToken in the cached policy). Once the legacy policy |
519 // framework is removed, this code can register a | 507 // framework is removed, this code can register a |
520 // CloudPolicyService::Observer to check whether the CloudPolicyClient was | 508 // CloudPolicyService::Observer to check whether the CloudPolicyClient was |
521 // able to register itself using the cached policy data, and then only | 509 // able to register itself using the cached policy data, and then only |
522 // create a PolicyOAuthFetcher if the client is still unregistered | 510 // 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) { | 1229 bool LoginUtils::IsWhitelisted(const std::string& username) { |
1242 CrosSettings* cros_settings = CrosSettings::Get(); | 1230 CrosSettings* cros_settings = CrosSettings::Get(); |
1243 bool allow_new_user = false; | 1231 bool allow_new_user = false; |
1244 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); | 1232 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); |
1245 if (allow_new_user) | 1233 if (allow_new_user) |
1246 return true; | 1234 return true; |
1247 return cros_settings->FindEmailInList(kAccountsPrefUsers, username); | 1235 return cros_settings->FindEmailInList(kAccountsPrefUsers, username); |
1248 } | 1236 } |
1249 | 1237 |
1250 } // namespace chromeos | 1238 } // namespace chromeos |
OLD | NEW |