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

Side by Side Diff: chrome/browser/resources/md_user_manager/create_profile.js

Issue 1993503004: MD User Manager: Clear existing error messages before browser calls (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments Created 4 years, 7 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 /** 5 /**
6 * @fileoverview 'create-profile' is a page that contains controls for creating 6 * @fileoverview 'create-profile' is a page that contains controls for creating
7 * a (optionally supervised) profile, including choosing a name, and an avatar. 7 * a (optionally supervised) profile, including choosing a name, and an avatar.
8 */ 8 */
9 (function() { 9 (function() {
10 /** 10 /**
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 * Handler for the 'Import Supervised User' link tap event. 212 * Handler for the 'Import Supervised User' link tap event.
213 * @param {!Event} event 213 * @param {!Event} event
214 * @private 214 * @private
215 */ 215 */
216 onImportUserTap_: function(event) { 216 onImportUserTap_: function(event) {
217 if (this.signedInUserIndex_ == NO_USER_SELECTED) { 217 if (this.signedInUserIndex_ == NO_USER_SELECTED) {
218 // A custodian must be selected. 218 // A custodian must be selected.
219 this.handleMessage_(this.i18n('custodianAccountNotSelectedError')); 219 this.handleMessage_(this.i18n('custodianAccountNotSelectedError'));
220 } else { 220 } else {
221 var signedInUser = this.signedInUser_(this.signedInUserIndex_); 221 var signedInUser = this.signedInUser_(this.signedInUserIndex_);
222 this.clearMessage_();
222 this.createInProgress_ = true; 223 this.createInProgress_ = true;
223 this.browserProxy_.getExistingSupervisedUsers(signedInUser.profilePath) 224 this.browserProxy_.getExistingSupervisedUsers(signedInUser.profilePath)
224 .then(this.showImportSupervisedUserPopup_.bind(this), 225 .then(this.showImportSupervisedUserPopup_.bind(this),
225 this.handleMessage_.bind(this)); 226 this.handleMessage_.bind(this));
226 } 227 }
227 }, 228 },
228 229
229 /** 230 /**
230 * Handler for the 'Save' button tap event. 231 * Handler for the 'Save' button tap event.
231 * @param {!Event} event 232 * @param {!Event} event
232 * @private 233 * @private
233 */ 234 */
234 onSaveTap_: function(event) { 235 onSaveTap_: function(event) {
235 if (!this.isSupervised_) { 236 if (!this.isSupervised_) {
236 // The new profile is not supervised. Go ahead and create it. 237 // The new profile is not supervised. Go ahead and create it.
237 this.createProfile_(); 238 this.createProfile_();
238 } else if (this.signedInUserIndex_ == NO_USER_SELECTED) { 239 } else if (this.signedInUserIndex_ == NO_USER_SELECTED) {
239 // If the new profile is supervised, a custodian must be selected. 240 // If the new profile is supervised, a custodian must be selected.
240 this.handleMessage_(this.i18n('custodianAccountNotSelectedError')); 241 this.handleMessage_(this.i18n('custodianAccountNotSelectedError'));
241 } else { 242 } else {
242 var signedInUser = this.signedInUser_(this.signedInUserIndex_); 243 var signedInUser = this.signedInUser_(this.signedInUserIndex_);
244 this.clearMessage_();
243 this.createInProgress_ = true; 245 this.createInProgress_ = true;
244 this.browserProxy_.getExistingSupervisedUsers(signedInUser.profilePath) 246 this.browserProxy_.getExistingSupervisedUsers(signedInUser.profilePath)
245 .then(this.createProfileIfValidSupervisedUser_.bind(this), 247 .then(this.createProfileIfValidSupervisedUser_.bind(this),
246 this.handleMessage_.bind(this)); 248 this.handleMessage_.bind(this));
247 } 249 }
248 }, 250 },
249 251
250 /** 252 /**
251 * Displays the import supervised user popup. 253 * Displays the import supervised user popup.
252 * @param {!Array<!SupervisedUser>} supervisedUsers The list of existing 254 * @param {!Array<!SupervisedUser>} supervisedUsers The list of existing
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 /** 321 /**
320 * Creates the new profile. 322 * Creates the new profile.
321 * @private 323 * @private
322 */ 324 */
323 createProfile_: function() { 325 createProfile_: function() {
324 var custodianProfilePath = ''; 326 var custodianProfilePath = '';
325 if (this.signedInUserIndex_ != NO_USER_SELECTED) { 327 if (this.signedInUserIndex_ != NO_USER_SELECTED) {
326 custodianProfilePath = 328 custodianProfilePath =
327 this.signedInUser_(this.signedInUserIndex_).profilePath; 329 this.signedInUser_(this.signedInUserIndex_).profilePath;
328 } 330 }
331 this.clearMessage_();
329 this.createInProgress_ = true; 332 this.createInProgress_ = true;
330 this.browserProxy_.createProfile( 333 this.browserProxy_.createProfile(
331 this.profileName_, this.profileIconUrl_, this.isSupervised_, '', 334 this.profileName_, this.profileIconUrl_, this.isSupervised_, '',
332 custodianProfilePath); 335 custodianProfilePath);
333 }, 336 },
334 337
335 /** 338 /**
336 * Handler for the 'import' event fired by #importUserPopup once a supervised 339 * Handler for the 'import' event fired by #importUserPopup once a supervised
337 * user is selected to be imported and the popup closes. 340 * user is selected to be imported and the popup closes.
338 * @param {!{detail: {supervisedUser: !SupervisedUser, 341 * @param {!{detail: {supervisedUser: !SupervisedUser,
339 * signedInUser: !SignedInUser}}} event 342 * signedInUser: !SignedInUser}}} event
340 * @private 343 * @private
341 */ 344 */
342 onImportUserPopupImport_: function(event) { 345 onImportUserPopupImport_: function(event) {
343 var supervisedUser = event.detail.supervisedUser; 346 var supervisedUser = event.detail.supervisedUser;
344 var signedInUser = event.detail.signedInUser; 347 var signedInUser = event.detail.signedInUser;
348 this.clearMessage_();
345 this.createInProgress_ = true; 349 this.createInProgress_ = true;
346 this.browserProxy_.createProfile( 350 this.browserProxy_.createProfile(
347 supervisedUser.name, supervisedUser.iconURL, true, supervisedUser.id, 351 supervisedUser.name, supervisedUser.iconURL, true, supervisedUser.id,
348 signedInUser.profilePath); 352 signedInUser.profilePath);
349 }, 353 },
350 354
351 /** 355 /**
352 * Handler for the 'Cancel' button tap event. 356 * Handler for the 'Cancel' button tap event.
353 * @param {!Event} event 357 * @param {!Event} event
354 * @private 358 * @private
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 this.createInProgress_ = false; 393 this.createInProgress_ = false;
390 if (profileInfo.showConfirmation) { 394 if (profileInfo.showConfirmation) {
391 this.fire('change-page', {page: 'supervised-create-confirm-page', 395 this.fire('change-page', {page: 'supervised-create-confirm-page',
392 data: profileInfo}); 396 data: profileInfo});
393 } else { 397 } else {
394 this.fire('change-page', {page: 'user-pods-page'}); 398 this.fire('change-page', {page: 'user-pods-page'});
395 } 399 }
396 }, 400 },
397 401
398 /** 402 /**
403 * Clears the warning/error message.
404 * @private
405 */
406 clearMessage_: function() {
407 this.message_ = '';
408 },
409
410 /**
399 * Handles profile create/import warning/error message pushed by the browser. 411 * Handles profile create/import warning/error message pushed by the browser.
400 * @param {*} message An HTML warning/error message. 412 * @param {*} message An HTML warning/error message.
401 * @private 413 * @private
402 */ 414 */
403 handleMessage_: function(message) { 415 handleMessage_: function(message) {
404 this.createInProgress_ = false; 416 this.createInProgress_ = false;
405 this.message_ = '' + message; 417 this.message_ = '' + message;
406 }, 418 },
407 419
408 /** 420 /**
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 * Computed binding that returns True if there are any signed-in users. 476 * Computed binding that returns True if there are any signed-in users.
465 * @param {!Array<!SignedInUser>} signedInUsers signed-in users. 477 * @param {!Array<!SignedInUser>} signedInUsers signed-in users.
466 * @return {boolean} 478 * @return {boolean}
467 * @private 479 * @private
468 */ 480 */
469 isSignedIn_: function(signedInUsers) { 481 isSignedIn_: function(signedInUsers) {
470 return signedInUsers.length > 0; 482 return signedInUsers.length > 0;
471 } 483 }
472 }); 484 });
473 }()); 485 }());
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698