Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 780 loadTimeData.getStringF( | 795 loadTimeData.getStringF( |
| 781 'manageProfilesSupervisedSignedInLabel', email); | 796 'manageProfilesSupervisedSignedInLabel', email); |
| 782 $('create-profile-supervised-signed-in-label').hidden = hasError; | 797 $('create-profile-supervised-signed-in-label').hidden = hasError; |
| 783 | 798 |
| 784 $('create-profile-supervised-sign-in-again-link').hidden = !hasError; | 799 $('create-profile-supervised-sign-in-again-link').hidden = !hasError; |
| 785 $('create-profile-supervised-signed-in-learn-more-link').hidden = | 800 $('create-profile-supervised-signed-in-learn-more-link').hidden = |
| 786 hasError; | 801 hasError; |
| 787 } | 802 } |
| 788 | 803 |
| 789 this.updateImportExistingSupervisedUserLink_(isSignedIn && !hasError); | 804 this.updateImportExistingSupervisedUserLink_(isSignedIn && !hasError); |
| 805 if (isSignedIn) | |
| 806 this.requestExistingSupervisedUsers_(); | |
| 790 }, | 807 }, |
| 791 | 808 |
| 792 /** | 809 /** |
| 793 * Enables/disables the 'import existing supervised users' link button. | 810 * Enables/disables the 'import existing supervised users' link button. |
| 794 * It also updates the button text. | 811 * It also updates the button text. |
| 795 * @param {boolean} enable True to enable the link button and | 812 * @param {boolean} enable True to enable the link button and |
| 796 * false otherwise. | 813 * false otherwise. |
| 797 * @private | 814 * @private |
| 798 */ | 815 */ |
| 799 updateImportExistingSupervisedUserLink_: function(enable) { | 816 updateImportExistingSupervisedUserLink_: function(enable) { |
| 800 var importSupervisedUserElement = | 817 var importSupervisedUserElement = |
| 801 $('import-existing-supervised-user-link'); | 818 $('import-existing-supervised-user-link'); |
| 802 importSupervisedUserElement.hidden = false; | 819 if (!enable) |
|
Pam (message me for reviews)
2014/08/06 23:36:36
This check is backwards, and it's not quite what w
Marc Treib
2014/08/07 07:39:34
When we're not signed in, the link is disabled (i.
| |
| 820 importSupervisedUserElement.hidden = false; | |
| 803 importSupervisedUserElement.disabled = !enable || this.createInProgress_; | 821 importSupervisedUserElement.disabled = !enable || this.createInProgress_; |
| 804 importSupervisedUserElement.textContent = enable ? | 822 importSupervisedUserElement.textContent = enable ? |
| 805 loadTimeData.getString('importExistingSupervisedUserLink') : | 823 loadTimeData.getString('importExistingSupervisedUserLink') : |
| 806 loadTimeData.getString('signInToImportSupervisedUsers'); | 824 loadTimeData.getString('signInToImportSupervisedUsers'); |
| 807 }, | 825 }, |
| 808 | 826 |
| 809 /** | 827 /** |
| 810 * Sets whether creating supervised users is allowed or not. Called by the | 828 * Sets whether creating supervised users is allowed or not. Called by the |
| 811 * handler in response to the 'requestCreateProfileUpdate' message or a | 829 * handler in response to the 'requestCreateProfileUpdate' message or a |
| 812 * change in the (policy-controlled) pref that prohibits creating supervised | 830 * change in the (policy-controlled) pref that prohibits creating supervised |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 858 return instance[name + '_'].apply(instance, arguments); | 876 return instance[name + '_'].apply(instance, arguments); |
| 859 }; | 877 }; |
| 860 }); | 878 }); |
| 861 | 879 |
| 862 // Export | 880 // Export |
| 863 return { | 881 return { |
| 864 ManageProfileOverlay: ManageProfileOverlay, | 882 ManageProfileOverlay: ManageProfileOverlay, |
| 865 CreateProfileOverlay: CreateProfileOverlay, | 883 CreateProfileOverlay: CreateProfileOverlay, |
| 866 }; | 884 }; |
| 867 }); | 885 }); |
| OLD | NEW |