Chromium Code Reviews| Index: chrome/browser/resources/settings/clear_browsing_data_dialog/clear_browsing_data_dialog.js |
| diff --git a/chrome/browser/resources/settings/clear_browsing_data_dialog/clear_browsing_data_dialog.js b/chrome/browser/resources/settings/clear_browsing_data_dialog/clear_browsing_data_dialog.js |
| index 5c8d55722aeff98d7b8e3bde1df11083fb4a7bb0..12526ff2c56b7c01d234927d064810a436186e0b 100644 |
| --- a/chrome/browser/resources/settings/clear_browsing_data_dialog/clear_browsing_data_dialog.js |
| +++ b/chrome/browser/resources/settings/clear_browsing_data_dialog/clear_browsing_data_dialog.js |
| @@ -21,6 +21,15 @@ Polymer({ |
| }, |
| /** |
| + * State of this dialog, either "clearBrowsingData" or "importantSites". |
| + * @private |
| + */ |
| + dialogState_: { |
| + type: String, |
| + value: 'clearBrowsingData', |
| + }, |
| + |
| + /** |
| * Results of browsing data counters, keyed by the suffix of |
| * the corresponding data type deletion preference, as reported |
| * by the C++ side. |
| @@ -29,7 +38,7 @@ Polymer({ |
| counters_: { |
| type: Object, |
| value: { |
| - // Will be filled as results are reported. |
| + // Will be filled as results are reported. |
|
dullweber
2017/04/07 09:39:21
This formatting by "git cl format --js" seems odd,
dschuyler
2017/04/07 22:57:34
I agree that's weird and I would expect a two spac
dullweber
2017/04/10 10:59:50
I submitted a bug for clang-format
|
| } |
|
dschuyler
2017/04/07 22:57:34
Hey that helps point out another issue that I miss
dullweber
2017/04/10 10:59:50
Ah, that looks interesting, thanks. I guess the sa
|
| }, |
| @@ -60,6 +69,19 @@ Polymer({ |
| type: Boolean, |
| value: false, |
| }, |
| + |
| + /** @private {!Array<ImportantSite>} */ |
| + importantSites_: { |
| + type: Array, |
| + value: [], |
| + }, |
| + |
| + /** @private */ |
| + importantSitesFlagEnabled_: { |
| + type: Boolean, |
| + value: false, |
| + }, |
| + |
| }, |
| /** @private {settings.ClearBrowsingDataBrowserProxy} */ |
| @@ -82,10 +104,21 @@ Polymer({ |
| settings.ClearBrowsingDataBrowserProxyImpl.getInstance(); |
| this.browserProxy_.initialize().then(function() { |
| this.$.dialog.showModal(); |
| + this.browserProxy_.fetchImportantSites().then( |
| + this.receiveImportantSites.bind(this)); |
| }.bind(this)); |
| }, |
| /** |
| + * @param {!ImportantSitesResponse} result |
| + * @private |
| + */ |
| + receiveImportantSites: function(result) { |
| + this.importantSitesFlagEnabled_ = result.flagEnabled; |
| + this.set('importantSites_', result.importantSites); |
| + }, |
| + |
| + /** |
| * Updates the footer to show only those sentences that are relevant to this |
| * user. |
| * @param {boolean} syncing Whether the user is syncing data. |
| @@ -114,24 +147,65 @@ Polymer({ |
| }, |
| /** |
| + * @param {string} currentDialogState The current dialog state. |
| + * @return {boolean} Whether this is the clear browsing data dialog. |
| + * @private |
| + */ |
| + isClearBrowsingDataDialog_: function(currentDialogState) { |
| + return currentDialogState == 'clearBrowsingData'; |
| + }, |
| + |
| + /** |
| + * @param {string} currentDialogState The current dialog state. |
| + * @return {boolean} Whether this is the important sites dialog. |
| + * @private |
| + */ |
| + isImportantSitesDialog_: function(currentDialogState) { |
| + return currentDialogState == 'importantSites'; |
| + }, |
| + |
| + /** @private */ |
| + shouldShowImportantSites_: function() { |
| + if (this.isImportantSitesDialog_(this.dialogState_)) |
| + return false; |
| + if (!this.importantSitesFlagEnabled_) |
| + return false; |
| + if (!this.$.cookiesCheckbox.checked && !this.$.cacheCheckbox.checked) { |
| + return false; |
| + } |
| + var haveImportantSites = this.importantSites_.length > 0; |
| + chrome.send( |
| + 'metricsHandler:recordBooleanHistogram', |
| + ['History.ClearBrowsingData.ImportantDialogShown', haveImportantSites]); |
| + return haveImportantSites; |
| + }, |
| + |
| + /** |
| * Handles the tap on the Clear Data button. |
| * @private |
| */ |
| onClearBrowsingDataTap_: function() { |
| + if (this.shouldShowImportantSites_()) { |
| + this.dialogState_ = 'importantSites'; |
| + return; |
| + } |
| + |
| this.clearingInProgress_ = true; |
| - this.browserProxy_.clearBrowsingData().then( |
| - /** |
| - * @param {boolean} shouldShowNotice Whether we should show the notice |
| - * about other forms of browsing history before closing the dialog. |
| - */ |
| - function(shouldShowNotice) { |
| - this.clearingInProgress_ = false; |
| - this.showHistoryDeletionDialog_ = shouldShowNotice; |
| - |
| - if (!shouldShowNotice) |
| - this.$.dialog.close(); |
| - }.bind(this)); |
| + this.browserProxy_.clearBrowsingData(this.importantSites_) |
| + .then( |
| + /** |
| + * @param {boolean} shouldShowNotice Whether we should show the |
| + * notice about other forms of browsing history before closing the |
| + * dialog. |
| + */ |
| + function(shouldShowNotice) { |
| + this.clearingInProgress_ = false; |
| + this.showHistoryDeletionDialog_ = shouldShowNotice; |
| + |
| + if (!shouldShowNotice) |
| + this.$.dialog.close(); |
| + }.bind(this)); |
| }, |
| /** @private */ |