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 Page = cr.ui.pageManager.Page; | 6 var Page = cr.ui.pageManager.Page; |
7 var PageManager = cr.ui.pageManager.PageManager; | 7 var PageManager = cr.ui.pageManager.PageManager; |
8 | 8 |
9 /** | 9 /** |
10 * ClearBrowserDataOverlay class | 10 * ClearBrowserDataOverlay class |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 types.forEach(function(type) { | 64 types.forEach(function(type) { |
65 Preferences.getInstance().addEventListener(type, f); | 65 Preferences.getInstance().addEventListener(type, f); |
66 }); | 66 }); |
67 | 67 |
68 var checkboxes = document.querySelectorAll( | 68 var checkboxes = document.querySelectorAll( |
69 '#cbd-content-area input[type=checkbox]'); | 69 '#cbd-content-area input[type=checkbox]'); |
70 for (var i = 0; i < checkboxes.length; i++) { | 70 for (var i = 0; i < checkboxes.length; i++) { |
71 checkboxes[i].onclick = f; | 71 checkboxes[i].onclick = f; |
72 } | 72 } |
73 | 73 |
74 this.createStuffRemainsFooter_(); | |
75 | |
76 $('clear-browser-data-dismiss').onclick = function(event) { | 74 $('clear-browser-data-dismiss').onclick = function(event) { |
77 ClearBrowserDataOverlay.dismiss(); | 75 ClearBrowserDataOverlay.dismiss(); |
78 }; | 76 }; |
79 $('clear-browser-data-commit').onclick = function(event) { | 77 $('clear-browser-data-commit').onclick = function(event) { |
80 ClearBrowserDataOverlay.setClearing(true); | 78 ClearBrowserDataOverlay.setClearing(true); |
81 chrome.send('performClearBrowserData'); | 79 chrome.send('performClearBrowserData'); |
82 }; | 80 }; |
83 | 81 |
84 // For managed profiles, hide the checkboxes controlling whether or not | 82 // For managed profiles, hide the checkboxes controlling whether or not |
85 // browsing and download history should be cleared. Note that this is | 83 // browsing and download history should be cleared. Note that this is |
86 // different than just disabling them as a result of enterprise policies. | 84 // different than just disabling them as a result of enterprise policies. |
87 if (!loadTimeData.getBoolean('showDeleteBrowsingHistoryCheckboxes')) { | 85 if (!loadTimeData.getBoolean('showDeleteBrowsingHistoryCheckboxes')) { |
88 $('delete-browsing-history-container').hidden = true; | 86 $('delete-browsing-history-container').hidden = true; |
89 $('delete-download-history-container').hidden = true; | 87 $('delete-download-history-container').hidden = true; |
90 } | 88 } |
91 | 89 |
92 this.updateStateOfControls_(); | 90 this.updateStateOfControls_(); |
93 }, | 91 }, |
94 | 92 |
95 /** | 93 /** |
96 * Create a footer that explains that some content is not cleared by the | 94 * Create a footer that explains that some content is not cleared by the |
97 * clear browsing history dialog. | 95 * clear browsing data dialog and warns that the deletion may be synced. |
| 96 * @param {boolean} simple Whether to use a simple support string. |
| 97 * @param {boolean} syncing Whether the user uses Sync. |
| 98 * @private |
98 */ | 99 */ |
99 createStuffRemainsFooter_: function() { | 100 createFooter_: function(simple, syncing) { |
100 // The localized string is of the form "Saved [content settings] and | 101 // The localized string is of the form "Saved [content settings] and |
101 // {search engines} will not be cleared and may reflect your browsing | 102 // {search engines} will not be cleared and may reflect your browsing |
102 // habits.". The following parses out the parts in brackts and braces and | 103 // habits.", or of the form "Some settings that may reflect browsing |
103 // converts them into buttons whereas the remainders are represented as | 104 // habits |will not be cleared|." if the simplified support string |
104 // span elements. | 105 // experiment is enabled. The following parses out the parts in brackets |
| 106 // and braces and converts them into buttons whereas the remainders are |
| 107 // represented as span elements. |
105 var footer = | 108 var footer = |
106 document.querySelector('#some-stuff-remains-footer p'); | 109 document.querySelector('#some-stuff-remains-footer p'); |
107 var footerFragments = | 110 var footerFragments = |
108 loadTimeData.getString('contentSettingsAndSearchEnginesRemain') | 111 loadTimeData.getString('clearBrowserDataSupportString') |
109 .split(/([|#])/); | 112 .split(/([|#])/); |
| 113 |
| 114 if (simple) { |
| 115 footerFragments.unshift( |
| 116 loadTimeData.getString('clearBrowserDataSyncWarning') + |
| 117 ' ' // Padding between the sync warning and the rest of the footer. |
| 118 ); |
| 119 } |
| 120 |
110 for (var i = 0; i < footerFragments.length;) { | 121 for (var i = 0; i < footerFragments.length;) { |
111 var linkId = ''; | 122 var linkId = ''; |
112 if (i + 2 < footerFragments.length) { | 123 if (i + 2 < footerFragments.length) { |
113 if (footerFragments[i] == '|' && footerFragments[i + 2] == '|') { | 124 if (footerFragments[i] == '|' && footerFragments[i + 2] == '|') { |
114 linkId = 'open-content-settings-from-clear-browsing-data'; | 125 if (simple) |
| 126 linkId = 'open-not-deleted-help-from-clear-browsing-data'; |
| 127 else |
| 128 linkId = 'open-content-settings-from-clear-browsing-data'; |
115 } else if (footerFragments[i] == '#' && | 129 } else if (footerFragments[i] == '#' && |
116 footerFragments[i + 2] == '#') { | 130 footerFragments[i + 2] == '#') { |
117 linkId = 'open-search-engines-from-clear-browsing-data'; | 131 linkId = 'open-search-engines-from-clear-browsing-data'; |
118 } | 132 } |
119 } | 133 } |
120 | 134 |
121 if (linkId) { | 135 if (linkId) { |
122 var link = new ActionLink; | 136 var link = new ActionLink; |
123 link.id = linkId; | 137 link.id = linkId; |
124 link.textContent = footerFragments[i + 1]; | 138 link.textContent = footerFragments[i + 1]; |
125 footer.appendChild(link); | 139 footer.appendChild(link); |
126 i += 3; | 140 i += 3; |
127 } else { | 141 } else { |
128 var span = document.createElement('span'); | 142 var span = document.createElement('span'); |
129 span.textContent = footerFragments[i]; | 143 span.textContent = footerFragments[i]; |
| 144 if (simple && i == 0) { |
| 145 span.id = 'clear-browser-data-sync-warning'; |
| 146 span.hidden = !syncing; |
| 147 } |
130 footer.appendChild(span); | 148 footer.appendChild(span); |
131 i += 1; | 149 i += 1; |
132 } | 150 } |
133 } | 151 } |
134 $('open-content-settings-from-clear-browsing-data').onclick = | 152 |
135 function(event) { | 153 if (simple) { |
136 PageManager.showPageByName('content'); | 154 $('open-not-deleted-help-from-clear-browsing-data').onclick = |
137 }; | 155 function(event) { |
138 $('open-search-engines-from-clear-browsing-data').onclick = | 156 // TODO(msramek): Link to the exact page when the article is written. |
139 function(event) { | 157 window.open('https://support.google.com/chrome/'); |
140 PageManager.showPageByName('searchEngines'); | 158 }; |
141 }; | 159 } else { |
| 160 $('open-content-settings-from-clear-browsing-data').onclick = |
| 161 function(event) { |
| 162 PageManager.showPageByName('content'); |
| 163 }; |
| 164 $('open-search-engines-from-clear-browsing-data').onclick = |
| 165 function(event) { |
| 166 PageManager.showPageByName('searchEngines'); |
| 167 }; |
| 168 } |
142 }, | 169 }, |
143 | 170 |
144 /** | 171 /** |
| 172 * Shows or hides the sync warning based on whether the user uses Sync. |
| 173 * @param {boolean} syncing Whether the user uses Sync. |
| 174 * @private |
| 175 */ |
| 176 updateSyncWarning_: function(syncing) { |
| 177 $('clear-browser-data-sync-warning').hidden = !syncing; |
| 178 }, |
| 179 |
| 180 /** |
145 * Sets whether or not we are in the process of clearing data. | 181 * Sets whether or not we are in the process of clearing data. |
146 * @param {boolean} clearing Whether the browsing data is currently being | 182 * @param {boolean} clearing Whether the browsing data is currently being |
147 * cleared. | 183 * cleared. |
148 * @private | 184 * @private |
149 */ | 185 */ |
150 setClearing_: function(clearing) { | 186 setClearing_: function(clearing) { |
151 this.isClearingInProgress_ = clearing; | 187 this.isClearingInProgress_ = clearing; |
152 this.updateStateOfControls_(); | 188 this.updateStateOfControls_(); |
153 }, | 189 }, |
154 | 190 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 // Chrome callbacks | 276 // Chrome callbacks |
241 // | 277 // |
242 ClearBrowserDataOverlay.setAllowDeletingHistory = function(allowed) { | 278 ClearBrowserDataOverlay.setAllowDeletingHistory = function(allowed) { |
243 ClearBrowserDataOverlay.getInstance().setAllowDeletingHistory_(allowed); | 279 ClearBrowserDataOverlay.getInstance().setAllowDeletingHistory_(allowed); |
244 }; | 280 }; |
245 | 281 |
246 ClearBrowserDataOverlay.updateCounter = function(pref_name, text) { | 282 ClearBrowserDataOverlay.updateCounter = function(pref_name, text) { |
247 ClearBrowserDataOverlay.getInstance().updateCounter_(pref_name, text); | 283 ClearBrowserDataOverlay.getInstance().updateCounter_(pref_name, text); |
248 }; | 284 }; |
249 | 285 |
| 286 ClearBrowserDataOverlay.createFooter = function(simple, syncing) { |
| 287 ClearBrowserDataOverlay.getInstance().createFooter_(simple, syncing); |
| 288 }; |
| 289 |
| 290 ClearBrowserDataOverlay.updateSyncWarning = function(syncing) { |
| 291 ClearBrowserDataOverlay.getInstance().updateSyncWarning_(syncing); |
| 292 }; |
| 293 |
250 ClearBrowserDataOverlay.setClearing = function(clearing) { | 294 ClearBrowserDataOverlay.setClearing = function(clearing) { |
251 ClearBrowserDataOverlay.getInstance().setClearing_(clearing); | 295 ClearBrowserDataOverlay.getInstance().setClearing_(clearing); |
252 }; | 296 }; |
253 | 297 |
254 ClearBrowserDataOverlay.markInitializationComplete = function() { | 298 ClearBrowserDataOverlay.markInitializationComplete = function() { |
255 ClearBrowserDataOverlay.getInstance().markInitializationComplete_(); | 299 ClearBrowserDataOverlay.getInstance().markInitializationComplete_(); |
256 }; | 300 }; |
257 | 301 |
258 ClearBrowserDataOverlay.setBannerText = function(text) { | 302 ClearBrowserDataOverlay.setBannerText = function(text) { |
259 $('clear-browser-data-info-banner').innerText = text; | 303 $('clear-browser-data-info-banner').innerText = text; |
(...skipping 13 matching lines...) Expand all Loading... |
273 var topmostVisiblePage = PageManager.getTopmostVisiblePage(); | 317 var topmostVisiblePage = PageManager.getTopmostVisiblePage(); |
274 if (topmostVisiblePage && topmostVisiblePage.name == 'clearBrowserData') | 318 if (topmostVisiblePage && topmostVisiblePage.name == 'clearBrowserData') |
275 PageManager.closeOverlay(); | 319 PageManager.closeOverlay(); |
276 }; | 320 }; |
277 | 321 |
278 // Export | 322 // Export |
279 return { | 323 return { |
280 ClearBrowserDataOverlay: ClearBrowserDataOverlay | 324 ClearBrowserDataOverlay: ClearBrowserDataOverlay |
281 }; | 325 }; |
282 }); | 326 }); |
OLD | NEW |