Chromium Code Reviews| 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 3300cdb0c3fe3993464176a08e38b32cec7ba940..2657407b1af494b5b99a499a9991b44de91755b5 100644 |
| --- a/chrome/browser/resources/options/managed_user_settings.js |
| +++ b/chrome/browser/resources/options/managed_user_settings.js |
| @@ -28,10 +28,28 @@ cr.define('options', function() { |
| cr.addSingletonGetter(ManagedUserSettings); |
| + var ManagedUserAuthentication = { |
|
James Hawkins
2013/02/20 17:24:56
nit: Document enum.
Adrian Kuegel
2013/02/20 18:05:02
Done.
|
| + // The manager of the managed account is not authenticated. |
| + UNAUTHENTICATED: 'unauthenticated', |
| + |
| + // The authentication is currently being checked. |
| + CHECKING: 'checking', |
| + |
| + // The manager of the managed account is authenticated. |
| + AUTHENTICATED: 'authenticated' |
| + }; |
| + |
| ManagedUserSettings.prototype = { |
| // Inherit from SettingsDialog. |
| __proto__: SettingsDialog.prototype, |
| + // The current authentication state of the manager of the managed account. |
| + authenticationState: ManagedUserAuthentication.UNAUTHENTICATED, |
| + |
| + // Stores if the local passphrase of the manager of the managed account is |
|
James Hawkins
2013/02/20 17:24:56
nit: // True if the local passphrase...
Adrian Kuegel
2013/02/20 18:05:02
Done.
|
| + // set. If it is not set, no authentication is required. |
| + isPassphraseSet: false, |
| + |
| /** |
| * Initialize the page. |
| * @override |
| @@ -39,6 +57,7 @@ cr.define('options', function() { |
| initializePage: function() { |
| // Call base class implementation to start preference initialization. |
| SettingsDialog.prototype.initializePage.call(this); |
| + var self = this; |
|
James Hawkins
2013/02/20 17:24:56
nit: Move this var to right above where it's used.
Adrian Kuegel
2013/02/20 18:05:02
Done.
|
| $('get-content-packs-button').onclick = function(event) { |
| window.open(loadTimeData.getString('getContentPacksURL')); |
| @@ -48,24 +67,93 @@ cr.define('options', function() { |
| OptionsPage.navigateToPage('setPassphrase'); |
| }; |
| + $('use-passphrase-checkbox').onclick = function() { |
| + $('set-passphrase').disabled = !$('use-passphrase-checkbox').checked; |
| + }; |
| + |
| + $('unlock-settings').onclick = function() { |
| + if (self.authenticationState == ManagedUserAuthentication.CHECKING) |
| + return; |
| + chrome.send('displayPassphraseDialog', |
| + ['options.ManagedUserSettings.isAuthenticated']); |
| + self.authenticationState = ManagedUserAuthentication.CHECKING; |
| + }; |
| }, |
| /** @override */ |
|
James Hawkins
2013/02/20 17:24:56
nit: Add one blank line above each method where no
Adrian Kuegel
2013/02/20 18:05:02
Done.
|
| handleConfirm: function() { |
| + if ($('use-passphrase-checkbox').checked && !this.isPassphraseSet) { |
| + OptionsPage.navigateToPage('setPassphrase'); |
| + return; |
| + } |
| + if (!$('use-passphrase-checkbox').checked) |
| + chrome.send('resetPassphrase'); |
| chrome.send('confirmManagedUserSettings'); |
| SettingsDialog.prototype.handleConfirm.call(this); |
| }, |
| + enableControls: function(enable) { |
|
James Hawkins
2013/02/20 17:24:56
nit: Document new methods and params.
Adrian Kuegel
2013/02/20 18:05:02
Done.
|
| + $('set-passphrase').disabled = !enable; |
| + $('get-content-packs-button').disabled = !enable; |
| + $('contentpacks-allow').setDisabled('notManagedUserModifiable', !enable); |
| + $('contentpacks-warn').setDisabled('notManagedUserModifiable', !enable); |
| + $('contentpacks-block').setDisabled('notManagedUserModifiable', !enable); |
| + $('safe-search-checkbox').setDisabled( |
| + 'notManagedUserModifiable', !enable); |
| + // TODO(akuegel): Add disable-signin-checkbox and |
| + // disable-history-deletion-checkbox once these features are implemented |
| + $('use-passphrase-checkbox').disabled = !enable; |
| + $('unlock-settings').disabled = enable; |
| + }, |
| + isAuthenticated_: function(success) { |
| + if (success) { |
| + this.authenticationState = ManagedUserAuthentication.AUTHENTICATED; |
| + this.enableControls(true); |
| + } else { |
| + this.authenticationState = ManagedUserAuthentication.UNAUTHENTICATED; |
| + } |
| + }, |
| + didClosePage: function() { |
| + // Reset the authentication of the custodian. |
| + this.authenticationState = ManagedUserAuthentication.UNAUTHENTICATED; |
| + chrome.send('endAuthentication'); |
| + }, |
| + }; |
| + |
| + ManagedUserSettings.initializeSetPassphraseButton = function(hasPassphrase) { |
| + $('set-passphrase').disabled = !hasPassphrase; |
| + $('use-passphrase-checkbox').checked = hasPassphrase; |
| + var instance = ManagedUserSettings.getInstance(); |
| + instance.isPassphraseSet = hasPassphrase; |
| + if (hasPassphrase) { |
| + instance.authenticationState = ManagedUserAuthentication.UNAUTHENTICATED; |
| + instance.enableControls(false); |
| + } else { |
| + instance.authenticationState = ManagedUserAuthentication.AUTHENTICATED; |
| + $('unlock-settings').disabled = true; |
| + } |
| + }; |
| + |
| + ManagedUserSettings.isAuthenticated = function(success) { |
| + ManagedUserSettings.getInstance().isAuthenticated_(success); |
| + }; |
| + |
| + ManagedUserSettings.passphraseChanged = function(isPassphraseSet) { |
| + ManagedUserSettings.getInstance().isPassphraseSet = isPassphraseSet; |
| }; |
| var ManagedUserSettingsForTesting = { |
| getSetPassphraseButton: function() { |
| return $('set-passphrase'); |
| + }, |
| + getUnlockButton: function() { |
| + return $('unlock-settings'); |
| } |
| }; |
| - // Export |
| + // Export |
| return { |
| ManagedUserSettings: ManagedUserSettings, |
| - ManagedUserSettingsForTesting: ManagedUserSettingsForTesting |
| + ManagedUserSettingsForTesting: ManagedUserSettingsForTesting, |
| + ManagedUserAuthentication: ManagedUserAuthentication |
| }; |
| }); |