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 24 matching lines...) Expand all Loading... | |
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 f = 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, f); |
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 = f; |
54 } | 55 } |
55 this.updateCommitButtonState_(); | 56 this.updateCommitButtonState_(); |
56 | 57 |
58 (function(self, pref) { | |
Evan Stade
2010/12/22 00:16:40
why is this a single use function and not just a b
Bernhard Bauer
2010/12/22 03:40:05
To restrict the scope of |self| and |pref| to this
Evan Stade
2010/12/22 21:36:16
yes please
Bernhard Bauer
2011/01/03 11:56:30
Done.
| |
59 // Listen to pref changes. | |
60 Preferences.getInstance().addEventListener( | |
61 pref, | |
62 function(event) { | |
63 var value = event.value && event.value['value'] != undefined ? | |
64 event.value['value'] : event.value; | |
Evan Stade
2010/12/22 00:16:40
as long as you're casting to boolean, can't you ju
Bernhard Bauer
2010/12/22 03:40:05
Probably. I have to admit, I copied that piece of
Bernhard Bauer
2011/01/03 11:56:30
Done.
| |
65 self.pref_value = Boolean(value); | |
66 self.managed = event.value && | |
67 event.value['managed'] != undefined ? | |
68 event.value['managed'] : false; | |
69 self.updateState(); | |
70 }); | |
71 | |
72 ClearBrowserDataOverlay.setClearPluginLSODataEnabled = | |
73 function(enabled) { | |
74 self.manually_disabled = !enabled; | |
75 self.updateState(); | |
76 }; | |
77 | |
78 // Listen to user events. | |
79 self.addEventListener('click', | |
Evan Stade
2010/12/22 00:16:40
self.addEventListener('click', function (e) {
[.
Bernhard Bauer
2010/12/22 03:40:05
Done.
| |
80 function(e) { | |
81 Preferences.setBooleanPref(pref, self.checked, self.metric); | |
82 }); | |
83 | |
84 self.updateState = function() { | |
85 self.checked = self.pref_value && !self.manually_disabled; | |
86 self.disabled = self.managed || self.manually_disabled; | |
87 f(); | |
Evan Stade
2010/12/22 00:16:40
what
Bernhard Bauer
2010/12/22 03:40:05
|f| is the updateCommitButtonState_ function bound
Evan Stade
2010/12/22 21:36:16
oh, I see. Yes, it should have a better name.
Bernhard Bauer
2011/01/03 11:56:30
Done.
| |
88 }; | |
89 | |
90 })($('deleteLSODataCheckbox'), 'browser.clear_data.lso_data'); | |
91 | |
57 // Setup click handler for the clear(Ok) button. | 92 // Setup click handler for the clear(Ok) button. |
58 $('clearBrowsingDataCommit').onclick = function(event) { | 93 $('clearBrowsingDataCommit').onclick = function(event) { |
59 chrome.send('performClearBrowserData'); | 94 chrome.send('performClearBrowserData'); |
60 }; | 95 }; |
61 }, | 96 }, |
62 | 97 |
63 // Set the enabled state of the commit button. | 98 // Set the enabled state of the commit button. |
64 updateCommitButtonState_: function() { | 99 updateCommitButtonState_: function() { |
65 var checkboxes = document.querySelectorAll( | 100 var checkboxes = document.querySelectorAll( |
66 '#checkboxListData input[type=checkbox]'); | 101 '#checkboxListData input[type=checkbox]'); |
(...skipping 11 matching lines...) Expand all Loading... | |
78 // | 113 // |
79 // Chrome callbacks | 114 // Chrome callbacks |
80 // | 115 // |
81 ClearBrowserDataOverlay.setClearingState = function(state) { | 116 ClearBrowserDataOverlay.setClearingState = function(state) { |
82 $('deleteBrowsingHistoryCheckbox').disabled = state; | 117 $('deleteBrowsingHistoryCheckbox').disabled = state; |
83 $('deleteDownloadHistoryCheckbox').disabled = state; | 118 $('deleteDownloadHistoryCheckbox').disabled = state; |
84 $('deleteCacheCheckbox').disabled = state; | 119 $('deleteCacheCheckbox').disabled = state; |
85 $('deleteCookiesCheckbox').disabled = state; | 120 $('deleteCookiesCheckbox').disabled = state; |
86 $('deletePasswordsCheckbox').disabled = state; | 121 $('deletePasswordsCheckbox').disabled = state; |
87 $('deleteFormDataCheckbox').disabled = state; | 122 $('deleteFormDataCheckbox').disabled = state; |
123 $('deleteLSODataCheckbox').disabled = state; | |
88 $('clearBrowsingDataTimePeriod').disabled = state; | 124 $('clearBrowsingDataTimePeriod').disabled = state; |
89 $('clearBrowsingDataDismiss').disabled = state; | 125 $('clearBrowsingDataDismiss').disabled = state; |
90 $('cbdThrobber').style.visibility = state ? 'visible' : 'hidden'; | 126 $('cbdThrobber').style.visibility = state ? 'visible' : 'hidden'; |
91 | 127 |
92 if (state) | 128 if (state) |
93 $('clearBrowsingDataCommit').disabled = true; | 129 $('clearBrowsingDataCommit').disabled = true; |
94 else | 130 else |
95 ClearBrowserDataOverlay.getInstance().updateCommitButtonState_(); | 131 ClearBrowserDataOverlay.getInstance().updateCommitButtonState_(); |
96 | 132 |
97 function advanceThrobber() { | 133 function advanceThrobber() { |
(...skipping 16 matching lines...) Expand all Loading... | |
114 this.setClearingState(false); | 150 this.setClearingState(false); |
115 } | 151 } |
116 | 152 |
117 // Export | 153 // Export |
118 return { | 154 return { |
119 ClearBrowserDataOverlay: ClearBrowserDataOverlay | 155 ClearBrowserDataOverlay: ClearBrowserDataOverlay |
120 }; | 156 }; |
121 | 157 |
122 }); | 158 }); |
123 | 159 |
OLD | NEW |