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 | 9 |
10 ////////////////////////////////////////////////////////////////////////////// | 10 ////////////////////////////////////////////////////////////////////////////// |
(...skipping 10 matching lines...) Expand all Loading... |
21 'manageduser', | 21 'manageduser', |
22 loadTimeData.getString('managedUserSettingsPageTabTitle'), | 22 loadTimeData.getString('managedUserSettingsPageTabTitle'), |
23 'managed-user-settings-page'); | 23 'managed-user-settings-page'); |
24 } | 24 } |
25 | 25 |
26 cr.addSingletonGetter(ManagedUserSettings); | 26 cr.addSingletonGetter(ManagedUserSettings); |
27 | 27 |
28 ManagedUserSettings.prototype = { | 28 ManagedUserSettings.prototype = { |
29 // Inherit from OptionsPage. | 29 // Inherit from OptionsPage. |
30 __proto__: OptionsPage.prototype, | 30 __proto__: OptionsPage.prototype, |
| 31 authenticationChecked: false, |
| 32 authenticationChecking: false, |
31 | 33 |
32 /** | 34 /** |
33 * Initialize the page. | 35 * Initialize the page. |
34 * @override | 36 * @override |
35 */ | 37 */ |
36 initializePage: function() { | 38 initializePage: function() { |
| 39 var self = this; |
37 // Call base class implementation to start preference initialization. | 40 // Call base class implementation to start preference initialization. |
38 OptionsPage.prototype.initializePage.call(this); | 41 OptionsPage.prototype.initializePage.call(this); |
39 | 42 |
40 $('get-content-packs-button').onclick = function(event) { | 43 $('get-content-packs-button').onclick = function(event) { |
41 window.open(loadTimeData.getString('getContentPacksURL')); | 44 window.open(loadTimeData.getString('getContentPacksURL')); |
42 }; | 45 }; |
43 | 46 |
44 $('managed-user-settings-confirm').onclick = function() { | 47 $('managed-user-settings-confirm').onclick = function() { |
45 OptionsPage.closeOverlay(); | 48 if ($('use-passphrase-checkbox').checked) { |
| 49 chrome.send('isPassphraseSet'); |
| 50 } else { |
| 51 chrome.send('resetPassphrase'); |
| 52 OptionsPage.closeOverlay(); |
| 53 } |
46 }; | 54 }; |
47 | 55 |
48 $('set-passphrase').onclick = function() { | 56 $('set-passphrase').onclick = function() { |
49 // TODO(bauerb): Set passphrase | 57 OptionsPage.navigateToPage('setPassphrase'); |
50 }; | 58 }; |
51 }, | 59 }, |
| 60 getPassphraseButton_: function() { |
| 61 return $('set-passphrase'); |
| 62 }, |
| 63 /** @override */ |
| 64 canShowPage: function() { |
| 65 if (this.authenticationChecked) |
| 66 return true; |
| 67 if (!this.authenticationChecking) { |
| 68 chrome.send('displayPassphraseDialog', |
| 69 ['ManagedUserSettings.isAuthenticated']); |
| 70 this.authenticationChecking = true; |
| 71 } |
| 72 return false; |
| 73 }, |
| 74 didClosePage: function() { |
| 75 // Reset the authentication of the custodian. |
| 76 this.authenticationChecked = false; |
| 77 chrome.send('endAuthentication'); |
| 78 }, |
52 }; | 79 }; |
53 | 80 |
| 81 ManagedUserSettings.isAuthenticated = function(success) { |
| 82 var instance = ManagedUserSettings.getInstance(); |
| 83 if (success) { |
| 84 instance.authenticationChecked = true; |
| 85 OptionsPage.navigateToPage('managedUser'); |
| 86 } else { |
| 87 OptionsPage.closeOverlay(); |
| 88 } |
| 89 instance.authenticationChecking = false; |
| 90 }; |
| 91 |
| 92 ManagedUserSettings.isPassphraseSet = function(success) { |
| 93 if (success) { |
| 94 OptionsPage.closeOverlay(); |
| 95 } else { |
| 96 OptionsPage.navigateToPage('setPassphrase'); |
| 97 } |
| 98 }; |
| 99 |
| 100 // This method should only be called by the WebUI test. |
| 101 ManagedUserSettings.getPassphraseButton = function() { |
| 102 return ManagedUserSettings.getInstance().getPassphraseButton_(); |
| 103 }; |
| 104 |
54 // Export | 105 // Export |
55 return { | 106 return { |
56 ManagedUserSettings: ManagedUserSettings | 107 ManagedUserSettings: ManagedUserSettings |
57 }; | 108 }; |
58 }); | 109 }); |
59 | 110 |
60 } | 111 } |
OLD | NEW |