Commit b74c0c83 authored by zmin's avatar zmin Committed by Commit bot

Hide supervised user creation from UserManager when force sign in is enabled.

BUG=642059
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:closure_compilation

Review-Url: https://codereview.chromium.org/2561243002
Cr-Commit-Position: refs/heads/master@{#438194}
parent a17cccbc
...@@ -164,39 +164,41 @@ ...@@ -164,39 +164,41 @@
hidden="[[!isProfileShortcutsEnabled_]]"> hidden="[[!isProfileShortcutsEnabled_]]">
$i18n{createDesktopShortcutLabel} $i18n{createDesktopShortcutLabel}
</paper-checkbox> </paper-checkbox>
<paper-checkbox id="makeSupervisedCheckbox" checked="{{isSupervised_}}"> <template is="dom-if" if="[[!isForceSigninEnabled_]]">
$i18n{manageProfilesSupervisedSignedInLabel} <paper-checkbox id="makeSupervisedCheckbox" checked="{{isSupervised_}}">
</paper-checkbox> $i18n{manageProfilesSupervisedSignedInLabel}
<div id="supervised-user-container"> </paper-checkbox>
<div id="learn-more" > <div id="supervised-user-container">
<a is="action-link" on-tap="onLearnMoreTap_">$i18n{learnMore}</a> <div id="learn-more" >
</div> <a is="action-link" on-tap="onLearnMoreTap_">$i18n{learnMore}</a>
<template is="dom-if" if="[[isSupervised_]]">
<template is="dom-if" if="[[isSignedIn_(signedInUsers_)]]">
<paper-dropdown-menu label="$i18n{selectAnAccount}" no-label-float>
<paper-listbox class="dropdown-content"
selected="{{signedInUserIndex_}}"
attr-for-selected="data-user-index">
<template is="dom-repeat" items="[[signedInUsers_]]">
<paper-item data-user-index$="[[index]]">
[[item.username]]
</paper-item>
</template>
</paper-listbox>
</paper-dropdown-menu>
<a id="import-user" is="action-link" on-tap="onImportUserTap_"
hidden="[[isImportUserLinkHidden_(createInProgress_,
loadingSupervisedUsers_,
signedInUserIndex_)]]">
$i18n{importExistingSupervisedUserLink}
</a>
</template>
<div id="sign-in-howto-message"
hidden="[[isSignedIn_(signedInUsers_)]]"
inner-h-t-m-l="[[i18nAllowIDAttr_('noSignedInUserMessage')]]">
</div> </div>
</template> <template is="dom-if" if="[[isSupervised_]]">
</div> <template is="dom-if" if="[[isSignedIn_(signedInUsers_)]]">
<paper-dropdown-menu label="$i18n{selectAnAccount}" no-label-float>
<paper-listbox class="dropdown-content"
selected="{{signedInUserIndex_}}"
attr-for-selected="data-user-index">
<template is="dom-repeat" items="[[signedInUsers_]]">
<paper-item data-user-index$="[[index]]">
[[item.username]]
</paper-item>
</template>
</paper-listbox>
</paper-dropdown-menu>
<a id="import-user" is="action-link" on-tap="onImportUserTap_"
hidden="[[isImportUserLinkHidden_(createInProgress_,
loadingSupervisedUsers_,
signedInUserIndex_)]]">
$i18n{importExistingSupervisedUserLink}
</a>
</template>
<div id="sign-in-howto-message"
hidden="[[isSignedIn_(signedInUsers_)]]"
inner-h-t-m-l="[[i18nAllowIDAttr_('noSignedInUserMessage')]]">
</div>
</template>
</div>
</template>
<div id="actions"> <div id="actions">
<paper-spinner active="[[isSpinnerActive_(createInProgress_, <paper-spinner active="[[isSpinnerActive_(createInProgress_,
loadingSupervisedUsers_)]]"> loadingSupervisedUsers_)]]">
......
...@@ -138,6 +138,17 @@ Polymer({ ...@@ -138,6 +138,17 @@ Polymer({
return loadTimeData.getBoolean('profileShortcutsEnabled'); return loadTimeData.getBoolean('profileShortcutsEnabled');
}, },
readOnly: true readOnly: true
},
/**
* True if the force sign in policy is enabled.
* @private {boolean}
*/
isForceSigninEnabled_: {
type: Boolean,
value: function() {
return loadTimeData.getBoolean('isForceSigninEnabled');
},
} }
}, },
......
...@@ -66,7 +66,8 @@ cr.define('user_manager.create_profile_tests', function() { ...@@ -66,7 +66,8 @@ cr.define('user_manager.create_profile_tests', function() {
assertFalse(!!createProfileElement.$$('paper-dropdown-menu')); assertFalse(!!createProfileElement.$$('paper-dropdown-menu'));
// Simulate checking the supervised user checkbox. // Simulate checking the supervised user checkbox.
MockInteractions.tap(createProfileElement.$.makeSupervisedCheckbox); MockInteractions.tap(
createProfileElement.$$("#makeSupervisedCheckbox"));
Polymer.dom.flush(); Polymer.dom.flush();
// The dropdown menu is visible and is populated with signed in users. // The dropdown menu is visible and is populated with signed in users.
...@@ -115,7 +116,8 @@ cr.define('user_manager.create_profile_tests', function() { ...@@ -115,7 +116,8 @@ cr.define('user_manager.create_profile_tests', function() {
test('Has to select a custodian for the supervised profile', function() { test('Has to select a custodian for the supervised profile', function() {
// Simulate checking the supervised user checkbox. // Simulate checking the supervised user checkbox.
MockInteractions.tap(createProfileElement.$.makeSupervisedCheckbox); MockInteractions.tap(
createProfileElement.$$("#makeSupervisedCheckbox"));
Polymer.dom.flush(); Polymer.dom.flush();
// Simulate clicking 'Create'. // Simulate clicking 'Create'.
...@@ -135,7 +137,8 @@ cr.define('user_manager.create_profile_tests', function() { ...@@ -135,7 +137,8 @@ cr.define('user_manager.create_profile_tests', function() {
test('Supervised profile name is duplicate (on the device)', function() { test('Supervised profile name is duplicate (on the device)', function() {
// Simulate checking the supervised user checkbox. // Simulate checking the supervised user checkbox.
MockInteractions.tap(createProfileElement.$.makeSupervisedCheckbox); MockInteractions.tap(
createProfileElement.$$("#makeSupervisedCheckbox"));
Polymer.dom.flush(); Polymer.dom.flush();
// There is an existing supervised user with this name on the device. // There is an existing supervised user with this name on the device.
...@@ -166,7 +169,8 @@ cr.define('user_manager.create_profile_tests', function() { ...@@ -166,7 +169,8 @@ cr.define('user_manager.create_profile_tests', function() {
test('Supervised profile name is duplicate (remote)', function() { test('Supervised profile name is duplicate (remote)', function() {
// Simulate checking the supervised user checkbox. // Simulate checking the supervised user checkbox.
MockInteractions.tap(createProfileElement.$.makeSupervisedCheckbox); MockInteractions.tap(
createProfileElement.$$("#makeSupervisedCheckbox"));
Polymer.dom.flush(); Polymer.dom.flush();
// There is an existing supervised user with this name on the device. // There is an existing supervised user with this name on the device.
...@@ -199,7 +203,8 @@ cr.define('user_manager.create_profile_tests', function() { ...@@ -199,7 +203,8 @@ cr.define('user_manager.create_profile_tests', function() {
browserProxy.setExistingSupervisedUsers([]); browserProxy.setExistingSupervisedUsers([]);
// Simulate checking the supervised user checkbox. // Simulate checking the supervised user checkbox.
MockInteractions.tap(createProfileElement.$.makeSupervisedCheckbox); MockInteractions.tap(
createProfileElement.$$("#makeSupervisedCheckbox"));
Polymer.dom.flush(); Polymer.dom.flush();
// Select the first signed in user. // Select the first signed in user.
...@@ -227,7 +232,8 @@ cr.define('user_manager.create_profile_tests', function() { ...@@ -227,7 +232,8 @@ cr.define('user_manager.create_profile_tests', function() {
test('Create supervised profile', function() { test('Create supervised profile', function() {
// Simulate checking the supervised user checkbox. // Simulate checking the supervised user checkbox.
MockInteractions.tap(createProfileElement.$.makeSupervisedCheckbox); MockInteractions.tap(
createProfileElement.$$("#makeSupervisedCheckbox"));
Polymer.dom.flush(); Polymer.dom.flush();
// Select the first signed in user. // Select the first signed in user.
...@@ -418,7 +424,8 @@ cr.define('user_manager.create_profile_tests', function() { ...@@ -418,7 +424,8 @@ cr.define('user_manager.create_profile_tests', function() {
assertEquals(0, createProfileElement.signedInUsers_.length); assertEquals(0, createProfileElement.signedInUsers_.length);
// Simulate checking the supervised user checkbox. // Simulate checking the supervised user checkbox.
MockInteractions.tap(createProfileElement.$.makeSupervisedCheckbox); MockInteractions.tap(
createProfileElement.$$("#makeSupervisedCheckbox"));
Polymer.dom.flush(); Polymer.dom.flush();
// The dropdown menu is not visible when there are no signed in users. // The dropdown menu is not visible when there are no signed in users.
...@@ -507,6 +514,45 @@ cr.define('user_manager.create_profile_tests', function() { ...@@ -507,6 +514,45 @@ cr.define('user_manager.create_profile_tests', function() {
}); });
}); });
}); });
suite('CreateProfileTestsForceSigninPolicy', function() {
setup(function() {
browserProxy = new TestProfileBrowserProxy();
// Replace real proxy with mock proxy.
signin.ProfileBrowserProxyImpl.instance_ = browserProxy;
browserProxy.setIcons([{url: 'icon1.png', label: 'icon1'}]);
});
teardown(function(done) {
createProfileElement.remove();
// Allow asynchronous tasks to finish.
setTimeout(done);
});
test('force sign in policy enabled', function () {
loadTimeData.overrideValues({
isForceSigninEnabled: true,
});
createProfileElement = createElement();
Polymer.dom.flush();
var createSupervisedUserCheckbox =
createProfileElement.$$("#makeSupervisedCheckbox");
assertFalse(!!createSupervisedUserCheckbox);
});
test('force sign in policy not enabled', function () {
loadTimeData.overrideValues({
isForceSigninEnabled: false,
});
createProfileElement = createElement();
Polymer.dom.flush();
var createSupervisedUserCheckbox =
createProfileElement.$$("#makeSupervisedCheckbox");
assertTrue(createSupervisedUserCheckbox.clientHeight > 0);
});
});
} }
return { return {
......
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