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 "base/chromeos/chromeos_version.h" | 10 #include "base/chromeos/chromeos_version.h" |
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 if (!display_email.empty()) | 346 if (!display_email.empty()) |
347 user_manager->SaveUserDisplayEmail(user_context.username, display_email); | 347 user_manager->SaveUserDisplayEmail(user_context.username, display_email); |
348 | 348 |
349 user_context_ = user_context; | 349 user_context_ = user_context; |
350 | 350 |
351 using_oauth_ = using_oauth; | 351 using_oauth_ = using_oauth; |
352 has_web_auth_cookies_ = has_cookies; | 352 has_web_auth_cookies_ = has_cookies; |
353 delegate_ = delegate; | 353 delegate_ = delegate; |
354 InitSessionRestoreStrategy(); | 354 InitSessionRestoreStrategy(); |
355 | 355 |
356 policy::BrowserPolicyConnector* connector = | 356 bool wait_for_policy_fetch = false; |
357 g_browser_process->browser_policy_connector(); | |
358 | 357 |
359 // If this is an enterprise device and the user belongs to the enterprise | 358 // TODO(nkostylev): Figure out implementation for multiple-profiles. |
360 // domain, then wait for a policy fetch before logging the user in. This | 359 // http://crbug.com/230349 |
361 // will delay Profile creation until the policy is fetched, so that features | 360 bool is_primary_user = UserManager::Get()->GetLoggedInUsers().size() == 1; |
362 // controlled by policy (e.g. Sync, Startup tabs) only start after the | 361 if (is_primary_user) { |
363 // PrefService has the right values. | 362 policy::BrowserPolicyConnector* connector = |
364 // Profile creation is also resumed if the fetch attempt fails. | 363 g_browser_process->browser_policy_connector(); |
365 bool wait_for_policy_fetch = | |
366 using_oauth_ && | |
367 authenticator_.get() && | |
368 (connector->GetUserAffiliation(user_context_.username) == | |
369 policy::USER_AFFILIATION_MANAGED); | |
370 | 364 |
371 // Initialize user policy before the profile is created so the profile | 365 // If this is an enterprise device and the user belongs to the enterprise |
372 // initialization code sees the cached policy settings. | 366 // domain, then wait for a policy fetch before logging the user in. This |
373 connector->InitializeUserPolicy(user_context_.username, | 367 // will delay Profile creation until the policy is fetched, so that features |
374 user_manager->IsLoggedInAsPublicAccount(), | 368 // controlled by policy (e.g. Sync, Startup tabs) only start after the |
375 wait_for_policy_fetch); | 369 // PrefService has the right values. |
| 370 // Profile creation is also resumed if the fetch attempt fails. |
| 371 wait_for_policy_fetch = |
| 372 using_oauth_ && |
| 373 authenticator_.get() && |
| 374 (connector->GetUserAffiliation(user_context_.username) == |
| 375 policy::USER_AFFILIATION_MANAGED); |
| 376 |
| 377 // Initialize user policy before the profile is created so the profile |
| 378 // initialization code sees the cached policy settings. |
| 379 connector->InitializeUserPolicy(user_context_.username, |
| 380 user_manager->IsLoggedInAsPublicAccount(), |
| 381 wait_for_policy_fetch); |
| 382 } |
376 | 383 |
377 // The default profile will have been changed because the ProfileManager | 384 // The default profile will have been changed because the ProfileManager |
378 // will process the notification that the UserManager sends out. | 385 // will process the notification that the UserManager sends out so |
| 386 // username_hash has been already propogated to ProfileManager. |
379 ProfileManager::CreateDefaultProfileAsync( | 387 ProfileManager::CreateDefaultProfileAsync( |
380 base::Bind(&LoginUtilsImpl::OnProfileCreated, AsWeakPtr())); | 388 base::Bind(&LoginUtilsImpl::OnProfileCreated, AsWeakPtr())); |
381 | 389 |
382 if (wait_for_policy_fetch) { | 390 if (wait_for_policy_fetch) { |
383 // Profile creation will block until user policy is fetched, which | 391 // Profile creation will block until user policy is fetched, which |
384 // requires the DeviceManagement token. Try to fetch it now. | 392 // requires the DeviceManagement token. Try to fetch it now. |
385 // TODO(atwilson): This is somewhat racy, as we are trying to fetch a | 393 // TODO(atwilson): This is somewhat racy, as we are trying to fetch a |
386 // DMToken in parallel with loading the cached policy blob (there could | 394 // DMToken in parallel with loading the cached policy blob (there could |
387 // already be a DMToken in the cached policy). Once the legacy policy | 395 // already be a DMToken in the cached policy). Once the legacy policy |
388 // framework is removed, this code can register a | 396 // framework is removed, this code can register a |
(...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
951 bool LoginUtils::IsWhitelisted(const std::string& username) { | 959 bool LoginUtils::IsWhitelisted(const std::string& username) { |
952 CrosSettings* cros_settings = CrosSettings::Get(); | 960 CrosSettings* cros_settings = CrosSettings::Get(); |
953 bool allow_new_user = false; | 961 bool allow_new_user = false; |
954 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); | 962 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); |
955 if (allow_new_user) | 963 if (allow_new_user) |
956 return true; | 964 return true; |
957 return cros_settings->FindEmailInList(kAccountsPrefUsers, username); | 965 return cros_settings->FindEmailInList(kAccountsPrefUsers, username); |
958 } | 966 } |
959 | 967 |
960 } // namespace chromeos | 968 } // namespace chromeos |
OLD | NEW |