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) { | |
|
michaelpg
2017/05/03 21:48:05
add trailing underscore for @private
dullweber
2017/05/04 08:31:08
Done.
| |
| 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 |
| 144 /** @private */ | |
|
michaelpg
2017/05/03 21:48:05
document @return value
dullweber
2017/05/04 08:31:08
Done.
| |
| 145 shouldShowImportantSites_: function() { | |
| 146 if (!this.importantSitesFlagEnabled_) | |
| 147 return false; | |
| 148 if (!this.$.cookiesCheckbox.checked && !this.$.cacheCheckbox.checked) { | |
|
michaelpg
2017/05/03 21:48:05
nit: no {} here for consistency with above
dullweber
2017/05/04 08:31:08
Done.
| |
| 149 return false; | |
| 150 } | |
| 151 var haveImportantSites = this.importantSites_.length > 0; | |
| 152 chrome.send( | |
| 153 'metricsHandler:recordBooleanHistogram', | |
| 154 ['History.ClearBrowsingData.ImportantDialogShown', haveImportantSites]); | |
| 155 return haveImportantSites; | |
| 156 }, | |
| 157 | |
| 116 /** | 158 /** |
| 117 * Handles the tap on the Clear Data button. | 159 * Handles the tap on the Clear Data button. |
| 118 * @private | 160 * @private |
| 119 */ | 161 */ |
| 120 onClearBrowsingDataTap_: function() { | 162 onClearBrowsingDataTap_: function() { |
| 163 if (this.shouldShowImportantSites_()) { | |
| 164 this.$.importantSitesDialog.showModal(); | |
| 165 this.$.clearBrowsingDataDialog.close(); | |
| 166 } else { | |
| 167 this.clearBrowsingData_() | |
| 168 } | |
| 169 }, | |
| 170 | |
| 171 onClearBrowsingDataDialogClose_: function(event) { | |
| 172 // Stop event propagation if another dialog is shown to prevent the | |
| 173 // privacy-page from closing this dialog. | |
| 174 if (this.$.importantSitesDialog.open) | |
| 175 event.stopPropagation() | |
| 176 }, | |
| 177 | |
| 178 clearBrowsingData_: function() { | |
| 121 this.clearingInProgress_ = true; | 179 this.clearingInProgress_ = true; |
| 122 | 180 |
| 123 this.browserProxy_.clearBrowsingData().then( | 181 this.browserProxy_.clearBrowsingData(this.importantSites_) |
| 124 /** | 182 .then( |
| 125 * @param {boolean} shouldShowNotice Whether we should show the notice | 183 /** |
| 126 * about other forms of browsing history before closing the dialog. | 184 * @param {boolean} shouldShowNotice Whether we should show the |
| 127 */ | 185 * notice about other forms of browsing history before closing the |
| 128 function(shouldShowNotice) { | 186 * dialog. |
| 129 this.clearingInProgress_ = false; | 187 */ |
| 130 this.showHistoryDeletionDialog_ = shouldShowNotice; | 188 function(shouldShowNotice) { |
| 189 this.clearingInProgress_ = false; | |
| 190 this.showHistoryDeletionDialog_ = shouldShowNotice; | |
| 131 | 191 |
| 132 if (!shouldShowNotice) | 192 if (!shouldShowNotice) { |
| 133 this.$.dialog.close(); | 193 if (this.$.clearBrowsingDataDialog.open) |
| 134 }.bind(this)); | 194 this.$.clearBrowsingDataDialog.close(); |
| 195 if (this.$.importantSitesDialog.open) | |
| 196 this.$.importantSitesDialog.close(); | |
| 197 } | |
| 198 }.bind(this)); | |
| 135 }, | 199 }, |
| 136 | 200 |
| 137 /** @private */ | 201 /** @private */ |
| 138 onCancelTap_: function() { | 202 onCancelTap_: function() { |
| 139 this.$.dialog.cancel(); | 203 this.$.clearBrowsingDataDialog.cancel(); |
| 140 }, | 204 }, |
| 141 | 205 |
| 142 /** | 206 /** |
| 207 * Handles the tap confirm button in important sites. | |
| 208 * @private | |
| 209 */ | |
| 210 onImportantSitesConfirmTap_: function() { | |
| 211 this.clearBrowsingData_(); | |
| 212 }, | |
| 213 | |
| 214 /** @private */ | |
| 215 onImportantSitesCancelTap_: function() { | |
| 216 this.$.importantSitesDialog.cancel(); | |
| 217 }, | |
| 218 | |
| 219 /** | |
| 143 * Handles the closing of the notice about other forms of browsing history. | 220 * Handles the closing of the notice about other forms of browsing history. |
| 144 * @private | 221 * @private |
| 145 */ | 222 */ |
| 146 onHistoryDeletionDialogClose_: function() { | 223 onHistoryDeletionDialogClose_: function() { |
| 147 this.showHistoryDeletionDialog_ = false; | 224 this.showHistoryDeletionDialog_ = false; |
| 148 this.$.dialog.close(); | 225 if (this.$.clearBrowsingDataDialog.open) |
| 149 } | 226 this.$.clearBrowsingDataDialog.close(); |
| 227 if (this.$.importantSitesDialog.open) | |
| 228 this.$.importantSitesDialog.close(); | |
| 229 }, | |
| 230 | |
| 150 }); | 231 }); |
| OLD | NEW |