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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 OptionsPage.navigateToPage('manualExceptions'); | 66 OptionsPage.navigateToPage('manualExceptions'); |
67 uber.invokeMethodOnParent('setPath', {path: url}); | 67 uber.invokeMethodOnParent('setPath', {path: url}); |
68 uber.invokeMethodOnParent('setTitle', | 68 uber.invokeMethodOnParent('setTitle', |
69 {title: loadTimeData.getString('manualExceptionsTabTitle')}); | 69 {title: loadTimeData.getString('manualExceptionsTabTitle')}); |
70 }; | 70 }; |
71 | 71 |
72 $('get-content-packs-button').onclick = function(event) { | 72 $('get-content-packs-button').onclick = function(event) { |
73 window.open(loadTimeData.getString('getContentPacksURL')); | 73 window.open(loadTimeData.getString('getContentPacksURL')); |
74 }; | 74 }; |
75 | 75 |
76 $('set-passphrase').onclick = function() { | 76 if (!cr.isChromeOS) { |
77 OptionsPage.navigateToPage('setPassphrase'); | 77 $('set-passphrase').onclick = function() { |
78 }; | 78 OptionsPage.navigateToPage('setPassphrase'); |
| 79 }; |
79 | 80 |
80 $('use-passphrase-checkbox').onclick = function() { | 81 $('use-passphrase-checkbox').onclick = function() { |
81 $('set-passphrase').disabled = !$('use-passphrase-checkbox').checked; | 82 $('set-passphrase').disabled = !$('use-passphrase-checkbox').checked; |
82 }; | 83 }; |
83 | 84 |
84 var self = this; | 85 var self = this; |
| 86 $('lock-settings').onclick = function() { |
| 87 chrome.send('setElevated', [false]); |
| 88 // The managed user is currently authenticated, so don't wait for a |
| 89 // callback to set the new authentication state since a reset to not |
| 90 // elevated is done without showing the passphrase dialog. |
| 91 self.authenticationState = ManagedUserAuthentication.UNAUTHENTICATED; |
| 92 self.enableControls(false); |
| 93 }; |
85 | 94 |
86 $('lock-settings').onclick = function() { | 95 $('unlock-settings').onclick = function() { |
87 chrome.send('setElevated', [false]); | 96 if (self.authenticationState == ManagedUserAuthentication.CHECKING) |
88 // The managed user is currently authenticated, so don't wait for a | 97 return; |
89 // callback to set the new authentication state since a reset to not | 98 self.authenticationState = ManagedUserAuthentication.CHECKING; |
90 // elevated is done without showing the passphrase dialog. | 99 chrome.send('setElevated', [true]); |
91 self.authenticationState = ManagedUserAuthentication.UNAUTHENTICATED; | 100 }; |
92 self.enableControls(false); | 101 } |
93 }; | |
94 | |
95 $('unlock-settings').onclick = function() { | |
96 if (self.authenticationState == ManagedUserAuthentication.CHECKING) | |
97 return; | |
98 self.authenticationState = ManagedUserAuthentication.CHECKING; | |
99 chrome.send('setElevated', [true]); | |
100 }; | |
101 }, | 102 }, |
102 | 103 |
103 /** @override */ | 104 /** @override */ |
104 handleConfirm: function() { | 105 handleConfirm: function() { |
105 if ($('use-passphrase-checkbox').checked && !this.isPassphraseSet) { | 106 if (!cr.isChromeOS) { |
106 OptionsPage.navigateToPage('setPassphrase'); | 107 if ($('use-passphrase-checkbox').checked && !this.isPassphraseSet) { |
107 return; | 108 OptionsPage.navigateToPage('setPassphrase'); |
| 109 return; |
| 110 } |
| 111 if (!$('use-passphrase-checkbox').checked) |
| 112 chrome.send('resetPassphrase'); |
108 } | 113 } |
109 if (!$('use-passphrase-checkbox').checked) | |
110 chrome.send('resetPassphrase'); | |
111 SettingsDialog.prototype.handleConfirm.call(this); | 114 SettingsDialog.prototype.handleConfirm.call(this); |
112 }, | 115 }, |
113 | 116 |
114 /** Update the page according to the current authentication state */ | 117 /** Update the page according to the current authentication state */ |
115 didShowPage: function() { | 118 didShowPage: function() { |
116 var isAuthenticated = | 119 var isAuthenticated = |
117 this.authenticationState == ManagedUserAuthentication.AUTHENTICATED; | 120 this.authenticationState == ManagedUserAuthentication.AUTHENTICATED; |
118 this.enableControls(isAuthenticated); | 121 this.enableControls(isAuthenticated); |
119 chrome.send('settingsPageOpened'); | 122 chrome.send('settingsPageOpened'); |
120 }, | 123 }, |
121 | 124 |
122 // Enables or disables all controls based on the authentication state of | 125 // Enables or disables all controls based on the authentication state of |
123 // the managed user. If |enable| is true, the controls will be enabled. | 126 // the managed user. If |enable| is true, the controls will be enabled. |
124 enableControls: function(enable) { | 127 enableControls: function(enable) { |
125 $('set-passphrase').disabled = | 128 if (!cr.isChromeOS) { |
126 !enable || !$('use-passphrase-checkbox').checked; | 129 $('set-passphrase').disabled = |
| 130 !enable || !$('use-passphrase-checkbox').checked; |
| 131 $('use-passphrase-checkbox').disabled = !enable; |
| 132 } |
127 // TODO(sergiu): make $('get-content-packs-button') behave the same as | 133 // TODO(sergiu): make $('get-content-packs-button') behave the same as |
128 // the other controls once the button actually does something. | 134 // the other controls once the button actually does something. |
129 $('manage-exceptions-button').disabled = !enable; | 135 $('manage-exceptions-button').disabled = !enable; |
130 $('contentpacks-allow').setDisabled('notManagedUserModifiable', !enable); | 136 $('contentpacks-allow').setDisabled('notManagedUserModifiable', !enable); |
131 $('contentpacks-warn').setDisabled('notManagedUserModifiable', !enable); | 137 $('contentpacks-warn').setDisabled('notManagedUserModifiable', !enable); |
132 $('contentpacks-block').setDisabled('notManagedUserModifiable', !enable); | 138 $('contentpacks-block').setDisabled('notManagedUserModifiable', !enable); |
133 $('safe-search-checkbox').setDisabled('notManagedUserModifiable', | 139 $('safe-search-checkbox').setDisabled('notManagedUserModifiable', |
134 !enable); | 140 !enable); |
135 $('allow-signin-checkbox').setDisabled('notManagedUserModifiable', | 141 $('allow-signin-checkbox').setDisabled('notManagedUserModifiable', |
136 !enable); | 142 !enable); |
137 // TODO(akuegel): Add disable-history-deletion-checkbox once this feature | 143 // TODO(akuegel): Add disable-history-deletion-checkbox once this feature |
138 // is implemented. | 144 // is implemented. |
139 $('use-passphrase-checkbox').disabled = !enable; | |
140 if (enable) | 145 if (enable) |
141 $('managed-user-settings-page').classList.remove('locked'); | 146 $('managed-user-settings-page').classList.remove('locked'); |
142 else | 147 else |
143 $('managed-user-settings-page').classList.add('locked'); | 148 $('managed-user-settings-page').classList.add('locked'); |
144 }, | 149 }, |
145 | 150 |
146 // Is called when the passphrase dialog is closed. |success| is true | 151 // Is called when the passphrase dialog is closed. |success| is true |
147 // if the authentication was successful. | 152 // if the authentication was successful. |
148 isAuthenticated_: function(success) { | 153 isAuthenticated_: function(success) { |
149 if (success) { | 154 if (success) { |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 | 218 |
214 // Export | 219 // Export |
215 return { | 220 return { |
216 ManagedUserSettings: ManagedUserSettings, | 221 ManagedUserSettings: ManagedUserSettings, |
217 ManagedUserSettingsForTesting: ManagedUserSettingsForTesting, | 222 ManagedUserSettingsForTesting: ManagedUserSettingsForTesting, |
218 ManagedUserAuthentication: ManagedUserAuthentication | 223 ManagedUserAuthentication: ManagedUserAuthentication |
219 }; | 224 }; |
220 }); | 225 }); |
221 | 226 |
222 } | 227 } |
OLD | NEW |