Commit 4266e4cb authored by peletskyi's avatar peletskyi Committed by Commit bot

Expose kDeviceLoginScreenDomainAutoComplete through CrosSettings

BUG=471242

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

Cr-Commit-Position: refs/heads/master@{#324048}
parent 66411d52
...@@ -595,18 +595,6 @@ void DecodeAccessibilityPolicies(const em::ChromeDeviceSettingsProto& policy, ...@@ -595,18 +595,6 @@ void DecodeAccessibilityPolicies(const em::ChromeDeviceSettingsProto& policy,
container.login_screen_default_virtual_keyboard_enabled()), container.login_screen_default_virtual_keyboard_enabled()),
NULL); NULL);
} }
// The behavior when policy is not set and when it is set to an empty string
// is the same. Thus lets add policy to the map only if it is set and its
// value is not an empty string.
if (container.has_login_screen_domain_auto_complete() &&
!container.login_screen_domain_auto_complete().empty()) {
policies->Set(
key::kDeviceLoginScreenDomainAutoComplete, POLICY_LEVEL_MANDATORY,
POLICY_SCOPE_MACHINE,
new base::StringValue(container.login_screen_domain_auto_complete()),
nullptr);
}
} }
} }
...@@ -770,6 +758,16 @@ void DecodeGenericPolicies(const em::ChromeDeviceSettingsProto& policy, ...@@ -770,6 +758,16 @@ void DecodeGenericPolicies(const em::ChromeDeviceSettingsProto& policy,
nullptr); nullptr);
} }
} }
if (policy.has_login_screen_domain_auto_complete()) {
const em::LoginScreenDomainAutoCompleteProto& container(
policy.login_screen_domain_auto_complete());
policies->Set(
key::kDeviceLoginScreenDomainAutoComplete, POLICY_LEVEL_MANDATORY,
POLICY_SCOPE_MACHINE,
new base::StringValue(container.login_screen_domain_auto_complete()),
nullptr);
}
} }
} // namespace } // namespace
......
...@@ -465,14 +465,6 @@ message AccessibilitySettingsProto { ...@@ -465,14 +465,6 @@ message AccessibilitySettingsProto {
// shown. Users can enable or disable the on-screen keyboard anytime and its // shown. Users can enable or disable the on-screen keyboard anytime and its
// status on the login screen is persisted between users. // status on the login screen is persisted between users.
optional bool login_screen_default_virtual_keyboard_enabled = 5; optional bool login_screen_default_virtual_keyboard_enabled = 5;
// If this policy is not configured or set to a blank string,
// no autocomplete option during user sign-in flow will be shown.
// If this policy is set to a string representing a domain name, an
// autocomplete option during user sign-in will be shown allowing the user
// to type in only his user name without the domain name extension. The user
// will be able to overwrite this domain name extension.
optional string login_screen_domain_auto_complete = 6;
} }
message SupervisedUsersSettingsProto { message SupervisedUsersSettingsProto {
...@@ -622,6 +614,16 @@ message ExtensionCacheSizeProto { ...@@ -622,6 +614,16 @@ message ExtensionCacheSizeProto {
optional int64 extension_cache_size = 1; optional int64 extension_cache_size = 1;
} }
message LoginScreenDomainAutoCompleteProto {
// If this policy is not configured or set to a blank string,
// no autocomplete option during user sign-in flow will be shown.
// If this policy is set to a string representing a domain name, an
// autocomplete option during user sign-in will be shown allowing the user
// to type in only his user name without the domain name extension. The user
// will be able to overwrite this domain name extension.
optional string login_screen_domain_auto_complete = 1;
}
message ChromeDeviceSettingsProto { message ChromeDeviceSettingsProto {
optional DevicePolicyRefreshRateProto device_policy_refresh_rate = 1; optional DevicePolicyRefreshRateProto device_policy_refresh_rate = 1;
optional UserWhitelistProto user_whitelist = 2; optional UserWhitelistProto user_whitelist = 2;
...@@ -661,4 +663,6 @@ message ChromeDeviceSettingsProto { ...@@ -661,4 +663,6 @@ message ChromeDeviceSettingsProto {
optional RebootOnShutdownProto reboot_on_shutdown = 34; optional RebootOnShutdownProto reboot_on_shutdown = 34;
optional DeviceHeartbeatSettingsProto device_heartbeat_settings = 35; optional DeviceHeartbeatSettingsProto device_heartbeat_settings = 35;
optional ExtensionCacheSizeProto extension_cache_size = 36; optional ExtensionCacheSizeProto extension_cache_size = 36;
optional LoginScreenDomainAutoCompleteProto
login_screen_domain_auto_complete = 37;
} }
...@@ -51,6 +51,7 @@ const char* const kKnownSettings[] = { ...@@ -51,6 +51,7 @@ const char* const kKnownSettings[] = {
kAccountsPrefSupervisedUsersEnabled, kAccountsPrefSupervisedUsersEnabled,
kAccountsPrefTransferSAMLCookies, kAccountsPrefTransferSAMLCookies,
kAccountsPrefUsers, kAccountsPrefUsers,
kAccountsPrefLoginScreenDomainAutoComplete,
kAllowRedeemChromeOsRegistrationOffers, kAllowRedeemChromeOsRegistrationOffers,
kAllowedConnectionTypesForUpdate, kAllowedConnectionTypesForUpdate,
kAttestationForContentProtectionEnabled, kAttestationForContentProtectionEnabled,
...@@ -246,6 +247,20 @@ void DecodeLoginPolicies( ...@@ -246,6 +247,20 @@ void DecodeLoginPolicies(
kAccountsPrefTransferSAMLCookies, kAccountsPrefTransferSAMLCookies,
policy.saml_settings().transfer_saml_cookies()); policy.saml_settings().transfer_saml_cookies());
} }
// The behavior when policy is not set and when it is set to an empty string
// is the same. Thus lets add policy only if it is set and its value is not
// an empty string.
if (policy.has_login_screen_domain_auto_complete() &&
policy.login_screen_domain_auto_complete()
.has_login_screen_domain_auto_complete() &&
!policy.login_screen_domain_auto_complete()
.login_screen_domain_auto_complete()
.empty()) {
new_values_cache->SetString(kAccountsPrefLoginScreenDomainAutoComplete,
policy.login_screen_domain_auto_complete()
.login_screen_domain_auto_complete());
}
} }
void DecodeNetworkPolicies( void DecodeNetworkPolicies(
......
...@@ -142,6 +142,26 @@ class DeviceSettingsProviderTest : public DeviceSettingsTestBase { ...@@ -142,6 +142,26 @@ class DeviceSettingsProviderTest : public DeviceSettingsTestBase {
&expected_frequency_value)); &expected_frequency_value));
} }
// Helper routine to set LoginScreenDomainAutoComplete policy.
void SetDomainAutoComplete(const std::string& domain) {
EXPECT_CALL(*this, SettingChanged(_)).Times(AtLeast(1));
em::LoginScreenDomainAutoCompleteProto* proto =
device_policy_.payload().mutable_login_screen_domain_auto_complete();
proto->set_login_screen_domain_auto_complete(domain);
device_policy_.Build();
device_settings_test_helper_.set_policy_blob(device_policy_.GetBlob());
ReloadDeviceSettings();
Mock::VerifyAndClearExpectations(this);
}
// Helper routine to check value of the LoginScreenDomainAutoComplete policy.
void VerifyDomainAutoComplete(
const base::StringValue* const ptr_to_expected_value) {
EXPECT_TRUE(base::Value::Equals(
provider_->Get(kAccountsPrefLoginScreenDomainAutoComplete),
ptr_to_expected_value));
}
ScopedTestingLocalState local_state_; ScopedTestingLocalState local_state_;
scoped_ptr<DeviceSettingsProvider> provider_; scoped_ptr<DeviceSettingsProvider> provider_;
...@@ -445,4 +465,19 @@ TEST_F(DeviceSettingsProviderTest, DecodeHeartbeatSettings) { ...@@ -445,4 +465,19 @@ TEST_F(DeviceSettingsProviderTest, DecodeHeartbeatSettings) {
VerifyHeartbeatSettings(false, heartbeat_frequency); VerifyHeartbeatSettings(false, heartbeat_frequency);
} }
TEST_F(DeviceSettingsProviderTest, DecodeDomainAutoComplete) {
// By default LoginScreenDomainAutoComplete policy should not be set.
VerifyDomainAutoComplete(nullptr);
// Empty string means that the policy is not set.
SetDomainAutoComplete("");
VerifyDomainAutoComplete(nullptr);
// Check some meaningful value. Policy should be set.
const std::string domain = "domain.test";
const base::StringValue domain_value(domain);
SetDomainAutoComplete(domain);
VerifyDomainAutoComplete(&domain_value);
}
} // namespace chromeos } // namespace chromeos
...@@ -466,9 +466,6 @@ const PolicyToPreferenceMapEntry kSimplePolicyMap[] = { ...@@ -466,9 +466,6 @@ const PolicyToPreferenceMapEntry kSimplePolicyMap[] = {
{ key::kCaptivePortalAuthenticationIgnoresProxy, { key::kCaptivePortalAuthenticationIgnoresProxy,
prefs::kCaptivePortalAuthenticationIgnoresProxy, prefs::kCaptivePortalAuthenticationIgnoresProxy,
base::Value::TYPE_BOOLEAN }, base::Value::TYPE_BOOLEAN },
{ key::kDeviceLoginScreenDomainAutoComplete,
NULL,
base::Value::TYPE_STRING },
#endif // defined(OS_CHROMEOS) #endif // defined(OS_CHROMEOS)
#if !defined(OS_MACOSX) && !defined(OS_CHROMEOS) #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS)
......
...@@ -39,6 +39,11 @@ const char kAccountsPrefSupervisedUsersEnabled[] = ...@@ -39,6 +39,11 @@ const char kAccountsPrefSupervisedUsersEnabled[] =
const char kAccountsPrefTransferSAMLCookies[] = const char kAccountsPrefTransferSAMLCookies[] =
"cros.accounts.transferSAMLCookies"; "cros.accounts.transferSAMLCookies";
// A string pref that specifies a domain name for the autocomplete option during
// user sign-in flow.
const char kAccountsPrefLoginScreenDomainAutoComplete[] =
"cros.accounts.login_screen_domain_auto_complete";
// All cros.signed.* settings are stored in SignedSettings. // All cros.signed.* settings are stored in SignedSettings.
const char kSignedDataRoamingEnabled[] = "cros.signed.data_roaming_enabled"; const char kSignedDataRoamingEnabled[] = "cros.signed.data_roaming_enabled";
......
...@@ -33,6 +33,7 @@ CHROMEOS_EXPORT extern const char ...@@ -33,6 +33,7 @@ CHROMEOS_EXPORT extern const char
kAccountsPrefDeviceLocalAccountPromptForNetworkWhenOffline[]; kAccountsPrefDeviceLocalAccountPromptForNetworkWhenOffline[];
CHROMEOS_EXPORT extern const char kAccountsPrefSupervisedUsersEnabled[]; CHROMEOS_EXPORT extern const char kAccountsPrefSupervisedUsersEnabled[];
CHROMEOS_EXPORT extern const char kAccountsPrefTransferSAMLCookies[]; CHROMEOS_EXPORT extern const char kAccountsPrefTransferSAMLCookies[];
CHROMEOS_EXPORT extern const char kAccountsPrefLoginScreenDomainAutoComplete[];
CHROMEOS_EXPORT extern const char kSignedDataRoamingEnabled[]; CHROMEOS_EXPORT extern const char kSignedDataRoamingEnabled[];
...@@ -88,6 +89,7 @@ CHROMEOS_EXPORT extern const char kDeviceDisabledMessage[]; ...@@ -88,6 +89,7 @@ CHROMEOS_EXPORT extern const char kDeviceDisabledMessage[];
CHROMEOS_EXPORT extern const char kRebootOnShutdown[]; CHROMEOS_EXPORT extern const char kRebootOnShutdown[];
CHROMEOS_EXPORT extern const char kExtensionCacheSize[]; CHROMEOS_EXPORT extern const char kExtensionCacheSize[];
} // namespace chromeos } // namespace chromeos
#endif // CHROMEOS_SETTINGS_CROS_SETTINGS_NAMES_H_ #endif // CHROMEOS_SETTINGS_CROS_SETTINGS_NAMES_H_
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