| 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 var cacheTreeElement = this._addSidebarSection(Common.UIString('Cache')); | 81 var cacheTreeElement = this._addSidebarSection(Common.UIString('Cache')); |
| 82 this.cacheStorageListTreeElement = new Resources.ServiceWorkerCacheTreeEleme
nt(this); | 82 this.cacheStorageListTreeElement = new Resources.ServiceWorkerCacheTreeEleme
nt(this); |
| 83 cacheTreeElement.appendChild(this.cacheStorageListTreeElement); | 83 cacheTreeElement.appendChild(this.cacheStorageListTreeElement); |
| 84 this.applicationCacheListTreeElement = | 84 this.applicationCacheListTreeElement = |
| 85 new Resources.StorageCategoryTreeElement(this, Common.UIString('Applicat
ion Cache'), 'ApplicationCache'); | 85 new Resources.StorageCategoryTreeElement(this, Common.UIString('Applicat
ion Cache'), 'ApplicationCache'); |
| 86 var applicationCacheIcon = UI.Icon.create('mediumicon-table', 'resource-tree
-item'); | 86 var applicationCacheIcon = UI.Icon.create('mediumicon-table', 'resource-tree
-item'); |
| 87 this.applicationCacheListTreeElement.setLeadingIcons([applicationCacheIcon])
; | 87 this.applicationCacheListTreeElement.setLeadingIcons([applicationCacheIcon])
; |
| 88 | 88 |
| 89 cacheTreeElement.appendChild(this.applicationCacheListTreeElement); | 89 cacheTreeElement.appendChild(this.applicationCacheListTreeElement); |
| 90 | 90 |
| 91 this.resourcesListTreeElement = this._addSidebarSection(Common.UIString('Fra
mes')); | 91 this._resourcesSection = new Resources.ResourcesSection(this, this._addSideb
arSection(Common.UIString('Frames'))); |
| 92 | 92 |
| 93 var mainContainer = new UI.VBox(); | 93 var mainContainer = new UI.VBox(); |
| 94 this.storageViews = mainContainer.element.createChild('div', 'vbox flex-auto
'); | 94 this.storageViews = mainContainer.element.createChild('div', 'vbox flex-auto
'); |
| 95 this._storageViewToolbar = new UI.Toolbar('resources-toolbar', mainContainer
.element); | 95 this._storageViewToolbar = new UI.Toolbar('resources-toolbar', mainContainer
.element); |
| 96 this.splitWidget().setMainWidget(mainContainer); | 96 this.splitWidget().setMainWidget(mainContainer); |
| 97 | 97 |
| 98 /** @type {!Map.<!Resources.Database, !Object.<string, !Resources.DatabaseTa
bleView>>} */ | 98 /** @type {!Map.<!Resources.Database, !Object.<string, !Resources.DatabaseTa
bleView>>} */ |
| 99 this._databaseTableViews = new Map(); | 99 this._databaseTableViews = new Map(); |
| 100 /** @type {!Map.<!Resources.Database, !Resources.DatabaseQueryView>} */ | 100 /** @type {!Map.<!Resources.Database, !Resources.DatabaseQueryView>} */ |
| 101 this._databaseQueryViews = new Map(); | 101 this._databaseQueryViews = new Map(); |
| 102 /** @type {!Map.<!Resources.Database, !Resources.DatabaseTreeElement>} */ | 102 /** @type {!Map.<!Resources.Database, !Resources.DatabaseTreeElement>} */ |
| 103 this._databaseTreeElements = new Map(); | 103 this._databaseTreeElements = new Map(); |
| 104 /** @type {!Map.<!Resources.DOMStorage, !Resources.DOMStorageTreeElement>} *
/ | 104 /** @type {!Map.<!Resources.DOMStorage, !Resources.DOMStorageTreeElement>} *
/ |
| 105 this._domStorageTreeElements = new Map(); | 105 this._domStorageTreeElements = new Map(); |
| 106 /** @type {!Object.<string, boolean>} */ | 106 /** @type {!Object.<string, boolean>} */ |
| 107 this._domains = {}; | 107 this._domains = {}; |
| 108 | 108 |
| 109 /** @type {?Resources.DOMStorageItemsView} */ | 109 /** @type {?Resources.DOMStorageItemsView} */ |
| 110 this._domStorageView = null; | 110 this._domStorageView = null; |
| 111 /** @type {?Resources.CookieItemsView} */ | 111 /** @type {?Resources.CookieItemsView} */ |
| 112 this._cookieView = null; | 112 this._cookieView = null; |
| 113 | 113 |
| 114 this.panelSidebarElement().addEventListener('mousemove', this._onmousemove.b
ind(this), false); | 114 this.panelSidebarElement().addEventListener('mousemove', this._onmousemove.b
ind(this), false); |
| 115 this.panelSidebarElement().addEventListener('mouseleave', this._onmouseleave
.bind(this), false); | 115 this.panelSidebarElement().addEventListener('mouseleave', this._onmouseleave
.bind(this), false); |
| 116 | 116 |
| 117 SDK.targetManager.observeTargets(this); | 117 SDK.targetManager.observeTargets(this); |
| 118 SDK.targetManager.addModelListener( |
| 119 SDK.ResourceTreeModel, SDK.ResourceTreeModel.Events.FrameNavigated, this
._frameNavigated, this); |
| 118 } | 120 } |
| 119 | 121 |
| 120 /** | 122 /** |
| 121 * @return {!Resources.ResourcesPanel} | 123 * @return {!Resources.ResourcesPanel} |
| 122 */ | 124 */ |
| 123 static _instance() { | 125 static _instance() { |
| 124 return /** @type {!Resources.ResourcesPanel} */ (self.runtime.sharedInstance
(Resources.ResourcesPanel)); | 126 return /** @type {!Resources.ResourcesPanel} */ (self.runtime.sharedInstance
(Resources.ResourcesPanel)); |
| 125 } | 127 } |
| 126 | 128 |
| 127 /** | 129 /** |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 } | 186 } |
| 185 | 187 |
| 186 /** | 188 /** |
| 187 * @override | 189 * @override |
| 188 */ | 190 */ |
| 189 focus() { | 191 focus() { |
| 190 this._sidebarTree.focus(); | 192 this._sidebarTree.focus(); |
| 191 } | 193 } |
| 192 | 194 |
| 193 _initialize() { | 195 _initialize() { |
| 196 for (var frame of SDK.ResourceTreeModel.frames()) |
| 197 this._addCookieDocument(frame); |
| 194 this._databaseModel.enable(); | 198 this._databaseModel.enable(); |
| 195 | 199 |
| 196 var indexedDBModel = Resources.IndexedDBModel.fromTarget(this._target); | 200 var indexedDBModel = Resources.IndexedDBModel.fromTarget(this._target); |
| 197 if (indexedDBModel) | 201 if (indexedDBModel) |
| 198 indexedDBModel.enable(); | 202 indexedDBModel.enable(); |
| 199 | 203 |
| 200 var cacheStorageModel = SDK.ServiceWorkerCacheModel.fromTarget(this._target)
; | 204 var cacheStorageModel = SDK.ServiceWorkerCacheModel.fromTarget(this._target)
; |
| 201 if (cacheStorageModel) | 205 if (cacheStorageModel) |
| 202 cacheStorageModel.enable(); | 206 cacheStorageModel.enable(); |
| 203 var resourceTreeModel = SDK.ResourceTreeModel.fromTarget(this._target); | 207 var resourceTreeModel = SDK.ResourceTreeModel.fromTarget(this._target); |
| 204 if (resourceTreeModel) { | 208 if (resourceTreeModel) |
| 205 this._populateResourceTree(resourceTreeModel); | |
| 206 this._populateApplicationCacheTree(resourceTreeModel); | 209 this._populateApplicationCacheTree(resourceTreeModel); |
| 207 } | |
| 208 var domStorageModel = Resources.DOMStorageModel.fromTarget(this._target); | 210 var domStorageModel = Resources.DOMStorageModel.fromTarget(this._target); |
| 209 if (domStorageModel) | 211 if (domStorageModel) |
| 210 this._populateDOMStorageTree(domStorageModel); | 212 this._populateDOMStorageTree(domStorageModel); |
| 211 this.indexedDBListTreeElement._initialize(); | 213 this.indexedDBListTreeElement._initialize(); |
| 212 this.cacheStorageListTreeElement._initialize(); | 214 this.cacheStorageListTreeElement._initialize(); |
| 213 this._initDefaultSelection(); | 215 this._initDefaultSelection(); |
| 214 } | 216 } |
| 215 | 217 |
| 216 _initDefaultSelection() { | 218 _initDefaultSelection() { |
| 217 var itemURL = this._resourcesLastSelectedItemSetting.get(); | 219 var itemURL = this._resourcesLastSelectedItemSetting.get(); |
| 218 if (itemURL) { | 220 if (itemURL) { |
| 219 var rootElement = this._sidebarTree.rootElement(); | 221 var rootElement = this._sidebarTree.rootElement(); |
| 220 for (var treeElement = rootElement.firstChild(); treeElement; | 222 for (var treeElement = rootElement.firstChild(); treeElement; |
| 221 treeElement = treeElement.traverseNextTreeElement(false, rootElement,
true)) { | 223 treeElement = treeElement.traverseNextTreeElement(false, rootElement,
true)) { |
| 222 if (treeElement.itemURL === itemURL) { | 224 if (treeElement.itemURL === itemURL) { |
| 223 treeElement.revealAndSelect(true); | 225 treeElement.revealAndSelect(true); |
| 224 return; | 226 return; |
| 225 } | 227 } |
| 226 } | 228 } |
| 227 } | 229 } |
| 228 this._manifestTreeElement.select(); | 230 this._manifestTreeElement.select(); |
| 229 } | 231 } |
| 230 | 232 |
| 231 _resetWithFrames() { | 233 _resetWithFrames() { |
| 232 this.resourcesListTreeElement.removeChildren(); | 234 this._resourcesSection.reset(); |
| 233 this._treeElementForFrameId = {}; | |
| 234 this._reset(); | 235 this._reset(); |
| 235 } | 236 } |
| 236 | 237 |
| 237 _resetWebSQL() { | 238 _resetWebSQL() { |
| 238 if (this.visibleView instanceof Resources.DatabaseQueryView || | 239 if (this.visibleView instanceof Resources.DatabaseQueryView || |
| 239 this.visibleView instanceof Resources.DatabaseTableView) { | 240 this.visibleView instanceof Resources.DatabaseTableView) { |
| 240 this.visibleView.detach(); | 241 this.visibleView.detach(); |
| 241 delete this.visibleView; | 242 delete this.visibleView; |
| 242 } | 243 } |
| 243 | 244 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 this.visibleView.detach(); | 301 this.visibleView.detach(); |
| 301 delete this.visibleView; | 302 delete this.visibleView; |
| 302 } | 303 } |
| 303 | 304 |
| 304 this._storageViewToolbar.removeToolbarItems(); | 305 this._storageViewToolbar.removeToolbarItems(); |
| 305 | 306 |
| 306 if (this._sidebarTree.selectedTreeElement) | 307 if (this._sidebarTree.selectedTreeElement) |
| 307 this._sidebarTree.selectedTreeElement.deselect(); | 308 this._sidebarTree.selectedTreeElement.deselect(); |
| 308 } | 309 } |
| 309 | 310 |
| 310 /** | |
| 311 * @param {!SDK.ResourceTreeModel} resourceTreeModel | |
| 312 */ | |
| 313 _populateResourceTree(resourceTreeModel) { | |
| 314 this._treeElementForFrameId = {}; | |
| 315 resourceTreeModel.addEventListener(SDK.ResourceTreeModel.Events.FrameAdded,
this._frameAdded, this); | |
| 316 resourceTreeModel.addEventListener(SDK.ResourceTreeModel.Events.FrameNavigat
ed, this._frameNavigated, this); | |
| 317 resourceTreeModel.addEventListener(SDK.ResourceTreeModel.Events.FrameDetache
d, this._frameDetached, this); | |
| 318 resourceTreeModel.addEventListener(SDK.ResourceTreeModel.Events.ResourceAdde
d, this._resourceAdded, this); | |
| 319 | |
| 320 /** | |
| 321 * @param {!SDK.ResourceTreeFrame} frame | |
| 322 * @this {Resources.ResourcesPanel} | |
| 323 */ | |
| 324 function populateFrame(frame) { | |
| 325 this._frameAdded({data: frame}); | |
| 326 for (var i = 0; i < frame.childFrames.length; ++i) | |
| 327 populateFrame.call(this, frame.childFrames[i]); | |
| 328 | |
| 329 var resources = frame.resources(); | |
| 330 for (var i = 0; i < resources.length; ++i) | |
| 331 this._resourceAdded({data: resources[i]}); | |
| 332 } | |
| 333 populateFrame.call(this, resourceTreeModel.mainFrame); | |
| 334 } | |
| 335 | |
| 336 _frameAdded(event) { | |
| 337 var frame = event.data; | |
| 338 var parentFrame = frame.parentFrame; | |
| 339 | |
| 340 var parentTreeElement = parentFrame ? this._treeElementForFrameId[parentFram
e.id] : this.resourcesListTreeElement; | |
| 341 if (!parentTreeElement) { | |
| 342 console.warn('No frame to route ' + frame.url + ' to.'); | |
| 343 return; | |
| 344 } | |
| 345 | |
| 346 var frameTreeElement = new Resources.FrameTreeElement(this, frame); | |
| 347 this._treeElementForFrameId[frame.id] = frameTreeElement; | |
| 348 parentTreeElement.appendChild(frameTreeElement); | |
| 349 } | |
| 350 | |
| 351 _frameDetached(event) { | |
| 352 var frame = event.data; | |
| 353 var frameTreeElement = this._treeElementForFrameId[frame.id]; | |
| 354 if (!frameTreeElement) | |
| 355 return; | |
| 356 | |
| 357 delete this._treeElementForFrameId[frame.id]; | |
| 358 if (frameTreeElement.parent) | |
| 359 frameTreeElement.parent.removeChild(frameTreeElement); | |
| 360 } | |
| 361 | |
| 362 _resourceAdded(event) { | |
| 363 var resource = event.data; | |
| 364 var frameId = resource.frameId; | |
| 365 | |
| 366 if (resource.statusCode >= 301 && resource.statusCode <= 303) | |
| 367 return; | |
| 368 | |
| 369 var frameTreeElement = this._treeElementForFrameId[frameId]; | |
| 370 if (!frameTreeElement) { | |
| 371 // This is a frame's main resource, it will be retained | |
| 372 // and re-added by the resource manager; | |
| 373 return; | |
| 374 } | |
| 375 | |
| 376 frameTreeElement.appendResource(resource); | |
| 377 } | |
| 378 | |
| 379 _frameNavigated(event) { | 311 _frameNavigated(event) { |
| 380 var frame = event.data; | 312 var frame = event.data; |
| 381 | 313 |
| 382 if (!frame.parentFrame) | 314 if (!frame.parentFrame) |
| 383 this._reset(); | 315 this._reset(); |
| 384 | 316 |
| 385 var frameId = frame.id; | 317 var applicationCacheFrameTreeElement = this._applicationCacheFrameElements[f
rame.id]; |
| 386 var frameTreeElement = this._treeElementForFrameId[frameId]; | |
| 387 if (frameTreeElement) | |
| 388 frameTreeElement.frameNavigated(frame); | |
| 389 | |
| 390 var applicationCacheFrameTreeElement = this._applicationCacheFrameElements[f
rameId]; | |
| 391 if (applicationCacheFrameTreeElement) | 318 if (applicationCacheFrameTreeElement) |
| 392 applicationCacheFrameTreeElement.frameNavigated(frame); | 319 applicationCacheFrameTreeElement.frameNavigated(frame); |
| 320 this._addCookieDocument(frame); |
| 393 } | 321 } |
| 394 | 322 |
| 395 /** | 323 /** |
| 396 * @param {!Resources.DatabaseModel.DatabaseAddedEvent} event | 324 * @param {!Resources.DatabaseModel.DatabaseAddedEvent} event |
| 397 */ | 325 */ |
| 398 _databaseAdded(event) { | 326 _databaseAdded(event) { |
| 399 var databaseTreeElement = new Resources.DatabaseTreeElement(this, event.data
base); | 327 var databaseTreeElement = new Resources.DatabaseTreeElement(this, event.data
base); |
| 400 this._databaseTreeElements.set(event.database, databaseTreeElement); | 328 this._databaseTreeElements.set(event.database, databaseTreeElement); |
| 401 this.databasesListTreeElement.appendChild(databaseTreeElement); | 329 this.databasesListTreeElement.appendChild(databaseTreeElement); |
| 402 } | 330 } |
| 403 | 331 |
| 404 /** | 332 /** |
| 405 * @param {!SDK.ResourceTreeFrame} frame | 333 * @param {!SDK.ResourceTreeFrame} frame |
| 406 */ | 334 */ |
| 407 addCookieDocument(frame) { | 335 _addCookieDocument(frame) { |
| 408 var parsedURL = frame.url.asParsedURL(); | 336 var parsedURL = frame.url.asParsedURL(); |
| 409 if (!parsedURL || (parsedURL.scheme !== 'http' && parsedURL.scheme !== 'http
s' && parsedURL.scheme !== 'file')) | 337 if (!parsedURL || (parsedURL.scheme !== 'http' && parsedURL.scheme !== 'http
s' && parsedURL.scheme !== 'file')) |
| 410 return; | 338 return; |
| 411 | 339 |
| 412 var domain = parsedURL.securityOrigin(); | 340 var domain = parsedURL.securityOrigin(); |
| 413 if (!this._domains[domain]) { | 341 if (!this._domains[domain]) { |
| 414 this._domains[domain] = true; | 342 this._domains[domain] = true; |
| 415 var cookieDomainTreeElement = new Resources.CookieTreeElement(this, frame,
domain); | 343 var cookieDomainTreeElement = new Resources.CookieTreeElement(this, frame,
domain); |
| 416 this.cookieListTreeElement.appendChild(cookieDomainTreeElement); | 344 this.cookieListTreeElement.appendChild(cookieDomainTreeElement); |
| 417 } | 345 } |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 482 } | 410 } |
| 483 } | 411 } |
| 484 | 412 |
| 485 /** | 413 /** |
| 486 * @param {!SDK.Resource} resource | 414 * @param {!SDK.Resource} resource |
| 487 * @param {number=} line | 415 * @param {number=} line |
| 488 * @param {number=} column | 416 * @param {number=} column |
| 489 * @return {boolean} | 417 * @return {boolean} |
| 490 */ | 418 */ |
| 491 showResource(resource, line, column) { | 419 showResource(resource, line, column) { |
| 492 var resourceTreeElement = this._findTreeElementForResource(resource); | 420 var resourceTreeElement = Resources.FrameResourceTreeElement.forResource(res
ource); |
| 493 if (resourceTreeElement) | 421 if (resourceTreeElement) |
| 494 resourceTreeElement.revealAndSelect(true); | 422 resourceTreeElement.revealAndSelect(true); |
| 495 | 423 |
| 496 if (typeof line === 'number') { | 424 if (typeof line === 'number') { |
| 497 var resourceSourceFrame = this._resourceSourceFrameViewForResource(resourc
e); | 425 var resourceSourceFrame = this._resourceSourceFrameViewForResource(resourc
e); |
| 498 if (resourceSourceFrame) | 426 if (resourceSourceFrame) |
| 499 resourceSourceFrame.revealPosition(line, column, true); | 427 resourceSourceFrame.revealPosition(line, column, true); |
| 500 } | 428 } |
| 501 return true; | 429 return true; |
| 502 } | 430 } |
| 503 | 431 |
| 504 _showResourceView(resource) { | |
| 505 var view = this._resourceViewForResource(resource); | |
| 506 if (!view) { | |
| 507 this.visibleView.detach(); | |
| 508 return; | |
| 509 } | |
| 510 this._innerShowView(view); | |
| 511 } | |
| 512 | |
| 513 /** | |
| 514 * @param {!SDK.Resource} resource | |
| 515 * @return {?UI.Widget} | |
| 516 */ | |
| 517 _resourceViewForResource(resource) { | |
| 518 if (resource.hasTextContent()) { | |
| 519 var treeElement = this._findTreeElementForResource(resource); | |
| 520 if (!treeElement) | |
| 521 return null; | |
| 522 return treeElement.sourceView(); | |
| 523 } | |
| 524 | |
| 525 switch (resource.resourceType()) { | |
| 526 case Common.resourceTypes.Image: | |
| 527 return new SourceFrame.ImageView(resource.mimeType, resource); | |
| 528 case Common.resourceTypes.Font: | |
| 529 return new SourceFrame.FontView(resource.mimeType, resource); | |
| 530 default: | |
| 531 return new UI.EmptyWidget(resource.url); | |
| 532 } | |
| 533 } | |
| 534 | |
| 535 /** | 432 /** |
| 536 * @param {!SDK.Resource} resource | 433 * @param {!SDK.Resource} resource |
| 537 * @return {?SourceFrame.ResourceSourceFrame} | 434 * @return {?SourceFrame.ResourceSourceFrame} |
| 538 */ | 435 */ |
| 539 _resourceSourceFrameViewForResource(resource) { | 436 _resourceSourceFrameViewForResource(resource) { |
| 540 var resourceView = this._resourceViewForResource(resource); | 437 var resourceView = Resources.FrameResourceTreeElement.resourceViewForResourc
e(resource); |
| 541 if (resourceView && resourceView instanceof SourceFrame.ResourceSourceFrame) | 438 if (resourceView && resourceView instanceof SourceFrame.ResourceSourceFrame) |
| 542 return /** @type {!SourceFrame.ResourceSourceFrame} */ (resourceView); | 439 return /** @type {!SourceFrame.ResourceSourceFrame} */ (resourceView); |
| 543 return null; | 440 return null; |
| 544 } | 441 } |
| 545 | 442 |
| 546 /** | 443 /** |
| 547 * @param {!Resources.Database} database | 444 * @param {!Resources.Database} database |
| 548 * @param {string=} tableName | 445 * @param {string=} tableName |
| 549 */ | 446 */ |
| 550 _showDatabase(database, tableName) { | 447 _showDatabase(database, tableName) { |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 773 this._applicationCacheViews[frameId].updateStatus(status); | 670 this._applicationCacheViews[frameId].updateStatus(status); |
| 774 } | 671 } |
| 775 | 672 |
| 776 _applicationCacheNetworkStateChanged(event) { | 673 _applicationCacheNetworkStateChanged(event) { |
| 777 var isNowOnline = event.data; | 674 var isNowOnline = event.data; |
| 778 | 675 |
| 779 for (var manifestURL in this._applicationCacheViews) | 676 for (var manifestURL in this._applicationCacheViews) |
| 780 this._applicationCacheViews[manifestURL].updateNetworkState(isNowOnline); | 677 this._applicationCacheViews[manifestURL].updateNetworkState(isNowOnline); |
| 781 } | 678 } |
| 782 | 679 |
| 783 _findTreeElementForResource(resource) { | |
| 784 return resource[Resources.FrameResourceTreeElement._symbol]; | |
| 785 } | |
| 786 | |
| 787 showView(view) { | 680 showView(view) { |
| 788 if (view) | 681 if (view) |
| 789 this.showResource(view.resource); | 682 this.showResource(view.resource); |
| 790 } | 683 } |
| 791 | 684 |
| 792 _onmousemove(event) { | 685 _onmousemove(event) { |
| 793 var nodeUnderMouse = event.target; | 686 var nodeUnderMouse = event.target; |
| 794 if (!nodeUnderMouse) | 687 if (!nodeUnderMouse) |
| 795 return; | 688 return; |
| 796 | 689 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 858 * @return {boolean} | 751 * @return {boolean} |
| 859 */ | 752 */ |
| 860 onselect(selectedByUser) { | 753 onselect(selectedByUser) { |
| 861 if (!selectedByUser) | 754 if (!selectedByUser) |
| 862 return false; | 755 return false; |
| 863 var itemURL = this.itemURL; | 756 var itemURL = this.itemURL; |
| 864 if (itemURL) | 757 if (itemURL) |
| 865 this._storagePanel._resourcesLastSelectedItemSetting.set(itemURL); | 758 this._storagePanel._resourcesLastSelectedItemSetting.set(itemURL); |
| 866 return false; | 759 return false; |
| 867 } | 760 } |
| 761 |
| 762 /** |
| 763 * @protected |
| 764 * @param {?UI.Widget} view |
| 765 */ |
| 766 showView(view) { |
| 767 if (!view) { |
| 768 this._storagePanel.visibleView.detach(); |
| 769 return; |
| 770 } |
| 771 this._storagePanel._innerShowView(view); |
| 772 } |
| 868 }; | 773 }; |
| 869 | 774 |
| 870 /** | 775 /** |
| 871 * @unrestricted | 776 * @unrestricted |
| 872 */ | 777 */ |
| 873 Resources.StorageCategoryTreeElement = class extends Resources.BaseStorageTreeEl
ement { | 778 Resources.StorageCategoryTreeElement = class extends Resources.BaseStorageTreeEl
ement { |
| 874 /** | 779 /** |
| 875 * @param {!Resources.ResourcesPanel} storagePanel | 780 * @param {!Resources.ResourcesPanel} storagePanel |
| 876 * @param {string} categoryName | 781 * @param {string} categoryName |
| 877 * @param {string} settingsKey | 782 * @param {string} settingsKey |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 924 * @override | 829 * @override |
| 925 */ | 830 */ |
| 926 oncollapse() { | 831 oncollapse() { |
| 927 this._expandedSetting.set(false); | 832 this._expandedSetting.set(false); |
| 928 } | 833 } |
| 929 }; | 834 }; |
| 930 | 835 |
| 931 /** | 836 /** |
| 932 * @unrestricted | 837 * @unrestricted |
| 933 */ | 838 */ |
| 934 Resources.FrameTreeElement = class extends Resources.BaseStorageTreeElement { | |
| 935 /** | |
| 936 * @param {!Resources.ResourcesPanel} storagePanel | |
| 937 * @param {!SDK.ResourceTreeFrame} frame | |
| 938 */ | |
| 939 constructor(storagePanel, frame) { | |
| 940 super(storagePanel, '', false); | |
| 941 this._frame = frame; | |
| 942 this.frameNavigated(frame); | |
| 943 | |
| 944 var icon = UI.Icon.create('largeicon-navigator-frame', 'navigator-tree-item'
); | |
| 945 icon.classList.add('navigator-frame-tree-item'); | |
| 946 this.setLeadingIcons([icon]); | |
| 947 } | |
| 948 | |
| 949 frameNavigated(frame) { | |
| 950 this.removeChildren(); | |
| 951 this._frameId = frame.id; | |
| 952 this.title = frame.displayName(); | |
| 953 this._categoryElements = {}; | |
| 954 this._treeElementForResource = {}; | |
| 955 | |
| 956 this._storagePanel.addCookieDocument(frame); | |
| 957 } | |
| 958 | |
| 959 get itemURL() { | |
| 960 return 'frame://' + encodeURI(this.titleAsText()); | |
| 961 } | |
| 962 | |
| 963 /** | |
| 964 * @override | |
| 965 * @return {boolean} | |
| 966 */ | |
| 967 onselect(selectedByUser) { | |
| 968 super.onselect(selectedByUser); | |
| 969 this._storagePanel.showCategoryView(this.titleAsText()); | |
| 970 | |
| 971 this.listItemElement.classList.remove('hovered'); | |
| 972 SDK.DOMModel.hideDOMNodeHighlight(); | |
| 973 return false; | |
| 974 } | |
| 975 | |
| 976 set hovered(hovered) { | |
| 977 if (hovered) { | |
| 978 this.listItemElement.classList.add('hovered'); | |
| 979 var domModel = SDK.DOMModel.fromTarget(this._frame.target()); | |
| 980 if (domModel) | |
| 981 domModel.highlightFrame(this._frameId); | |
| 982 } else { | |
| 983 this.listItemElement.classList.remove('hovered'); | |
| 984 SDK.DOMModel.hideDOMNodeHighlight(); | |
| 985 } | |
| 986 } | |
| 987 | |
| 988 /** | |
| 989 * @param {!SDK.Resource} resource | |
| 990 */ | |
| 991 appendResource(resource) { | |
| 992 var resourceType = resource.resourceType(); | |
| 993 var categoryName = resourceType.name(); | |
| 994 var categoryElement = resourceType === Common.resourceTypes.Document ? this
: this._categoryElements[categoryName]; | |
| 995 if (!categoryElement) { | |
| 996 categoryElement = new Resources.StorageCategoryTreeElement( | |
| 997 this._storagePanel, resource.resourceType().category().title, category
Name); | |
| 998 this._categoryElements[resourceType.name()] = categoryElement; | |
| 999 this._insertInPresentationOrder(this, categoryElement); | |
| 1000 } | |
| 1001 var resourceTreeElement = new Resources.FrameResourceTreeElement(this._stora
gePanel, resource); | |
| 1002 this._insertInPresentationOrder(categoryElement, resourceTreeElement); | |
| 1003 this._treeElementForResource[resource.url] = resourceTreeElement; | |
| 1004 } | |
| 1005 | |
| 1006 /** | |
| 1007 * @param {string} url | |
| 1008 * @return {?SDK.Resource} | |
| 1009 */ | |
| 1010 resourceByURL(url) { | |
| 1011 var treeElement = this._treeElementForResource[url]; | |
| 1012 return treeElement ? treeElement._resource : null; | |
| 1013 } | |
| 1014 | |
| 1015 /** | |
| 1016 * @override | |
| 1017 */ | |
| 1018 appendChild(treeElement) { | |
| 1019 this._insertInPresentationOrder(this, treeElement); | |
| 1020 } | |
| 1021 | |
| 1022 _insertInPresentationOrder(parentTreeElement, childTreeElement) { | |
| 1023 // Insert in the alphabetical order, first frames, then resources. Document
resource goes last. | |
| 1024 function typeWeight(treeElement) { | |
| 1025 if (treeElement instanceof Resources.StorageCategoryTreeElement) | |
| 1026 return 2; | |
| 1027 if (treeElement instanceof Resources.FrameTreeElement) | |
| 1028 return 1; | |
| 1029 return 3; | |
| 1030 } | |
| 1031 | |
| 1032 function compare(treeElement1, treeElement2) { | |
| 1033 var typeWeight1 = typeWeight(treeElement1); | |
| 1034 var typeWeight2 = typeWeight(treeElement2); | |
| 1035 | |
| 1036 var result; | |
| 1037 if (typeWeight1 > typeWeight2) | |
| 1038 result = 1; | |
| 1039 else if (typeWeight1 < typeWeight2) | |
| 1040 result = -1; | |
| 1041 else | |
| 1042 result = treeElement1.titleAsText().localeCompare(treeElement2.titleAsTe
xt()); | |
| 1043 return result; | |
| 1044 } | |
| 1045 | |
| 1046 var childCount = parentTreeElement.childCount(); | |
| 1047 var i; | |
| 1048 for (i = 0; i < childCount; ++i) { | |
| 1049 if (compare(childTreeElement, parentTreeElement.childAt(i)) < 0) | |
| 1050 break; | |
| 1051 } | |
| 1052 parentTreeElement.insertChild(childTreeElement, i); | |
| 1053 } | |
| 1054 }; | |
| 1055 | |
| 1056 /** | |
| 1057 * @unrestricted | |
| 1058 */ | |
| 1059 Resources.FrameResourceTreeElement = class extends Resources.BaseStorageTreeElem
ent { | |
| 1060 /** | |
| 1061 * @param {!Resources.ResourcesPanel} storagePanel | |
| 1062 * @param {!SDK.Resource} resource | |
| 1063 */ | |
| 1064 constructor(storagePanel, resource) { | |
| 1065 super(storagePanel, resource.displayName, false); | |
| 1066 /** @type {!SDK.Resource} */ | |
| 1067 this._resource = resource; | |
| 1068 this.tooltip = resource.url; | |
| 1069 this._resource[Resources.FrameResourceTreeElement._symbol] = this; | |
| 1070 | |
| 1071 var icon = UI.Icon.create('largeicon-navigator-file', 'navigator-tree-item')
; | |
| 1072 icon.classList.add('navigator-file-tree-item'); | |
| 1073 icon.classList.add('navigator-' + resource.resourceType().name() + '-tree-it
em'); | |
| 1074 this.setLeadingIcons([icon]); | |
| 1075 } | |
| 1076 | |
| 1077 get itemURL() { | |
| 1078 return this._resource.url; | |
| 1079 } | |
| 1080 | |
| 1081 /** | |
| 1082 * @override | |
| 1083 * @return {boolean} | |
| 1084 */ | |
| 1085 onselect(selectedByUser) { | |
| 1086 super.onselect(selectedByUser); | |
| 1087 this._storagePanel._showResourceView(this._resource); | |
| 1088 return false; | |
| 1089 } | |
| 1090 | |
| 1091 /** | |
| 1092 * @override | |
| 1093 * @return {boolean} | |
| 1094 */ | |
| 1095 ondblclick(event) { | |
| 1096 InspectorFrontendHost.openInNewTab(this._resource.url); | |
| 1097 return false; | |
| 1098 } | |
| 1099 | |
| 1100 /** | |
| 1101 * @override | |
| 1102 */ | |
| 1103 onattach() { | |
| 1104 super.onattach(); | |
| 1105 this.listItemElement.draggable = true; | |
| 1106 this.listItemElement.addEventListener('dragstart', this._ondragstart.bind(th
is), false); | |
| 1107 this.listItemElement.addEventListener('contextmenu', this._handleContextMenu
Event.bind(this), true); | |
| 1108 } | |
| 1109 | |
| 1110 /** | |
| 1111 * @param {!MouseEvent} event | |
| 1112 * @return {boolean} | |
| 1113 */ | |
| 1114 _ondragstart(event) { | |
| 1115 event.dataTransfer.setData('text/plain', this._resource.content || ''); | |
| 1116 event.dataTransfer.effectAllowed = 'copy'; | |
| 1117 return true; | |
| 1118 } | |
| 1119 | |
| 1120 _handleContextMenuEvent(event) { | |
| 1121 var contextMenu = new UI.ContextMenu(event); | |
| 1122 contextMenu.appendApplicableItems(this._resource); | |
| 1123 contextMenu.show(); | |
| 1124 } | |
| 1125 | |
| 1126 /** | |
| 1127 * @return {!SourceFrame.ResourceSourceFrame} | |
| 1128 */ | |
| 1129 sourceView() { | |
| 1130 if (!this._sourceView) { | |
| 1131 var sourceFrame = new SourceFrame.ResourceSourceFrame(this._resource); | |
| 1132 sourceFrame.setHighlighterType(this._resource.canonicalMimeType()); | |
| 1133 this._sourceView = sourceFrame; | |
| 1134 } | |
| 1135 return this._sourceView; | |
| 1136 } | |
| 1137 }; | |
| 1138 | |
| 1139 Resources.FrameResourceTreeElement._symbol = Symbol('treeElement'); | |
| 1140 | |
| 1141 /** | |
| 1142 * @unrestricted | |
| 1143 */ | |
| 1144 Resources.DatabaseTreeElement = class extends Resources.BaseStorageTreeElement { | 839 Resources.DatabaseTreeElement = class extends Resources.BaseStorageTreeElement { |
| 1145 /** | 840 /** |
| 1146 * @param {!Resources.ResourcesPanel} storagePanel | 841 * @param {!Resources.ResourcesPanel} storagePanel |
| 1147 * @param {!Resources.Database} database | 842 * @param {!Resources.Database} database |
| 1148 */ | 843 */ |
| 1149 constructor(storagePanel, database) { | 844 constructor(storagePanel, database) { |
| 1150 super(storagePanel, database.name, true); | 845 super(storagePanel, database.name, true); |
| 1151 this._database = database; | 846 this._database = database; |
| 1152 | 847 |
| 1153 var icon = UI.Icon.create('mediumicon-database', 'resource-tree-item'); | 848 var icon = UI.Icon.create('mediumicon-database', 'resource-tree-item'); |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1375 | 1070 |
| 1376 /** | 1071 /** |
| 1377 * @override | 1072 * @override |
| 1378 * @return {boolean} | 1073 * @return {boolean} |
| 1379 */ | 1074 */ |
| 1380 onselect(selectedByUser) { | 1075 onselect(selectedByUser) { |
| 1381 super.onselect(selectedByUser); | 1076 super.onselect(selectedByUser); |
| 1382 if (!this._view) | 1077 if (!this._view) |
| 1383 this._view = new Resources.ServiceWorkerCacheView(this._model, this._cache
); | 1078 this._view = new Resources.ServiceWorkerCacheView(this._model, this._cache
); |
| 1384 | 1079 |
| 1385 this._storagePanel._innerShowView(this._view); | 1080 this.showView(this._view); |
| 1386 return false; | 1081 return false; |
| 1387 } | 1082 } |
| 1388 | 1083 |
| 1389 clear() { | 1084 clear() { |
| 1390 if (this._view) | 1085 if (this._view) |
| 1391 this._view.clear(); | 1086 this._view.clear(); |
| 1392 } | 1087 } |
| 1393 }; | 1088 }; |
| 1394 | 1089 |
| 1395 /** | 1090 /** |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1413 } | 1108 } |
| 1414 | 1109 |
| 1415 /** | 1110 /** |
| 1416 * @override | 1111 * @override |
| 1417 * @return {boolean} | 1112 * @return {boolean} |
| 1418 */ | 1113 */ |
| 1419 onselect(selectedByUser) { | 1114 onselect(selectedByUser) { |
| 1420 super.onselect(selectedByUser); | 1115 super.onselect(selectedByUser); |
| 1421 if (!this._view) | 1116 if (!this._view) |
| 1422 this._view = new Resources.ServiceWorkersView(); | 1117 this._view = new Resources.ServiceWorkersView(); |
| 1423 this._storagePanel._innerShowView(this._view); | 1118 this.showView(this._view); |
| 1424 return false; | 1119 return false; |
| 1425 } | 1120 } |
| 1426 }; | 1121 }; |
| 1427 | 1122 |
| 1428 /** | 1123 /** |
| 1429 * @unrestricted | 1124 * @unrestricted |
| 1430 */ | 1125 */ |
| 1431 Resources.AppManifestTreeElement = class extends Resources.BaseStorageTreeElemen
t { | 1126 Resources.AppManifestTreeElement = class extends Resources.BaseStorageTreeElemen
t { |
| 1432 /** | 1127 /** |
| 1433 * @param {!Resources.ResourcesPanel} storagePanel | 1128 * @param {!Resources.ResourcesPanel} storagePanel |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1446 } | 1141 } |
| 1447 | 1142 |
| 1448 /** | 1143 /** |
| 1449 * @override | 1144 * @override |
| 1450 * @return {boolean} | 1145 * @return {boolean} |
| 1451 */ | 1146 */ |
| 1452 onselect(selectedByUser) { | 1147 onselect(selectedByUser) { |
| 1453 super.onselect(selectedByUser); | 1148 super.onselect(selectedByUser); |
| 1454 if (!this._view) | 1149 if (!this._view) |
| 1455 this._view = new Resources.AppManifestView(); | 1150 this._view = new Resources.AppManifestView(); |
| 1456 this._storagePanel._innerShowView(this._view); | 1151 this.showView(this._view); |
| 1457 return false; | 1152 return false; |
| 1458 } | 1153 } |
| 1459 }; | 1154 }; |
| 1460 | 1155 |
| 1461 /** | 1156 /** |
| 1462 * @unrestricted | 1157 * @unrestricted |
| 1463 */ | 1158 */ |
| 1464 Resources.ClearStorageTreeElement = class extends Resources.BaseStorageTreeEleme
nt { | 1159 Resources.ClearStorageTreeElement = class extends Resources.BaseStorageTreeEleme
nt { |
| 1465 /** | 1160 /** |
| 1466 * @param {!Resources.ResourcesPanel} storagePanel | 1161 * @param {!Resources.ResourcesPanel} storagePanel |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1479 } | 1174 } |
| 1480 | 1175 |
| 1481 /** | 1176 /** |
| 1482 * @override | 1177 * @override |
| 1483 * @return {boolean} | 1178 * @return {boolean} |
| 1484 */ | 1179 */ |
| 1485 onselect(selectedByUser) { | 1180 onselect(selectedByUser) { |
| 1486 super.onselect(selectedByUser); | 1181 super.onselect(selectedByUser); |
| 1487 if (!this._view) | 1182 if (!this._view) |
| 1488 this._view = new Resources.ClearStorageView(this._storagePanel); | 1183 this._view = new Resources.ClearStorageView(this._storagePanel); |
| 1489 this._storagePanel._innerShowView(this._view); | 1184 this.showView(this._view); |
| 1490 return false; | 1185 return false; |
| 1491 } | 1186 } |
| 1492 }; | 1187 }; |
| 1493 | 1188 |
| 1494 /** | 1189 /** |
| 1495 * @unrestricted | 1190 * @unrestricted |
| 1496 */ | 1191 */ |
| 1497 Resources.IndexedDBTreeElement = class extends Resources.StorageCategoryTreeElem
ent { | 1192 Resources.IndexedDBTreeElement = class extends Resources.StorageCategoryTreeElem
ent { |
| 1498 /** | 1193 /** |
| 1499 * @param {!Resources.ResourcesPanel} storagePanel | 1194 * @param {!Resources.ResourcesPanel} storagePanel |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1687 | 1382 |
| 1688 /** | 1383 /** |
| 1689 * @override | 1384 * @override |
| 1690 * @return {boolean} | 1385 * @return {boolean} |
| 1691 */ | 1386 */ |
| 1692 onselect(selectedByUser) { | 1387 onselect(selectedByUser) { |
| 1693 super.onselect(selectedByUser); | 1388 super.onselect(selectedByUser); |
| 1694 if (!this._view) | 1389 if (!this._view) |
| 1695 this._view = new Resources.IDBDatabaseView(this._model, this._database); | 1390 this._view = new Resources.IDBDatabaseView(this._model, this._database); |
| 1696 | 1391 |
| 1697 this._storagePanel._innerShowView(this._view); | 1392 this.showView(this._view); |
| 1698 return false; | 1393 return false; |
| 1699 } | 1394 } |
| 1700 | 1395 |
| 1701 /** | 1396 /** |
| 1702 * @param {string} objectStoreName | 1397 * @param {string} objectStoreName |
| 1703 */ | 1398 */ |
| 1704 _objectStoreRemoved(objectStoreName) { | 1399 _objectStoreRemoved(objectStoreName) { |
| 1705 var objectStoreTreeElement = this._idbObjectStoreTreeElements[objectStoreNam
e]; | 1400 var objectStoreTreeElement = this._idbObjectStoreTreeElements[objectStoreNam
e]; |
| 1706 objectStoreTreeElement.clear(); | 1401 objectStoreTreeElement.clear(); |
| 1707 this.removeChild(objectStoreTreeElement); | 1402 this.removeChild(objectStoreTreeElement); |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1810 | 1505 |
| 1811 /** | 1506 /** |
| 1812 * @override | 1507 * @override |
| 1813 * @return {boolean} | 1508 * @return {boolean} |
| 1814 */ | 1509 */ |
| 1815 onselect(selectedByUser) { | 1510 onselect(selectedByUser) { |
| 1816 super.onselect(selectedByUser); | 1511 super.onselect(selectedByUser); |
| 1817 if (!this._view) | 1512 if (!this._view) |
| 1818 this._view = new Resources.IDBDataView(this._model, this._databaseId, this
._objectStore, null); | 1513 this._view = new Resources.IDBDataView(this._model, this._databaseId, this
._objectStore, null); |
| 1819 | 1514 |
| 1820 this._storagePanel._innerShowView(this._view); | 1515 this.showView(this._view); |
| 1821 return false; | 1516 return false; |
| 1822 } | 1517 } |
| 1823 | 1518 |
| 1824 /** | 1519 /** |
| 1825 * @param {string} indexName | 1520 * @param {string} indexName |
| 1826 */ | 1521 */ |
| 1827 _indexRemoved(indexName) { | 1522 _indexRemoved(indexName) { |
| 1828 var indexTreeElement = this._idbIndexTreeElements[indexName]; | 1523 var indexTreeElement = this._idbIndexTreeElements[indexName]; |
| 1829 indexTreeElement.clear(); | 1524 indexTreeElement.clear(); |
| 1830 this.removeChild(indexTreeElement); | 1525 this.removeChild(indexTreeElement); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1888 | 1583 |
| 1889 /** | 1584 /** |
| 1890 * @override | 1585 * @override |
| 1891 * @return {boolean} | 1586 * @return {boolean} |
| 1892 */ | 1587 */ |
| 1893 onselect(selectedByUser) { | 1588 onselect(selectedByUser) { |
| 1894 super.onselect(selectedByUser); | 1589 super.onselect(selectedByUser); |
| 1895 if (!this._view) | 1590 if (!this._view) |
| 1896 this._view = new Resources.IDBDataView(this._model, this._databaseId, this
._objectStore, this._index); | 1591 this._view = new Resources.IDBDataView(this._model, this._databaseId, this
._objectStore, this._index); |
| 1897 | 1592 |
| 1898 this._storagePanel._innerShowView(this._view); | 1593 this.showView(this._view); |
| 1899 return false; | 1594 return false; |
| 1900 } | 1595 } |
| 1901 | 1596 |
| 1902 clear() { | 1597 clear() { |
| 1903 if (this._view) | 1598 if (this._view) |
| 1904 this._view.clear(); | 1599 this._view.clear(); |
| 1905 } | 1600 } |
| 1906 }; | 1601 }; |
| 1907 | 1602 |
| 1908 /** | 1603 /** |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2085 | 1780 |
| 2086 this.element.classList.add('storage-view'); | 1781 this.element.classList.add('storage-view'); |
| 2087 this._emptyWidget = new UI.EmptyWidget(''); | 1782 this._emptyWidget = new UI.EmptyWidget(''); |
| 2088 this._emptyWidget.show(this.element); | 1783 this._emptyWidget.show(this.element); |
| 2089 } | 1784 } |
| 2090 | 1785 |
| 2091 setText(text) { | 1786 setText(text) { |
| 2092 this._emptyWidget.text = text; | 1787 this._emptyWidget.text = text; |
| 2093 } | 1788 } |
| 2094 }; | 1789 }; |
| OLD | NEW |