| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/profiles/profile_window.h" | 5 #include "chrome/browser/profiles/profile_window.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| 11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 12 #include "chrome/browser/about_flags.h" | 12 #include "chrome/browser/about_flags.h" |
| 13 #include "chrome/browser/browser_process.h" | 13 #include "chrome/browser/browser_process.h" |
| 14 #include "chrome/browser/lifetime/application_lifetime.h" | 14 #include "chrome/browser/lifetime/application_lifetime.h" |
| 15 #include "chrome/browser/pref_service_flags_storage.h" | 15 #include "chrome/browser/pref_service_flags_storage.h" |
| 16 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
| 17 #include "chrome/browser/profiles/profile_avatar_icon_util.h" | 17 #include "chrome/browser/profiles/profile_avatar_icon_util.h" |
| 18 #include "chrome/browser/profiles/profile_manager.h" | 18 #include "chrome/browser/profiles/profile_manager.h" |
| 19 #include "chrome/browser/signin/account_reconcilor_factory.h" | 19 #include "chrome/browser/signin/account_reconcilor_factory.h" |
| 20 #include "chrome/browser/signin/account_tracker_service_factory.h" | 20 #include "chrome/browser/signin/account_tracker_service_factory.h" |
| 21 #include "chrome/browser/signin/signin_manager_factory.h" |
| 21 #include "chrome/browser/sync/profile_sync_service.h" | 22 #include "chrome/browser/sync/profile_sync_service.h" |
| 22 #include "chrome/browser/sync/profile_sync_service_factory.h" | 23 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 23 #include "chrome/browser/ui/browser.h" | 24 #include "chrome/browser/ui/browser.h" |
| 24 #include "chrome/browser/ui/browser_dialogs.h" | 25 #include "chrome/browser/ui/browser_dialogs.h" |
| 25 #include "chrome/browser/ui/profile_chooser_constants.h" | 26 #include "chrome/browser/ui/profile_chooser_constants.h" |
| 26 #include "chrome/browser/ui/user_manager.h" | 27 #include "chrome/browser/ui/user_manager.h" |
| 27 #include "chrome/common/chrome_switches.h" | 28 #include "chrome/common/chrome_switches.h" |
| 28 #include "chrome/common/pref_names.h" | 29 #include "chrome/common/pref_names.h" |
| 29 #include "chrome/common/url_constants.h" | 30 #include "chrome/common/url_constants.h" |
| 30 #include "components/signin/core/browser/account_reconcilor.h" | 31 #include "components/signin/core/browser/account_reconcilor.h" |
| 31 #include "components/signin/core/browser/account_tracker_service.h" | 32 #include "components/signin/core/browser/account_tracker_service.h" |
| 33 #include "components/signin/core/browser/signin_manager.h" |
| 32 #include "components/signin/core/common/profile_management_switches.h" | 34 #include "components/signin/core/common/profile_management_switches.h" |
| 33 #include "content/public/browser/browser_thread.h" | 35 #include "content/public/browser/browser_thread.h" |
| 34 #include "content/public/browser/user_metrics.h" | 36 #include "content/public/browser/user_metrics.h" |
| 35 | 37 |
| 36 #if defined(ENABLE_EXTENSIONS) | 38 #if defined(ENABLE_EXTENSIONS) |
| 37 #include "chrome/browser/extensions/extension_service.h" | 39 #include "chrome/browser/extensions/extension_service.h" |
| 38 #include "extensions/browser/extension_prefs.h" | 40 #include "extensions/browser/extension_prefs.h" |
| 39 #include "extensions/browser/extension_registry.h" | 41 #include "extensions/browser/extension_registry.h" |
| 40 #include "extensions/browser/extension_registry_factory.h" | 42 #include "extensions/browser/extension_registry_factory.h" |
| 41 #include "extensions/browser/extension_system.h" | 43 #include "extensions/browser/extension_system.h" |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 } | 379 } |
| 378 | 380 |
| 379 bool IsLockAvailable(Profile* profile) { | 381 bool IsLockAvailable(Profile* profile) { |
| 380 DCHECK(profile); | 382 DCHECK(profile); |
| 381 if (!switches::IsNewProfileManagement()) | 383 if (!switches::IsNewProfileManagement()) |
| 382 return false; | 384 return false; |
| 383 | 385 |
| 384 if (profile->IsGuestSession()) | 386 if (profile->IsGuestSession()) |
| 385 return false; | 387 return false; |
| 386 | 388 |
| 387 const ProfileInfoCache& cache = | |
| 388 g_browser_process->profile_manager()->GetProfileInfoCache(); | |
| 389 std::string hosted_domain = profile->GetPrefs()-> | 389 std::string hosted_domain = profile->GetPrefs()-> |
| 390 GetString(prefs::kGoogleServicesHostedDomain); | 390 GetString(prefs::kGoogleServicesHostedDomain); |
| 391 // TODO(mlerman): After one release remove any hosted_domain reference to the | 391 // TODO(mlerman): After one release remove any hosted_domain reference to the |
| 392 // pref, since all users will have this in the AccountTrackerService. | 392 // pref, since all users will have this in the AccountTrackerService. |
| 393 if (hosted_domain.empty()) { | 393 if (hosted_domain.empty()) { |
| 394 AccountTrackerService* account_tracker = | 394 AccountTrackerService* account_tracker = |
| 395 AccountTrackerServiceFactory::GetForProfile(profile); | 395 AccountTrackerServiceFactory::GetForProfile(profile); |
| 396 int profile_index = cache.GetIndexOfProfileWithPath(profile->GetPath()); | 396 std::string account_id = |
| 397 hosted_domain = account_tracker->FindAccountInfoByEmail(base::UTF16ToUTF8( | 397 SigninManagerFactory::GetForProfile(profile)->GetAuthenticatedAccountId(); |
| 398 cache.GetUserNameOfProfileAtIndex(profile_index))).hosted_domain; | 398 hosted_domain = account_tracker->GetAccountInfo(account_id).hosted_domain; |
| 399 } | 399 } |
| 400 // TODO(mlerman): Prohibit only users who authenticate using SAML. Until then, | 400 // TODO(mlerman): Prohibit only users who authenticate using SAML. Until then, |
| 401 // prohibited users who use hosted domains (aside from google.com). | 401 // prohibited users who use hosted domains (aside from google.com). |
| 402 if (hosted_domain != Profile::kNoHostedDomainFound && | 402 if (hosted_domain != Profile::kNoHostedDomainFound && |
| 403 hosted_domain != "google.com") { | 403 hosted_domain != "google.com") { |
| 404 return false; | 404 return false; |
| 405 } | 405 } |
| 406 | 406 |
| 407 const ProfileInfoCache& cache = |
| 408 g_browser_process->profile_manager()->GetProfileInfoCache(); |
| 407 for (size_t i = 0; i < cache.GetNumberOfProfiles(); ++i) { | 409 for (size_t i = 0; i < cache.GetNumberOfProfiles(); ++i) { |
| 408 if (cache.ProfileIsSupervisedAtIndex(i)) | 410 if (cache.ProfileIsSupervisedAtIndex(i)) |
| 409 return true; | 411 return true; |
| 410 } | 412 } |
| 411 return false; | 413 return false; |
| 412 } | 414 } |
| 413 | 415 |
| 414 void CreateSystemProfileForUserManager( | 416 void CreateSystemProfileForUserManager( |
| 415 const base::FilePath& profile_path_to_focus, | 417 const base::FilePath& profile_path_to_focus, |
| 416 profiles::UserManagerTutorialMode tutorial_mode, | 418 profiles::UserManagerTutorialMode tutorial_mode, |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 517 return; | 519 return; |
| 518 case BrowserWindow::AVATAR_BUBBLE_MODE_FAST_USER_SWITCH: | 520 case BrowserWindow::AVATAR_BUBBLE_MODE_FAST_USER_SWITCH: |
| 519 *bubble_view_mode = profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER; | 521 *bubble_view_mode = profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER; |
| 520 return; | 522 return; |
| 521 default: | 523 default: |
| 522 *bubble_view_mode = profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER; | 524 *bubble_view_mode = profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER; |
| 523 } | 525 } |
| 524 } | 526 } |
| 525 | 527 |
| 526 } // namespace profiles | 528 } // namespace profiles |
| OLD | NEW |