Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2863)

Unified Diff: chrome/browser/resources/options/managed_user_settings.js

Issue 11783008: Add a lock to the managed user settings page and require authentication for unlocking. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase to ToT and address review comments. Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..4fc79bf4bb10fa6d5fa2a15f46ba8a60a8de6ded 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 Authentication = {
Bernhard Bauer 2013/02/20 13:06:20 I think we should prefix this with ManagedUser?
Adrian Kuegel 2013/02/20 13:28:26 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: Authentication.UNAUTHENTICATED,
+
+ // Stores if the local passphrase of the manager of the managed account is
+ // 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;
$('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 == Authentication.CHECKING)
+ return;
+ chrome.send('displayPassphraseDialog',
+ ['options.ManagedUserSettings.isAuthenticated']);
+ self.authenticationState = Authentication.CHECKING;
+ };
},
/** @override */
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) {
+ $('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 = Authentication.AUTHENTICATED;
+ this.enableControls(true);
+ } else {
+ this.authenticationState = Authentication.UNAUTHENTICATED;
+ }
+ },
+ didClosePage: function() {
+ // Reset the authentication of the custodian.
+ this.authenticationState = Authentication.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 = Authentication.UNAUTHENTICATED;
+ instance.enableControls(false);
+ } else {
+ instance.authenticationState = Authentication.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,
+ Authentication: Authentication
};
});

Powered by Google App Engine
This is Rietveld 408576698