Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1273)

Unified Diff: chrome/browser/resources/options/manage_profile_overlay.js

Issue 132013002: Replace own callback handling with Promises. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address nits. Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/resources/options/managed_user_import.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/options/manage_profile_overlay.js
diff --git a/chrome/browser/resources/options/manage_profile_overlay.js b/chrome/browser/resources/options/manage_profile_overlay.js
index f9cf0767e7fc9683ece7d15ab6aca26ce0d5927c..509d3c2acff94a5acd51977b546b9a240c3b5dd4 100644
--- a/chrome/browser/resources/options/manage_profile_overlay.js
+++ b/chrome/browser/resources/options/manage_profile_overlay.js
@@ -67,7 +67,7 @@ cr.define('options', function() {
if (BrowserOptions.getCurrentProfile().isManaged)
return;
chrome.send('deleteProfile', [self.profileInfo_.filePath]);
- options.ManagedUserListData.reloadExistingManagedUsers();
+ options.ManagedUserListData.resetPromise();
};
$('add-shortcut-button').onclick = function(event) {
chrome.send('addProfileShortcut', [self.profileInfo_.filePath]);
@@ -276,6 +276,7 @@ cr.define('options', function() {
* @private
*/
hideErrorBubble_: function(mode) {
+ $(mode + '-profile-error-bubble').innerHTML = '';
$(mode + '-profile-error-bubble').hidden = true;
$(mode + '-profile-ok').disabled = false;
},
@@ -294,34 +295,18 @@ cr.define('options', function() {
// existing supervised user.
if (newName == oldName && mode == 'manage') {
this.hideErrorBubble_(mode);
- } else if (this.profileNames_[newName] != undefined) {
- var errorHtml =
- loadTimeData.getString('manageProfilesDuplicateNameError');
- this.showErrorBubble_(errorHtml, mode, true);
} else if (mode == 'create' &&
- loadTimeData.getBoolean('allowCreateExistingManagedUsers')) {
- this.checkIfSupervisedUserExists_();
+ loadTimeData.getBoolean('allowCreateExistingManagedUsers') &&
+ $('create-profile-managed').checked) {
+ options.ManagedUserListData.requestExistingManagedUsers().then(
+ this.receiveExistingManagedUsers_.bind(this),
+ this.onSigninError_.bind(this));
} else {
this.updateOkButton_(mode);
}
},
/**
- * Checks if a supervised user with the currently entered name already
- * exists.
- * @private
- */
- checkIfSupervisedUserExists_: function() {
- if (!$('create-profile-managed').checked) {
- this.updateOkButton_('create');
- return;
- }
- options.ManagedUserListData.requestExistingManagedUsers(
- this.receiveExistingManagedUsers_.bind(this),
- this.onSigninError_.bind(this));
- },
-
- /**
* Callback which receives the list of existing managed users. Checks if the
* currently entered name is the name of an already existing managed user.
* If yes, the user is prompted to import the existing managed user, and the
@@ -376,20 +361,27 @@ cr.define('options', function() {
*/
onSigninError_: function() {
this.updateImportExistingManagedUserLink_(false);
- this.updateManagedUsersAllowed_(false);
},
/**
- * Called if the name seems to be unused so far.
+ * Called to update the state of the ok button depending if the name is
+ * already used or not.
* @param {string} mode A label that specifies the type of dialog box which
* is currently being viewed (i.e. 'create' or 'manage').
* @private
*/
updateOkButton_: function(mode) {
- this.hideErrorBubble_(mode);
+ var newName = $(mode + '-profile-name').value;
+ if (this.profileNames_[newName] != undefined) {
+ var errorHtml =
+ loadTimeData.getString('manageProfilesDuplicateNameError');
+ this.showErrorBubble_(errorHtml, mode, true);
+ } else {
+ this.hideErrorBubble_(mode);
- var nameIsValid = $(mode + '-profile-name').validity.valid;
- $(mode + '-profile-ok').disabled = !nameIsValid;
+ var nameIsValid = $(mode + '-profile-name').validity.valid;
+ $(mode + '-profile-ok').disabled = !nameIsValid;
+ }
},
/**
@@ -403,6 +395,8 @@ cr.define('options', function() {
chrome.send('setProfileIconAndName',
[this.profileInfo_.filePath, iconURL, name]);
+ if (name != this.profileInfo_.name)
+ options.ManagedUserListData.resetPromise();
},
/**
@@ -670,7 +664,7 @@ cr.define('options', function() {
this.updateCreateInProgress_(false);
OptionsPage.closeOverlay();
if (profileInfo.isManaged) {
- options.ManagedUserListData.reloadExistingManagedUsers();
+ options.ManagedUserListData.resetPromise();
profileInfo.custodianEmail = this.signedInEmail_;
ManagedUserCreateConfirmOverlay.setProfileInfo(profileInfo);
OptionsPage.showPageByName('managedUserCreateConfirm', false);
« no previous file with comments | « no previous file | chrome/browser/resources/options/managed_user_import.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698