| Index: chrome/browser/resources/settings/site_settings/website_usage_private_api.js
|
| diff --git a/chrome/browser/resources/settings/site_settings/website_usage_private_api.js b/chrome/browser/resources/settings/site_settings/website_usage_private_api.js
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..9bb866ff0cb6a46acdfee49dec9df6465c52615f
|
| --- /dev/null
|
| +++ b/chrome/browser/resources/settings/site_settings/website_usage_private_api.js
|
| @@ -0,0 +1,64 @@
|
| +// Copyright 2016 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +(function() {
|
| +'use strict';
|
| +
|
| +Polymer({
|
| + is: 'website-usage-private-api',
|
| +
|
| + properties: {
|
| + /**
|
| + * The amount of data used by the given website.
|
| + */
|
| + websiteDataUsage: {
|
| + type: String,
|
| + notify: true,
|
| + },
|
| + },
|
| +
|
| + attached: function() {
|
| + settings.WebsiteUsagePrivateApi.websiteUsagePolymerInstance = this;
|
| + },
|
| +
|
| + fetchUsageTotal: function(origin) {
|
| + settings.WebsiteUsagePrivateApi.fetchUsageTotal(origin);
|
| + },
|
| +});
|
| +})();
|
| +
|
| +cr.define('settings.WebsiteUsagePrivateApi', function() {
|
| + /**
|
| + * @type {Object} An instance of the polymer object defined above.
|
| + * All data will be set here.
|
| + */
|
| + websiteUsagePolymerInstance = null;
|
| +
|
| + /**
|
| + * Encapsulates the calls between JS and C++ to fetch how much storage the
|
| + * origin is using.
|
| + * Will update the data in |websiteUsagePolymerInstance|.
|
| + */
|
| + fetchUsageTotal = function(origin) {
|
| + chrome.send('fetchUsageTotal', [origin]);
|
| + };
|
| +
|
| + /**
|
| + * Callback for when the usage total is known.
|
| + * @param {string} usage The string showing how much data the given origin
|
| + * is using.
|
| + */
|
| + returnUsageTotal = function(usage) {
|
| + var instance = settings.WebsiteUsagePrivateApi.websiteUsagePolymerInstance;
|
| + if (instance == null) {
|
| + return;
|
| + }
|
| +
|
| + instance.websiteDataUsage = usage;
|
| + };
|
| +
|
| + return { websiteUsagePolymerInstance: websiteUsagePolymerInstance,
|
| + fetchUsageTotal: fetchUsageTotal,
|
| + returnUsageTotal: returnUsageTotal };
|
| +});
|
|
|