| 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 | 9 |
| 10 /** @typedef {{url: string, label:string}} */ | 10 /** @typedef {{url: string, label:string}} */ |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 }, | 257 }, |
| 258 | 258 |
| 259 /** | 259 /** |
| 260 * Handler for the 'Import Supervised User' link tap event. | 260 * Handler for the 'Import Supervised User' link tap event. |
| 261 * @param {!Event} event | 261 * @param {!Event} event |
| 262 * @private | 262 * @private |
| 263 */ | 263 */ |
| 264 onImportUserTap_: function(event) { | 264 onImportUserTap_: function(event) { |
| 265 if (this.signedInUserIndex_ == NO_USER_SELECTED) { | 265 if (this.signedInUserIndex_ == NO_USER_SELECTED) { |
| 266 // A custodian must be selected. | 266 // A custodian must be selected. |
| 267 this.handleMessage_(this.i18n('custodianAccountNotSelectedError')); | 267 this.handleMessage_( |
| 268 this.i18nAdvanced('custodianAccountNotSelectedError')); |
| 268 } else { | 269 } else { |
| 269 var signedInUser = this.signedInUser_(this.signedInUserIndex_); | 270 var signedInUser = this.signedInUser_(this.signedInUserIndex_); |
| 270 this.hideMessage_(); | 271 this.hideMessage_(); |
| 271 this.loadingSupervisedUsers_ = true; | 272 this.loadingSupervisedUsers_ = true; |
| 272 this.browserProxy_.getExistingSupervisedUsers(signedInUser.profilePath) | 273 this.browserProxy_.getExistingSupervisedUsers(signedInUser.profilePath) |
| 273 .then(this.showImportSupervisedUserPopup_.bind(this), | 274 .then(this.showImportSupervisedUserPopup_.bind(this), |
| 274 this.handleMessage_.bind(this)); | 275 this.handleMessage_.bind(this)); |
| 275 } | 276 } |
| 276 }, | 277 }, |
| 277 | 278 |
| 278 /** | 279 /** |
| 279 * Handler for the 'Save' button tap event. | 280 * Handler for the 'Save' button tap event. |
| 280 * @param {!Event} event | 281 * @param {!Event} event |
| 281 * @private | 282 * @private |
| 282 */ | 283 */ |
| 283 onSaveTap_: function(event) { | 284 onSaveTap_: function(event) { |
| 284 if (!this.isSupervised_) { | 285 if (!this.isSupervised_) { |
| 285 // The new profile is not supervised. Go ahead and create it. | 286 // The new profile is not supervised. Go ahead and create it. |
| 286 this.createProfile_(); | 287 this.createProfile_(); |
| 287 } else if (this.signedInUserIndex_ == NO_USER_SELECTED) { | 288 } else if (this.signedInUserIndex_ == NO_USER_SELECTED) { |
| 288 // If the new profile is supervised, a custodian must be selected. | 289 // If the new profile is supervised, a custodian must be selected. |
| 289 this.handleMessage_(this.i18n('custodianAccountNotSelectedError')); | 290 this.handleMessage_( |
| 291 this.i18nAdvanced('custodianAccountNotSelectedError')); |
| 290 } else { | 292 } else { |
| 291 var signedInUser = this.signedInUser_(this.signedInUserIndex_); | 293 var signedInUser = this.signedInUser_(this.signedInUserIndex_); |
| 292 this.hideMessage_(); | 294 this.hideMessage_(); |
| 293 this.loadingSupervisedUsers_ = true; | 295 this.loadingSupervisedUsers_ = true; |
| 294 this.browserProxy_.getExistingSupervisedUsers(signedInUser.profilePath) | 296 this.browserProxy_.getExistingSupervisedUsers(signedInUser.profilePath) |
| 295 .then(this.createProfileIfValidSupervisedUser_.bind(this), | 297 .then(this.createProfileIfValidSupervisedUser_.bind(this), |
| 296 this.handleMessage_.bind(this)); | 298 this.handleMessage_.bind(this)); |
| 297 } | 299 } |
| 298 }, | 300 }, |
| 299 | 301 |
| 300 /** | 302 /** |
| 301 * Displays the import supervised user popup or an error message if there are | 303 * Displays the import supervised user popup or an error message if there are |
| 302 * no existing supervised users. | 304 * no existing supervised users. |
| 303 * @param {!Array<!SupervisedUser>} supervisedUsers The list of existing | 305 * @param {!Array<!SupervisedUser>} supervisedUsers The list of existing |
| 304 * supervised users. | 306 * supervised users. |
| 305 * @private | 307 * @private |
| 306 */ | 308 */ |
| 307 showImportSupervisedUserPopup_: function(supervisedUsers) { | 309 showImportSupervisedUserPopup_: function(supervisedUsers) { |
| 308 this.loadingSupervisedUsers_ = false; | 310 this.loadingSupervisedUsers_ = false; |
| 309 if (supervisedUsers.length > 0) { | 311 if (supervisedUsers.length > 0) { |
| 310 this.$.importUserPopup.show(this.signedInUser_(this.signedInUserIndex_), | 312 this.$.importUserPopup.show(this.signedInUser_(this.signedInUserIndex_), |
| 311 supervisedUsers); | 313 supervisedUsers); |
| 312 } else { | 314 } else { |
| 313 this.handleMessage_(this.i18n('noSupervisedUserImportText')); | 315 this.handleMessage_(this.i18nAdvanced('noSupervisedUserImportText')); |
| 314 } | 316 } |
| 315 }, | 317 }, |
| 316 | 318 |
| 317 /** | 319 /** |
| 318 * Checks if the entered name matches name of an existing supervised user. | 320 * Checks if the entered name matches name of an existing supervised user. |
| 319 * If yes, the user is prompted to import the existing supervised user. | 321 * If yes, the user is prompted to import the existing supervised user. |
| 320 * If no, the new supervised profile gets created. | 322 * If no, the new supervised profile gets created. |
| 321 * @param {!Array<!SupervisedUser>} supervisedUsers The list of existing | 323 * @param {!Array<!SupervisedUser>} supervisedUsers The list of existing |
| 322 * supervised users. | 324 * supervised users. |
| 323 * @private | 325 * @private |
| (...skipping 30 matching lines...) Expand all Loading... |
| 354 }, | 356 }, |
| 355 'role': function(node, value) { | 357 'role': function(node, value) { |
| 356 return node.tagName == 'A' && value == 'link'; | 358 return node.tagName == 'A' && value == 'link'; |
| 357 }, | 359 }, |
| 358 'tabindex': function(node, value) { | 360 'tabindex': function(node, value) { |
| 359 return node.tagName == 'A'; | 361 return node.tagName == 'A'; |
| 360 } | 362 } |
| 361 } | 363 } |
| 362 }; | 364 }; |
| 363 | 365 |
| 364 this.handleMessage_(allOnCurrentDevice ? | 366 this.handleMessage_( |
| 365 this.i18n('managedProfilesExistingLocalSupervisedUser') : | 367 allOnCurrentDevice ? |
| 366 this.i18nAdvanced('manageProfilesExistingSupervisedUser', opts)); | 368 this.i18nAdvanced('managedProfilesExistingLocalSupervisedUser') : |
| 369 this.i18nAdvanced('manageProfilesExistingSupervisedUser', opts)); |
| 367 return; | 370 return; |
| 368 } | 371 } |
| 369 // No existing supervised user's name matches the entered profile name. | 372 // No existing supervised user's name matches the entered profile name. |
| 370 // Continue with creating the new supervised profile. | 373 // Continue with creating the new supervised profile. |
| 371 this.createProfile_(); | 374 this.createProfile_(); |
| 372 // Set this to false after createInProgress_ has been set to true in | 375 // Set this to false after createInProgress_ has been set to true in |
| 373 // order for the 'Save' button to remain disabled. | 376 // order for the 'Save' button to remain disabled. |
| 374 this.loadingSupervisedUsers_ = false; | 377 this.loadingSupervisedUsers_ = false; |
| 375 }, | 378 }, |
| 376 | 379 |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 543 * Computed binding that returns True if there are any signed-in users. | 546 * Computed binding that returns True if there are any signed-in users. |
| 544 * @param {!Array<!SignedInUser>} signedInUsers signed-in users. | 547 * @param {!Array<!SignedInUser>} signedInUsers signed-in users. |
| 545 * @return {boolean} | 548 * @return {boolean} |
| 546 * @private | 549 * @private |
| 547 */ | 550 */ |
| 548 isSignedIn_: function(signedInUsers) { | 551 isSignedIn_: function(signedInUsers) { |
| 549 return signedInUsers.length > 0; | 552 return signedInUsers.length > 0; |
| 550 } | 553 } |
| 551 }); | 554 }); |
| 552 }()); | 555 }()); |
| OLD | NEW |