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 cr.define('options', function() { | 5 cr.define('options', function() { |
6 var OptionsPage = options.OptionsPage; | 6 var OptionsPage = options.OptionsPage; |
7 var ArrayDataModel = cr.ui.ArrayDataModel; | 7 var ArrayDataModel = cr.ui.ArrayDataModel; |
8 var RepeatingButton = cr.ui.RepeatingButton; | 8 var RepeatingButton = cr.ui.RepeatingButton; |
9 | 9 |
10 // | 10 // |
11 // BrowserOptions class | 11 // BrowserOptions class |
12 // Encapsulated handling of browser options page. | 12 // Encapsulated handling of browser options page. |
13 // | 13 // |
14 function BrowserOptions() { | 14 function BrowserOptions() { |
15 OptionsPage.call(this, 'settings', loadTimeData.getString('settingsTitle'), | 15 OptionsPage.call(this, 'settings', loadTimeData.getString('settingsTitle'), |
16 'settings'); | 16 'settings'); |
17 } | 17 } |
18 | 18 |
19 cr.addSingletonGetter(BrowserOptions); | 19 cr.addSingletonGetter(BrowserOptions); |
20 | 20 |
21 BrowserOptions.prototype = { | 21 BrowserOptions.prototype = { |
22 __proto__: options.OptionsPage.prototype, | 22 __proto__: options.OptionsPage.prototype, |
23 | 23 |
24 // State variables. | 24 // State variables. |
25 syncSetupCompleted: false, | 25 syncSetupCompleted: false, |
26 | 26 |
27 /** | 27 /** |
28 * The cached value of the instant.confirm_dialog_shown preference. | |
29 * @type {bool} | |
30 * @private | |
31 */ | |
32 instantConfirmDialogShown_: false, | |
33 | |
34 /** | |
35 * The cached value of the spellcheck.confirm_dialog_shown preference. | |
36 * @type {bool} | |
37 * @private | |
38 */ | |
39 spellcheckConfirmDialogShown_: false, | |
40 | |
41 /** | |
42 * Keeps track of whether |onShowHomeButtonChanged_| has been called. See | 28 * Keeps track of whether |onShowHomeButtonChanged_| has been called. See |
43 * |onShowHomeButtonChanged_|. | 29 * |onShowHomeButtonChanged_|. |
44 * @type {bool} | 30 * @type {bool} |
45 * @private | 31 * @private |
46 */ | 32 */ |
47 onShowHomeButtonChangedCalled_: false, | 33 onShowHomeButtonChangedCalled_: false, |
48 | 34 |
49 /** | 35 /** |
50 * @inheritDoc | 36 * @inheritDoc |
51 */ | 37 */ |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 } | 144 } |
159 | 145 |
160 // Search section. | 146 // Search section. |
161 $('manage-default-search-engines').onclick = function(event) { | 147 $('manage-default-search-engines').onclick = function(event) { |
162 OptionsPage.navigateToPage('searchEngines'); | 148 OptionsPage.navigateToPage('searchEngines'); |
163 chrome.send('coreOptionsUserMetricsAction', | 149 chrome.send('coreOptionsUserMetricsAction', |
164 ['Options_ManageSearchEngines']); | 150 ['Options_ManageSearchEngines']); |
165 }; | 151 }; |
166 $('default-search-engine').addEventListener('change', | 152 $('default-search-engine').addEventListener('change', |
167 this.setDefaultSearchEngine_); | 153 this.setDefaultSearchEngine_); |
168 $('instant-enabled-control').customChangeHandler = function(event) { | |
169 if (this.checked && !self.instantConfirmDialogShown_) { | |
170 OptionsPage.showPageByName('instantConfirm', false); | |
171 return true; // Stop default preference processing. | |
172 } | |
173 return false; // Allow default preference processing. | |
174 }; | |
175 Preferences.getInstance().addEventListener('instant.confirm_dialog_shown', | |
176 this.onInstantConfirmDialogShownChanged_.bind(this)); | |
177 | 154 |
178 // Users section. | 155 // Users section. |
179 if (loadTimeData.valueExists('profilesInfo')) { | 156 if (loadTimeData.valueExists('profilesInfo')) { |
180 $('profiles-section').hidden = false; | 157 $('profiles-section').hidden = false; |
181 | 158 |
182 var profilesList = $('profiles-list'); | 159 var profilesList = $('profiles-list'); |
183 options.browser_options.ProfileList.decorate(profilesList); | 160 options.browser_options.ProfileList.decorate(profilesList); |
184 profilesList.autoExpands = true; | 161 profilesList.autoExpands = true; |
185 | 162 |
186 this.setProfilesInfo_(loadTimeData.getValue('profilesInfo')); | 163 this.setProfilesInfo_(loadTimeData.getValue('profilesInfo')); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 $('privacyContentSettingsButton').onclick = function(event) { | 221 $('privacyContentSettingsButton').onclick = function(event) { |
245 OptionsPage.navigateToPage('content'); | 222 OptionsPage.navigateToPage('content'); |
246 OptionsPage.showTab($('cookies-nav-tab')); | 223 OptionsPage.showTab($('cookies-nav-tab')); |
247 chrome.send('coreOptionsUserMetricsAction', | 224 chrome.send('coreOptionsUserMetricsAction', |
248 ['Options_ContentSettings']); | 225 ['Options_ContentSettings']); |
249 }; | 226 }; |
250 $('privacyClearDataButton').onclick = function(event) { | 227 $('privacyClearDataButton').onclick = function(event) { |
251 OptionsPage.navigateToPage('clearBrowserData'); | 228 OptionsPage.navigateToPage('clearBrowserData'); |
252 chrome.send('coreOptionsUserMetricsAction', ['Options_ClearData']); | 229 chrome.send('coreOptionsUserMetricsAction', ['Options_ClearData']); |
253 }; | 230 }; |
254 // 'spelling-enabled-control' element is only present on Chrome branded | |
255 // builds. | |
256 if ($('spelling-enabled-control')) { | |
257 $('spelling-enabled-control').customChangeHandler = function(event) { | |
258 if (this.checked && !self.spellcheckConfirmDialogShown_) { | |
259 OptionsPage.showPageByName('spellingConfirm', false); | |
260 return true; | |
261 } | |
262 return false; | |
263 }; | |
264 Preferences.getInstance().addEventListener( | |
265 'spellcheck.confirm_dialog_shown', | |
266 this.onSpellcheckConfirmDialogShownChanged_.bind(this)); | |
267 } | |
268 // 'metricsReportingEnabled' element is only present on Chrome branded | 231 // 'metricsReportingEnabled' element is only present on Chrome branded |
269 // builds. | 232 // builds. |
270 if ($('metricsReportingEnabled')) { | 233 if ($('metricsReportingEnabled')) { |
271 $('metricsReportingEnabled').onclick = function(event) { | 234 $('metricsReportingEnabled').onclick = function(event) { |
272 chrome.send('metricsReportingCheckboxAction', | 235 chrome.send('metricsReportingCheckboxAction', |
273 [String(event.target.checked)]); | 236 [String(event.target.checked)]); |
274 }; | 237 }; |
275 } | 238 } |
276 $('do-not-track-enabled').customChangeHandler = function(event) { | |
277 if (this.checked) { | |
278 OptionsPage.showPageByName('doNotTrackConfirm', false); | |
279 return true; | |
280 } | |
281 return false; | |
282 }; | |
283 | 239 |
284 // Bluetooth (CrOS only). | 240 // Bluetooth (CrOS only). |
285 if (cr.isChromeOS) { | 241 if (cr.isChromeOS) { |
286 options.system.bluetooth.BluetoothDeviceList.decorate( | 242 options.system.bluetooth.BluetoothDeviceList.decorate( |
287 $('bluetooth-paired-devices-list')); | 243 $('bluetooth-paired-devices-list')); |
288 | 244 |
289 $('bluetooth-add-device').onclick = | 245 $('bluetooth-add-device').onclick = |
290 this.handleAddBluetoothDevice_.bind(this); | 246 this.handleAddBluetoothDevice_.bind(this); |
291 | 247 |
292 $('enable-bluetooth').onchange = function(event) { | 248 $('enable-bluetooth').onchange = function(event) { |
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
730 * Shows the autoLaunch preference and initializes its checkbox value. | 686 * Shows the autoLaunch preference and initializes its checkbox value. |
731 * @param {bool} enabled Whether autolaunch is enabled or or not. | 687 * @param {bool} enabled Whether autolaunch is enabled or or not. |
732 * @private | 688 * @private |
733 */ | 689 */ |
734 updateAutoLaunchState_: function(enabled) { | 690 updateAutoLaunchState_: function(enabled) { |
735 $('auto-launch-option').hidden = false; | 691 $('auto-launch-option').hidden = false; |
736 $('auto-launch').checked = enabled; | 692 $('auto-launch').checked = enabled; |
737 }, | 693 }, |
738 | 694 |
739 /** | 695 /** |
740 * Called when the value of the instant.confirm_dialog_shown preference | |
741 * changes. Cache this value. | |
742 * @param {Event} event Change event. | |
743 * @private | |
744 */ | |
745 onInstantConfirmDialogShownChanged_: function(event) { | |
746 this.instantConfirmDialogShown_ = event.value.value; | |
747 }, | |
748 | |
749 /** | |
750 * Called when the value of the spellcheck.confirm_dialog_shown preference | |
751 * changes. Cache this value. | |
752 * @param {Event} event Change event. | |
753 * @private | |
754 */ | |
755 onSpellcheckConfirmDialogShownChanged_: function(event) { | |
756 this.spellcheckConfirmDialogShown_ = event.value.value; | |
757 }, | |
758 | |
759 /** | |
760 * Called when the value of the download.default_directory preference | 696 * Called when the value of the download.default_directory preference |
761 * changes. | 697 * changes. |
762 * @param {Event} event Change event. | 698 * @param {Event} event Change event. |
763 * @private | 699 * @private |
764 */ | 700 */ |
765 onDefaultDownloadDirectoryChanged_: function(event) { | 701 onDefaultDownloadDirectoryChanged_: function(event) { |
766 $('downloadLocationPath').value = event.value.value; | 702 $('downloadLocationPath').value = event.value.value; |
767 if (cr.isChromeOS) { | 703 if (cr.isChromeOS) { |
768 // On ChromeOS, replace /special/drive with Drive for drive paths, and | 704 // On ChromeOS, replace /special/drive with Drive for drive paths, and |
769 // /home/chronos/user/Downloads with Downloads for local files. | 705 // /home/chronos/user/Downloads with Downloads for local files. |
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1344 BrowserOptions.getLoggedInUsername = function() { | 1280 BrowserOptions.getLoggedInUsername = function() { |
1345 return BrowserOptions.getInstance().username_; | 1281 return BrowserOptions.getInstance().username_; |
1346 }; | 1282 }; |
1347 } | 1283 } |
1348 | 1284 |
1349 // Export | 1285 // Export |
1350 return { | 1286 return { |
1351 BrowserOptions: BrowserOptions | 1287 BrowserOptions: BrowserOptions |
1352 }; | 1288 }; |
1353 }); | 1289 }); |
OLD | NEW |