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 /** | 5 /** |
6 * @typedef {{hasChildren: boolean, | 6 * @typedef {{hasChildren: boolean, |
7 * id: string, | 7 * id: string, |
8 * idPath: string, | 8 * idPath: string, |
9 * title: string, | 9 * title: string, |
10 * totalUsage: string, | 10 * totalUsage: string, |
11 * type: string}} | 11 * type: string}} |
12 */ | 12 */ |
13 var CookieDetails; | 13 var CookieDetails; |
14 | 14 |
15 /** | 15 /** |
16 * @typedef {{content: string, | 16 * @typedef {{content: string, |
17 * label: string}} | 17 * label: string}} |
18 */ | 18 */ |
19 var CookieDataForDisplay; | 19 var CookieDataForDisplay; |
20 | 20 |
21 // This structure maps the various cookie type names from C++ (hence the | 21 // This structure maps the various cookie type names from C++ (hence the |
22 // underscores) to arrays of the different types of data each has, along with | 22 // underscores) to arrays of the different types of data each has, along with |
23 // the i18n name for the description of that data type. | 23 // the i18n name for the description of that data type. |
24 // This structure serves three purposes: | 24 // This structure serves three purposes: |
25 // 1) to list what subset of the cookie data we want to show in the UI. | 25 // 1) to list what subset of the cookie data we want to show in the UI. |
26 // 2) What order to show it in. | 26 // 2) What order to show it in. |
27 // 3) What user friendly label to prefix the data with. | 27 // 3) What user friendly label to prefix the data with. |
28 /** @const */ var cookieInfo = { | 28 /** @const */ var cookieInfo = { |
29 'cookie': [['name', 'cookieName'], | 29 'cookie': [ |
30 ['content', 'cookieContent'], | 30 ['name', 'cookieName'], ['content', 'cookieContent'], |
31 ['domain', 'cookieDomain'], | 31 ['domain', 'cookieDomain'], ['path', 'cookiePath'], |
32 ['path', 'cookiePath'], | 32 ['sendfor', 'cookieSendFor'], |
33 ['sendfor', 'cookieSendFor'], | 33 ['accessibleToScript', 'cookieAccessibleToScript'], |
34 ['accessibleToScript', 'cookieAccessibleToScript'], | 34 ['created', 'cookieCreated'], ['expires', 'cookieExpires'] |
35 ['created', 'cookieCreated'], | 35 ], |
36 ['expires', 'cookieExpires']], | 36 'app_cache': [ |
37 'app_cache': [['manifest', 'appCacheManifest'], | 37 ['manifest', 'appCacheManifest'], ['size', 'localStorageSize'], |
38 ['size', 'localStorageSize'], | 38 ['created', 'cookieCreated'], ['accessed', 'cookieLastAccessed'] |
39 ['created', 'cookieCreated'], | 39 ], |
40 ['accessed', 'cookieLastAccessed']], | 40 'database': [ |
41 'database': [['name', 'cookieName'], | 41 ['name', 'cookieName'], ['desc', 'webdbDesc'], ['size', 'localStorageSize'], |
42 ['desc', 'webdbDesc'], | 42 ['modified', 'localStorageLastModified'] |
43 ['size', 'localStorageSize'], | 43 ], |
44 ['modified', 'localStorageLastModified']], | 44 'local_storage': [ |
45 'local_storage': [['origin', 'localStorageOrigin'], | 45 ['origin', 'localStorageOrigin'], ['size', 'localStorageSize'], |
46 ['size', 'localStorageSize'], | 46 ['modified', 'localStorageLastModified'] |
47 ['modified', 'localStorageLastModified']], | 47 ], |
48 'indexed_db': [['origin', 'indexedDbOrigin'], | 48 'indexed_db': [ |
49 ['size', 'indexedDbSize'], | 49 ['origin', 'indexedDbOrigin'], ['size', 'indexedDbSize'], |
50 ['modified', 'indexedDbLastModified']], | 50 ['modified', 'indexedDbLastModified'] |
51 'file_system': [['origin', 'fileSystemOrigin'], | 51 ], |
52 ['persistent', 'fileSystemPersistentUsage'], | 52 'file_system': [ |
53 ['temporary', 'fileSystemTemporaryUsage']], | 53 ['origin', 'fileSystemOrigin'], ['persistent', 'fileSystemPersistentUsage'], |
54 'channel_id': [['serverId', 'channelIdServerId'], | 54 ['temporary', 'fileSystemTemporaryUsage'] |
55 ['certType', 'channelIdType'], | 55 ], |
56 ['created', 'channelIdCreated']], | 56 'channel_id': [ |
57 'service_worker': [['origin', 'serviceWorkerOrigin'], | 57 ['serverId', 'channelIdServerId'], ['certType', 'channelIdType'], |
58 ['size', 'serviceWorkerSize'], | 58 ['created', 'channelIdCreated'] |
59 ['scopes', 'serviceWorkerScopes']], | 59 ], |
60 'cache_storage': [['origin', 'cacheStorageOrigin'], | 60 'service_worker': [ |
61 ['size', 'cacheStorageSize'], | 61 ['origin', 'serviceWorkerOrigin'], ['size', 'serviceWorkerSize'], |
62 ['modified', 'cacheStorageLastModified']], | 62 ['scopes', 'serviceWorkerScopes'] |
| 63 ], |
| 64 'cache_storage': [ |
| 65 ['origin', 'cacheStorageOrigin'], ['size', 'cacheStorageSize'], |
| 66 ['modified', 'cacheStorageLastModified'] |
| 67 ], |
63 'flash_lso': [['domain', 'cookieDomain']], | 68 'flash_lso': [['domain', 'cookieDomain']], |
64 'media_license': [['origin', 'mediaLicenseOrigin'], | 69 'media_license': [ |
65 ['size', 'mediaLicenseSize'], | 70 ['origin', 'mediaLicenseOrigin'], ['size', 'mediaLicenseSize'], |
66 ['modified', 'mediaLicenseLastModified']], | 71 ['modified', 'mediaLicenseLastModified'] |
| 72 ], |
67 }; | 73 }; |
68 | 74 |
69 /** | 75 /** |
70 * Get cookie data for a given HTML node. | 76 * Get cookie data for a given HTML node. |
71 * @param {CookieDetails} data The contents of the cookie. | 77 * @param {CookieDetails} data The contents of the cookie. |
72 * @return {!Array<CookieDataForDisplay>} | 78 * @return {!Array<CookieDataForDisplay>} |
73 */ | 79 */ |
74 var getCookieData = function(data) { | 80 var getCookieData = function(data) { |
75 /** @type {!Array<CookieDataForDisplay>} */ | 81 /** @type {!Array<CookieDataForDisplay>} */ |
76 var out = []; | 82 var out = []; |
77 var fields = cookieInfo[data.type]; | 83 var fields = cookieInfo[data.type]; |
78 for (var i = 0; i < fields.length; i++) { | 84 for (var i = 0; i < fields.length; i++) { |
79 var field = fields[i]; | 85 var field = fields[i]; |
80 // Iterate through the keys found in |cookieInfo| for the given |type| | 86 // Iterate through the keys found in |cookieInfo| for the given |type| |
81 // and see if those keys are present in the data. If so, display them | 87 // and see if those keys are present in the data. If so, display them |
82 // (in the order determined by |cookieInfo|). | 88 // (in the order determined by |cookieInfo|). |
83 var key = field[0]; | 89 var key = field[0]; |
84 if (data[key].length > 0) { | 90 if (data[key].length > 0) { |
85 var entry = /** @type {CookieDataForDisplay} */({ | 91 var entry = /** @type {CookieDataForDisplay} */ ({ |
86 label: loadTimeData.getString(field[1]), | 92 label: loadTimeData.getString(field[1]), |
87 content: data[key], | 93 content: data[key], |
88 }); | 94 }); |
89 out.push(entry); | 95 out.push(entry); |
90 } | 96 } |
91 } | 97 } |
92 return out; | 98 return out; |
93 }; | 99 }; |
OLD | NEW |