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

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

Issue 2451553008: [MD settings] move cookie tree management to cookie tree behavior (Closed)
Patch Set: review changes Created 4 years, 2 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/cookie_info.js
diff --git a/chrome/browser/resources/settings/site_settings/cookie_info.js b/chrome/browser/resources/settings/site_settings/cookie_info.js
index f78e161f278db19ce3d2f656250b9f800e225417..e50692f854684106dc2057ade586ba77bce51b96 100644
--- a/chrome/browser/resources/settings/site_settings/cookie_info.js
+++ b/chrome/browser/resources/settings/site_settings/cookie_info.js
@@ -2,6 +2,21 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+/**
+ * @typedef {{hasChildren: boolean,
+ * id: string,
+ * title: string,
+ * totalUsage: string,
+ * type: string}}
+ */
+var CookieDetails;
+
+/**
+ * @typedef {{content: string,
+ * label: string}}
+ */
+var CookieDataForDisplay;
+
// This structure maps the various cookie type names from C++ (hence the
// underscores) to arrays of the different types of data each has, along with
// the i18n name for the description of that data type.
@@ -49,3 +64,28 @@
['size', 'mediaLicenseSize'],
['modified', 'mediaLicenseLastModified']],
};
+
+/**
+ * Get cookie data for a given HTML node.
+ * @param {CookieDetails} data The contents of the cookie.
+ * @return {!Array<CookieDataForDisplay>}
+ */
+var getCookieData = function(data) {
+ /** @type {!Array<CookieDataForDisplay>} */
+ var out = [];
+ var fields = cookieInfo[data.type];
+ for (var field of fields) {
+ // Iterate through the keys found in |cookieInfo| for the given |type|
+ // and see if those keys are present in the data. If so, display them
+ // (in the order determined by |cookieInfo|).
+ var key = field[0];
+ if (data[key].length > 0) {
+ var entry = /** @type {CookieDataForDisplay} */({
+ label: loadTimeData.getString(field[1]),
+ content: data[key],
+ });
+ out.push(entry);
+ }
+ }
+ return out;
+};

Powered by Google App Engine
This is Rietveld 408576698