Chromium Code Reviews| 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 if (loadTimeData.getBoolean('managedUsersEnabled')) { | 5 if (loadTimeData.getBoolean('managedUsersEnabled')) { |
| 6 | 6 |
| 7 cr.define('options', function() { | 7 cr.define('options', function() { |
| 8 /** @const */ var OptionsPage = options.OptionsPage; | 8 /** @const */ var OptionsPage = options.OptionsPage; |
| 9 /** @const */ var SettingsDialog = options.SettingsDialog; | 9 /** @const */ var SettingsDialog = options.SettingsDialog; |
| 10 | 10 |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 24 'managed-user-settings-page', | 24 'managed-user-settings-page', |
| 25 $('managed-user-settings-confirm'), | 25 $('managed-user-settings-confirm'), |
| 26 $('managed-user-settings-cancel')); | 26 $('managed-user-settings-cancel')); |
| 27 } | 27 } |
| 28 | 28 |
| 29 cr.addSingletonGetter(ManagedUserSettings); | 29 cr.addSingletonGetter(ManagedUserSettings); |
| 30 | 30 |
| 31 ManagedUserSettings.prototype = { | 31 ManagedUserSettings.prototype = { |
| 32 // Inherit from SettingsDialog. | 32 // Inherit from SettingsDialog. |
| 33 __proto__: SettingsDialog.prototype, | 33 __proto__: SettingsDialog.prototype, |
| 34 authenticationChecked: false, | |
|
Bernhard Bauer
2013/02/15 10:05:20
I think a better name for this would be "isAuthent
Adrian Kuegel
2013/02/20 12:42:13
Yes, good idea. I changed it like that.
| |
| 35 authenticationChecking: false, | |
| 34 | 36 |
| 35 /** | 37 /** |
| 36 * Initialize the page. | 38 * Initialize the page. |
| 37 * @override | 39 * @override |
| 38 */ | 40 */ |
| 39 initializePage: function() { | 41 initializePage: function() { |
| 40 // Call base class implementation to start preference initialization. | 42 // Call base class implementation to start preference initialization. |
| 41 SettingsDialog.prototype.initializePage.call(this); | 43 SettingsDialog.prototype.initializePage.call(this); |
| 42 | 44 |
| 43 $('get-content-packs-button').onclick = function(event) { | 45 $('get-content-packs-button').onclick = function(event) { |
| 44 window.open(loadTimeData.getString('getContentPacksURL')); | 46 window.open(loadTimeData.getString('getContentPacksURL')); |
| 45 }; | 47 }; |
| 46 | 48 |
| 47 $('set-passphrase').onclick = function() { | 49 $('set-passphrase').onclick = function() { |
| 48 OptionsPage.navigateToPage('setPassphrase'); | 50 OptionsPage.navigateToPage('setPassphrase'); |
| 49 }; | 51 }; |
| 50 | 52 |
| 53 $('use-passphrase-checkbox').onclick = function() { | |
| 54 $('set-passphrase').disabled = !$('use-passphrase-checkbox').checked; | |
| 55 }; | |
| 56 | |
| 57 $('unlock-settings').onclick = function() { | |
| 58 if (!this.isAuthenticationChecking) { | |
|
Bernhard Bauer
2013/02/15 10:05:20
You could invert the condition and early-return.
Adrian Kuegel
2013/02/20 12:42:13
Done.
| |
| 59 chrome.send('displayPassphraseDialog', | |
| 60 ['ManagedUserSettings.isAuthenticated']); | |
| 61 this.authenticationChecking = true; | |
| 62 } | |
| 63 }; | |
| 51 }, | 64 }, |
| 52 /** @override */ | 65 /** @override */ |
| 53 handleConfirm: function() { | 66 handleConfirm: function() { |
| 54 chrome.send('confirmManagedUserSettings'); | 67 if ($('use-passphrase-checkbox').checked) { |
| 55 SettingsDialog.prototype.handleConfirm.call(this); | 68 chrome.send('isPassphraseSet', ['ManagedUserSettings.isPassphraseSet']); |
| 69 } else { | |
| 70 chrome.send('confirmManagedUserSettings'); | |
| 71 chrome.send('resetPassphrase'); | |
| 72 SettingsDialog.prototype.handleConfirm.call(this); | |
| 73 } | |
| 56 }, | 74 }, |
| 75 updateControls: function(disable) { | |
| 76 $('set-passphrase').disabled = disable; | |
|
Bernhard Bauer
2013/02/15 10:05:20
Please don't simply set the disabled attribute. Th
Adrian Kuegel
2013/02/20 12:42:13
If I understand that right, I can only use this on
| |
| 77 $('get-content-packs-button').disabled = disable; | |
| 78 $('contentpacks-allow').disabled = disable; | |
| 79 $('contentpacks-warn').disabled = disable; | |
| 80 $('contentpacks-block').disabled = disable; | |
| 81 $('safe-search-checkbox').disabled = disable; | |
| 82 $('disable-signin-checkbox').disabled = disable; | |
| 83 $('disable-history-deletion-checkbox').disabled = disable; | |
| 84 $('use-passphrase-checkbox').disabled = disable; | |
| 85 $('unlock-settings').disabled = !disable; | |
| 86 }, | |
| 87 didShowPage: function() { | |
| 88 chrome.send('isPassphraseSet', | |
|
Bernhard Bauer
2013/02/15 10:05:20
Instead of asking the browser asynchronously, coul
Adrian Kuegel
2013/02/20 12:42:13
Done.
| |
| 89 ['ManagedUserSettings.initializeSetPassphraseButton']); | |
| 90 }, | |
| 91 didClosePage: function() { | |
| 92 // Reset the authentication of the custodian. | |
| 93 this.authenticationChecked = false; | |
| 94 chrome.send('endAuthentication'); | |
| 95 }, | |
| 96 }; | |
| 97 | |
| 98 ManagedUserSettings.initializeSetPassphraseButton = function(hasPassphrase) { | |
| 99 $('set-passphrase').disabled = !hasPassphrase; | |
| 100 $('use-passphrase-checkbox').checked = hasPassphrase; | |
| 101 if (hasPassphrase) { | |
| 102 ManagedUserSettings.getInstance().updateControls(true); | |
|
Pam (message me for reviews)
2013/02/15 09:31:18
This would be clearer if the argument were flipped
Adrian Kuegel
2013/02/15 09:56:02
Done. I also renamed the function to enableControl
| |
| 103 } else { | |
| 104 ManagedUserSettings.getInstance().authenticationChecked = true; | |
| 105 $('unlock-settings').disabled = true; | |
| 106 } | |
| 107 }; | |
| 108 | |
| 109 ManagedUserSettings.isAuthenticated = function(success) { | |
|
Bernhard Bauer
2013/02/15 10:05:20
I think it would be nicer if you delegate to an in
Adrian Kuegel
2013/02/20 12:42:13
Done.
| |
| 110 var instance = ManagedUserSettings.getInstance(); | |
| 111 if (success) { | |
| 112 instance.authenticationChecked = true; | |
| 113 instance.updateControls(false); | |
| 114 } | |
| 115 instance.authenticationChecking = false; | |
| 116 }; | |
| 117 | |
| 118 ManagedUserSettings.isPassphraseSet = function(success) { | |
|
Bernhard Bauer
2013/02/15 10:05:20
|success| means whether the passphrase is set? Cou
Adrian Kuegel
2013/02/20 12:42:13
Done.
| |
| 119 if (success) { | |
| 120 var instance = ManagedUserSettings.getInstance(); | |
| 121 SettingsDialog.prototype.handleConfirm.call(instance); | |
| 122 } else { | |
| 123 OptionsPage.navigateToPage('setPassphrase'); | |
| 124 } | |
| 57 }; | 125 }; |
| 58 | 126 |
| 59 var ManagedUserSettingsForTesting = { | 127 var ManagedUserSettingsForTesting = { |
| 60 getSetPassphraseButton: function() { | 128 getSetPassphraseButton: function() { |
| 61 return $('set-passphrase'); | 129 return $('set-passphrase'); |
| 130 }, | |
| 131 getUnlockButton: function() { | |
| 132 return $('unlock-settings'); | |
| 62 } | 133 } |
| 63 }; | 134 }; |
| 64 | 135 |
| 65 // Export | 136 // Export |
| 66 return { | 137 return { |
| 67 ManagedUserSettings: ManagedUserSettings, | 138 ManagedUserSettings: ManagedUserSettings, |
| 68 ManagedUserSettingsForTesting: ManagedUserSettingsForTesting | 139 ManagedUserSettingsForTesting: ManagedUserSettingsForTesting |
| 69 }; | 140 }; |
| 70 }); | 141 }); |
| 71 | 142 |
| 72 } | 143 } |
| OLD | NEW |