| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007, 2008, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2008, 2010 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2009 Joseph Pecoraro | 3 * Copyright (C) 2009 Joseph Pecoraro |
| 4 * Copyright (C) 2013 Samsung Electronics. All rights reserved. | 4 * Copyright (C) 2013 Samsung Electronics. All rights reserved. |
| 5 * | 5 * |
| 6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
| 7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
| 8 * are met: | 8 * are met: |
| 9 * | 9 * |
| 10 * 1. Redistributions of source code must retain the above copyright | 10 * 1. Redistributions of source code must retain the above copyright |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 */ | 37 */ |
| 38 constructor(panel) { | 38 constructor(panel) { |
| 39 super(); | 39 super(); |
| 40 | 40 |
| 41 this._panel = panel; | 41 this._panel = panel; |
| 42 | 42 |
| 43 this._sidebarTree = new UI.TreeOutlineInShadow(); | 43 this._sidebarTree = new UI.TreeOutlineInShadow(); |
| 44 this._sidebarTree.element.classList.add('resources-sidebar'); | 44 this._sidebarTree.element.classList.add('resources-sidebar'); |
| 45 this._sidebarTree.registerRequiredCSS('resources/resourcesSidebar.css'); | 45 this._sidebarTree.registerRequiredCSS('resources/resourcesSidebar.css'); |
| 46 this._sidebarTree.element.classList.add('filter-all'); | 46 this._sidebarTree.element.classList.add('filter-all'); |
| 47 // Listener needs to have been set up before the elements are added |
| 48 this._sidebarTree.addEventListener(UI.TreeOutline.Events.ElementAttached, th
is._treeElementAdded, this); |
| 49 |
| 47 this.contentElement.appendChild(this._sidebarTree.element); | 50 this.contentElement.appendChild(this._sidebarTree.element); |
| 48 | |
| 49 this._applicationTreeElement = this._addSidebarSection(Common.UIString('Appl
ication')); | 51 this._applicationTreeElement = this._addSidebarSection(Common.UIString('Appl
ication')); |
| 50 this._manifestTreeElement = new Resources.AppManifestTreeElement(panel); | 52 this._manifestTreeElement = new Resources.AppManifestTreeElement(panel); |
| 51 this._applicationTreeElement.appendChild(this._manifestTreeElement); | 53 this._applicationTreeElement.appendChild(this._manifestTreeElement); |
| 52 this.serviceWorkersTreeElement = new Resources.ServiceWorkersTreeElement(pan
el); | 54 this.serviceWorkersTreeElement = new Resources.ServiceWorkersTreeElement(pan
el); |
| 53 this._applicationTreeElement.appendChild(this.serviceWorkersTreeElement); | 55 this._applicationTreeElement.appendChild(this.serviceWorkersTreeElement); |
| 54 var clearStorageTreeElement = new Resources.ClearStorageTreeElement(panel); | 56 var clearStorageTreeElement = new Resources.ClearStorageTreeElement(panel); |
| 55 this._applicationTreeElement.appendChild(clearStorageTreeElement); | 57 this._applicationTreeElement.appendChild(clearStorageTreeElement); |
| 56 | 58 |
| 57 var storageTreeElement = this._addSidebarSection(Common.UIString('Storage'))
; | 59 var storageTreeElement = this._addSidebarSection(Common.UIString('Storage'))
; |
| 58 this.localStorageListTreeElement = | 60 this.localStorageListTreeElement = |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 this._databaseTableViews = new Map(); | 98 this._databaseTableViews = new Map(); |
| 97 /** @type {!Map.<!Resources.Database, !Resources.DatabaseQueryView>} */ | 99 /** @type {!Map.<!Resources.Database, !Resources.DatabaseQueryView>} */ |
| 98 this._databaseQueryViews = new Map(); | 100 this._databaseQueryViews = new Map(); |
| 99 /** @type {!Map.<!Resources.Database, !Resources.DatabaseTreeElement>} */ | 101 /** @type {!Map.<!Resources.Database, !Resources.DatabaseTreeElement>} */ |
| 100 this._databaseTreeElements = new Map(); | 102 this._databaseTreeElements = new Map(); |
| 101 /** @type {!Map.<!Resources.DOMStorage, !Resources.DOMStorageTreeElement>} *
/ | 103 /** @type {!Map.<!Resources.DOMStorage, !Resources.DOMStorageTreeElement>} *
/ |
| 102 this._domStorageTreeElements = new Map(); | 104 this._domStorageTreeElements = new Map(); |
| 103 /** @type {!Object.<string, boolean>} */ | 105 /** @type {!Object.<string, boolean>} */ |
| 104 this._domains = {}; | 106 this._domains = {}; |
| 105 | 107 |
| 108 this._shouldRestoreSelection = true; |
| 109 |
| 106 this._sidebarTree.contentElement.addEventListener('mousemove', this._onmouse
move.bind(this), false); | 110 this._sidebarTree.contentElement.addEventListener('mousemove', this._onmouse
move.bind(this), false); |
| 107 this._sidebarTree.contentElement.addEventListener('mouseleave', this._onmous
eleave.bind(this), false); | 111 this._sidebarTree.contentElement.addEventListener('mouseleave', this._onmous
eleave.bind(this), false); |
| 108 | 112 |
| 109 SDK.targetManager.observeTargets(this); | 113 SDK.targetManager.observeTargets(this); |
| 110 SDK.targetManager.addModelListener( | 114 SDK.targetManager.addModelListener( |
| 111 SDK.ResourceTreeModel, SDK.ResourceTreeModel.Events.FrameNavigated, this
._frameNavigated, this); | 115 SDK.ResourceTreeModel, SDK.ResourceTreeModel.Events.FrameNavigated, this
._frameNavigated, this); |
| 116 SDK.targetManager.addModelListener( |
| 117 SDK.ResourceTreeModel, SDK.ResourceTreeModel.Events.WillReloadPage, this
._willReloadPage, this); |
| 112 } | 118 } |
| 113 | 119 |
| 114 /** | 120 /** |
| 115 * @param {string} title | 121 * @param {string} title |
| 116 * @return {!UI.TreeElement} | 122 * @return {!UI.TreeElement} |
| 117 */ | 123 */ |
| 118 _addSidebarSection(title) { | 124 _addSidebarSection(title) { |
| 119 var treeElement = new UI.TreeElement(title, true); | 125 var treeElement = new UI.TreeElement(title, true); |
| 120 treeElement.listItemElement.classList.add('storage-group-list-item'); | 126 treeElement.listItemElement.classList.add('storage-group-list-item'); |
| 121 treeElement.setCollapsible(false); | 127 treeElement.setCollapsible(false); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 cacheStorageModel.enable(); | 196 cacheStorageModel.enable(); |
| 191 var resourceTreeModel = this._target.model(SDK.ResourceTreeModel); | 197 var resourceTreeModel = this._target.model(SDK.ResourceTreeModel); |
| 192 if (resourceTreeModel) | 198 if (resourceTreeModel) |
| 193 this._populateApplicationCacheTree(resourceTreeModel); | 199 this._populateApplicationCacheTree(resourceTreeModel); |
| 194 var domStorageModel = this._target.model(Resources.DOMStorageModel); | 200 var domStorageModel = this._target.model(Resources.DOMStorageModel); |
| 195 if (domStorageModel) | 201 if (domStorageModel) |
| 196 this._populateDOMStorageTree(domStorageModel); | 202 this._populateDOMStorageTree(domStorageModel); |
| 197 this.indexedDBListTreeElement._initialize(); | 203 this.indexedDBListTreeElement._initialize(); |
| 198 var serviceWorkerCacheModel = this._target.model(SDK.ServiceWorkerCacheModel
); | 204 var serviceWorkerCacheModel = this._target.model(SDK.ServiceWorkerCacheModel
); |
| 199 this.cacheStorageListTreeElement._initialize(serviceWorkerCacheModel); | 205 this.cacheStorageListTreeElement._initialize(serviceWorkerCacheModel); |
| 200 this._initDefaultSelection(); | |
| 201 } | |
| 202 | |
| 203 _initDefaultSelection() { | |
| 204 var itemURL = this._panel.lastSelectedItemURL(); | |
| 205 if (itemURL) { | |
| 206 var rootElement = this._sidebarTree.rootElement(); | |
| 207 for (var treeElement = rootElement.firstChild(); treeElement; | |
| 208 treeElement = treeElement.traverseNextTreeElement(false, rootElement,
true)) { | |
| 209 if (treeElement.itemURL === itemURL) { | |
| 210 treeElement.revealAndSelect(true); | |
| 211 return; | |
| 212 } | |
| 213 } | |
| 214 } | |
| 215 this._manifestTreeElement.select(); | |
| 216 } | 206 } |
| 217 | 207 |
| 218 _resetWithFrames() { | 208 _resetWithFrames() { |
| 219 this._resourcesSection.reset(); | 209 this._resourcesSection.reset(); |
| 220 this._reset(); | 210 this._reset(); |
| 221 } | 211 } |
| 222 | 212 |
| 223 _resetWebSQL() { | 213 _resetWebSQL() { |
| 224 var queryViews = this._databaseQueryViews.valuesArray(); | 214 var queryViews = this._databaseQueryViews.valuesArray(); |
| 225 for (var i = 0; i < queryViews.length; ++i) { | 215 for (var i = 0; i < queryViews.length; ++i) { |
| 226 queryViews[i].removeEventListener( | 216 queryViews[i].removeEventListener( |
| 227 Resources.DatabaseQueryView.Events.SchemaUpdated, this._updateDatabase
Tables, this); | 217 Resources.DatabaseQueryView.Events.SchemaUpdated, this._updateDatabase
Tables, this); |
| 228 } | 218 } |
| 229 this._databaseTableViews.clear(); | 219 this._databaseTableViews.clear(); |
| 230 this._databaseQueryViews.clear(); | 220 this._databaseQueryViews.clear(); |
| 231 this._databaseTreeElements.clear(); | 221 this._databaseTreeElements.clear(); |
| 232 this.databasesListTreeElement.removeChildren(); | 222 this.databasesListTreeElement.removeChildren(); |
| 233 this.databasesListTreeElement.setExpandable(false); | 223 this.databasesListTreeElement.setExpandable(false); |
| 234 } | 224 } |
| 235 | 225 |
| 236 _resetAppCache() { | 226 _resetAppCache() { |
| 237 for (var frameId of Object.keys(this._applicationCacheFrameElements)) | 227 for (var frameId of Object.keys(this._applicationCacheFrameElements)) |
| 238 this._applicationCacheFrameManifestRemoved({data: frameId}); | 228 this._applicationCacheFrameManifestRemoved({data: frameId}); |
| 239 this.applicationCacheListTreeElement.setExpandable(false); | 229 this.applicationCacheListTreeElement.setExpandable(false); |
| 240 } | 230 } |
| 241 | 231 |
| 232 _willReloadPage() { |
| 233 this._shouldRestoreSelection = true; |
| 234 } |
| 235 |
| 236 /** |
| 237 * @param {!Common.Event} event |
| 238 */ |
| 239 _treeElementAdded(event) { |
| 240 if (!this._shouldRestoreSelection) |
| 241 return; |
| 242 var selection = this._panel.lastSelectedItemPath(); |
| 243 if (!selection.length) |
| 244 return; |
| 245 var element = event.data; |
| 246 var index = selection.indexOf(element.itemURL); |
| 247 if (index > 0) |
| 248 element.expand(); |
| 249 if (index) |
| 250 return; |
| 251 for (var parent = element.parent; parent; parent = parent.parent) |
| 252 parent.expand(); |
| 253 element.select(); |
| 254 this._shouldRestoreSelection = false; |
| 255 } |
| 256 |
| 242 _reset() { | 257 _reset() { |
| 243 this._domains = {}; | 258 this._domains = {}; |
| 244 this._resetWebSQL(); | 259 this._resetWebSQL(); |
| 245 this.cookieListTreeElement.removeChildren(); | 260 this.cookieListTreeElement.removeChildren(); |
| 246 } | 261 } |
| 247 | 262 |
| 248 _frameNavigated(event) { | 263 _frameNavigated(event) { |
| 249 var frame = event.data; | 264 var frame = event.data; |
| 250 | 265 |
| 251 if (!frame.parentFrame) | 266 if (!frame.parentFrame) |
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 591 this._storagePanel = storagePanel; | 606 this._storagePanel = storagePanel; |
| 592 } | 607 } |
| 593 | 608 |
| 594 /** | 609 /** |
| 595 * @override | 610 * @override |
| 596 * @return {boolean} | 611 * @return {boolean} |
| 597 */ | 612 */ |
| 598 onselect(selectedByUser) { | 613 onselect(selectedByUser) { |
| 599 if (!selectedByUser) | 614 if (!selectedByUser) |
| 600 return false; | 615 return false; |
| 601 var itemURL = this.itemURL; | 616 |
| 602 if (itemURL) | 617 var path = []; |
| 603 this._storagePanel.setLastSelectedItemURL(itemURL); | 618 for (var el = this; el; el = el.parent) { |
| 619 var url = el.itemURL; |
| 620 if (!url) |
| 621 break; |
| 622 path.push(url); |
| 623 } |
| 624 this._storagePanel.setLastSelectedItemPath(path); |
| 625 |
| 604 return false; | 626 return false; |
| 605 } | 627 } |
| 606 | 628 |
| 607 /** | 629 /** |
| 608 * @protected | 630 * @protected |
| 609 * @param {?UI.Widget} view | 631 * @param {?UI.Widget} view |
| 610 */ | 632 */ |
| 611 showView(view) { | 633 showView(view) { |
| 612 this._storagePanel.showView(view); | 634 this._storagePanel.showView(view); |
| 613 } | 635 } |
| (...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1239 this.removeChild(objectStoreTreeElement); | 1261 this.removeChild(objectStoreTreeElement); |
| 1240 delete this._idbObjectStoreTreeElements[objectStoreName]; | 1262 delete this._idbObjectStoreTreeElements[objectStoreName]; |
| 1241 } | 1263 } |
| 1242 | 1264 |
| 1243 clear() { | 1265 clear() { |
| 1244 for (var objectStoreName in this._idbObjectStoreTreeElements) | 1266 for (var objectStoreName in this._idbObjectStoreTreeElements) |
| 1245 this._objectStoreRemoved(objectStoreName); | 1267 this._objectStoreRemoved(objectStoreName); |
| 1246 } | 1268 } |
| 1247 }; | 1269 }; |
| 1248 | 1270 |
| 1249 /** | |
| 1250 * @unrestricted | |
| 1251 */ | |
| 1252 Resources.IDBObjectStoreTreeElement = class extends Resources.BaseStorageTreeEle
ment { | 1271 Resources.IDBObjectStoreTreeElement = class extends Resources.BaseStorageTreeEle
ment { |
| 1253 /** | 1272 /** |
| 1254 * @param {!Resources.ResourcesPanel} storagePanel | 1273 * @param {!Resources.ResourcesPanel} storagePanel |
| 1255 * @param {!Resources.IndexedDBModel} model | 1274 * @param {!Resources.IndexedDBModel} model |
| 1256 * @param {!Resources.IndexedDBModel.DatabaseId} databaseId | 1275 * @param {!Resources.IndexedDBModel.DatabaseId} databaseId |
| 1257 * @param {!Resources.IndexedDBModel.ObjectStore} objectStore | 1276 * @param {!Resources.IndexedDBModel.ObjectStore} objectStore |
| 1258 */ | 1277 */ |
| 1259 constructor(storagePanel, model, databaseId, objectStore) { | 1278 constructor(storagePanel, model, databaseId, objectStore) { |
| 1260 super(storagePanel, objectStore.name, false); | 1279 super(storagePanel, objectStore.name, false); |
| 1261 this._model = model; | 1280 this._model = model; |
| 1262 this._databaseId = databaseId; | 1281 this._databaseId = databaseId; |
| 1263 this._idbIndexTreeElements = {}; | 1282 this._idbIndexTreeElements = {}; |
| 1283 this._objectStore = objectStore; |
| 1284 /** @type {?Resources.IDBDataView} */ |
| 1285 this._view = null; |
| 1264 var icon = UI.Icon.create('mediumicon-table', 'resource-tree-item'); | 1286 var icon = UI.Icon.create('mediumicon-table', 'resource-tree-item'); |
| 1265 this.setLeadingIcons([icon]); | 1287 this.setLeadingIcons([icon]); |
| 1266 } | 1288 } |
| 1267 | 1289 |
| 1268 get itemURL() { | 1290 get itemURL() { |
| 1269 return 'indexedDB://' + this._databaseId.securityOrigin + '/' + this._databa
seId.name + '/' + | 1291 return 'indexedDB://' + this._databaseId.securityOrigin + '/' + this._databa
seId.name + '/' + |
| 1270 this._objectStore.name; | 1292 this._objectStore.name; |
| 1271 } | 1293 } |
| 1272 | 1294 |
| 1273 /** | 1295 /** |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1320 if (!indexNames[indexName]) { | 1342 if (!indexNames[indexName]) { |
| 1321 this.removeChild(this._idbIndexTreeElements[indexName]); | 1343 this.removeChild(this._idbIndexTreeElements[indexName]); |
| 1322 delete this._idbIndexTreeElements[indexName]; | 1344 delete this._idbIndexTreeElements[indexName]; |
| 1323 } | 1345 } |
| 1324 } | 1346 } |
| 1325 | 1347 |
| 1326 if (this.childCount()) | 1348 if (this.childCount()) |
| 1327 this.expand(); | 1349 this.expand(); |
| 1328 | 1350 |
| 1329 if (this._view) | 1351 if (this._view) |
| 1330 this._view.update(this._objectStore); | 1352 this._view.update(this._objectStore, null); |
| 1331 | 1353 |
| 1332 this._updateTooltip(); | 1354 this._updateTooltip(); |
| 1333 } | 1355 } |
| 1334 | 1356 |
| 1335 _updateTooltip() { | 1357 _updateTooltip() { |
| 1336 var keyPathString = this._objectStore.keyPathString; | 1358 var keyPathString = this._objectStore.keyPathString; |
| 1337 var tooltipString = keyPathString !== null ? (Common.UIString('Key path: ')
+ keyPathString) : ''; | 1359 var tooltipString = keyPathString !== null ? (Common.UIString('Key path: ')
+ keyPathString) : ''; |
| 1338 if (this._objectStore.autoIncrement) | 1360 if (this._objectStore.autoIncrement) |
| 1339 tooltipString += '\n' + Common.UIString('autoIncrement'); | 1361 tooltipString += '\n' + Common.UIString('autoIncrement'); |
| 1340 this.tooltip = tooltipString; | 1362 this.tooltip = tooltipString; |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1626 | 1648 |
| 1627 this.element.classList.add('storage-view'); | 1649 this.element.classList.add('storage-view'); |
| 1628 this._emptyWidget = new UI.EmptyWidget(''); | 1650 this._emptyWidget = new UI.EmptyWidget(''); |
| 1629 this._emptyWidget.show(this.element); | 1651 this._emptyWidget.show(this.element); |
| 1630 } | 1652 } |
| 1631 | 1653 |
| 1632 setText(text) { | 1654 setText(text) { |
| 1633 this._emptyWidget.text = text; | 1655 this._emptyWidget.text = text; |
| 1634 } | 1656 } |
| 1635 }; | 1657 }; |
| OLD | NEW |