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..6ef6cf101d8043869d30af47da75e13b03ab46d6 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. |
@@ -60,6 +69,12 @@ Polymer({ |
type: Boolean, |
value: false, |
}, |
+ |
+ /** @private {!Array<ImportantSite>} */ |
+ importantSites_: { |
+ type: Array, |
+ value: [], |
+ }, |
}, |
/** @private {settings.ClearBrowsingDataBrowserProxy} */ |
@@ -82,10 +97,24 @@ 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) { |
+ if (result.dialogDisabled) { |
+ this.set('importantSites_', []); |
+ } else { |
+ 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,13 +143,46 @@ 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.$.cookiesCheckbox.checked && !this.$.cacheCheckbox.checked) { |
+ return false; |
+ } |
+ return this.isClearBrowsingDataDialog_(this.dialogState_) && |
dmurph
2017/03/06 21:16:48
Please also reference
https://cs.chromium.org/chro
dullweber
2017/03/07 12:24:34
I'm already passing the result of this method to j
|
+ this.importantSites_.length; |
+ // TODO(dullweber): Log Histogram? |
+ }, |
+ |
+ /** |
* 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( |
+ 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. |