Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(59)

Unified Diff: chrome/browser/resources/settings/clear_browsing_data_dialog/clear_browsing_data_dialog.js

Issue 2716333002: Implement important sites dialog for desktop. (Closed)
Patch Set: log histogram when important sites is shown Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..b5ea4495a3f4f7295061dee3127d1ba5b797a523 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 */
+ importantSitesDialogDisabled_: {
+ 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.importantSitesDialogDisabled_ = result.dialogDisabled;
+ 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,52 @@ 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.importantSitesDialogDisabled_) return false;
+ if (!this.$.cookiesCheckbox.checked && !this.$.cacheCheckbox.checked) {
+ return false;
+ }
+ var haveImportantSites = this.importantSites_.length > 0;
dmurph 2017/03/13 22:26:38 Can you capture the dialog being disabled here? In
dullweber 2017/03/14 10:32:04 This function will return false in line 170 when t
+ 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(
+ var importantSites = this.importantSitesDialogDisabled_
+ ? [] : this.importantSites_;
+
+ this.browserProxy_.clearBrowsingData(importantSites).then(
/**
* @param {boolean} shouldShowNotice Whether we should show the notice
* about other forms of browsing history before closing the dialog.

Powered by Google App Engine
This is Rietveld 408576698