Chromium Code Reviews| OLD | NEW |
|---|---|
| 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; | |
|
dschuyler
2016/10/26 00:18:38
These were moved (unchanged).
| |
| 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 Loading... | |
| 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) { | |
|
dschuyler
2016/10/26 00:18:38
This was moved and slightly changed.
|data| was a
| |
| 74 /** @type {!Array<CookieDataForDisplay>} */ | |
| 75 var out = []; | |
| 76 var fields = cookieInfo[data.type]; | |
| 77 if (fields) | |
| 78 for (var field of fields) { | |
| 79 // Iterate through the keys found in |cookieInfo| for the given |type| | |
| 80 // and see if those keys are present in the data. If so, display them | |
| 81 // (in the order determined by |cookieInfo|). | |
| 82 var key = field[0]; | |
| 83 if (data[key].length > 0) { | |
| 84 var entry = /** @type {CookieDataForDisplay} */({ | |
| 85 label: loadTimeData.getString(field[1]), | |
| 86 content: data[key], | |
| 87 }); | |
| 88 out.push(entry); | |
| 89 } | |
| 90 } | |
| 91 return out; | |
| 92 }; | |
| OLD | NEW |