Commit 677ec3ad authored by mlerman's avatar mlerman Committed by Commit bot

Lock only when there is at least one supervised user on the machine.

BUG=420746

Review URL: https://codereview.chromium.org/633233002

Cr-Commit-Position: refs/heads/master@{#302412}
parent 07969eff
...@@ -318,11 +318,25 @@ void LockProfile(Profile* profile) { ...@@ -318,11 +318,25 @@ void LockProfile(Profile* profile) {
bool IsLockAvailable(Profile* profile) { bool IsLockAvailable(Profile* profile) {
DCHECK(profile); DCHECK(profile);
if (!switches::IsNewProfileManagement())
return false;
const std::string& hosted_domain = profile->GetPrefs()-> const std::string& hosted_domain = profile->GetPrefs()->
GetString(prefs::kGoogleServicesHostedDomain); GetString(prefs::kGoogleServicesHostedDomain);
return switches::IsNewProfileManagement() && // TODO(mlerman): Prohibit only users who authenticate using SAML. Until then,
(hosted_domain == Profile::kNoHostedDomainFound || // prohibited users who use hosted domains (aside from google.com).
hosted_domain == "google.com"); if (hosted_domain != Profile::kNoHostedDomainFound &&
hosted_domain != "google.com") {
return false;
}
const ProfileInfoCache& cache =
g_browser_process->profile_manager()->GetProfileInfoCache();
for (size_t i = 0; i < cache.GetNumberOfProfiles(); ++i) {
if (cache.ProfileIsSupervisedAtIndex(i))
return true;
}
return false;
} }
void CreateGuestProfileForUserManager( void CreateGuestProfileForUserManager(
......
...@@ -499,6 +499,8 @@ TEST_F(ProfileChooserControllerTest, SignedInProfileLockEnabled) { ...@@ -499,6 +499,8 @@ TEST_F(ProfileChooserControllerTest, SignedInProfileLockEnabled) {
// The preference, not the email, determines whether the profile can lock. // The preference, not the email, determines whether the profile can lock.
browser()->profile()->GetPrefs()->SetString( browser()->profile()->GetPrefs()->SetString(
prefs::kGoogleServicesHostedDomain, "google.com"); prefs::kGoogleServicesHostedDomain, "google.com");
// Lock is only available where a supervised user is present.
cache->SetSupervisedUserIdOfProfileAtIndex(1, kEmail);
StartProfileChooserController(); StartProfileChooserController();
NSArray* subviews = [[[controller() window] contentView] subviews]; NSArray* subviews = [[[controller() window] contentView] subviews];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment