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 && event.value['managed']; |
| 66 checkbox.updateState(); |
| 67 }); |
| 68 |
| 69 ClearBrowserDataOverlay.setClearPluginLSODataEnabled = function(enabled) { |
| 70 checkbox.manually_disabled = !enabled; |
| 71 checkbox.updateState(); |
| 72 }; |
| 73 |
| 74 // Listen to user events. |
| 75 checkbox.addEventListener('click', function(e) { |
| 76 Preferences.setBooleanPref('browser.clear_data.lso_data', |
| 77 checkbox.checked, checkbox.metric); |
| 78 }); |
| 79 |
| 80 checkbox.updateState = function() { |
| 81 checkbox.checked = checkbox.pref_value && !checkbox.manually_disabled; |
| 82 checkbox.disabled = checkbox.managed || checkbox.manually_disabled; |
| 83 updateCommitButton(); |
| 84 }; |
56 | 85 |
57 // Setup click handler for the clear(Ok) button. | 86 // Setup click handler for the clear(Ok) button. |
58 $('clearBrowsingDataCommit').onclick = function(event) { | 87 $('clearBrowsingDataCommit').onclick = function(event) { |
59 chrome.send('performClearBrowserData'); | 88 chrome.send('performClearBrowserData'); |
60 }; | 89 }; |
61 }, | 90 }, |
62 | 91 |
63 // Set the enabled state of the commit button. | 92 // Set the enabled state of the commit button. |
64 updateCommitButtonState_: function() { | 93 updateCommitButtonState_: function() { |
65 var checkboxes = document.querySelectorAll( | 94 var checkboxes = document.querySelectorAll( |
(...skipping 12 matching lines...) Expand all Loading... |
78 // | 107 // |
79 // Chrome callbacks | 108 // Chrome callbacks |
80 // | 109 // |
81 ClearBrowserDataOverlay.setClearingState = function(state) { | 110 ClearBrowserDataOverlay.setClearingState = function(state) { |
82 $('deleteBrowsingHistoryCheckbox').disabled = state; | 111 $('deleteBrowsingHistoryCheckbox').disabled = state; |
83 $('deleteDownloadHistoryCheckbox').disabled = state; | 112 $('deleteDownloadHistoryCheckbox').disabled = state; |
84 $('deleteCacheCheckbox').disabled = state; | 113 $('deleteCacheCheckbox').disabled = state; |
85 $('deleteCookiesCheckbox').disabled = state; | 114 $('deleteCookiesCheckbox').disabled = state; |
86 $('deletePasswordsCheckbox').disabled = state; | 115 $('deletePasswordsCheckbox').disabled = state; |
87 $('deleteFormDataCheckbox').disabled = state; | 116 $('deleteFormDataCheckbox').disabled = state; |
| 117 $('deleteLSODataCheckbox').disabled = state; |
88 $('clearBrowsingDataTimePeriod').disabled = state; | 118 $('clearBrowsingDataTimePeriod').disabled = state; |
89 $('clearBrowsingDataDismiss').disabled = state; | 119 $('clearBrowsingDataDismiss').disabled = state; |
90 $('cbdThrobber').style.visibility = state ? 'visible' : 'hidden'; | 120 $('cbdThrobber').style.visibility = state ? 'visible' : 'hidden'; |
91 | 121 |
92 if (state) | 122 if (state) |
93 $('clearBrowsingDataCommit').disabled = true; | 123 $('clearBrowsingDataCommit').disabled = true; |
94 else | 124 else |
95 ClearBrowserDataOverlay.getInstance().updateCommitButtonState_(); | 125 ClearBrowserDataOverlay.getInstance().updateCommitButtonState_(); |
96 | 126 |
97 function advanceThrobber() { | 127 function advanceThrobber() { |
(...skipping 16 matching lines...) Expand all Loading... |
114 this.setClearingState(false); | 144 this.setClearingState(false); |
115 } | 145 } |
116 | 146 |
117 // Export | 147 // Export |
118 return { | 148 return { |
119 ClearBrowserDataOverlay: ClearBrowserDataOverlay | 149 ClearBrowserDataOverlay: ClearBrowserDataOverlay |
120 }; | 150 }; |
121 | 151 |
122 }); | 152 }); |
123 | 153 |
OLD | NEW |