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

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

Issue 1607483005: Show data usage on Site Details (MDSettings) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix update problem 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
(Empty)
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
3 // found in the LICENSE file.
4
5 (function() {
6 'use strict';
7
8 Polymer({
9 is: 'website-usage-private-api',
10
11 properties: {
12 /**
13 * The amount of data used by the given website.
14 */
15 websiteDataUsage: {
16 type: String,
17 notify: true,
18 },
19 },
20
21 attached: function() {
22 settings.WebsiteUsagePrivateApi.websiteUsagePolymerInstance = this;
23 },
24
25 /** @param {string} host */
26 fetchUsageTotal: function(host) {
27 settings.WebsiteUsagePrivateApi.fetchUsageTotal(host);
28 },
29 });
30 })();
31
32 cr.define('settings.WebsiteUsagePrivateApi', function() {
33 /**
34 * @type {Object} An instance of the polymer object defined above.
35 * All data will be set here.
36 */
37 var websiteUsagePolymerInstance = null;
38
39 /**
40 * @type {string} The host for which the usage total is being fetched.
41 */
42 var hostName_;
43
44 /**
45 * Encapsulates the calls between JS and C++ to fetch how much storage the
46 * host is using.
47 * Will update the data in |websiteUsagePolymerInstance|.
48 */
49 var fetchUsageTotal = function(host) {
50 var instance = settings.WebsiteUsagePrivateApi.websiteUsagePolymerInstance;
51 if (instance != null)
52 instance.websiteDataUsage = '';
53
54 hostName_ = host;
55 chrome.send('fetchUsageTotal', [host]);
56 };
57
58 /**
59 * Callback for when the usage total is known.
60 * @param {string} host The host that the usage was fetched for.
61 * @param {string} usage The string showing how much data the given host
62 * is using.
63 */
64 var returnUsageTotal = function(host, usage) {
65 var instance = settings.WebsiteUsagePrivateApi.websiteUsagePolymerInstance;
66 if (instance == null)
67 return;
68
69 if (hostName_ == host)
70 instance.websiteDataUsage = usage;
71 };
72
73 return { websiteUsagePolymerInstance: websiteUsagePolymerInstance,
74 fetchUsageTotal: fetchUsageTotal,
75 returnUsageTotal: returnUsageTotal };
76 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/settings/site_settings/website_usage_private_api.html ('k') | chrome/browser/storage/OWNERS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698