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

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

Issue 445003002: Supervised users: UI updates for new-profile-management launch. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: change label in profile list Created 6 years, 4 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
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 a1bfab6a7ba80a70599a442e33aad3d265f350f4..7dd290072b4517e6607478ca96984876dc623569 100644
--- a/chrome/browser/resources/options/manage_profile_overlay.js
+++ b/chrome/browser/resources/options/manage_profile_overlay.js
@@ -89,13 +89,16 @@ cr.define('options', function() {
[BrowserOptions.getCurrentProfile().filePath]);
};
+ $('create-profile-supervised-not-signed-in').innerHTML =
+ loadTimeData.getStringF('manageProfilesSupervisedNotSignedIn');
Pam (message me for reviews) 2014/08/13 14:25:47 You can do this directly in the HTML file, using
Marc Treib 2014/08/13 16:08:45 Ah, nice! TIL :)
+
$('create-profile-supervised-signed-in-learn-more-link').onclick =
function(event) {
PageManager.showPageByName('supervisedUserLearnMore');
return false;
};
- $('create-profile-supervised-not-signed-in-link').onclick =
+ $('create-profile-supervised-sign-in-link').onclick =
function(event) {
// The signin process will open an overlay to configure sync, which
// would replace this overlay. It's smoother to close this one now.
@@ -335,24 +338,39 @@ cr.define('options', function() {
updateCreateOrImport_: function(mode) {
// In 'create' mode, check for existing supervised users with the same
// name.
- if (mode == 'create' && $('create-profile-supervised').checked) {
- options.SupervisedUserListData.requestExistingSupervisedUsers().then(
- this.receiveExistingSupervisedUsers_.bind(this),
- this.onSigninError_.bind(this));
+ if (mode == 'create') {
+ this.requestExistingSupervisedUsers_();
} else {
this.updateOkButton_(mode);
}
},
/**
+ * Tries to get the list of existing supervised users and updates the UI
+ * accordingly.
+ * @private
+ */
+ requestExistingSupervisedUsers_: function() {
+ options.SupervisedUserListData.requestExistingSupervisedUsers().then(
+ this.receiveExistingSupervisedUsers_.bind(this),
+ this.onSigninError_.bind(this));
+ },
+
+ /**
* Callback which receives the list of existing supervised users. Checks if
* the currently entered name is the name of an already existing supervised
* user. If yes, the user is prompted to import the existing supervised
* user, and the create button is disabled.
+ * If the received list is empty, hides the "import" link.
* @param {Array.<Object>} The list of existing supervised users.
* @private
*/
receiveExistingSupervisedUsers_: function(supervisedUsers) {
+ $('import-existing-supervised-user-link').hidden =
+ supervisedUsers.length === 0;
+ if (!$('create-profile-supervised').checked)
+ return;
+
var newName = $('create-profile-name').value;
var i;
for (i = 0; i < supervisedUsers.length; ++i) {
@@ -401,7 +419,7 @@ cr.define('options', function() {
* @private
*/
onSigninError_: function() {
- this.updateImportExistingSupervisedUserLink_(false);
+ this.updateSignedInStatus_(this.signedInEmail_, true);
},
/**
@@ -649,6 +667,7 @@ cr.define('options', function() {
$('create-profile-supervised').onchange = function() {
ManageProfileOverlay.getInstance().updateCreateOrImport_('create');
};
+ $('create-profile-supervised').hidden = true;
$('create-profile-supervised-signed-in').disabled = true;
$('create-profile-supervised-signed-in').hidden = true;
$('create-profile-supervised-not-signed-in').hidden = true;
@@ -766,6 +785,7 @@ cr.define('options', function() {
this.signedInEmail_ = email;
this.hasError_ = hasError;
var isSignedIn = email !== '';
+ $('create-profile-supervised').hidden = !isSignedIn;
$('create-profile-supervised-signed-in').hidden = !isSignedIn;
$('create-profile-supervised-not-signed-in').hidden = isSignedIn;
@@ -786,24 +806,13 @@ cr.define('options', function() {
hasError;
}
- this.updateImportExistingSupervisedUserLink_(isSignedIn && !hasError);
- },
-
- /**
- * Enables/disables the 'import existing supervised users' link button.
- * It also updates the button text.
- * @param {boolean} enable True to enable the link button and
- * false otherwise.
- * @private
- */
- updateImportExistingSupervisedUserLink_: function(enable) {
- var importSupervisedUserElement =
- $('import-existing-supervised-user-link');
- importSupervisedUserElement.hidden = false;
- importSupervisedUserElement.disabled = !enable || this.createInProgress_;
- importSupervisedUserElement.textContent = enable ?
- loadTimeData.getString('importExistingSupervisedUserLink') :
- loadTimeData.getString('signInToImportSupervisedUsers');
+ this.updateCreateSupervisedUserCheckbox_();
+ // If we're signed in, showing/hiding import-existing-supervised-user-link
+ // is handled in receiveExistingSupervisedUsers_.
+ if (isSignedIn && !hasError)
+ this.requestExistingSupervisedUsers_();
+ else
+ $('import-existing-supervised-user-link').hidden = true;
},
/**
@@ -819,7 +828,7 @@ cr.define('options', function() {
this.supervisedUsersAllowed_ = allowed;
this.updateCreateSupervisedUserCheckbox_();
- $('create-profile-supervised-not-signed-in-link').hidden = !allowed;
+ $('create-profile-supervised-sign-in-link').enabled = allowed;
if (!allowed) {
$('create-profile-supervised-indicator').setAttribute('controlled-by',
'policy');

Powered by Google App Engine
This is Rietveld 408576698