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

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: Address feedback and add owner 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 fetchUsageTotal: function(host) {
michaelpg 2016/01/27 18:42:48 /** @param {string} host */
Finnur 2016/01/28 11:17:49 Done.
26 settings.WebsiteUsagePrivateApi.fetchUsageTotal(host);
27 },
28 });
29 })();
30
31 cr.define('settings.WebsiteUsagePrivateApi', function() {
32 /**
33 * @type {Object} An instance of the polymer object defined above.
34 * All data will be set here.
35 */
36 websiteUsagePolymerInstance = null;
michaelpg 2016/01/27 18:42:48 var
Finnur 2016/01/28 11:17:49 Done.
37
38 /**
39 * @type {string} The host for which the usage total is being fetched.
40 */
41 var host;
42
43 /**
44 * Encapsulates the calls between JS and C++ to fetch how much storage the
45 * host is using.
46 * Will update the data in |websiteUsagePolymerInstance|.
47 */
48 fetchUsageTotal = function(host) {
michaelpg 2016/01/27 18:42:48 var. You're creating global variables, they should
Finnur 2016/01/28 11:17:49 Done, I believe. Happy to do a follow-up if I got
49 var instance = settings.WebsiteUsagePrivateApi.websiteUsagePolymerInstance;
50 if (instance != null)
51 instance.websiteDataUsage = '';
52
53 this.host = host;
michaelpg 2016/01/27 18:42:48 do you mean to use the "var host" defined at 41? y
Finnur 2016/01/28 11:17:49 Done.
54 chrome.send('fetchUsageTotal', [host]);
55 };
56
57 /**
58 * Callback for when the usage total is known.
59 * @param {string} host The host that the usage was fetched for.
60 * @param {string} usage The string showing how much data the given host
61 * is using.
62 */
63 returnUsageTotal = function(host, usage) {
64 var instance = settings.WebsiteUsagePrivateApi.websiteUsagePolymerInstance;
65 if (instance == null)
66 return;
67
68 if (this.host == host)
69 instance.websiteDataUsage = usage;
70 };
71
72 return { websiteUsagePolymerInstance: websiteUsagePolymerInstance,
73 fetchUsageTotal: fetchUsageTotal,
74 returnUsageTotal: returnUsageTotal };
75 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698