OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 cr.define('options', function() { | 5 cr.define('options', function() { |
6 var Page = cr.ui.pageManager.Page; | 6 var Page = cr.ui.pageManager.Page; |
7 var PageManager = cr.ui.pageManager.PageManager; | 7 var PageManager = cr.ui.pageManager.PageManager; |
8 var ArrayDataModel = cr.ui.ArrayDataModel; | 8 var ArrayDataModel = cr.ui.ArrayDataModel; |
9 | 9 |
10 /** | 10 /** |
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 * Callback which receives the list of existing supervised users. Checks if | 364 * Callback which receives the list of existing supervised users. Checks if |
365 * the currently entered name is the name of an already existing supervised | 365 * the currently entered name is the name of an already existing supervised |
366 * user. If yes, the user is prompted to import the existing supervised | 366 * user. If yes, the user is prompted to import the existing supervised |
367 * user, and the create button is disabled. | 367 * user, and the create button is disabled. |
368 * If the received list is empty, hides the "import" link. | 368 * If the received list is empty, hides the "import" link. |
369 * @param {Array<Object>} supervisedUsers The list of existing supervised | 369 * @param {Array<Object>} supervisedUsers The list of existing supervised |
370 * users. | 370 * users. |
371 * @private | 371 * @private |
372 */ | 372 */ |
373 receiveExistingSupervisedUsers_: function(supervisedUsers) { | 373 receiveExistingSupervisedUsers_: function(supervisedUsers) { |
| 374 // After a supervised user has been created and the dialog has been |
| 375 // hidden, this gets called again with a list including |
| 376 // the just-created SU. Ignore, to prevent the "already exists" bubble |
| 377 // from showing up if the overlay is already hidden. |
| 378 if (!this.visible) |
| 379 return; |
374 $('import-existing-supervised-user-link').hidden = | 380 $('import-existing-supervised-user-link').hidden = |
375 supervisedUsers.length === 0; | 381 supervisedUsers.length === 0; |
376 if (!$('create-profile-supervised').checked) | 382 if (!$('create-profile-supervised').checked) |
377 return; | 383 return; |
378 | 384 |
379 var newName = $('create-profile-name').value; | 385 var newName = $('create-profile-name').value; |
380 var i; | 386 var i; |
381 for (i = 0; i < supervisedUsers.length; ++i) { | 387 for (i = 0; i < supervisedUsers.length; ++i) { |
382 if (supervisedUsers[i].name != newName) | 388 if (supervisedUsers[i].name != newName) |
383 continue; | 389 continue; |
(...skipping 15 matching lines...) Expand all Loading... |
399 } | 405 } |
400 | 406 |
401 var errorHtml = allOnCurrentDevice ? | 407 var errorHtml = allOnCurrentDevice ? |
402 loadTimeData.getStringF( | 408 loadTimeData.getStringF( |
403 'managedProfilesExistingLocalSupervisedUser') : | 409 'managedProfilesExistingLocalSupervisedUser') : |
404 loadTimeData.getStringF( | 410 loadTimeData.getStringF( |
405 'manageProfilesExistingSupervisedUser', | 411 'manageProfilesExistingSupervisedUser', |
406 HTMLEscape(elide(newName, /* maxLength */ 50))); | 412 HTMLEscape(elide(newName, /* maxLength */ 50))); |
407 this.showErrorBubble_(errorHtml, 'create', true); | 413 this.showErrorBubble_(errorHtml, 'create', true); |
408 | 414 |
409 $('supervised-user-import-existing').onclick = | 415 if ($('supervised-user-import-existing')) { |
410 this.getImportHandler_(supervisedUsers[i], nameIsUnique); | 416 $('supervised-user-import-existing').onclick = |
| 417 this.getImportHandler_(supervisedUsers[i], nameIsUnique); |
| 418 } |
411 $('create-profile-ok').disabled = true; | 419 $('create-profile-ok').disabled = true; |
412 return; | 420 return; |
413 } | 421 } |
414 }, | 422 }, |
415 | 423 |
416 /** | 424 /** |
417 * Called in case the request for the list of supervised users fails because | 425 * Called in case the request for the list of supervised users fails because |
418 * of a signin error. | 426 * of a signin error. |
419 * @private | 427 * @private |
420 */ | 428 */ |
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
871 'updateSignedInStatus', | 879 'updateSignedInStatus', |
872 'updateSupervisedUsersAllowed', | 880 'updateSupervisedUsersAllowed', |
873 ]); | 881 ]); |
874 | 882 |
875 // Export | 883 // Export |
876 return { | 884 return { |
877 ManageProfileOverlay: ManageProfileOverlay, | 885 ManageProfileOverlay: ManageProfileOverlay, |
878 CreateProfileOverlay: CreateProfileOverlay, | 886 CreateProfileOverlay: CreateProfileOverlay, |
879 }; | 887 }; |
880 }); | 888 }); |
OLD | NEW |