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

Unified Diff: chrome/browser/resources/settings/site_settings/site_details.js

Issue 1661533002: Implement deletion of storage per site. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address nits Created 4 years, 10 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/site_settings/site_details.js
diff --git a/chrome/browser/resources/settings/site_settings/site_details.js b/chrome/browser/resources/settings/site_settings/site_details.js
index 18b706d5fd160b555fe9c407ee507264406205f1..1a2bd2018a1aef333dc59b6c9ec9980f54423fa5 100644
--- a/chrome/browser/resources/settings/site_settings/site_details.js
+++ b/chrome/browser/resources/settings/site_settings/site_details.js
@@ -43,6 +43,28 @@ Polymer({
type: String,
value: '',
},
+
+ /**
+ * The type of storage for the origin.
+ */
+ storageType_: Number,
+
+ /**
+ * The category the user selected to get to this page.
+ */
+ categorySelected: String,
+
+ /**
+ * The current active route.
+ */
+ currentRoute: {
+ type: Object,
+ notify: true,
+ },
+ },
+
+ listeners: {
+ 'usage-deleted': 'onUsageDeleted',
},
ready: function() {
@@ -68,7 +90,17 @@ Polymer({
* Clears all data stored for the current origin.
*/
onClearStorage_: function() {
- // TODO(finnur): Implement.
+ this.$.usageApi.clearUsage(this.origin, this.storageType_);
+ },
+
+ /**
+ * Called when usage has been deleted for an origin.
+ */
+ onUsageDeleted: function(event) {
+ if (event.detail.origin == this.origin) {
+ this.storedData_ = '';
+ this.navigateBackIfNoData_();
+ }
},
/**
@@ -79,6 +111,26 @@ Polymer({
this.root.querySelectorAll('site-details-permission'),
function(element) { element.resetPermission(); });
- this.onClearStorage_();
+ if (this.storedData_ != '')
+ this.onClearStorage_();
+ else
+ this.navigateBackIfNoData_();
+ },
+
+ /**
+ * Navigate back if the UI is empty (everything been cleared).
+ */
+ navigateBackIfNoData_: function() {
+ if (this.storedData_ == '' && !this.permissionShowing_())
+ this.fire('subpage-back');
+ },
+
+ /**
+ * Returns true if one or more permission is showing.
+ */
+ permissionShowing_: function() {
+ return Array.prototype.some.call(
+ this.root.querySelectorAll('site-details-permission'),
+ function(element) { return element.offsetHeight > 0; });
},
});

Powered by Google App Engine
This is Rietveld 408576698