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

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..2f4782e4d92f3e6ca139425e8dd57c8433c22da8 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
@@ -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;
Dan Beam 2016/04/20 22:38:55 it's odd that createInProgress_ is set to true the
Moe 2016/04/21 17:32:30 It is indeed. I moved all instances of "this.creat
+ } 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));
Dan Beam 2016/04/20 22:38:55 can we just update handleMessage_ to take an {Erro
Moe 2016/04/21 17:32:30 Done. The catch is there'll be type cast needed he
Dan Beam 2016/04/22 01:25:30 could we just make it a real string? this.messa
Moe 2016/04/22 18:46:04 Done.
+ }
+ },
+
+ /**
* 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
Dan Beam 2016/04/20 22:38:55 nit: this row needs a * at the start
Moe 2016/04/21 17:32:30 Done.
+ * @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