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 OptionsPage = options.OptionsPage; | 6 var OptionsPage = options.OptionsPage; |
7 var ArrayDataModel = cr.ui.ArrayDataModel; | 7 var ArrayDataModel = cr.ui.ArrayDataModel; |
8 | 8 |
9 /** | 9 /** |
10 * ManageProfileOverlay class | 10 * ManageProfileOverlay class |
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
410 loadTimeData.getString('createProfileTabTitle'), | 410 loadTimeData.getString('createProfileTabTitle'), |
411 'manage-profile-overlay'); | 411 'manage-profile-overlay'); |
412 }; | 412 }; |
413 | 413 |
414 cr.addSingletonGetter(CreateProfileOverlay); | 414 cr.addSingletonGetter(CreateProfileOverlay); |
415 | 415 |
416 CreateProfileOverlay.prototype = { | 416 CreateProfileOverlay.prototype = { |
417 // Inherit from ManageProfileOverlay. | 417 // Inherit from ManageProfileOverlay. |
418 __proto__: ManageProfileOverlay.prototype, | 418 __proto__: ManageProfileOverlay.prototype, |
419 | 419 |
| 420 // The signed-in email address of the current profile, or empty if they're |
| 421 // not signed in. |
| 422 signedInEmail_: '', |
| 423 |
420 /** | 424 /** |
421 * Configures the overlay to the "create user" mode. | 425 * Configures the overlay to the "create user" mode. |
422 * @override | 426 * @override |
423 */ | 427 */ |
424 didShowPage: function() { | 428 didShowPage: function() { |
425 chrome.send('requestSignedInText'); | 429 chrome.send('requestSignedInText'); |
426 chrome.send('requestDefaultProfileIcons'); | 430 chrome.send('requestDefaultProfileIcons'); |
427 chrome.send('requestNewProfileDefaults'); | 431 chrome.send('requestNewProfileDefaults'); |
428 | 432 |
429 $('manage-profile-overlay-create').hidden = false; | 433 $('manage-profile-overlay-create').hidden = false; |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
520 * name: "Profile Name", | 524 * name: "Profile Name", |
521 * filePath: "/path/to/profile/data/on/disk" | 525 * filePath: "/path/to/profile/data/on/disk" |
522 * isManaged: (true|false), | 526 * isManaged: (true|false), |
523 * }; | 527 * }; |
524 * @private | 528 * @private |
525 */ | 529 */ |
526 onSuccess_: function(profileInfo) { | 530 onSuccess_: function(profileInfo) { |
527 this.updateCreateInProgress_(false); | 531 this.updateCreateInProgress_(false); |
528 OptionsPage.closeOverlay(); | 532 OptionsPage.closeOverlay(); |
529 if (profileInfo.isManaged) { | 533 if (profileInfo.isManaged) { |
| 534 profileInfo.custodianEmail = this.signedInEmail_; |
530 ManagedUserCreateConfirmOverlay.setProfileInfo(profileInfo); | 535 ManagedUserCreateConfirmOverlay.setProfileInfo(profileInfo); |
531 OptionsPage.navigateToPage('managedUserCreateConfirm'); | 536 OptionsPage.navigateToPage('managedUserCreateConfirm'); |
532 } | 537 } |
533 }, | 538 }, |
534 | 539 |
535 /** | 540 /** |
536 * Updates the signed-in or not-signed-in UI when in create mode. Called by | 541 * Updates the signed-in or not-signed-in UI when in create mode. Called by |
537 * the handler in response to the 'requestSignedInText' message. | 542 * the handler in response to the 'requestSignedInText' message. |
538 * @param {string} text The text to show for a signed-in user. An empty | 543 * @param {string} email The email address of the currently signed-in user. |
539 * string indicates that the user is not signed in. | 544 * An empty string indicates that the user is not signed in. |
540 * @private | 545 * @private |
541 */ | 546 */ |
542 updateSignedInStatus_: function(text) { | 547 updateSignedInStatus_: function(email) { |
543 var isSignedIn = text !== ''; | 548 this.signedInEmail_ = email; |
| 549 var isSignedIn = email !== ''; |
544 $('create-profile-managed-signed-in').hidden = !isSignedIn; | 550 $('create-profile-managed-signed-in').hidden = !isSignedIn; |
545 $('create-profile-managed-not-signed-in').hidden = isSignedIn; | 551 $('create-profile-managed-not-signed-in').hidden = isSignedIn; |
546 $('create-profile-managed').disabled = !isSignedIn; | 552 $('create-profile-managed').disabled = !isSignedIn; |
547 if (!isSignedIn) | 553 if (isSignedIn) { |
| 554 $('create-profile-managed-signed-in-label').textContent = |
| 555 loadTimeData.getStringF( |
| 556 'manageProfilesManagedSignedInLabel', email); |
| 557 } else { |
548 $('create-profile-managed').checked = false; | 558 $('create-profile-managed').checked = false; |
549 | 559 } |
550 $('create-profile-managed-signed-in-label').textContent = text; | |
551 }, | 560 }, |
552 }; | 561 }; |
553 | 562 |
554 // Forward public APIs to private implementations. | 563 // Forward public APIs to private implementations. |
555 [ | 564 [ |
556 'cancelCreateProfile', | 565 'cancelCreateProfile', |
557 'onLocalError', | 566 'onLocalError', |
558 'onRemoteError', | 567 'onRemoteError', |
559 'onSuccess', | 568 'onSuccess', |
560 'updateCreateInProgress', | 569 'updateCreateInProgress', |
561 'updateSignedInStatus', | 570 'updateSignedInStatus', |
562 ].forEach(function(name) { | 571 ].forEach(function(name) { |
563 CreateProfileOverlay[name] = function() { | 572 CreateProfileOverlay[name] = function() { |
564 var instance = CreateProfileOverlay.getInstance(); | 573 var instance = CreateProfileOverlay.getInstance(); |
565 return instance[name + '_'].apply(instance, arguments); | 574 return instance[name + '_'].apply(instance, arguments); |
566 }; | 575 }; |
567 }); | 576 }); |
568 | 577 |
569 // Export | 578 // Export |
570 return { | 579 return { |
571 ManageProfileOverlay: ManageProfileOverlay, | 580 ManageProfileOverlay: ManageProfileOverlay, |
572 CreateProfileOverlay: CreateProfileOverlay, | 581 CreateProfileOverlay: CreateProfileOverlay, |
573 }; | 582 }; |
574 }); | 583 }); |
OLD | NEW |