Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 /** | 5 /** |
| 6 * @fileoverview 'settings-clear-browsing-data-dialog' allows the user to delete | 6 * @fileoverview 'settings-clear-browsing-data-dialog' allows the user to delete |
| 7 * browsing data that has been cached by Chromium. | 7 * browsing data that has been cached by Chromium. |
| 8 */ | 8 */ |
| 9 Polymer({ | 9 Polymer({ |
| 10 is: 'settings-clear-browsing-data-dialog', | 10 is: 'settings-clear-browsing-data-dialog', |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 21 }, | 21 }, |
| 22 | 22 |
| 23 /** | 23 /** |
| 24 * Results of browsing data counters, keyed by the suffix of | 24 * Results of browsing data counters, keyed by the suffix of |
| 25 * the corresponding data type deletion preference, as reported | 25 * the corresponding data type deletion preference, as reported |
| 26 * by the C++ side. | 26 * by the C++ side. |
| 27 * @private {!Object<string>} | 27 * @private {!Object<string>} |
| 28 */ | 28 */ |
| 29 counters_: { | 29 counters_: { |
| 30 type: Object, | 30 type: Object, |
| 31 value: { | 31 // Will be filled as results are reported. |
| 32 // Will be filled as results are reported. | 32 value: function() { |
| 33 return {}; | |
| 33 } | 34 } |
| 34 }, | 35 }, |
| 35 | 36 |
| 36 /** | 37 /** |
| 37 * List of options for the dropdown menu. | 38 * List of options for the dropdown menu. |
| 38 * @private {!DropdownMenuOptionList} | 39 * @private {!DropdownMenuOptionList} |
| 39 */ | 40 */ |
| 40 clearFromOptions_: { | 41 clearFromOptions_: { |
| 41 readOnly: true, | 42 readOnly: true, |
| 42 type: Array, | 43 type: Array, |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 53 clearingInProgress_: { | 54 clearingInProgress_: { |
| 54 type: Boolean, | 55 type: Boolean, |
| 55 value: false, | 56 value: false, |
| 56 }, | 57 }, |
| 57 | 58 |
| 58 /** @private */ | 59 /** @private */ |
| 59 showHistoryDeletionDialog_: { | 60 showHistoryDeletionDialog_: { |
| 60 type: Boolean, | 61 type: Boolean, |
| 61 value: false, | 62 value: false, |
| 62 }, | 63 }, |
| 64 | |
| 65 /** @private {!Array<ImportantSite>} */ | |
| 66 importantSites_: { | |
| 67 type: Array, | |
| 68 value: function() { | |
| 69 return []; | |
| 70 } | |
| 71 }, | |
| 72 | |
| 73 /** @private */ | |
| 74 importantSitesFlagEnabled_: { | |
| 75 type: Boolean, | |
| 76 value: false, | |
| 77 }, | |
| 78 | |
| 63 }, | 79 }, |
| 64 | 80 |
| 65 /** @private {settings.ClearBrowsingDataBrowserProxy} */ | 81 /** @private {settings.ClearBrowsingDataBrowserProxy} */ |
| 66 browserProxy_: null, | 82 browserProxy_: null, |
| 67 | 83 |
| 68 /** @override */ | 84 /** @override */ |
| 69 ready: function() { | 85 ready: function() { |
| 70 this.$.clearFrom.menuOptions = this.clearFromOptions_; | 86 this.$.clearFrom.menuOptions = this.clearFromOptions_; |
| 71 this.addWebUIListener( | 87 this.addWebUIListener( |
| 72 'update-footer', | 88 'update-footer', |
| 73 this.updateFooter_.bind(this)); | 89 this.updateFooter_.bind(this)); |
| 74 this.addWebUIListener( | 90 this.addWebUIListener( |
| 75 'update-counter-text', | 91 'update-counter-text', |
| 76 this.updateCounterText_.bind(this)); | 92 this.updateCounterText_.bind(this)); |
| 77 }, | 93 }, |
| 78 | 94 |
| 79 /** @override */ | 95 /** @override */ |
| 80 attached: function() { | 96 attached: function() { |
| 81 this.browserProxy_ = | 97 this.browserProxy_ = |
| 82 settings.ClearBrowsingDataBrowserProxyImpl.getInstance(); | 98 settings.ClearBrowsingDataBrowserProxyImpl.getInstance(); |
| 83 this.browserProxy_.initialize().then(function() { | 99 this.browserProxy_.initialize() |
| 84 this.$.dialog.showModal(); | 100 .then(function() { |
| 85 }.bind(this)); | 101 this.$.clearBrowsingDataDialog.showModal(); |
| 102 return this.browserProxy_.fetchImportantSites(); | |
| 103 }.bind(this)) | |
| 104 .then(this.receiveImportantSites_.bind(this)); | |
| 86 }, | 105 }, |
| 87 | 106 |
| 88 /** | 107 /** |
| 108 * @param {!ImportantSitesResponse} result | |
| 109 * @private | |
| 110 */ | |
| 111 receiveImportantSites_: function(result) { | |
| 112 this.importantSitesFlagEnabled_ = result.flagEnabled; | |
| 113 this.set('importantSites_', result.importantSites); | |
| 114 }, | |
| 115 | |
| 116 /** | |
| 89 * Updates the footer to show only those sentences that are relevant to this | 117 * Updates the footer to show only those sentences that are relevant to this |
| 90 * user. | 118 * user. |
| 91 * @param {boolean} syncing Whether the user is syncing data. | 119 * @param {boolean} syncing Whether the user is syncing data. |
| 92 * @param {boolean} otherFormsOfBrowsingHistory Whether the user has other | 120 * @param {boolean} otherFormsOfBrowsingHistory Whether the user has other |
| 93 * forms of browsing history in their account. | 121 * forms of browsing history in their account. |
| 94 * @private | 122 * @private |
| 95 */ | 123 */ |
| 96 updateFooter_: function(syncing, otherFormsOfBrowsingHistory) { | 124 updateFooter_: function(syncing, otherFormsOfBrowsingHistory) { |
| 97 this.$.googleFooter.hidden = !otherFormsOfBrowsingHistory; | 125 this.$.googleFooter.hidden = !otherFormsOfBrowsingHistory; |
| 98 this.$.syncedDataSentence.hidden = !syncing; | 126 this.$.syncedDataSentence.hidden = !syncing; |
| 99 this.$.dialog.classList.add('fully-rendered'); | 127 this.$.clearBrowsingDataDialog.classList.add('fully-rendered'); |
| 100 }, | 128 }, |
| 101 | 129 |
| 102 /** | 130 /** |
| 103 * Updates the text of a browsing data counter corresponding to the given | 131 * Updates the text of a browsing data counter corresponding to the given |
| 104 * preference. | 132 * preference. |
| 105 * @param {string} prefName Browsing data type deletion preference. | 133 * @param {string} prefName Browsing data type deletion preference. |
| 106 * @param {string} text The text with which to update the counter | 134 * @param {string} text The text with which to update the counter |
| 107 * @private | 135 * @private |
| 108 */ | 136 */ |
| 109 updateCounterText_: function(prefName, text) { | 137 updateCounterText_: function(prefName, text) { |
| 110 // Data type deletion preferences are named "browser.clear_data.<datatype>". | 138 // Data type deletion preferences are named "browser.clear_data.<datatype>". |
| 111 // Strip the common prefix, i.e. use only "<datatype>". | 139 // Strip the common prefix, i.e. use only "<datatype>". |
| 112 var matches = prefName.match(/^browser\.clear_data\.(\w+)$/); | 140 var matches = prefName.match(/^browser\.clear_data\.(\w+)$/); |
| 113 this.set('counters_.' + assert(matches[1]), text); | 141 this.set('counters_.' + assert(matches[1]), text); |
| 114 }, | 142 }, |
| 115 | 143 |
| 116 /** | 144 /** |
| 145 * @return {boolean} Whether the ImportantSites dialog should be shown. | |
| 146 * @private | |
| 147 */ | |
| 148 shouldShowImportantSites_: function() { | |
| 149 if (!this.importantSitesFlagEnabled_) | |
| 150 return false; | |
| 151 if (!this.$.cookiesCheckbox.checked && !this.$.cacheCheckbox.checked) | |
| 152 return false; | |
| 153 | |
| 154 var haveImportantSites = this.importantSites_.length > 0; | |
| 155 chrome.send( | |
| 156 'metricsHandler:recordBooleanHistogram', | |
| 157 ['History.ClearBrowsingData.ImportantDialogShown', haveImportantSites]); | |
| 158 return haveImportantSites; | |
| 159 }, | |
| 160 | |
| 161 /** | |
| 117 * Handles the tap on the Clear Data button. | 162 * Handles the tap on the Clear Data button. |
| 118 * @private | 163 * @private |
| 119 */ | 164 */ |
| 120 onClearBrowsingDataTap_: function() { | 165 onClearBrowsingDataTap_: function() { |
| 166 if (this.shouldShowImportantSites_()) { | |
| 167 this.$.importantSitesDialog.showModal(); | |
| 168 this.$.clearBrowsingDataDialog.close(); | |
| 169 } else { | |
| 170 this.clearBrowsingData_() | |
| 171 } | |
| 172 }, | |
| 173 | |
|
Dan Beam
2017/05/05 17:52:51
jsdoc
dullweber
2017/05/09 08:56:39
Done.
| |
| 174 onClearBrowsingDataDialogClose_: function(event) { | |
| 175 // Stop event propagation if another dialog is shown to prevent the | |
| 176 // privacy-page from closing this dialog. | |
| 177 if (this.$.importantSitesDialog.open) | |
| 178 event.stopPropagation() | |
| 179 }, | |
| 180 | |
|
Dan Beam
2017/05/05 17:52:51
jsdoc
dullweber
2017/05/09 08:56:39
Done.
| |
| 181 clearBrowsingData_: function() { | |
| 121 this.clearingInProgress_ = true; | 182 this.clearingInProgress_ = true; |
| 122 | 183 |
| 123 this.browserProxy_.clearBrowsingData().then( | 184 this.browserProxy_.clearBrowsingData(this.importantSites_) |
| 124 /** | 185 .then( |
| 125 * @param {boolean} shouldShowNotice Whether we should show the notice | 186 /** |
| 126 * about other forms of browsing history before closing the dialog. | 187 * @param {boolean} shouldShowNotice Whether we should show the |
| 127 */ | 188 * notice about other forms of browsing history before closing the |
| 128 function(shouldShowNotice) { | 189 * dialog. |
| 129 this.clearingInProgress_ = false; | 190 */ |
| 130 this.showHistoryDeletionDialog_ = shouldShowNotice; | 191 function(shouldShowNotice) { |
| 192 this.clearingInProgress_ = false; | |
| 193 this.showHistoryDeletionDialog_ = shouldShowNotice; | |
| 131 | 194 |
| 132 if (!shouldShowNotice) | 195 if (!shouldShowNotice) { |
| 133 this.$.dialog.close(); | 196 if (this.$.clearBrowsingDataDialog.open) |
| 134 }.bind(this)); | 197 this.$.clearBrowsingDataDialog.close(); |
| 198 if (this.$.importantSitesDialog.open) | |
| 199 this.$.importantSitesDialog.close(); | |
|
Dan Beam
2017/05/05 17:52:51
can we share this code between onHistoryDeletionDi
dullweber
2017/05/09 08:56:39
Done.
| |
| 200 } | |
| 201 }.bind(this)); | |
| 135 }, | 202 }, |
| 136 | 203 |
| 137 /** @private */ | 204 /** @private */ |
| 138 onCancelTap_: function() { | 205 onCancelTap_: function() { |
| 139 this.$.dialog.cancel(); | 206 this.$.clearBrowsingDataDialog.cancel(); |
| 140 }, | 207 }, |
| 141 | 208 |
| 142 /** | 209 /** |
| 210 * Handles the tap confirm button in important sites. | |
| 211 * @private | |
| 212 */ | |
| 213 onImportantSitesConfirmTap_: function() { | |
| 214 this.clearBrowsingData_(); | |
| 215 }, | |
| 216 | |
| 217 /** @private */ | |
| 218 onImportantSitesCancelTap_: function() { | |
| 219 this.$.importantSitesDialog.cancel(); | |
| 220 }, | |
| 221 | |
| 222 /** | |
| 143 * Handles the closing of the notice about other forms of browsing history. | 223 * Handles the closing of the notice about other forms of browsing history. |
| 144 * @private | 224 * @private |
| 145 */ | 225 */ |
| 146 onHistoryDeletionDialogClose_: function() { | 226 onHistoryDeletionDialogClose_: function() { |
| 147 this.showHistoryDeletionDialog_ = false; | 227 this.showHistoryDeletionDialog_ = false; |
| 148 this.$.dialog.close(); | 228 if (this.$.clearBrowsingDataDialog.open) |
| 149 } | 229 this.$.clearBrowsingDataDialog.close(); |
| 230 if (this.$.importantSitesDialog.open) | |
| 231 this.$.importantSitesDialog.close(); | |
| 232 }, | |
| 233 | |
|
Dan Beam
2017/05/05 17:52:51
remove extra \n
dullweber
2017/05/09 08:56:39
Done.
| |
| 150 }); | 234 }); |
| OLD | NEW |