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

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: Augment test 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 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(origin) {
26 settings.WebsiteUsagePrivateApi.fetchUsageTotal(origin);
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;
37
38 /**
39 * Encapsulates the calls between JS and C++ to fetch how much storage the
40 * origin is using.
41 * Will update the data in |websiteUsagePolymerInstance|.
42 */
43 fetchUsageTotal = function(origin) {
44 chrome.send('fetchUsageTotal', [origin]);
45 };
46
47 /**
48 * Callback for when the usage total is known.
49 * @param {string} usage The string showing how much data the given origin
50 * is using.
51 */
52 returnUsageTotal = function(usage) {
53 var instance = settings.WebsiteUsagePrivateApi.websiteUsagePolymerInstance;
54 if (instance == null) {
55 return;
56 }
57
58 instance.websiteDataUsage = usage;
michaelpg 2016/01/25 18:33:54 shouldn't we check that the origin is still the sa
Finnur 2016/01/26 15:54:53 Like so?
michaelpg 2016/01/27 06:37:46 Yeah, but no need to assert -- it's a valid sequen
Finnur 2016/01/27 10:27:26 Done.
59 };
60
61 return { websiteUsagePolymerInstance: websiteUsagePolymerInstance,
62 fetchUsageTotal: fetchUsageTotal,
63 returnUsageTotal: returnUsageTotal };
64 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698