diff options
author | bauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-05 23:06:16 +0000 |
---|---|---|
committer | bauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-05 23:06:16 +0000 |
commit | 74dc11910032bac35e3a1e68416c4da8dc3b41ea (patch) | |
tree | 150fd57f66280e428606ebdf781dbc3e6311ee55 | |
parent | f50f930ad9f6f476c96072cd1e221f2a43764312 (diff) | |
download | chromium_src-74dc11910032bac35e3a1e68416c4da8dc3b41ea.zip chromium_src-74dc11910032bac35e3a1e68416c4da8dc3b41ea.tar.gz chromium_src-74dc11910032bac35e3a1e68416c4da8dc3b41ea.tar.bz2 |
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
-rw-r--r-- | chrome/browser/resources/options/manage_profile_overlay.js | 24 | ||||
-rw-r--r-- | chrome/browser/ui/webui/options/manage_profile_browsertest.js | 30 |
2 files changed, 49 insertions, 5 deletions
diff --git a/chrome/browser/resources/options/manage_profile_overlay.js b/chrome/browser/resources/options/manage_profile_overlay.js index 200fcca..8ba25f4 100644 --- a/chrome/browser/resources/options/manage_profile_overlay.js +++ b/chrome/browser/resources/options/manage_profile_overlay.js @@ -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. diff --git a/chrome/browser/ui/webui/options/manage_profile_browsertest.js b/chrome/browser/ui/webui/options/manage_profile_browsertest.js index e02a526..f17f6f0 100644 --- a/chrome/browser/ui/webui/options/manage_profile_browsertest.js +++ b/chrome/browser/ui/webui/options/manage_profile_browsertest.js @@ -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); |