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

Side by Side 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: A few more fixes. 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 10
10 ////////////////////////////////////////////////////////////////////////////// 11 //////////////////////////////////////////////////////////////////////////////
11 // ManagedUserSettings class: 12 // ManagedUserSettings class:
12 13
13 /** 14 /**
14 * Encapsulated handling of the Managed User Settings page. 15 * Encapsulated handling of the Managed User Settings page.
15 * @constructor 16 * @constructor
16 * @class 17 * @class
17 */ 18 */
18 function ManagedUserSettings() { 19 function ManagedUserSettings() {
19 OptionsPage.call( 20 SettingsDialog.call(
20 this, 21 this,
21 'manageduser', 22 'manageduser',
22 loadTimeData.getString('managedUserSettingsPageTabTitle'), 23 loadTimeData.getString('managedUserSettingsPageTabTitle'),
23 'managed-user-settings-page'); 24 'managed-user-settings-page',
25 $('managed-user-settings-confirm'),
26 $('managed-user-settings-cancel'));
24 } 27 }
25 28
26 cr.addSingletonGetter(ManagedUserSettings); 29 cr.addSingletonGetter(ManagedUserSettings);
27 30
28 ManagedUserSettings.prototype = { 31 ManagedUserSettings.prototype = {
29 // Inherit from OptionsPage. 32 // Inherit from SettingsDialog.
30 __proto__: OptionsPage.prototype, 33 __proto__: SettingsDialog.prototype,
34 authenticationChecked: false,
35 authenticationChecking: false,
31 36
32 /** 37 /**
33 * Initialize the page. 38 * Initialize the page.
34 * @override 39 * @override
35 */ 40 */
36 initializePage: function() { 41 initializePage: function() {
37 // Call base class implementation to start preference initialization. 42 // Call base class implementation to start preference initialization.
38 OptionsPage.prototype.initializePage.call(this); 43 SettingsDialog.prototype.initializePage.call(this);
39 44
40 $('get-content-packs-button').onclick = function(event) { 45 $('get-content-packs-button').onclick = function(event) {
41 window.open(loadTimeData.getString('getContentPacksURL')); 46 window.open(loadTimeData.getString('getContentPacksURL'));
42 }; 47 };
43 48
44 $('managed-user-settings-confirm').onclick = function() { 49 $('set-passphrase').onclick = function() {
45 chrome.send('confirmManagedUserSettings'); 50 OptionsPage.navigateToPage('setPassphrase');
46 OptionsPage.closeOverlay();
47 }; 51 };
48 52
49 $('set-passphrase').onclick = function() { 53 $('use-passphrase-checkbox').onclick = function() {
50 // TODO(bauerb): Set passphrase 54 $('set-passphrase').disabled = !$('use-passphrase-checkbox').checked;
51 }; 55 };
56
57 chrome.send('isPassphraseSet',
58 ['ManagedUserSettings.initializeSetPassphraseButton']);
52 }, 59 },
60 getPassphraseButton_: function() {
61 return $('set-passphrase');
62 },
63 getUsePassphraseCheckbox_: function() {
64 return $('use-passphrase-checkbox');
65 },
66 /** @override */
67 canShowPage: function() {
68 if (this.authenticationChecked)
69 return true;
70 if (!this.authenticationChecking) {
71 chrome.send('displayPassphraseDialog',
72 ['ManagedUserSettings.isAuthenticated']);
73 this.authenticationChecking = true;
74 }
75 return false;
76 },
77 didClosePage: function() {
78 // Reset the authentication of the custodian.
79 this.authenticationChecked = false;
80 chrome.send('endAuthentication');
81 },
82 /** @override */
83 handleConfirm: function() {
84 if ($('use-passphrase-checkbox').checked) {
85 chrome.send('isPassphraseSet', ['ManagedUserSettings.isPassphraseSet']);
86 } else {
87 chrome.send('confirmManagedUserSettings');
88 chrome.send('resetPassphrase');
89 SettingsDialog.prototype.handleConfirm.call(this);
90 }
91 },
92 };
93
94 ManagedUserSettings.initializeSetPassphraseButton = function(success) {
95 var instance = ManagedUserSettings.getInstance();
96 instance.getPassphraseButton_().disabled = !success;
97 instance.getUsePassphraseCheckbox_().checked = success;
98 };
99
100 ManagedUserSettings.isAuthenticated = function(success) {
101 var instance = ManagedUserSettings.getInstance();
102 if (success) {
103 instance.authenticationChecked = true;
104 OptionsPage.navigateToPage('managedUser');
105 } else {
106 OptionsPage.closeOverlay();
107 }
108 instance.authenticationChecking = false;
109 };
110
111 ManagedUserSettings.isPassphraseSet = function(success) {
112 if (success) {
113 var instance = ManagedUserSettings.getInstance();
114 SettingsDialog.prototype.handleConfirm.call(instance);
115 } else {
116 OptionsPage.navigateToPage('setPassphrase');
117 }
118 };
119
120 // This method should only be called by the WebUI test.
121 ManagedUserSettings.getPassphraseButton = function() {
122 return ManagedUserSettings.getInstance().getPassphraseButton_();
53 }; 123 };
54 124
55 // Export 125 // Export
56 return { 126 return {
57 ManagedUserSettings: ManagedUserSettings 127 ManagedUserSettings: ManagedUserSettings
58 }; 128 };
59 }); 129 });
60 130
61 } 131 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698