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

Unified Diff: chrome/browser/resources/settings/site_settings/site_settings_handler.js

Issue 1607483005: Show data usage on Site Details (MDSettings) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 side-by-side diff with in-line comments
Download patch
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.

Powered by Google App Engine
This is Rietveld 408576698