OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 | 6 |
7 var OptionsPage = options.OptionsPage; | 7 var OptionsPage = options.OptionsPage; |
8 | 8 |
9 /** | 9 /** |
10 * ClearBrowserData class | 10 * ClearBrowserData class |
(...skipping 18 matching lines...) Expand all Loading... | |
29 * Initialize the page. | 29 * Initialize the page. |
30 */ | 30 */ |
31 initializePage: function() { | 31 initializePage: function() { |
32 // Call base class implementation to starts preference initialization. | 32 // Call base class implementation to starts preference initialization. |
33 OptionsPage.prototype.initializePage.call(this); | 33 OptionsPage.prototype.initializePage.call(this); |
34 | 34 |
35 // Setup option values for the time period select control. | 35 // Setup option values for the time period select control. |
36 $('clearBrowsingDataTimePeriod').initializeValues( | 36 $('clearBrowsingDataTimePeriod').initializeValues( |
37 templateData.clearBrowsingDataTimeList); | 37 templateData.clearBrowsingDataTimeList); |
38 | 38 |
39 var f = this.updateCommitButtonState_.bind(this); | 39 var updateCommitButton = this.updateCommitButtonState_.bind(this); |
40 var types = ['browser.clear_data.browsing_history', | 40 var types = ['browser.clear_data.browsing_history', |
41 'browser.clear_data.download_history', | 41 'browser.clear_data.download_history', |
42 'browser.clear_data.cache', | 42 'browser.clear_data.cache', |
43 'browser.clear_data.cookies', | 43 'browser.clear_data.cookies', |
44 'browser.clear_data.passwords', | 44 'browser.clear_data.passwords', |
45 'browser.clear_data.lso_data', | |
45 'browser.clear_data.form_data']; | 46 'browser.clear_data.form_data']; |
46 types.forEach(function(type) { | 47 types.forEach(function(type) { |
47 Preferences.getInstance().addEventListener(type, f); | 48 Preferences.getInstance().addEventListener(type, updateCommitButton); |
48 }); | 49 }); |
49 | 50 |
50 var checkboxes = document.querySelectorAll( | 51 var checkboxes = document.querySelectorAll( |
51 '#checkboxListData input[type=checkbox]'); | 52 '#checkboxListData input[type=checkbox]'); |
52 for (var i = 0; i < checkboxes.length; i++) { | 53 for (var i = 0; i < checkboxes.length; i++) { |
53 checkboxes[i].onclick = f; | 54 checkboxes[i].onclick = updateCommitButton; |
54 } | 55 } |
55 this.updateCommitButtonState_(); | 56 updateCommitButton(); |
57 | |
58 var checkbox = $('deleteLSODataCheckbox'); | |
59 // Listen to pref changes. | |
60 Preferences.getInstance().addEventListener( | |
61 'browser.clear_data.lso_data', | |
62 function(event) { | |
63 var value = event.value && event.value['value']; | |
64 checkbox.pref_value = Boolean(value); | |
65 checkbox.managed = event.value && | |
66 event.value['managed']; | |
Evan Stade
2011/01/04 22:59:24
can this not fit on the above line? either way, th
Bernhard Bauer
2011/01/04 23:15:32
Done.
| |
67 checkbox.updateState(); | |
68 }); | |
69 | |
70 ClearBrowserDataOverlay.setClearPluginLSODataEnabled = | |
71 function(enabled) { | |
Evan Stade
2011/01/04 22:59:24
this can fit on the above line I believe
Bernhard Bauer
2011/01/04 23:15:32
Done.
| |
72 checkbox.manually_disabled = !enabled; | |
73 checkbox.updateState(); | |
74 }; | |
75 | |
76 // Listen to user events. | |
77 checkbox.addEventListener('click', function(e) { | |
Evan Stade
2011/01/04 22:59:24
why is it insufficient to use a pref attribute lik
Bernhard Bauer
2011/01/04 23:15:32
The checkbox is only checked if the preference is
| |
78 Preferences.setBooleanPref('browser.clear_data.lso_data', | |
79 checkbox.checked, checkbox.metric); | |
80 }); | |
81 | |
82 checkbox.updateState = function() { | |
83 checkbox.checked = checkbox.pref_value && !checkbox.manually_disabled; | |
84 checkbox.disabled = checkbox.managed || checkbox.manually_disabled; | |
85 updateCommitButton(); | |
86 }; | |
56 | 87 |
57 // Setup click handler for the clear(Ok) button. | 88 // Setup click handler for the clear(Ok) button. |
58 $('clearBrowsingDataCommit').onclick = function(event) { | 89 $('clearBrowsingDataCommit').onclick = function(event) { |
59 chrome.send('performClearBrowserData'); | 90 chrome.send('performClearBrowserData'); |
60 }; | 91 }; |
61 }, | 92 }, |
62 | 93 |
63 // Set the enabled state of the commit button. | 94 // Set the enabled state of the commit button. |
64 updateCommitButtonState_: function() { | 95 updateCommitButtonState_: function() { |
65 var checkboxes = document.querySelectorAll( | 96 var checkboxes = document.querySelectorAll( |
(...skipping 12 matching lines...) Expand all Loading... | |
78 // | 109 // |
79 // Chrome callbacks | 110 // Chrome callbacks |
80 // | 111 // |
81 ClearBrowserDataOverlay.setClearingState = function(state) { | 112 ClearBrowserDataOverlay.setClearingState = function(state) { |
82 $('deleteBrowsingHistoryCheckbox').disabled = state; | 113 $('deleteBrowsingHistoryCheckbox').disabled = state; |
83 $('deleteDownloadHistoryCheckbox').disabled = state; | 114 $('deleteDownloadHistoryCheckbox').disabled = state; |
84 $('deleteCacheCheckbox').disabled = state; | 115 $('deleteCacheCheckbox').disabled = state; |
85 $('deleteCookiesCheckbox').disabled = state; | 116 $('deleteCookiesCheckbox').disabled = state; |
86 $('deletePasswordsCheckbox').disabled = state; | 117 $('deletePasswordsCheckbox').disabled = state; |
87 $('deleteFormDataCheckbox').disabled = state; | 118 $('deleteFormDataCheckbox').disabled = state; |
119 $('deleteLSODataCheckbox').disabled = state; | |
88 $('clearBrowsingDataTimePeriod').disabled = state; | 120 $('clearBrowsingDataTimePeriod').disabled = state; |
89 $('clearBrowsingDataDismiss').disabled = state; | 121 $('clearBrowsingDataDismiss').disabled = state; |
90 $('cbdThrobber').style.visibility = state ? 'visible' : 'hidden'; | 122 $('cbdThrobber').style.visibility = state ? 'visible' : 'hidden'; |
91 | 123 |
92 if (state) | 124 if (state) |
93 $('clearBrowsingDataCommit').disabled = true; | 125 $('clearBrowsingDataCommit').disabled = true; |
94 else | 126 else |
95 ClearBrowserDataOverlay.getInstance().updateCommitButtonState_(); | 127 ClearBrowserDataOverlay.getInstance().updateCommitButtonState_(); |
96 | 128 |
97 function advanceThrobber() { | 129 function advanceThrobber() { |
(...skipping 16 matching lines...) Expand all Loading... | |
114 this.setClearingState(false); | 146 this.setClearingState(false); |
115 } | 147 } |
116 | 148 |
117 // Export | 149 // Export |
118 return { | 150 return { |
119 ClearBrowserDataOverlay: ClearBrowserDataOverlay | 151 ClearBrowserDataOverlay: ClearBrowserDataOverlay |
120 }; | 152 }; |
121 | 153 |
122 }); | 154 }); |
123 | 155 |
OLD | NEW |