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

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: Created 4 years, 11 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..8ce9d73d1ccc18bbaa2e9852a01845a06d847979 100644
--- a/chrome/browser/resources/settings/site_settings/site_details.js
+++ b/chrome/browser/resources/settings/site_settings/site_details.js
@@ -43,6 +43,24 @@ 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,
+ },
},
ready: function() {
@@ -68,7 +86,9 @@ Polymer({
* Clears all data stored for the current origin.
*/
onClearStorage_: function() {
- // TODO(finnur): Implement.
+ this.$.usageApi.clearUsage(this.origin, this.storageType_);
+ this.storedData_ = '';
michaelpg 2016/02/03 18:39:13 Typically we would wait for a callback from C++ to
Finnur 2016/02/04 14:56:58 Done.
+ this.navigateBackIfNoData_();
},
/**
@@ -79,6 +99,34 @@ 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.currentRoute = {
michaelpg 2016/02/03 18:39:13 Is this the same as this.fire('subpage-back')? Tha
Finnur 2016/02/04 14:56:58 That was actually the first thing I tried, but rea
michaelpg 2016/02/04 19:18:01 Awesome!!
+ page: this.currentRoute.page,
+ section: 'privacy',
+ subpage: ['site-settings', 'site-settings-category-' +
+ this.categorySelected],
+ };
+ }
+ },
+
+ /**
+ * Returns true if one or more permission is showing.
+ */
+ permissionShowing_: function() {
+ var height = 0;
+ Array.prototype.forEach.call(
michaelpg 2016/02/03 18:39:13 see Array.prototype.some
Finnur 2016/02/04 14:56:58 Hey, neat!
+ this.root.querySelectorAll('site-details-permission'),
+ function(element) { height += element.offsetHeight; });
michaelpg 2016/02/03 18:39:13 with some: function(element) { return element.
Finnur 2016/02/04 14:56:58 Hmmm... is there a benefit to the latter syntax? I
michaelpg 2016/02/04 19:18:01 It's called an arrow function. Relatively new, no
michaelpg 2016/02/05 01:32:22 btw, arrow functions will break the presubmit lint
+ return height > 0;
},
});

Powered by Google App Engine
This is Rietveld 408576698