Commit 74dc1191 authored by bauerb@chromium.org's avatar bauerb@chromium.org

Correctly update enabled state of the "create managed user" checkbox.

BUG=281244

Review URL: https://chromiumcodereview.appspot.com/23875002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@221536 0039d316-1c4b-4281-b951-d872f2087c98
parent f50f930a
......@@ -514,10 +514,12 @@ cr.define('options', function() {
* @private
*/
updateCreateInProgress_: function(inProgress) {
this.createInProgress_ = inProgress;
this.updateCreateManagedUserCheckbox_();
$('create-profile-icon-grid').disabled = inProgress;
$('create-profile-name').disabled = inProgress;
$('create-shortcut').disabled = inProgress;
$('create-profile-managed').disabled = inProgress;
$('create-profile-ok').disabled = inProgress;
$('create-profile-throbber').hidden = !inProgress;
......@@ -620,7 +622,7 @@ cr.define('options', function() {
},
/**
* Updates the status of the "create managed user" checkbox. Called by the
* Sets whether creating managed users is allowed or not. Called by the
* handler in response to the 'requestCreateProfileUpdate' message or a
* change in the (policy-controlled) pref that prohibits creating managed
* users, after the signed-in status has been updated.
......@@ -629,9 +631,8 @@ cr.define('options', function() {
* @private
*/
updateManagedUsersAllowed_: function(allowed) {
var isSignedIn = this.signedInEmail_ !== '';
$('create-profile-managed').disabled =
!isSignedIn || !allowed || this.hasError_;
this.managedUsersAllowed_ = allowed;
this.updateCreateManagedUserCheckbox_();
$('create-profile-managed-not-signed-in-link').hidden = !allowed;
if (!allowed) {
......@@ -641,6 +642,19 @@ cr.define('options', function() {
$('create-profile-managed-indicator').removeAttribute('controlled-by');
}
},
/**
* Updates the status of the "create managed user" checkbox. Called from
* updateManagedUsersAllowed_() or updateCreateInProgress_().
* updateSignedInStatus_() does not call this method directly, because it
* will be followed by a call to updateManagedUsersAllowed_().
* @private
*/
updateCreateManagedUserCheckbox_: function() {
$('create-profile-managed').disabled =
!this.managedUsersAllowed_ || this.createInProgress_ ||
this.signedInEmail_ == '' || this.hasError_;
},
};
// Forward public APIs to private implementations.
......
......@@ -301,6 +301,36 @@ TEST_F('ManageProfileUITest', 'PolicyDynamicRefresh', function() {
're-allowed and signed in');
});
// The managed user checkbox should correctly update its state during profile
// creation and afterwards.
TEST_F('ManageProfileUITest', 'CreateInProgress', function() {
ManageProfileOverlay.getInstance().initializePage();
var custodianEmail = 'chrome.playpen.test@gmail.com';
CreateProfileOverlay.updateSignedInStatus(custodianEmail);
CreateProfileOverlay.updateManagedUsersAllowed(true);
var checkbox = $('create-profile-managed');
var link = $('create-profile-managed-not-signed-in-link');
var indicator = $('create-profile-managed-indicator');
assertFalse(checkbox.disabled, 'allowed and signed in');
assertFalse(link.hidden, 'allowed and signed in');
assertEquals('none', window.getComputedStyle(indicator, null).display,
'allowed and signed in');
assertFalse(indicator.hasAttribute('controlled-by'));
CreateProfileOverlay.updateCreateInProgress(true);
assertTrue(checkbox.disabled, 'creation in progress');
// A no-op update to the sign-in status should not change the UI.
CreateProfileOverlay.updateSignedInStatus(custodianEmail);
CreateProfileOverlay.updateManagedUsersAllowed(true);
assertTrue(checkbox.disabled, 'creation in progress');
CreateProfileOverlay.updateCreateInProgress(false);
assertFalse(checkbox.disabled, 'creation finished');
});
// Managed users shouldn't be able to open the delete or create dialogs.
TEST_F('ManageProfileUITest', 'ManagedShowDeleteAndCreate', function() {
this.setProfileManaged_(false);
......
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