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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @fileoverview 6 * @fileoverview
7 * 'site-details' show the details (permissions and usage) for a given origin 7 * 'site-details' show the details (permissions and usage) for a given origin
8 * under Site Settings. 8 * under Site Settings.
9 * 9 *
10 * Example: 10 * Example:
(...skipping 25 matching lines...) Expand all
36 observer: 'onOriginChanged_', 36 observer: 'onOriginChanged_',
37 }, 37 },
38 38
39 /** 39 /**
40 * The amount of data stored for the origin. 40 * The amount of data stored for the origin.
41 */ 41 */
42 storedData_: { 42 storedData_: {
43 type: String, 43 type: String,
44 value: '', 44 value: '',
45 }, 45 },
46
47 /**
48 * The type of storage for the origin.
49 */
50 storageType_: Number,
51
52 /**
53 * The category the user selected to get to this page.
54 */
55 categorySelected: String,
56
57 /**
58 * The current active route.
59 */
60 currentRoute: {
61 type: Object,
62 notify: true,
63 },
64 },
65
66 listeners: {
67 'usage-deleted': 'onUsageDeleted',
46 }, 68 },
47 69
48 ready: function() { 70 ready: function() {
49 this.$.cookies.category = settings.ContentSettingsTypes.COOKIES; 71 this.$.cookies.category = settings.ContentSettingsTypes.COOKIES;
50 this.$.javascript.category = settings.ContentSettingsTypes.JAVASCRIPT; 72 this.$.javascript.category = settings.ContentSettingsTypes.JAVASCRIPT;
51 this.$.popups.category = settings.ContentSettingsTypes.POPUPS; 73 this.$.popups.category = settings.ContentSettingsTypes.POPUPS;
52 this.$.geolocation.category = settings.ContentSettingsTypes.GEOLOCATION; 74 this.$.geolocation.category = settings.ContentSettingsTypes.GEOLOCATION;
53 this.$.notification.category = settings.ContentSettingsTypes.NOTIFICATIONS; 75 this.$.notification.category = settings.ContentSettingsTypes.NOTIFICATIONS;
54 this.$.fullscreen.category = settings.ContentSettingsTypes.FULLSCREEN; 76 this.$.fullscreen.category = settings.ContentSettingsTypes.FULLSCREEN;
55 this.$.camera.category = settings.ContentSettingsTypes.CAMERA; 77 this.$.camera.category = settings.ContentSettingsTypes.CAMERA;
56 this.$.mic.category = settings.ContentSettingsTypes.MIC; 78 this.$.mic.category = settings.ContentSettingsTypes.MIC;
57 }, 79 },
58 80
59 /** 81 /**
60 * Handler for when the origin changes. 82 * Handler for when the origin changes.
61 */ 83 */
62 onOriginChanged_: function() { 84 onOriginChanged_: function() {
63 var url = /** @type {{hostname: string}} */(new URL(this.origin)); 85 var url = /** @type {{hostname: string}} */(new URL(this.origin));
64 this.$.usageApi.fetchUsageTotal(url.hostname); 86 this.$.usageApi.fetchUsageTotal(url.hostname);
65 }, 87 },
66 88
67 /** 89 /**
68 * Clears all data stored for the current origin. 90 * Clears all data stored for the current origin.
69 */ 91 */
70 onClearStorage_: function() { 92 onClearStorage_: function() {
71 // TODO(finnur): Implement. 93 this.$.usageApi.clearUsage(this.origin, this.storageType_);
72 }, 94 },
73 95
74 /** 96 /**
97 * Called when usage has been deleted for an origin.
98 */
99 onUsageDeleted: function(event) {
100 if (event.detail.origin == this.origin) {
101 this.storedData_ = '';
102 this.navigateBackIfNoData_();
103 }
104 },
105
106 /**
75 * Resets all permissions and clears all data stored for the current origin. 107 * Resets all permissions and clears all data stored for the current origin.
76 */ 108 */
77 onClearAndReset_: function() { 109 onClearAndReset_: function() {
78 Array.prototype.forEach.call( 110 Array.prototype.forEach.call(
79 this.root.querySelectorAll('site-details-permission'), 111 this.root.querySelectorAll('site-details-permission'),
80 function(element) { element.resetPermission(); }); 112 function(element) { element.resetPermission(); });
81 113
82 this.onClearStorage_(); 114 if (this.storedData_ != '')
115 this.onClearStorage_();
116 else
117 this.navigateBackIfNoData_();
118 },
119
120 /**
121 * Navigate back if the UI is empty (everything been cleared).
122 */
123 navigateBackIfNoData_: function() {
124 if (this.storedData_ == '' && !this.permissionShowing_())
125 this.fire('subpage-back');
126 },
127
128 /**
129 * Returns true if one or more permission is showing.
130 */
131 permissionShowing_: function() {
132 return Array.prototype.some.call(
133 this.root.querySelectorAll('site-details-permission'),
134 function(element) { return element.offsetHeight > 0; });
83 }, 135 },
84 }); 136 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698