Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 207 * Handler for the 'Import Supervised User' link tap event. | 207 * Handler for the 'Import Supervised User' link tap event. |
| 208 * @param {!Event} event | 208 * @param {!Event} event |
| 209 * @private | 209 * @private |
| 210 */ | 210 */ |
| 211 onImportUserTap_: function(event) { | 211 onImportUserTap_: function(event) { |
| 212 if (this.signedInUserIndex_ == NO_USER_SELECTED) { | 212 if (this.signedInUserIndex_ == NO_USER_SELECTED) { |
| 213 // A custodian must be selected. | 213 // A custodian must be selected. |
| 214 this.handleMessage_(this.i18n('custodianAccountNotSelectedError')); | 214 this.handleMessage_(this.i18n('custodianAccountNotSelectedError')); |
| 215 } else { | 215 } else { |
| 216 var signedInUser = this.signedInUser_(this.signedInUserIndex_); | 216 var signedInUser = this.signedInUser_(this.signedInUserIndex_); |
| 217 // Clear any existing error messages. | |
| 218 this.handleMessage_(''); | |
|
Dan Beam
2016/05/19 20:30:44
this is fine, but if you feel the need to add a co
Dan Beam
2016/05/19 22:28:32
sorry, this should be handleMessage_('')
Moe
2016/05/20 13:49:27
Makes sense. Done.
Moe
2016/05/20 13:49:27
Ended up setting the message to '' directly in cle
| |
| 217 this.createInProgress_ = true; | 219 this.createInProgress_ = true; |
| 218 this.browserProxy_.getExistingSupervisedUsers(signedInUser.profilePath) | 220 this.browserProxy_.getExistingSupervisedUsers(signedInUser.profilePath) |
| 219 .then(this.showImportSupervisedUserPopup_.bind(this), | 221 .then(this.showImportSupervisedUserPopup_.bind(this), |
| 220 this.handleMessage_.bind(this)); | 222 this.handleMessage_.bind(this)); |
| 221 } | 223 } |
| 222 }, | 224 }, |
| 223 | 225 |
| 224 /** | 226 /** |
| 225 * Handler for the 'Save' button tap event. | 227 * Handler for the 'Save' button tap event. |
| 226 * @param {!Event} event | 228 * @param {!Event} event |
| 227 * @private | 229 * @private |
| 228 */ | 230 */ |
| 229 onSaveTap_: function(event) { | 231 onSaveTap_: function(event) { |
| 230 if (!this.isSupervised_) { | 232 if (!this.isSupervised_) { |
| 231 // The new profile is not supervised. Go ahead and create it. | 233 // The new profile is not supervised. Go ahead and create it. |
| 232 this.createProfile_(); | 234 this.createProfile_(); |
| 233 } else if (this.signedInUserIndex_ == NO_USER_SELECTED) { | 235 } else if (this.signedInUserIndex_ == NO_USER_SELECTED) { |
| 234 // If the new profile is supervised, a custodian must be selected. | 236 // If the new profile is supervised, a custodian must be selected. |
| 235 this.handleMessage_(this.i18n('custodianAccountNotSelectedError')); | 237 this.handleMessage_(this.i18n('custodianAccountNotSelectedError')); |
| 236 } else { | 238 } else { |
| 237 var signedInUser = this.signedInUser_(this.signedInUserIndex_); | 239 var signedInUser = this.signedInUser_(this.signedInUserIndex_); |
| 240 // Clear any existing error messages. | |
| 241 this.handleMessage_(''); | |
| 238 this.createInProgress_ = true; | 242 this.createInProgress_ = true; |
| 239 this.browserProxy_.getExistingSupervisedUsers(signedInUser.profilePath) | 243 this.browserProxy_.getExistingSupervisedUsers(signedInUser.profilePath) |
| 240 .then(this.createProfileIfValidSupervisedUser_.bind(this), | 244 .then(this.createProfileIfValidSupervisedUser_.bind(this), |
| 241 this.handleMessage_.bind(this)); | 245 this.handleMessage_.bind(this)); |
| 242 } | 246 } |
| 243 }, | 247 }, |
| 244 | 248 |
| 245 /** | 249 /** |
| 246 * Displays the import supervised user popup. | 250 * Displays the import supervised user popup. |
| 247 * @param {!Array<!SupervisedUser>} supervisedUsers The list of existing | 251 * @param {!Array<!SupervisedUser>} supervisedUsers The list of existing |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 314 /** | 318 /** |
| 315 * Creates the new profile. | 319 * Creates the new profile. |
| 316 * @private | 320 * @private |
| 317 */ | 321 */ |
| 318 createProfile_: function() { | 322 createProfile_: function() { |
| 319 var custodianProfilePath = ''; | 323 var custodianProfilePath = ''; |
| 320 if (this.signedInUserIndex_ != NO_USER_SELECTED) { | 324 if (this.signedInUserIndex_ != NO_USER_SELECTED) { |
| 321 custodianProfilePath = | 325 custodianProfilePath = |
| 322 this.signedInUser_(this.signedInUserIndex_).profilePath; | 326 this.signedInUser_(this.signedInUserIndex_).profilePath; |
| 323 } | 327 } |
| 328 // Clear any existing error messages. | |
| 329 this.handleMessage_(''); | |
| 324 this.createInProgress_ = true; | 330 this.createInProgress_ = true; |
| 325 this.browserProxy_.createProfile( | 331 this.browserProxy_.createProfile( |
| 326 this.profileName_, this.profileIconUrl_, this.isSupervised_, '', | 332 this.profileName_, this.profileIconUrl_, this.isSupervised_, '', |
| 327 custodianProfilePath); | 333 custodianProfilePath); |
| 328 }, | 334 }, |
| 329 | 335 |
| 330 /** | 336 /** |
| 331 * Handler for the 'import' event fired by #importUserPopup once a supervised | 337 * Handler for the 'import' event fired by #importUserPopup once a supervised |
| 332 * user is selected to be imported and the popup closes. | 338 * user is selected to be imported and the popup closes. |
| 333 * @param {!{detail: {supervisedUser: !SupervisedUser, | 339 * @param {!{detail: {supervisedUser: !SupervisedUser, |
| 334 * signedInUser: !SignedInUser}}} event | 340 * signedInUser: !SignedInUser}}} event |
| 335 * @private | 341 * @private |
| 336 */ | 342 */ |
| 337 onImportUserPopupImport_: function(event) { | 343 onImportUserPopupImport_: function(event) { |
| 338 var supervisedUser = event.detail.supervisedUser; | 344 var supervisedUser = event.detail.supervisedUser; |
| 339 var signedInUser = event.detail.signedInUser; | 345 var signedInUser = event.detail.signedInUser; |
| 346 // Clear any existing error messages. | |
| 347 this.handleMessage_(''); | |
| 340 this.createInProgress_ = true; | 348 this.createInProgress_ = true; |
| 341 this.browserProxy_.createProfile( | 349 this.browserProxy_.createProfile( |
| 342 supervisedUser.name, supervisedUser.iconURL, true, supervisedUser.id, | 350 supervisedUser.name, supervisedUser.iconURL, true, supervisedUser.id, |
| 343 signedInUser.profilePath); | 351 signedInUser.profilePath); |
| 344 }, | 352 }, |
| 345 | 353 |
| 346 /** | 354 /** |
| 347 * Handler for the 'Cancel' button tap event. | 355 * Handler for the 'Cancel' button tap event. |
| 348 * @param {!Event} event | 356 * @param {!Event} event |
| 349 * @private | 357 * @private |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 384 this.createInProgress_ = false; | 392 this.createInProgress_ = false; |
| 385 if (profileInfo.showConfirmation) { | 393 if (profileInfo.showConfirmation) { |
| 386 this.fire('change-page', {page: 'supervised-create-confirm-page', | 394 this.fire('change-page', {page: 'supervised-create-confirm-page', |
| 387 data: profileInfo}); | 395 data: profileInfo}); |
| 388 } else { | 396 } else { |
| 389 this.fire('change-page', {page: 'user-pods-page'}); | 397 this.fire('change-page', {page: 'user-pods-page'}); |
| 390 } | 398 } |
| 391 }, | 399 }, |
| 392 | 400 |
| 393 /** | 401 /** |
| 394 * Handles profile create/import warning/error message pushed by the browser. | 402 * Handles profile create/import warning/error message pushed by the browser. |
|
Dan Beam
2016/05/19 20:30:44
this says "pushed by the browser" which is a littl
| |
| 395 * @param {*} message An HTML warning/error message. | 403 * @param {*} message An HTML warning/error message. |
| 396 * @private | 404 * @private |
| 397 */ | 405 */ |
| 398 handleMessage_: function(message) { | 406 handleMessage_: function(message) { |
| 399 this.createInProgress_ = false; | 407 this.createInProgress_ = false; |
| 400 this.message_ = '' + message; | 408 this.message_ = '' + message; |
| 401 }, | 409 }, |
| 402 | 410 |
| 403 /** | 411 /** |
| 404 * Returns a translated message that contains link elements with the 'id' | 412 * Returns a translated message that contains link elements with the 'id' |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 459 * Computed binding that returns True if there are any signed-in users. | 467 * Computed binding that returns True if there are any signed-in users. |
| 460 * @param {!Array<!SignedInUser>} signedInUsers signed-in users. | 468 * @param {!Array<!SignedInUser>} signedInUsers signed-in users. |
| 461 * @return {boolean} | 469 * @return {boolean} |
| 462 * @private | 470 * @private |
| 463 */ | 471 */ |
| 464 isSignedIn_: function(signedInUsers) { | 472 isSignedIn_: function(signedInUsers) { |
| 465 return signedInUsers.length > 0; | 473 return signedInUsers.length > 0; |
| 466 } | 474 } |
| 467 }); | 475 }); |
| 468 }()); | 476 }()); |
| OLD | NEW |