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

Side by Side 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, 1 month 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /**
6 * @typedef {{hasChildren: boolean,
7 * id: string,
8 * title: string,
9 * totalUsage: string,
10 * type: string}}
11 */
12 var CookieDetails;
13
14 /**
15 * @typedef {{content: string,
16 * label: string}}
17 */
18 var CookieDataForDisplay;
19
5 // This structure maps the various cookie type names from C++ (hence the 20 // This structure maps the various cookie type names from C++ (hence the
6 // underscores) to arrays of the different types of data each has, along with 21 // underscores) to arrays of the different types of data each has, along with
7 // the i18n name for the description of that data type. 22 // the i18n name for the description of that data type.
8 // This structure serves three purposes: 23 // This structure serves three purposes:
9 // 1) to list what subset of the cookie data we want to show in the UI. 24 // 1) to list what subset of the cookie data we want to show in the UI.
10 // 2) What order to show it in. 25 // 2) What order to show it in.
11 // 3) What user friendly label to prefix the data with. 26 // 3) What user friendly label to prefix the data with.
12 /** @const */ var cookieInfo = { 27 /** @const */ var cookieInfo = {
13 'cookie': [['name', 'cookieName'], 28 'cookie': [['name', 'cookieName'],
14 ['content', 'cookieContent'], 29 ['content', 'cookieContent'],
(...skipping 27 matching lines...) Expand all
42 ['size', 'serviceWorkerSize'], 57 ['size', 'serviceWorkerSize'],
43 ['scopes', 'serviceWorkerScopes']], 58 ['scopes', 'serviceWorkerScopes']],
44 'cache_storage': [['origin', 'cacheStorageOrigin'], 59 'cache_storage': [['origin', 'cacheStorageOrigin'],
45 ['size', 'cacheStorageSize'], 60 ['size', 'cacheStorageSize'],
46 ['modified', 'cacheStorageLastModified']], 61 ['modified', 'cacheStorageLastModified']],
47 'flash_lso': [['domain', 'cookieDomain']], 62 'flash_lso': [['domain', 'cookieDomain']],
48 'media_license': [['origin', 'mediaLicenseOrigin'], 63 'media_license': [['origin', 'mediaLicenseOrigin'],
49 ['size', 'mediaLicenseSize'], 64 ['size', 'mediaLicenseSize'],
50 ['modified', 'mediaLicenseLastModified']], 65 ['modified', 'mediaLicenseLastModified']],
51 }; 66 };
67
68 /**
69 * Get cookie data for a given HTML node.
70 * @param {CookieDetails} data The contents of the cookie.
71 * @return {!Array<CookieDataForDisplay>}
72 */
73 var getCookieData = function(data) {
74 /** @type {!Array<CookieDataForDisplay>} */
75 var out = [];
76 var fields = cookieInfo[data.type];
77 for (var field of fields) {
78 // Iterate through the keys found in |cookieInfo| for the given |type|
79 // and see if those keys are present in the data. If so, display them
80 // (in the order determined by |cookieInfo|).
81 var key = field[0];
82 if (data[key].length > 0) {
83 var entry = /** @type {CookieDataForDisplay} */({
84 label: loadTimeData.getString(field[1]),
85 content: data[key],
86 });
87 out.push(entry);
88 }
89 }
90 return out;
91 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698