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

Side by Side 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: fix tests 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 cr.define('options', function() { 5 cr.define('options', function() {
6 var Page = cr.ui.pageManager.Page; 6 var Page = cr.ui.pageManager.Page;
7 var PageManager = cr.ui.pageManager.PageManager; 7 var PageManager = cr.ui.pageManager.PageManager;
8 var ArrayDataModel = cr.ui.ArrayDataModel; 8 var ArrayDataModel = cr.ui.ArrayDataModel;
9 9
10 /** 10 /**
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 chrome.send('deleteProfile', 88 chrome.send('deleteProfile',
89 [BrowserOptions.getCurrentProfile().filePath]); 89 [BrowserOptions.getCurrentProfile().filePath]);
90 }; 90 };
91 91
92 $('create-profile-supervised-signed-in-learn-more-link').onclick = 92 $('create-profile-supervised-signed-in-learn-more-link').onclick =
93 function(event) { 93 function(event) {
94 PageManager.showPageByName('supervisedUserLearnMore'); 94 PageManager.showPageByName('supervisedUserLearnMore');
95 return false; 95 return false;
96 }; 96 };
97 97
98 $('create-profile-supervised-not-signed-in-link').onclick = 98 $('create-profile-supervised-sign-in-link').onclick =
99 function(event) { 99 function(event) {
100 // The signin process will open an overlay to configure sync, which 100 // The signin process will open an overlay to configure sync, which
101 // would replace this overlay. It's smoother to close this one now. 101 // would replace this overlay. It's smoother to close this one now.
102 // TODO(pamg): Move the sync-setup overlay to a higher layer so this one 102 // TODO(pamg): Move the sync-setup overlay to a higher layer so this one
103 // can stay open under it, after making sure that doesn't break anything 103 // can stay open under it, after making sure that doesn't break anything
104 // else. 104 // else.
105 PageManager.closeOverlay(); 105 PageManager.closeOverlay();
106 SyncSetupOverlay.startSignIn(); 106 SyncSetupOverlay.startSignIn();
107 }; 107 };
108 108
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 * Called when the profile name is changed or the 'create supervised' 328 * Called when the profile name is changed or the 'create supervised'
329 * checkbox is toggled. Updates the 'ok' button and the 'import existing 329 * checkbox is toggled. Updates the 'ok' button and the 'import existing
330 * supervised user' link. 330 * supervised user' link.
331 * @param {string} mode A label that specifies the type of dialog box which 331 * @param {string} mode A label that specifies the type of dialog box which
332 * is currently being viewed (i.e. 'create' or 'manage'). 332 * is currently being viewed (i.e. 'create' or 'manage').
333 * @private 333 * @private
334 */ 334 */
335 updateCreateOrImport_: function(mode) { 335 updateCreateOrImport_: function(mode) {
336 // In 'create' mode, check for existing supervised users with the same 336 // In 'create' mode, check for existing supervised users with the same
337 // name. 337 // name.
338 if (mode == 'create' && $('create-profile-supervised').checked) { 338 if (mode == 'create') {
339 options.SupervisedUserListData.requestExistingSupervisedUsers().then( 339 this.requestExistingSupervisedUsers_();
340 this.receiveExistingSupervisedUsers_.bind(this),
341 this.onSigninError_.bind(this));
342 } else { 340 } else {
343 this.updateOkButton_(mode); 341 this.updateOkButton_(mode);
344 } 342 }
345 }, 343 },
346 344
347 /** 345 /**
346 * Tries to get the list of existing supervised users and updates the UI
347 * accordingly.
348 * @private
349 */
350 requestExistingSupervisedUsers_: function() {
351 options.SupervisedUserListData.requestExistingSupervisedUsers().then(
352 this.receiveExistingSupervisedUsers_.bind(this),
353 this.onSigninError_.bind(this));
354 },
355
356 /**
348 * Callback which receives the list of existing supervised users. Checks if 357 * Callback which receives the list of existing supervised users. Checks if
349 * the currently entered name is the name of an already existing supervised 358 * the currently entered name is the name of an already existing supervised
350 * user. If yes, the user is prompted to import the existing supervised 359 * user. If yes, the user is prompted to import the existing supervised
351 * user, and the create button is disabled. 360 * user, and the create button is disabled.
361 * If the received list is empty, hides the "import" link.
352 * @param {Array.<Object>} The list of existing supervised users. 362 * @param {Array.<Object>} The list of existing supervised users.
353 * @private 363 * @private
354 */ 364 */
355 receiveExistingSupervisedUsers_: function(supervisedUsers) { 365 receiveExistingSupervisedUsers_: function(supervisedUsers) {
366 $('import-existing-supervised-user-link').hidden =
367 supervisedUsers.length === 0;
368 if (!$('create-profile-supervised').checked)
369 return;
370
356 var newName = $('create-profile-name').value; 371 var newName = $('create-profile-name').value;
357 var i; 372 var i;
358 for (i = 0; i < supervisedUsers.length; ++i) { 373 for (i = 0; i < supervisedUsers.length; ++i) {
359 if (supervisedUsers[i].name == newName && 374 if (supervisedUsers[i].name == newName &&
360 !supervisedUsers[i].onCurrentDevice) { 375 !supervisedUsers[i].onCurrentDevice) {
361 var errorHtml = loadTimeData.getStringF( 376 var errorHtml = loadTimeData.getStringF(
362 'manageProfilesExistingSupervisedUser', 377 'manageProfilesExistingSupervisedUser',
363 HTMLEscape(elide(newName, /* maxLength */ 50))); 378 HTMLEscape(elide(newName, /* maxLength */ 50)));
364 this.showErrorBubble_(errorHtml, 'create', true); 379 this.showErrorBubble_(errorHtml, 'create', true);
365 380
(...skipping 28 matching lines...) Expand all
394 } 409 }
395 this.updateOkButton_('create'); 410 this.updateOkButton_('create');
396 }, 411 },
397 412
398 /** 413 /**
399 * Called in case the request for the list of supervised users fails because 414 * Called in case the request for the list of supervised users fails because
400 * of a signin error. 415 * of a signin error.
401 * @private 416 * @private
402 */ 417 */
403 onSigninError_: function() { 418 onSigninError_: function() {
404 this.updateImportExistingSupervisedUserLink_(false); 419 this.updateSignedInStatus_(this.signedInEmail_, true);
405 }, 420 },
406 421
407 /** 422 /**
408 * Called to update the state of the ok button depending if the name is 423 * Called to update the state of the ok button depending if the name is
409 * already used or not. 424 * already used or not.
410 * @param {string} mode A label that specifies the type of dialog box which 425 * @param {string} mode A label that specifies the type of dialog box which
411 * is currently being viewed (i.e. 'create' or 'manage'). 426 * is currently being viewed (i.e. 'create' or 'manage').
412 * @private 427 * @private
413 */ 428 */
414 updateOkButton_: function(mode) { 429 updateOkButton_: function(mode) {
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 657
643 $('create-profile-name-label').hidden = true; 658 $('create-profile-name-label').hidden = true;
644 $('create-profile-name').hidden = true; 659 $('create-profile-name').hidden = true;
645 $('create-profile-ok').disabled = true; 660 $('create-profile-ok').disabled = true;
646 661
647 $('create-profile-supervised').checked = false; 662 $('create-profile-supervised').checked = false;
648 $('import-existing-supervised-user-link').hidden = true; 663 $('import-existing-supervised-user-link').hidden = true;
649 $('create-profile-supervised').onchange = function() { 664 $('create-profile-supervised').onchange = function() {
650 ManageProfileOverlay.getInstance().updateCreateOrImport_('create'); 665 ManageProfileOverlay.getInstance().updateCreateOrImport_('create');
651 }; 666 };
667 $('create-profile-supervised').hidden = true;
652 $('create-profile-supervised-signed-in').disabled = true; 668 $('create-profile-supervised-signed-in').disabled = true;
653 $('create-profile-supervised-signed-in').hidden = true; 669 $('create-profile-supervised-signed-in').hidden = true;
654 $('create-profile-supervised-not-signed-in').hidden = true; 670 $('create-profile-supervised-not-signed-in').hidden = true;
655 671
656 this.profileNameIsDefault_ = false; 672 this.profileNameIsDefault_ = false;
657 }, 673 },
658 674
659 /** @override */ 675 /** @override */
660 handleCancel: function() { 676 handleCancel: function() {
661 this.cancelCreateProfile_(); 677 this.cancelCreateProfile_();
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
759 * @param {string} email The email address of the currently signed-in user. 775 * @param {string} email The email address of the currently signed-in user.
760 * An empty string indicates that the user is not signed in. 776 * An empty string indicates that the user is not signed in.
761 * @param {boolean} hasError Whether the user's sign-in credentials are 777 * @param {boolean} hasError Whether the user's sign-in credentials are
762 * still valid. 778 * still valid.
763 * @private 779 * @private
764 */ 780 */
765 updateSignedInStatus_: function(email, hasError) { 781 updateSignedInStatus_: function(email, hasError) {
766 this.signedInEmail_ = email; 782 this.signedInEmail_ = email;
767 this.hasError_ = hasError; 783 this.hasError_ = hasError;
768 var isSignedIn = email !== ''; 784 var isSignedIn = email !== '';
785 $('create-profile-supervised').hidden = !isSignedIn;
769 $('create-profile-supervised-signed-in').hidden = !isSignedIn; 786 $('create-profile-supervised-signed-in').hidden = !isSignedIn;
770 $('create-profile-supervised-not-signed-in').hidden = isSignedIn; 787 $('create-profile-supervised-not-signed-in').hidden = isSignedIn;
771 788
772 if (isSignedIn) { 789 if (isSignedIn) {
773 var accountDetailsOutOfDate = 790 var accountDetailsOutOfDate =
774 $('create-profile-supervised-account-details-out-of-date-label'); 791 $('create-profile-supervised-account-details-out-of-date-label');
775 accountDetailsOutOfDate.textContent = loadTimeData.getStringF( 792 accountDetailsOutOfDate.textContent = loadTimeData.getStringF(
776 'manageProfilesSupervisedAccountDetailsOutOfDate', email); 793 'manageProfilesSupervisedAccountDetailsOutOfDate', email);
777 accountDetailsOutOfDate.hidden = !hasError; 794 accountDetailsOutOfDate.hidden = !hasError;
778 795
779 $('create-profile-supervised-signed-in-label').textContent = 796 $('create-profile-supervised-signed-in-label').textContent =
780 loadTimeData.getStringF( 797 loadTimeData.getStringF(
781 'manageProfilesSupervisedSignedInLabel', email); 798 'manageProfilesSupervisedSignedInLabel', email);
782 $('create-profile-supervised-signed-in-label').hidden = hasError; 799 $('create-profile-supervised-signed-in-label').hidden = hasError;
783 800
784 $('create-profile-supervised-sign-in-again-link').hidden = !hasError; 801 $('create-profile-supervised-sign-in-again-link').hidden = !hasError;
785 $('create-profile-supervised-signed-in-learn-more-link').hidden = 802 $('create-profile-supervised-signed-in-learn-more-link').hidden =
786 hasError; 803 hasError;
787 } 804 }
788 805
789 this.updateImportExistingSupervisedUserLink_(isSignedIn && !hasError); 806 this.updateCreateSupervisedUserCheckbox_();
807 // If we're signed in, showing/hiding import-existing-supervised-user-link
808 // is handled in receiveExistingSupervisedUsers_.
809 if (isSignedIn && !hasError)
810 this.requestExistingSupervisedUsers_();
811 else
812 $('import-existing-supervised-user-link').hidden = true;
790 }, 813 },
791 814
792 /** 815 /**
793 * Enables/disables the 'import existing supervised users' link button.
794 * It also updates the button text.
795 * @param {boolean} enable True to enable the link button and
796 * false otherwise.
797 * @private
798 */
799 updateImportExistingSupervisedUserLink_: function(enable) {
800 var importSupervisedUserElement =
801 $('import-existing-supervised-user-link');
802 importSupervisedUserElement.hidden = false;
803 importSupervisedUserElement.disabled = !enable || this.createInProgress_;
804 importSupervisedUserElement.textContent = enable ?
805 loadTimeData.getString('importExistingSupervisedUserLink') :
806 loadTimeData.getString('signInToImportSupervisedUsers');
807 },
808
809 /**
810 * Sets whether creating supervised users is allowed or not. Called by the 816 * Sets whether creating supervised users is allowed or not. Called by the
811 * handler in response to the 'requestCreateProfileUpdate' message or a 817 * handler in response to the 'requestCreateProfileUpdate' message or a
812 * change in the (policy-controlled) pref that prohibits creating supervised 818 * change in the (policy-controlled) pref that prohibits creating supervised
813 * users, after the signed-in status has been updated. 819 * users, after the signed-in status has been updated.
814 * @param {boolean} allowed True if creating supervised users should be 820 * @param {boolean} allowed True if creating supervised users should be
815 * allowed. 821 * allowed.
816 * @private 822 * @private
817 */ 823 */
818 updateSupervisedUsersAllowed_: function(allowed) { 824 updateSupervisedUsersAllowed_: function(allowed) {
819 this.supervisedUsersAllowed_ = allowed; 825 this.supervisedUsersAllowed_ = allowed;
820 this.updateCreateSupervisedUserCheckbox_(); 826 this.updateCreateSupervisedUserCheckbox_();
821 827
822 $('create-profile-supervised-not-signed-in-link').hidden = !allowed; 828 $('create-profile-supervised-sign-in-link').enabled = allowed;
823 if (!allowed) { 829 if (!allowed) {
824 $('create-profile-supervised-indicator').setAttribute('controlled-by', 830 $('create-profile-supervised-indicator').setAttribute('controlled-by',
825 'policy'); 831 'policy');
826 } else { 832 } else {
827 $('create-profile-supervised-indicator').removeAttribute( 833 $('create-profile-supervised-indicator').removeAttribute(
828 'controlled-by'); 834 'controlled-by');
829 } 835 }
830 }, 836 },
831 837
832 /** 838 /**
(...skipping 25 matching lines...) Expand all
858 return instance[name + '_'].apply(instance, arguments); 864 return instance[name + '_'].apply(instance, arguments);
859 }; 865 };
860 }); 866 });
861 867
862 // Export 868 // Export
863 return { 869 return {
864 ManageProfileOverlay: ManageProfileOverlay, 870 ManageProfileOverlay: ManageProfileOverlay,
865 CreateProfileOverlay: CreateProfileOverlay, 871 CreateProfileOverlay: CreateProfileOverlay,
866 }; 872 };
867 }); 873 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698