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

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: remove favicon Created 3 years, 8 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..c7eb23d9bab54423b85504ef96f0dd903b71625e 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
@@ -28,8 +28,9 @@ Polymer({
*/
counters_: {
type: Object,
- value: {
- // Will be filled as results are reported.
+ // Will be filled as results are reported.
+ value: function() {
+ return {};
}
},
@@ -60,6 +61,27 @@ Polymer({
type: Boolean,
value: false,
},
+
+ /** @private */
+ showImportantSitesDialog_: {
+ type: Boolean,
+ value: false,
+ },
+
+ /** @private {!Array<ImportantSite>} */
+ importantSites_: {
+ type: Array,
+ value: function() {
+ return [];
+ }
+ },
+
+ /** @private */
+ importantSitesFlagEnabled_: {
+ type: Boolean,
+ value: false,
+ },
+
},
/** @private {settings.ClearBrowsingDataBrowserProxy} */
@@ -80,9 +102,21 @@ Polymer({
attached: function() {
this.browserProxy_ =
settings.ClearBrowsingDataBrowserProxyImpl.getInstance();
- this.browserProxy_.initialize().then(function() {
- this.$.dialog.showModal();
- }.bind(this));
+ this.browserProxy_.initialize()
+ .then(function() {
+ this.$.clearBrowsingDataDialog.showModal();
+ return this.browserProxy_.fetchImportantSites();
+ }.bind(this))
+ .then(this.receiveImportantSites.bind(this));
+ },
+
+ /**
+ * @param {!ImportantSitesResponse} result
+ * @private
+ */
+ receiveImportantSites: function(result) {
+ this.importantSitesFlagEnabled_ = result.flagEnabled;
+ this.set('importantSites_', result.importantSites);
},
/**
@@ -96,7 +130,7 @@ Polymer({
updateFooter_: function(syncing, otherFormsOfBrowsingHistory) {
this.$.googleFooter.hidden = !otherFormsOfBrowsingHistory;
this.$.syncedDataSentence.hidden = !syncing;
- this.$.dialog.classList.add('fully-rendered');
+ this.$.clearBrowsingDataDialog.classList.add('fully-rendered');
},
/**
@@ -113,30 +147,74 @@ Polymer({
this.set('counters_.' + assert(matches[1]), text);
},
+ /** @private */
+ shouldShowImportantSites_: function() {
+ 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_()) {
+ // Closing one dialog closes everything, can this be prevented?
dschuyler 2017/04/27 23:10:25 Please see email with advice from dpapad@.
dullweber 2017/04/28 12:34:03 Thanks for asking him. event.stopPropagation() sol
+ // this.$.clearBrowsingDataDialog.close();
+ this.showImportantSitesDialog_ = true;
+ this.$.importantSitesDialog.showModal();
+ } else {
+ this.clearBrowsingData_()
+ }
+ },
+
+ clearBrowsingData_: function() {
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) {
+ if (this.$.clearBrowsingDataDialog.open)
+ this.$.clearBrowsingDataDialog.close();
+ if (this.$.importantSitesDialog.open)
+ this.$.importantSitesDialog.close();
+ }
+ }.bind(this));
},
/** @private */
onCancelTap_: function() {
- this.$.dialog.cancel();
+ this.$.clearBrowsingDataDialog.cancel();
+ },
+
+ /**
+ * Handles the tap confirm button in important sites.
+ * @private
+ */
+ onImportantSitesConfirmTap_: function() {
+ this.clearBrowsingData_();
+ },
+
+ /** @private */
+ onImportantSitesCancelTap_: function() {
+ this.$.importantSitesDialog.cancel();
},
/**
@@ -145,6 +223,10 @@ Polymer({
*/
onHistoryDeletionDialogClose_: function() {
this.showHistoryDeletionDialog_ = false;
- this.$.dialog.close();
- }
+ if (this.$.clearBrowsingDataDialog.open)
+ this.$.clearBrowsingDataDialog.close();
+ if (this.$.importantSitesDialog.open)
+ this.$.importantSitesDialog.close();
+ },
+
});

Powered by Google App Engine
This is Rietveld 408576698