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 OptionsPage = options.OptionsPage; | 6 var OptionsPage = options.OptionsPage; |
7 var ArrayDataModel = cr.ui.ArrayDataModel; | 7 var ArrayDataModel = cr.ui.ArrayDataModel; |
8 | 8 |
9 /** | 9 /** |
10 * ManageProfileOverlay class | 10 * ManageProfileOverlay class |
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
507 | 507 |
508 /** | 508 /** |
509 * Updates the UI when a profile create step begins or ends. | 509 * Updates the UI when a profile create step begins or ends. |
510 * Note that hideErrorBubble_() also enables the "OK" button, so it | 510 * Note that hideErrorBubble_() also enables the "OK" button, so it |
511 * must be called before this function if both are used. | 511 * must be called before this function if both are used. |
512 * @param {boolean} inProgress True if the UI should be updated to show that | 512 * @param {boolean} inProgress True if the UI should be updated to show that |
513 * profile creation is now in progress. | 513 * profile creation is now in progress. |
514 * @private | 514 * @private |
515 */ | 515 */ |
516 updateCreateInProgress_: function(inProgress) { | 516 updateCreateInProgress_: function(inProgress) { |
| 517 this.createInProgress_ = inProgress; |
| 518 this.updateCreateManagedUserCheckbox_(); |
| 519 |
517 $('create-profile-icon-grid').disabled = inProgress; | 520 $('create-profile-icon-grid').disabled = inProgress; |
518 $('create-profile-name').disabled = inProgress; | 521 $('create-profile-name').disabled = inProgress; |
519 $('create-shortcut').disabled = inProgress; | 522 $('create-shortcut').disabled = inProgress; |
520 $('create-profile-managed').disabled = inProgress; | |
521 $('create-profile-ok').disabled = inProgress; | 523 $('create-profile-ok').disabled = inProgress; |
522 | 524 |
523 $('create-profile-throbber').hidden = !inProgress; | 525 $('create-profile-throbber').hidden = !inProgress; |
524 }, | 526 }, |
525 | 527 |
526 /** | 528 /** |
527 * Cancels the creation of the a profile. It is safe to call this even | 529 * Cancels the creation of the a profile. It is safe to call this even |
528 * when no profile is in the process of being created. | 530 * when no profile is in the process of being created. |
529 * @private | 531 * @private |
530 */ | 532 */ |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
613 */ | 615 */ |
614 updateImportExistingManagedUserLink_: function(enable) { | 616 updateImportExistingManagedUserLink_: function(enable) { |
615 var importManagedUserElement = $('import-existing-managed-user-link'); | 617 var importManagedUserElement = $('import-existing-managed-user-link'); |
616 importManagedUserElement.disabled = !enable; | 618 importManagedUserElement.disabled = !enable; |
617 importManagedUserElement.textContent = enable ? | 619 importManagedUserElement.textContent = enable ? |
618 loadTimeData.getString('importExistingManagedUserLink') : | 620 loadTimeData.getString('importExistingManagedUserLink') : |
619 loadTimeData.getString('signInToImportManagedUsers'); | 621 loadTimeData.getString('signInToImportManagedUsers'); |
620 }, | 622 }, |
621 | 623 |
622 /** | 624 /** |
623 * Updates the status of the "create managed user" checkbox. Called by the | 625 * Sets whether creating managed users is allowed or not. Called by the |
624 * handler in response to the 'requestCreateProfileUpdate' message or a | 626 * handler in response to the 'requestCreateProfileUpdate' message or a |
625 * change in the (policy-controlled) pref that prohibits creating managed | 627 * change in the (policy-controlled) pref that prohibits creating managed |
626 * users, after the signed-in status has been updated. | 628 * users, after the signed-in status has been updated. |
627 * @param {boolean} allowed True if creating managed users should be | 629 * @param {boolean} allowed True if creating managed users should be |
628 * allowed. | 630 * allowed. |
629 * @private | 631 * @private |
630 */ | 632 */ |
631 updateManagedUsersAllowed_: function(allowed) { | 633 updateManagedUsersAllowed_: function(allowed) { |
632 var isSignedIn = this.signedInEmail_ !== ''; | 634 this.managedUsersAllowed_ = allowed; |
633 $('create-profile-managed').disabled = | 635 this.updateCreateManagedUserCheckbox_(); |
634 !isSignedIn || !allowed || this.hasError_; | |
635 | 636 |
636 $('create-profile-managed-not-signed-in-link').hidden = !allowed; | 637 $('create-profile-managed-not-signed-in-link').hidden = !allowed; |
637 if (!allowed) { | 638 if (!allowed) { |
638 $('create-profile-managed-indicator').setAttribute('controlled-by', | 639 $('create-profile-managed-indicator').setAttribute('controlled-by', |
639 'policy'); | 640 'policy'); |
640 } else { | 641 } else { |
641 $('create-profile-managed-indicator').removeAttribute('controlled-by'); | 642 $('create-profile-managed-indicator').removeAttribute('controlled-by'); |
642 } | 643 } |
643 }, | 644 }, |
| 645 |
| 646 /** |
| 647 * Updates the status of the "create managed user" checkbox. Called from |
| 648 * updateManagedUsersAllowed_() or updateCreateInProgress_(). |
| 649 * updateSignedInStatus_() does not call this method directly, because it |
| 650 * will be followed by a call to updateManagedUsersAllowed_(). |
| 651 * @private |
| 652 */ |
| 653 updateCreateManagedUserCheckbox_: function() { |
| 654 $('create-profile-managed').disabled = |
| 655 !this.managedUsersAllowed_ || this.createInProgress_ || |
| 656 this.signedInEmail_ == '' || this.hasError_; |
| 657 }, |
644 }; | 658 }; |
645 | 659 |
646 // Forward public APIs to private implementations. | 660 // Forward public APIs to private implementations. |
647 [ | 661 [ |
648 'cancelCreateProfile', | 662 'cancelCreateProfile', |
649 'onError', | 663 'onError', |
650 'onSuccess', | 664 'onSuccess', |
651 'updateCreateInProgress', | 665 'updateCreateInProgress', |
652 'updateManagedUsersAllowed', | 666 'updateManagedUsersAllowed', |
653 'updateSignedInStatus', | 667 'updateSignedInStatus', |
654 ].forEach(function(name) { | 668 ].forEach(function(name) { |
655 CreateProfileOverlay[name] = function() { | 669 CreateProfileOverlay[name] = function() { |
656 var instance = CreateProfileOverlay.getInstance(); | 670 var instance = CreateProfileOverlay.getInstance(); |
657 return instance[name + '_'].apply(instance, arguments); | 671 return instance[name + '_'].apply(instance, arguments); |
658 }; | 672 }; |
659 }); | 673 }); |
660 | 674 |
661 // Export | 675 // Export |
662 return { | 676 return { |
663 ManageProfileOverlay: ManageProfileOverlay, | 677 ManageProfileOverlay: ManageProfileOverlay, |
664 CreateProfileOverlay: CreateProfileOverlay, | 678 CreateProfileOverlay: CreateProfileOverlay, |
665 }; | 679 }; |
666 }); | 680 }); |
OLD | NEW |