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..143fd51d70d5a057d818f2e89f8ccc050432e5d8 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,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)); |
dschuyler
2017/04/07 00:02:06
Try chaining the .thens out linearly rather than n
dullweber
2017/04/07 09:39:21
Done.
|
}, |
/** |
+ * @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,13 +147,49 @@ 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( |
+ 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. |