Index: chrome/browser/resources/options/managed_user_settings.js |
diff --git a/chrome/browser/resources/options/managed_user_settings.js b/chrome/browser/resources/options/managed_user_settings.js |
index 1151e9f631dc6b5d6b9588cd4c93a714e6cf29ca..cb53eba3f53cc67ff29705a9bf3cdacb64ba6f9b 100644 |
--- a/chrome/browser/resources/options/managed_user_settings.js |
+++ b/chrome/browser/resources/options/managed_user_settings.js |
@@ -6,6 +6,7 @@ if (loadTimeData.getBoolean('managedUsersEnabled')) { |
cr.define('options', function() { |
/** @const */ var OptionsPage = options.OptionsPage; |
+ /** @const */ var SettingsDialog = options.SettingsDialog; |
////////////////////////////////////////////////////////////////////////////// |
// ManagedUserSettings class: |
@@ -16,18 +17,22 @@ cr.define('options', function() { |
* @class |
*/ |
function ManagedUserSettings() { |
- OptionsPage.call( |
+ SettingsDialog.call( |
this, |
'manageduser', |
loadTimeData.getString('managedUserSettingsPageTabTitle'), |
- 'managed-user-settings-page'); |
+ 'managed-user-settings-page', |
+ $('managed-user-settings-confirm'), |
+ $('managed-user-settings-cancel')); |
} |
cr.addSingletonGetter(ManagedUserSettings); |
ManagedUserSettings.prototype = { |
- // Inherit from OptionsPage. |
- __proto__: OptionsPage.prototype, |
+ // Inherit from SettingsDialog. |
+ __proto__: SettingsDialog.prototype, |
+ authenticationChecked: false, |
+ authenticationChecking: false, |
/** |
* Initialize the page. |
@@ -35,23 +40,88 @@ cr.define('options', function() { |
*/ |
initializePage: function() { |
// Call base class implementation to start preference initialization. |
- OptionsPage.prototype.initializePage.call(this); |
+ SettingsDialog.prototype.initializePage.call(this); |
$('get-content-packs-button').onclick = function(event) { |
window.open(loadTimeData.getString('getContentPacksURL')); |
}; |
- $('managed-user-settings-confirm').onclick = function() { |
- chrome.send('confirmManagedUserSettings'); |
- OptionsPage.closeOverlay(); |
+ $('set-passphrase').onclick = function() { |
+ OptionsPage.navigateToPage('setPassphrase'); |
}; |
- $('set-passphrase').onclick = function() { |
- // TODO(bauerb): Set passphrase |
+ $('use-passphrase-checkbox').onclick = function() { |
+ $('set-passphrase').disabled = !$('use-passphrase-checkbox').checked; |
}; |
+ |
+ chrome.send('isPassphraseSet', |
+ ['ManagedUserSettings.initializeSetPassphraseButton']); |
+ }, |
+ getPassphraseButton_: function() { |
+ return $('set-passphrase'); |
+ }, |
+ getUsePassphraseCheckbox_: function() { |
+ return $('use-passphrase-checkbox'); |
+ }, |
+ /** @override */ |
+ canShowPage: function() { |
+ if (this.authenticationChecked) |
+ return true; |
+ if (!this.authenticationChecking) { |
+ chrome.send('displayPassphraseDialog', |
+ ['ManagedUserSettings.isAuthenticated']); |
+ this.authenticationChecking = true; |
+ } |
+ return false; |
+ }, |
+ didClosePage: function() { |
+ // Reset the authentication of the custodian. |
+ this.authenticationChecked = false; |
+ chrome.send('endAuthentication'); |
+ }, |
+ /** @override */ |
+ handleConfirm: function() { |
+ if ($('use-passphrase-checkbox').checked) { |
+ chrome.send('isPassphraseSet', ['ManagedUserSettings.isPassphraseSet']); |
+ } else { |
+ chrome.send('confirmManagedUserSettings'); |
+ chrome.send('resetPassphrase'); |
+ SettingsDialog.prototype.handleConfirm.call(this); |
+ } |
}, |
}; |
+ ManagedUserSettings.initializeSetPassphraseButton = function(success) { |
+ var instance = ManagedUserSettings.getInstance(); |
+ instance.getPassphraseButton_().disabled = !success; |
+ instance.getUsePassphraseCheckbox_().checked = success; |
+ }; |
+ |
+ ManagedUserSettings.isAuthenticated = function(success) { |
+ var instance = ManagedUserSettings.getInstance(); |
+ if (success) { |
+ instance.authenticationChecked = true; |
+ OptionsPage.navigateToPage('managedUser'); |
+ } else { |
+ OptionsPage.closeOverlay(); |
+ } |
+ instance.authenticationChecking = false; |
+ }; |
+ |
+ ManagedUserSettings.isPassphraseSet = function(success) { |
+ if (success) { |
+ var instance = ManagedUserSettings.getInstance(); |
+ SettingsDialog.prototype.handleConfirm.call(instance); |
+ } else { |
+ OptionsPage.navigateToPage('setPassphrase'); |
+ } |
+ }; |
+ |
+ // This method should only be called by the WebUI test. |
+ ManagedUserSettings.getPassphraseButton = function() { |
+ return ManagedUserSettings.getInstance().getPassphraseButton_(); |
+ }; |
+ |
// Export |
return { |
ManagedUserSettings: ManagedUserSettings |