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

Side by Side Diff: chrome/browser/resources/settings/site_settings/website_usage_private_api.js

Issue 1661533002: Implement deletion of storage per site. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address feedback 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 (function() { 5 (function() {
6 'use strict'; 6 'use strict';
7 7
8 Polymer({ 8 Polymer({
9 is: 'website-usage-private-api', 9 is: 'website-usage-private-api',
10 10
11 properties: { 11 properties: {
12 /** 12 /**
13 * The amount of data used by the given website. 13 * The amount of data used by the given website.
14 */ 14 */
15 websiteDataUsage: { 15 websiteDataUsage: {
16 type: String, 16 type: String,
17 notify: true, 17 notify: true,
18 }, 18 },
19
20 /**
21 * The type of data used by the given website.
22 */
23 websiteStorageType: {
24 type: Number,
25 notify: true,
26 },
19 }, 27 },
20 28
21 attached: function() { 29 attached: function() {
22 settings.WebsiteUsagePrivateApi.websiteUsagePolymerInstance = this; 30 settings.WebsiteUsagePrivateApi.websiteUsagePolymerInstance = this;
23 }, 31 },
24 32
25 /** @param {string} host */ 33 /** @param {string} host */
26 fetchUsageTotal: function(host) { 34 fetchUsageTotal: function(host) {
27 settings.WebsiteUsagePrivateApi.fetchUsageTotal(host); 35 settings.WebsiteUsagePrivateApi.fetchUsageTotal(host);
28 }, 36 },
37
38 /** @param {string} origin */
michaelpg 2016/02/04 19:18:01 add type param
39 clearUsage: function(origin, type) {
40 settings.WebsiteUsagePrivateApi.clearUsage(origin, type);
41 },
42
43 notifyUsageDeleted: function(origin) {
michaelpg 2016/02/04 19:18:01 nit: @param
44 this.fire('usage-deleted', {origin: origin});
45 },
29 }); 46 });
30 })(); 47 })();
31 48
32 cr.define('settings.WebsiteUsagePrivateApi', function() { 49 cr.define('settings.WebsiteUsagePrivateApi', function() {
33 /** 50 /**
34 * @type {Object} An instance of the polymer object defined above. 51 * @type {Object} An instance of the polymer object defined above.
35 * All data will be set here. 52 * All data will be set here.
36 */ 53 */
37 var websiteUsagePolymerInstance = null; 54 var websiteUsagePolymerInstance = null;
38 55
(...skipping 14 matching lines...) Expand all
53 70
54 hostName_ = host; 71 hostName_ = host;
55 chrome.send('fetchUsageTotal', [host]); 72 chrome.send('fetchUsageTotal', [host]);
56 }; 73 };
57 74
58 /** 75 /**
59 * Callback for when the usage total is known. 76 * Callback for when the usage total is known.
60 * @param {string} host The host that the usage was fetched for. 77 * @param {string} host The host that the usage was fetched for.
61 * @param {string} usage The string showing how much data the given host 78 * @param {string} usage The string showing how much data the given host
62 * is using. 79 * is using.
80 * @param {number} type The storage type.
63 */ 81 */
64 var returnUsageTotal = function(host, usage) { 82 var returnUsageTotal = function(host, usage, type) {
65 var instance = settings.WebsiteUsagePrivateApi.websiteUsagePolymerInstance; 83 var instance = settings.WebsiteUsagePrivateApi.websiteUsagePolymerInstance;
66 if (instance == null) 84 if (instance == null)
67 return; 85 return;
68 86
69 if (hostName_ == host) 87 if (hostName_ == host) {
70 instance.websiteDataUsage = usage; 88 instance.websiteDataUsage = usage;
89 instance.websiteStorageType = type;
90 }
91 };
92
93 /**
94 * Deletes the storage being used for a given origin.
95 * @param {string} origin The origin to delete storage for.
96 * @param {number} type The type of storage to delete.
97 */
98 var clearUsage = function(origin, type) {
99 chrome.send('clearUsage', [origin, type]);
100 };
101
102 /**
103 * Callback for when the usage has been cleared.
104 * @param {string} origin The origin that the usage was fetched for.
105 */
106 var onUsageCleared = function(origin) {
107 var instance = settings.WebsiteUsagePrivateApi.websiteUsagePolymerInstance;
108 if (instance == null)
109 return;
110
111 instance.notifyUsageDeleted(origin);
71 }; 112 };
72 113
73 return { websiteUsagePolymerInstance: websiteUsagePolymerInstance, 114 return { websiteUsagePolymerInstance: websiteUsagePolymerInstance,
74 fetchUsageTotal: fetchUsageTotal, 115 fetchUsageTotal: fetchUsageTotal,
75 returnUsageTotal: returnUsageTotal }; 116 returnUsageTotal: returnUsageTotal,
117 clearUsage: clearUsage,
118 onUsageCleared: onUsageCleared, };
76 }); 119 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698