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 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 options.SupervisedUserListData.requestExistingSupervisedUsers().then( | 349 options.SupervisedUserListData.requestExistingSupervisedUsers().then( |
350 this.receiveExistingSupervisedUsers_.bind(this), | 350 this.receiveExistingSupervisedUsers_.bind(this), |
351 this.onSigninError_.bind(this)); | 351 this.onSigninError_.bind(this)); |
352 }, | 352 }, |
353 | 353 |
354 /** | 354 /** |
355 * @param {Object} supervisedUser | 355 * @param {Object} supervisedUser |
356 * @param {boolean} nameIsUnique | 356 * @param {boolean} nameIsUnique |
357 */ | 357 */ |
358 getImportHandler_: function(supervisedUser, nameIsUnique) { | 358 getImportHandler_: function(supervisedUser, nameIsUnique) { |
359 return function() { | 359 return (function() { |
360 if (supervisedUser.needAvatar || !nameIsUnique) { | 360 if (supervisedUser.needAvatar || !nameIsUnique) { |
361 PageManager.showPageByName('supervisedUserImport'); | 361 PageManager.showPageByName('supervisedUserImport'); |
362 } else { | 362 } else { |
363 this.hideErrorBubble_('create'); | 363 this.hideErrorBubble_('create'); |
364 CreateProfileOverlay.updateCreateInProgress(true); | 364 CreateProfileOverlay.updateCreateInProgress(true); |
365 chrome.send('createProfile', | 365 chrome.send('createProfile', |
366 [supervisedUser.name, supervisedUser.iconURL, false, true, | 366 [supervisedUser.name, supervisedUser.iconURL, false, true, |
367 supervisedUser.id]); | 367 supervisedUser.id]); |
368 } | 368 } |
369 }.bind(this); | 369 }).bind(this); |
370 }, | 370 }, |
371 | 371 |
372 /** | 372 /** |
373 * Callback which receives the list of existing supervised users. Checks if | 373 * Callback which receives the list of existing supervised users. Checks if |
374 * the currently entered name is the name of an already existing supervised | 374 * the currently entered name is the name of an already existing supervised |
375 * user. If yes, the user is prompted to import the existing supervised | 375 * user. If yes, the user is prompted to import the existing supervised |
376 * user, and the create button is disabled. | 376 * user, and the create button is disabled. |
377 * If the received list is empty, hides the "import" link. | 377 * If the received list is empty, hides the "import" link. |
378 * @param {Array.<Object>} supervisedUsers The list of existing supervised | 378 * @param {Array.<Object>} supervisedUsers The list of existing supervised |
379 * users. | 379 * users. |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
590 /** | 590 /** |
591 * Display the "Create Profile" dialog. | 591 * Display the "Create Profile" dialog. |
592 * @private | 592 * @private |
593 */ | 593 */ |
594 showCreateDialog_: function() { | 594 showCreateDialog_: function() { |
595 PageManager.showPageByName('createProfile'); | 595 PageManager.showPageByName('createProfile'); |
596 }, | 596 }, |
597 }; | 597 }; |
598 | 598 |
599 // Forward public APIs to private implementations. | 599 // Forward public APIs to private implementations. |
600 cr.makePublic(ManageProfileOverlay, [ | 600 [ |
601 'receiveDefaultProfileIconsAndNames', | 601 'receiveDefaultProfileIconsAndNames', |
602 'receiveNewProfileDefaults', | 602 'receiveNewProfileDefaults', |
603 'receiveExistingProfileNames', | 603 'receiveExistingProfileNames', |
604 'receiveHasProfileShortcuts', | 604 'receiveHasProfileShortcuts', |
605 'setProfileInfo', | 605 'setProfileInfo', |
606 'setProfileName', | 606 'setProfileName', |
607 'showManageDialog', | 607 'showManageDialog', |
608 'showDeleteDialog', | 608 'showDeleteDialog', |
609 'showDisconnectManagedProfileDialog', | 609 'showDisconnectManagedProfileDialog', |
610 'showCreateDialog', | 610 'showCreateDialog', |
611 ]); | 611 ].forEach(function(name) { |
| 612 ManageProfileOverlay[name] = function() { |
| 613 var instance = ManageProfileOverlay.getInstance(); |
| 614 return instance[name + '_'].apply(instance, arguments); |
| 615 }; |
| 616 }); |
612 | 617 |
613 function CreateProfileOverlay() { | 618 function CreateProfileOverlay() { |
614 Page.call(this, 'createProfile', | 619 Page.call(this, 'createProfile', |
615 loadTimeData.getString('createProfileTabTitle'), | 620 loadTimeData.getString('createProfileTabTitle'), |
616 'manage-profile-overlay'); | 621 'manage-profile-overlay'); |
617 }; | 622 }; |
618 | 623 |
619 cr.addSingletonGetter(CreateProfileOverlay); | 624 cr.addSingletonGetter(CreateProfileOverlay); |
620 | 625 |
621 CreateProfileOverlay.prototype = { | 626 CreateProfileOverlay.prototype = { |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
841 * @private | 846 * @private |
842 */ | 847 */ |
843 updateCreateSupervisedUserCheckbox_: function() { | 848 updateCreateSupervisedUserCheckbox_: function() { |
844 $('create-profile-supervised').disabled = | 849 $('create-profile-supervised').disabled = |
845 !this.supervisedUsersAllowed_ || this.createInProgress_ || | 850 !this.supervisedUsersAllowed_ || this.createInProgress_ || |
846 this.signedInEmail_ == '' || this.hasError_; | 851 this.signedInEmail_ == '' || this.hasError_; |
847 }, | 852 }, |
848 }; | 853 }; |
849 | 854 |
850 // Forward public APIs to private implementations. | 855 // Forward public APIs to private implementations. |
851 cr.makePublic(CreateProfileOverlay, [ | 856 [ |
852 'cancelCreateProfile', | 857 'cancelCreateProfile', |
853 'onError', | 858 'onError', |
854 'onSuccess', | 859 'onSuccess', |
855 'onWarning', | 860 'onWarning', |
856 'updateCreateInProgress', | 861 'updateCreateInProgress', |
857 'updateSignedInStatus', | 862 'updateSignedInStatus', |
858 'updateSupervisedUsersAllowed', | 863 'updateSupervisedUsersAllowed', |
859 ]); | 864 ].forEach(function(name) { |
| 865 CreateProfileOverlay[name] = function() { |
| 866 var instance = CreateProfileOverlay.getInstance(); |
| 867 return instance[name + '_'].apply(instance, arguments); |
| 868 }; |
| 869 }); |
860 | 870 |
861 // Export | 871 // Export |
862 return { | 872 return { |
863 ManageProfileOverlay: ManageProfileOverlay, | 873 ManageProfileOverlay: ManageProfileOverlay, |
864 CreateProfileOverlay: CreateProfileOverlay, | 874 CreateProfileOverlay: CreateProfileOverlay, |
865 }; | 875 }; |
866 }); | 876 }); |
OLD | NEW |