Chromium Code Reviews| 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..59d356d25dc65082747baae8fec62d95b1481d72 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; |
|
dschuyler
2016/10/26 00:18:38
These were moved (unchanged).
|
| + |
| // 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,29 @@ |
| ['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) { |
|
dschuyler
2016/10/26 00:18:38
This was moved and slightly changed.
|data| was a
|
| + /** @type {!Array<CookieDataForDisplay>} */ |
| + var out = []; |
| + var fields = cookieInfo[data.type]; |
| + if (fields) |
| + 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; |
| +}; |