Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3322)

Unified Diff: chrome/browser/resources/md_user_manager/create_profile.js

Issue 1901853002: Import supervised user dialog (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@md-user-manager-confirmation-page
Patch Set: Addressed comments Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 671429e40708519d5cf1b2f7a082f49cfd27c825..c35cc655fabbb09f3c03f36a0ec300c33d516952 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({
},
/**
+ * General handler for tap event on the host, used to handle tap events for
tommycli 2016/04/20 18:58:56 In the comment, it would be helpful to call out sp
Moe 2016/04/20 20:10:31 Makes sense. Done.
+ * dynamically added '<a>' elements.
+ * @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
@@ -172,6 +193,28 @@ Polymer({
},
/**
+ * Handler for the 'Import Supervised User' link tap event.
+ * @param {!Event} event
+ * @private
+ */
+ onImportUserTap_: function(event) {
+ this.createInProgress_ = true;
+
+ if (this.signedInUserIndex_ == NO_USER_SELECTED) {
+ // 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.showImportSupervisedUserPopup_.bind(this),
+ /** @param {*} error */
+ function(error) { this.handleMessage_(error); }.bind(this));
+ }
+ },
+
+ /**
* Handler for the 'Save' button tap event.
* @param {!Event} event
* @private
@@ -197,6 +240,18 @@ Polymer({
},
/**
+ * 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.
@@ -249,11 +304,27 @@ Polymer({
}
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) {
+ this.createInProgress_ = true;
+ var supervisedUser = event.detail.supervisedUser;
+ var signedInUser = event.detail.signedInUser;
+ this.browserProxy_.createProfile(
+ supervisedUser.name, supervisedUser.iconURL, true, supervisedUser.id,
+ signedInUser.profilePath);
+ },
+
+ /**
* Handler for the 'Cancel' button tap event.
* @param {!Event} event
* @private
@@ -308,12 +379,6 @@ Polymer({
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.
},
/**
@@ -343,6 +408,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}

Powered by Google App Engine
This is Rietveld 408576698