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 [ | 600 cr.makePublic(ManageProfileOverlay, [ |
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 ].forEach(function(name) { | 611 ]); |
612 ManageProfileOverlay[name] = function() { | |
613 var instance = ManageProfileOverlay.getInstance(); | |
614 return instance[name + '_'].apply(instance, arguments); | |
615 }; | |
616 }); | |
617 | 612 |
618 function CreateProfileOverlay() { | 613 function CreateProfileOverlay() { |
619 Page.call(this, 'createProfile', | 614 Page.call(this, 'createProfile', |
620 loadTimeData.getString('createProfileTabTitle'), | 615 loadTimeData.getString('createProfileTabTitle'), |
621 'manage-profile-overlay'); | 616 'manage-profile-overlay'); |
622 }; | 617 }; |
623 | 618 |
624 cr.addSingletonGetter(CreateProfileOverlay); | 619 cr.addSingletonGetter(CreateProfileOverlay); |
625 | 620 |
626 CreateProfileOverlay.prototype = { | 621 CreateProfileOverlay.prototype = { |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
846 * @private | 841 * @private |
847 */ | 842 */ |
848 updateCreateSupervisedUserCheckbox_: function() { | 843 updateCreateSupervisedUserCheckbox_: function() { |
849 $('create-profile-supervised').disabled = | 844 $('create-profile-supervised').disabled = |
850 !this.supervisedUsersAllowed_ || this.createInProgress_ || | 845 !this.supervisedUsersAllowed_ || this.createInProgress_ || |
851 this.signedInEmail_ == '' || this.hasError_; | 846 this.signedInEmail_ == '' || this.hasError_; |
852 }, | 847 }, |
853 }; | 848 }; |
854 | 849 |
855 // Forward public APIs to private implementations. | 850 // Forward public APIs to private implementations. |
856 [ | 851 cr.makePublic(CreateProfileOverlay, [ |
857 'cancelCreateProfile', | 852 'cancelCreateProfile', |
858 'onError', | 853 'onError', |
859 'onSuccess', | 854 'onSuccess', |
860 'onWarning', | 855 'onWarning', |
861 'updateCreateInProgress', | 856 'updateCreateInProgress', |
862 'updateSignedInStatus', | 857 'updateSignedInStatus', |
863 'updateSupervisedUsersAllowed', | 858 'updateSupervisedUsersAllowed', |
864 ].forEach(function(name) { | 859 ]); |
865 CreateProfileOverlay[name] = function() { | |
866 var instance = CreateProfileOverlay.getInstance(); | |
867 return instance[name + '_'].apply(instance, arguments); | |
868 }; | |
869 }); | |
870 | 860 |
871 // Export | 861 // Export |
872 return { | 862 return { |
873 ManageProfileOverlay: ManageProfileOverlay, | 863 ManageProfileOverlay: ManageProfileOverlay, |
874 CreateProfileOverlay: CreateProfileOverlay, | 864 CreateProfileOverlay: CreateProfileOverlay, |
875 }; | 865 }; |
876 }); | 866 }); |
OLD | NEW |