Index: chrome/browser/resources/settings/site_settings/site_settings_handler.js |
diff --git a/chrome/browser/resources/settings/site_settings/site_settings_handler.js b/chrome/browser/resources/settings/site_settings/site_settings_handler.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..aa3a22dae7d4444dbea0f79c77cd3988a84fc0c9 |
--- /dev/null |
+++ b/chrome/browser/resources/settings/site_settings/site_settings_handler.js |
@@ -0,0 +1,40 @@ |
+// 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. |
+ |
+/** |
+ * @constructor |
+ */ |
+function SiteSettingsHandler() {} |
+ |
+/** |
+ * Asynchronously fetches the total amount of data attributed to a given origin. |
+ * If no data is attributed to the origin, the callback does not fire. |
+ * @param {string} origin The origin to look up. |
+ * @param {!Element} context The context to use for the callback. |
+ * @param {Function=} callback The callback to run when the data is ready. |
michaelpg
2016/01/19 20:47:54
uncapitalize function, and have it take a string:
Finnur
2016/01/22 15:07:35
Done.
|
+ */ |
+SiteSettingsHandler.prototype.fetchUsageTotal = function( |
+ origin, context, callback) { |
+ this.context = context; |
+ this.callback = callback; |
+ |
+ var self = this; |
+ cr.define('SiteSettingsHandler', function() { |
+ return { |
+ OnUsageDataAvailable: function() { |
+ return self.returnUsageTotal.apply(self, arguments); |
+ }, |
+ }; |
+ }); |
+ |
+ chrome.send('fetchUsageTotal', [origin]); |
+}; |
+ |
+/** |
+ * Handles reporting the amount (of usage data) back to the caller. |
+ * @param {string} usage The total amount of data attributed to a given origin. |
+ */ |
+SiteSettingsHandler.prototype.returnUsageTotal = function(usage) { |
+ this.callback.call(this.context, usage); |
+}; |
Finnur
2016/01/19 17:08:57
Is all of the above a reasonable way to do this ab
michaelpg
2016/01/19 20:47:54
I would make SiteSettingsHandler "static" and simp
Finnur
2016/01/22 15:07:35
Obsolete code now.
|