| Index: chrome/browser/resources/md_user_manager/create_profile.js
|
| diff --git a/chrome/browser/resources/md_user_manager/create_profile.js b/chrome/browser/resources/md_user_manager/create_profile.js
|
| index e7d0113315a0e775471f672ae6bb904e80e7750a..74e2627192a0e63c77c75756b98d31745aa76b46 100644
|
| --- a/chrome/browser/resources/md_user_manager/create_profile.js
|
| +++ b/chrome/browser/resources/md_user_manager/create_profile.js
|
| @@ -98,6 +98,11 @@ Polymer({
|
| browserProxy_: Object
|
| },
|
|
|
| + listeners: {
|
| + 'tap': 'onTap_',
|
| + 'importUserPopup.import': 'onImportUserPopupImport_'
|
| + },
|
| +
|
| /** @override */
|
| created: function() {
|
| this.browserProxy_ = signin.ProfileBrowserProxyImpl.getInstance();
|
| @@ -126,6 +131,22 @@ Polymer({
|
| },
|
|
|
| /**
|
| + * Handles tap events from dynamically created links in warning/error messages
|
| + * pushed by the browser.
|
| + * @param {!Event} event
|
| + * @private
|
| + */
|
| + onTap_: function(event) {
|
| + var element = Polymer.dom(event).rootTarget;
|
| +
|
| + if (element.id == 'supervised-user-import-existing') {
|
| + this.onImportUserTap_(event);
|
| + event.preventDefault();
|
| + }
|
| + // TODO(mahmadi): handle tap event on '#reauth' to re-auth the custodian.
|
| + },
|
| +
|
| + /**
|
| * Handler for when the profile icons are pushed from the browser.
|
| * @param {!Array<string>} iconUrls
|
| * @private
|
| @@ -137,7 +158,7 @@ Polymer({
|
|
|
| /**
|
| * Handler for when the profile defaults are pushed from the browser.
|
| - * @param {ProfileInfo} profileInfo Default Info for the new profile.
|
| + * @param {!ProfileInfo} profileInfo Default Info for the new profile.
|
| * @private
|
| */
|
| handleProfileDefaults_: function(profileInfo) {
|
| @@ -172,35 +193,61 @@ Polymer({
|
| },
|
|
|
| /**
|
| + * Handler for the 'Import Supervised User' link tap event.
|
| + * @param {!Event} event
|
| + * @private
|
| + */
|
| + onImportUserTap_: function(event) {
|
| + if (this.signedInUserIndex_ == NO_USER_SELECTED) {
|
| + // A custodian must be selected.
|
| + this.handleMessage_(this.i18n('custodianAccountNotSelectedError'));
|
| + } else {
|
| + var signedInUser = this.signedInUser_(this.signedInUserIndex_);
|
| + this.createInProgress_ = true;
|
| + this.browserProxy_.getExistingSupervisedUsers(signedInUser.profilePath)
|
| + .then(this.showImportSupervisedUserPopup_.bind(this),
|
| + this.handleMessage_.bind(this));
|
| + }
|
| + },
|
| +
|
| + /**
|
| * Handler for the 'Save' button tap event.
|
| * @param {!Event} event
|
| * @private
|
| */
|
| onSaveTap_: function(event) {
|
| - this.createInProgress_ = true;
|
| -
|
| if (!this.isSupervised_) {
|
| // The new profile is not supervised. Go ahead and create it.
|
| this.createProfile_();
|
| } else if (this.signedInUserIndex_ == NO_USER_SELECTED) {
|
| // If the new profile is supervised, a custodian must be selected.
|
| this.handleMessage_(this.i18n('custodianAccountNotSelectedError'));
|
| - this.createInProgress_ = false;
|
| } else {
|
| var signedInUser = this.signedInUser_(this.signedInUserIndex_);
|
| - this.browserProxy_.getExistingSupervisedUsers(
|
| - signedInUser.profilePath).then(
|
| - this.createProfileIfValidSupervisedUser_.bind(this),
|
| - /** @param {*} error */
|
| - function(error) { this.handleMessage_(error); }.bind(this));
|
| + this.createInProgress_ = true;
|
| + this.browserProxy_.getExistingSupervisedUsers(signedInUser.profilePath)
|
| + .then(this.createProfileIfValidSupervisedUser_.bind(this),
|
| + this.handleMessage_.bind(this));
|
| }
|
| },
|
|
|
| /**
|
| + * Displays the import supervised user popup.
|
| + * @param {!Array<!SupervisedUser>} supervisedUsers The list of existing
|
| + * supervised users.
|
| + * @private
|
| + */
|
| + showImportSupervisedUserPopup_: function(supervisedUsers) {
|
| + this.createInProgress_ = false;
|
| + this.$.importUserPopup.show(this.signedInUser_(this.signedInUserIndex_),
|
| + supervisedUsers);
|
| + },
|
| +
|
| + /**
|
| * Checks if the entered name matches name of an existing supervised user.
|
| * If yes, the user is prompted to import the existing supervised user.
|
| * If no, the new supervised profile gets created.
|
| - * @param {Array<SupervisedUser>} supervisedUsers The list of existing
|
| + * @param {!Array<!SupervisedUser>} supervisedUsers The list of existing
|
| * supervised users.
|
| * @private
|
| */
|
| @@ -228,8 +275,6 @@ Polymer({
|
| this.i18n('managedProfilesExistingLocalSupervisedUser') :
|
| this.i18n('manageProfilesExistingSupervisedUser',
|
| HTMLEscape(elide(this.profileName_, /* maxLength */ 50))));
|
| -
|
| - this.createInProgress_ = false;
|
| return;
|
| }
|
| // No existing supervised user's name matches the entered profile name.
|
| @@ -247,13 +292,29 @@ Polymer({
|
| custodianProfilePath =
|
| this.signedInUser_(this.signedInUserIndex_).profilePath;
|
| }
|
| -
|
| + this.createInProgress_ = true;
|
| this.browserProxy_.createProfile(
|
| - this.profileName_, this.profileIconUrl_, this.isSupervised_,
|
| + this.profileName_, this.profileIconUrl_, this.isSupervised_, '',
|
| custodianProfilePath);
|
| },
|
|
|
| /**
|
| + * Handler for the 'import' event fired by #importUserPopup once a supervised
|
| + * user is selected to be imported and the popup closes.
|
| + * @param {!{detail: {supervisedUser: !SupervisedUser,
|
| + * signedInUser: !SignedInUser}}} event
|
| + * @private
|
| + */
|
| + onImportUserPopupImport_: function(event) {
|
| + var supervisedUser = event.detail.supervisedUser;
|
| + var signedInUser = event.detail.signedInUser;
|
| + this.createInProgress_ = true;
|
| + this.browserProxy_.createProfile(
|
| + supervisedUser.name, supervisedUser.iconURL, true, supervisedUser.id,
|
| + signedInUser.profilePath);
|
| + },
|
| +
|
| + /**
|
| * Handler for the 'Cancel' button tap event.
|
| * @param {!Event} event
|
| * @private
|
| @@ -297,18 +358,12 @@ Polymer({
|
|
|
| /**
|
| * Handles profile create/import warning/error message pushed by the browser.
|
| - * @param {string} message An HTML warning/error message.
|
| + * @param {*} message An HTML warning/error message.
|
| * @private
|
| */
|
| handleMessage_: function(message) {
|
| this.createInProgress_ = false;
|
| - this.message_ = message;
|
| -
|
| - // TODO(mahmadi): attach handler to '#supervised-user-import-existing'
|
| - // in order to import supervised user with the given name.
|
| -
|
| - // TODO(mahmadi): attach handler to '#reauth' in order to re-authenticate
|
| - // custodian.
|
| + this.message_ = '' + message;
|
| },
|
|
|
| /**
|
| @@ -338,6 +393,17 @@ Polymer({
|
| },
|
|
|
| /**
|
| + * Returns True if the import supervised user link should be hidden.
|
| + * @param {boolean} createInProgress True if create/import is in progress
|
| + * @param {number} signedInUserIndex Index of the selected signed-in user.
|
| + * @return {boolean}
|
| + * @private
|
| + */
|
| + isImportUserLinkHidden_: function(createInProgress, signedInUserIndex) {
|
| + return createInProgress || !this.signedInUser_(signedInUserIndex);
|
| + },
|
| +
|
| + /**
|
| * Computed binding that returns True if there are any signed-in users.
|
| * @param {!Array<!SignedInUser>} signedInUsers signed-in users.
|
| * @return {boolean}
|
|
|