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 // |
(...skipping 14 matching lines...) Expand all Loading... |
25 syncSetupCompleted: false, | 25 syncSetupCompleted: false, |
26 | 26 |
27 /** | 27 /** |
28 * The cached value of the instant.confirm_dialog_shown preference. | 28 * The cached value of the instant.confirm_dialog_shown preference. |
29 * @type {bool} | 29 * @type {bool} |
30 * @private | 30 * @private |
31 */ | 31 */ |
32 instantConfirmDialogShown_: false, | 32 instantConfirmDialogShown_: false, |
33 | 33 |
34 /** | 34 /** |
35 * True if the default cookie settings is session only. Used for deciding | |
36 * whether to show the session restore info dialog. The value is undefined | |
37 * until the preference has been read. | |
38 * @type {bool} | |
39 * @private | |
40 */ | |
41 sessionOnlyCookies_: undefined, | |
42 | |
43 /** | |
44 * The cached value of the spellcheck.confirm_dialog_shown preference. | 35 * The cached value of the spellcheck.confirm_dialog_shown preference. |
45 * @type {bool} | 36 * @type {bool} |
46 * @private | 37 * @private |
47 */ | 38 */ |
48 spellcheckConfirmDialogShown_: false, | 39 spellcheckConfirmDialogShown_: false, |
49 | 40 |
50 /** | 41 /** |
51 * True if the "clear cookies and other site data on exit" setting is | |
52 * selected. Used for deciding whether to show the session restore info | |
53 * dialog. The value is undefined until the preference has been read. | |
54 * @type {bool} | |
55 * @private | |
56 */ | |
57 clearCookiesOnExit_: undefined, | |
58 | |
59 /** | |
60 * Keeps track of whether |onShowHomeButtonChanged_| has been called. See | 42 * Keeps track of whether |onShowHomeButtonChanged_| has been called. See |
61 * |onShowHomeButtonChanged_|. | 43 * |onShowHomeButtonChanged_|. |
62 * @type {bool} | 44 * @type {bool} |
63 * @private | 45 * @private |
64 */ | 46 */ |
65 onShowHomeButtonChangedCalled_: false, | 47 onShowHomeButtonChangedCalled_: false, |
66 | 48 |
67 /** | 49 /** |
68 * @inheritDoc | 50 * @inheritDoc |
69 */ | 51 */ |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 } | 118 } |
137 | 119 |
138 // On Startup section. | 120 // On Startup section. |
139 Preferences.getInstance().addEventListener('session.restore_on_startup', | 121 Preferences.getInstance().addEventListener('session.restore_on_startup', |
140 this.onRestoreOnStartupChanged_.bind(this)); | 122 this.onRestoreOnStartupChanged_.bind(this)); |
141 | 123 |
142 $('startup-set-pages').onclick = function() { | 124 $('startup-set-pages').onclick = function() { |
143 OptionsPage.navigateToPage('startup'); | 125 OptionsPage.navigateToPage('startup'); |
144 }; | 126 }; |
145 | 127 |
146 // Session restore. | |
147 // TODO(marja): clean up the options UI after the decision on the session | |
148 // restore changes has stabilized. For now, only the startup option is | |
149 // renamed to "continue where I left off", but the session related content | |
150 // settings are not disabled or overridden (because | |
151 // 'enable_restore_session_state' is forced to false). | |
152 this.sessionRestoreEnabled_ = | |
153 loadTimeData.getBoolean('enable_restore_session_state'); | |
154 if (this.sessionRestoreEnabled_) { | |
155 $('startup-restore-session').onclick = function(event) { | |
156 if (!event.currentTarget.checked) | |
157 return; | |
158 | |
159 if (!BrowserOptions.getInstance().maybeShowSessionRestoreDialog_()) { | |
160 // The dialog is not shown; handle the event normally. | |
161 event.currentTarget.savePrefState(); | |
162 } | |
163 }; | |
164 } | |
165 | |
166 // Appearance section. | 128 // Appearance section. |
167 Preferences.getInstance().addEventListener('browser.show_home_button', | 129 Preferences.getInstance().addEventListener('browser.show_home_button', |
168 this.onShowHomeButtonChanged_.bind(this)); | 130 this.onShowHomeButtonChanged_.bind(this)); |
169 | 131 |
170 Preferences.getInstance().addEventListener('homepage', | 132 Preferences.getInstance().addEventListener('homepage', |
171 this.onHomePageChanged_.bind(this)); | 133 this.onHomePageChanged_.bind(this)); |
172 Preferences.getInstance().addEventListener('homepage_is_newtabpage', | 134 Preferences.getInstance().addEventListener('homepage_is_newtabpage', |
173 this.onHomePageIsNtpChanged_.bind(this)); | 135 this.onHomePageIsNtpChanged_.bind(this)); |
174 | 136 |
175 $('change-home-page').onclick = function(event) { | 137 $('change-home-page').onclick = function(event) { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 chrome.send('enableInstant'); | 175 chrome.send('enableInstant'); |
214 else | 176 else |
215 OptionsPage.showPageByName('instantConfirm', false); | 177 OptionsPage.showPageByName('instantConfirm', false); |
216 } else { | 178 } else { |
217 chrome.send('disableInstant'); | 179 chrome.send('disableInstant'); |
218 } | 180 } |
219 return true; | 181 return true; |
220 }; | 182 }; |
221 Preferences.getInstance().addEventListener('instant.confirm_dialog_shown', | 183 Preferences.getInstance().addEventListener('instant.confirm_dialog_shown', |
222 this.onInstantConfirmDialogShownChanged_.bind(this)); | 184 this.onInstantConfirmDialogShownChanged_.bind(this)); |
223 Preferences.getInstance().addEventListener( | |
224 'restore_session_state.dialog_shown', | |
225 this.onSessionRestoreDialogShownChanged_.bind(this)); | |
226 var self = this; | |
227 Preferences.getInstance().addEventListener( | |
228 'profile.clear_site_data_on_exit', | |
229 function(event) { | |
230 if (event.value && typeof event.value['value'] != 'undefined') { | |
231 self.clearCookiesOnExit_ = event.value['value'] == true; | |
232 } | |
233 }); | |
234 | 185 |
235 // Users section. | 186 // Users section. |
236 if (loadTimeData.valueExists('profilesInfo')) { | 187 if (loadTimeData.valueExists('profilesInfo')) { |
237 $('profiles-section').hidden = false; | 188 $('profiles-section').hidden = false; |
238 | 189 |
239 var profilesList = $('profiles-list'); | 190 var profilesList = $('profiles-list'); |
240 options.browser_options.ProfileList.decorate(profilesList); | 191 options.browser_options.ProfileList.decorate(profilesList); |
241 profilesList.autoExpands = true; | 192 profilesList.autoExpands = true; |
242 | 193 |
243 this.setProfilesInfo_(loadTimeData.getValue('profilesInfo')); | 194 this.setProfilesInfo_(loadTimeData.getValue('profilesInfo')); |
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
787 * Called when the value of the instant.confirm_dialog_shown preference | 738 * Called when the value of the instant.confirm_dialog_shown preference |
788 * changes. Cache this value. | 739 * changes. Cache this value. |
789 * @param {Event} event Change event. | 740 * @param {Event} event Change event. |
790 * @private | 741 * @private |
791 */ | 742 */ |
792 onInstantConfirmDialogShownChanged_: function(event) { | 743 onInstantConfirmDialogShownChanged_: function(event) { |
793 this.instantConfirmDialogShown_ = event.value['value']; | 744 this.instantConfirmDialogShown_ = event.value['value']; |
794 }, | 745 }, |
795 | 746 |
796 /** | 747 /** |
797 * Called when the value of the restore_session_state.dialog_shown | |
798 * preference changes. | |
799 * @param {Event} event Change event. | |
800 * @private | |
801 */ | |
802 onSessionRestoreDialogShownChanged_: function(event) { | |
803 this.sessionRestoreDialogShown_ = event.value['value']; | |
804 }, | |
805 | |
806 /** | |
807 * Called when the value of the spellcheck.confirm_dialog_shown preference | 748 * Called when the value of the spellcheck.confirm_dialog_shown preference |
808 * changes. Cache this value. | 749 * changes. Cache this value. |
809 * @param {Event} event Change event. | 750 * @param {Event} event Change event. |
810 * @private | 751 * @private |
811 */ | 752 */ |
812 onSpellcheckConfirmDialogShownChanged_: function(event) { | 753 onSpellcheckConfirmDialogShownChanged_: function(event) { |
813 this.spellcheckConfirmDialogShown_ = event.value['value']; | 754 this.spellcheckConfirmDialogShown_ = event.value['value']; |
814 }, | 755 }, |
815 | 756 |
816 /** | 757 /** |
817 * Called when the value of the download.default_directory preference | 758 * Called when the value of the download.default_directory preference |
818 * changes. | 759 * changes. |
819 * @param {Event} event Change event. | 760 * @param {Event} event Change event. |
820 * @private | 761 * @private |
821 */ | 762 */ |
822 onDefaultDownloadDirectoryChanged_: function(event) { | 763 onDefaultDownloadDirectoryChanged_: function(event) { |
823 $('downloadLocationPath').value = event.value['value']; | 764 $('downloadLocationPath').value = event.value['value']; |
824 if (cr.isChromeOS) { | 765 if (cr.isChromeOS) { |
825 // On ChromeOS, strip out /special for drive paths, and | 766 // On ChromeOS, strip out /special for drive paths, and |
826 // /home/chronos/user for local files. | 767 // /home/chronos/user for local files. |
827 $('downloadLocationPath').value = $('downloadLocationPath').value. | 768 $('downloadLocationPath').value = $('downloadLocationPath').value. |
828 replace(/^\/(special|home\/chronos\/user)/, ''); | 769 replace(/^\/(special|home\/chronos\/user)/, ''); |
829 } | 770 } |
830 }, | 771 }, |
831 | 772 |
832 /** | 773 /** |
833 * Displays the session restore info dialog if options depending on sessions | |
834 * (session only cookies or clearning data on exit) are selected, and the | |
835 * dialog has never been shown. | |
836 * @private | |
837 * @return {boolean} True if the dialog is shown, false otherwise. | |
838 */ | |
839 maybeShowSessionRestoreDialog_: function() { | |
840 // Don't show this dialog in Guest mode. | |
841 if (cr.isChromeOS && UIAccountTweaks.loggedInAsGuest()) | |
842 return false; | |
843 // If some of the needed preferences haven't been read yet, the | |
844 // corresponding member variable will be undefined and we won't display | |
845 // the dialog yet. | |
846 if (this.userHasSelectedSessionContentSettings_() && | |
847 this.sessionRestoreDialogShown_ === false) { | |
848 OptionsPage.showPageByName('sessionRestoreOverlay', false); | |
849 return true; | |
850 } | |
851 return false; | |
852 }, | |
853 | |
854 /** | |
855 * Called when the user clicks the "ok" button in the session restore | |
856 * dialog. | |
857 */ | |
858 sessionRestoreDialogOk: function() { | |
859 // Set the preference. | |
860 $('startup-restore-session').savePrefState(); | |
861 this.sessionRestoreDialogShown_ = true; | |
862 Preferences.setBooleanPref('restore_session_state.dialog_shown', true); | |
863 }, | |
864 | |
865 /** | |
866 * Called when the user clicks the "cancel" button in the session restore | |
867 * dialog. | |
868 */ | |
869 sessionRestoreDialogCancel: function() { | |
870 // The preference was never set to "continue where I left off". Update the | |
871 // UI to reflect the preference. | |
872 $('startup-newtab').resetPrefState(); | |
873 $('startup-restore-session').resetPrefState(); | |
874 $('startup-show-pages').resetPrefState(); | |
875 }, | |
876 | |
877 /** | |
878 * Returns true if the user has selected content settings which rely on | |
879 * sessions: clearning the browsing data on exit or defaulting the cookie | |
880 * content setting to session only. | |
881 * @private | |
882 */ | |
883 userHasSelectedSessionContentSettings_: function() { | |
884 return this.clearCookiesOnExit_ || this.sessionOnlyCookies_; | |
885 }, | |
886 | |
887 /** | |
888 * Update the Default Browsers section based on the current state. | 774 * Update the Default Browsers section based on the current state. |
889 * @param {string} statusString Description of the current default state. | 775 * @param {string} statusString Description of the current default state. |
890 * @param {boolean} isDefault Whether or not the browser is currently | 776 * @param {boolean} isDefault Whether or not the browser is currently |
891 * default. | 777 * default. |
892 * @param {boolean} canBeDefault Whether or not the browser can be default. | 778 * @param {boolean} canBeDefault Whether or not the browser can be default. |
893 * @private | 779 * @private |
894 */ | 780 */ |
895 updateDefaultBrowserState_: function(statusString, isDefault, | 781 updateDefaultBrowserState_: function(statusString, isDefault, |
896 canBeDefault) { | 782 canBeDefault) { |
897 if (!cr.isChromeOS) { | 783 if (!cr.isChromeOS) { |
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1395 */ | 1281 */ |
1396 removeBluetoothDevice_: function(address) { | 1282 removeBluetoothDevice_: function(address) { |
1397 var index = $('bluetooth-unpaired-devices-list').find(address); | 1283 var index = $('bluetooth-unpaired-devices-list').find(address); |
1398 if (index != undefined) { | 1284 if (index != undefined) { |
1399 $('bluetooth-unpaired-devices-list').deleteItemAtIndex(index); | 1285 $('bluetooth-unpaired-devices-list').deleteItemAtIndex(index); |
1400 } else { | 1286 } else { |
1401 index = $('bluetooth-paired-devices-list').find(address); | 1287 index = $('bluetooth-paired-devices-list').find(address); |
1402 if (index != undefined) | 1288 if (index != undefined) |
1403 $('bluetooth-paired-devices-list').deleteItemAtIndex(index); | 1289 $('bluetooth-paired-devices-list').deleteItemAtIndex(index); |
1404 } | 1290 } |
1405 }, | |
1406 | |
1407 /** | |
1408 * Called when the default content setting value for a content type changes. | |
1409 * @param {Object} dict A mapping content setting types to the default | |
1410 * value. | |
1411 * @private | |
1412 */ | |
1413 setContentFilterSettingsValue_: function(dict) { | |
1414 if ('cookies' in dict && 'value' in dict['cookies']) | |
1415 this.sessionOnlyCookies_ = dict['cookies']['value'] == 'session'; | |
1416 } | 1291 } |
1417 | 1292 |
1418 }; | 1293 }; |
1419 | 1294 |
1420 //Forward public APIs to private implementations. | 1295 //Forward public APIs to private implementations. |
1421 [ | 1296 [ |
1422 'addBluetoothDevice', | 1297 'addBluetoothDevice', |
1423 'getCurrentProfile', | 1298 'getCurrentProfile', |
1424 'getStartStopSyncButton', | 1299 'getStartStopSyncButton', |
1425 'hideBluetoothSettings', | 1300 'hideBluetoothSettings', |
1426 'removeCloudPrintConnectorSection', | 1301 'removeCloudPrintConnectorSection', |
1427 'removeBluetoothDevice', | 1302 'removeBluetoothDevice', |
1428 'setAutoOpenFileTypesDisplayed', | 1303 'setAutoOpenFileTypesDisplayed', |
1429 'setBackgroundModeCheckboxState', | 1304 'setBackgroundModeCheckboxState', |
1430 'setBluetoothState', | 1305 'setBluetoothState', |
1431 'setCheckRevocationCheckboxState', | 1306 'setCheckRevocationCheckboxState', |
1432 'setContentFilterSettingsValue', | |
1433 'setFontSize', | 1307 'setFontSize', |
1434 'setGtkThemeButtonEnabled', | 1308 'setGtkThemeButtonEnabled', |
1435 'setHighContrastCheckboxState', | 1309 'setHighContrastCheckboxState', |
1436 'setMetricsReportingCheckboxState', | 1310 'setMetricsReportingCheckboxState', |
1437 'setMetricsReportingSettingVisibility', | 1311 'setMetricsReportingSettingVisibility', |
1438 'setPasswordGenerationSettingVisibility', | 1312 'setPasswordGenerationSettingVisibility', |
1439 'setProfilesInfo', | 1313 'setProfilesInfo', |
1440 'setScreenMagnifierCheckboxState', | 1314 'setScreenMagnifierCheckboxState', |
1441 'setSpokenFeedbackCheckboxState', | 1315 'setSpokenFeedbackCheckboxState', |
1442 'setThemesResetButtonEnabled', | 1316 'setThemesResetButtonEnabled', |
(...skipping 28 matching lines...) Expand all Loading... |
1471 BrowserOptions.getLoggedInUsername = function() { | 1345 BrowserOptions.getLoggedInUsername = function() { |
1472 return BrowserOptions.getInstance().username_; | 1346 return BrowserOptions.getInstance().username_; |
1473 }; | 1347 }; |
1474 } | 1348 } |
1475 | 1349 |
1476 // Export | 1350 // Export |
1477 return { | 1351 return { |
1478 BrowserOptions: BrowserOptions | 1352 BrowserOptions: BrowserOptions |
1479 }; | 1353 }; |
1480 }); | 1354 }); |
OLD | NEW |