Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 * @implements {Network.GroupLookupInterface} | 6 * @implements {Network.GroupLookupInterface} |
| 7 */ | 7 */ |
| 8 Network.FrameGrouper = class { | 8 Network.NetworkFrameGrouper = class { |
| 9 /** | 9 /** |
| 10 * @param {!Network.NetworkLogView} parentView | 10 * @param {!Network.NetworkLogView} parentView |
| 11 */ | 11 */ |
| 12 constructor(parentView) { | 12 constructor(parentView) { |
| 13 this._parentView = parentView; | 13 this._parentView = parentView; |
| 14 /** @type {?ProductRegistry.Registry} */ | |
| 15 this._productRegistry = null; | |
| 16 /** @type {!Map<!SDK.ResourceTreeFrame, !Network.FrameGroupNode>} */ | 14 /** @type {!Map<!SDK.ResourceTreeFrame, !Network.FrameGroupNode>} */ |
| 17 this._activeGroups = new Map(); | 15 this._activeGroups = new Map(); |
| 18 } | 16 } |
| 19 | 17 |
| 20 /** | 18 /** |
| 21 * @override | 19 * @override |
| 22 * @return {!Promise} | |
| 23 */ | |
| 24 initialize() { | |
| 25 return ProductRegistry.instance().then(productRegistry => { | |
| 26 this._productRegistry = productRegistry; | |
| 27 this._activeGroups.forEach(node => node.refresh()); | |
| 28 }); | |
| 29 } | |
| 30 | |
| 31 /** | |
| 32 * @override | |
| 33 * @param {!SDK.NetworkRequest} request | 20 * @param {!SDK.NetworkRequest} request |
| 34 * @return {?Network.NetworkGroupNode} | 21 * @return {?Network.NetworkGroupNode} |
| 35 */ | 22 */ |
| 36 groupNodeForRequest(request) { | 23 groupNodeForRequest(request) { |
| 37 var frame = SDK.ResourceTreeModel.frameForRequest(request); | 24 var frame = SDK.ResourceTreeModel.frameForRequest(request); |
| 38 if (!frame || frame.isMainFrame()) | 25 if (!frame || frame.isMainFrame()) |
| 39 return null; | 26 return null; |
| 40 var groupNode = this._activeGroups.get(frame); | 27 var groupNode = this._activeGroups.get(frame); |
| 41 if (groupNode) | 28 if (groupNode) |
| 42 return groupNode; | 29 return groupNode; |
| 43 groupNode = new Network.FrameGroupNode(this._parentView, frame, this); | 30 groupNode = new Network.FrameGroupNode(this._parentView, frame); |
| 44 this._activeGroups.set(frame, groupNode); | 31 this._activeGroups.set(frame, groupNode); |
| 45 return groupNode; | 32 return groupNode; |
| 46 } | 33 } |
| 47 | 34 |
| 48 /** | 35 /** |
| 49 * @override | 36 * @override |
| 50 */ | 37 */ |
| 51 reset() { | 38 reset() { |
| 52 this._activeGroups.clear(); | 39 this._activeGroups.clear(); |
| 53 } | 40 } |
| 54 }; | 41 }; |
| 55 | 42 |
| 56 Network.FrameGroupNode = class extends Network.NetworkGroupNode { | 43 Network.FrameGroupNode = class extends Network.NetworkGroupNode { |
| 57 /** | 44 /** |
| 58 * @param {!Network.NetworkLogView} parentView | 45 * @param {!Network.NetworkLogView} parentView |
| 59 * @param {!SDK.ResourceTreeFrame} frame | 46 * @param {!SDK.ResourceTreeFrame} frame |
| 60 * @param {!Network.FrameGrouper} grouper | |
| 61 */ | 47 */ |
| 62 constructor(parentView, frame, grouper) { | 48 constructor(parentView, frame) { |
| 63 super(parentView); | 49 super(parentView); |
| 64 this._frame = frame; | 50 this._frame = frame; |
| 65 this._grouper = grouper; | 51 /** @type {?Element} */ |
| 66 /** @type {?Network.NetworkNode._ProductEntryInfo|undefined} */ | 52 this._productBadge = null; |
| 67 this._productInfoEntryCache; | |
| 68 } | 53 } |
| 69 | 54 |
| 70 /** | 55 /** |
| 71 * @override | 56 * @override |
| 72 * @return {boolean} | 57 * @return {boolean} |
| 73 */ | 58 */ |
| 74 isFromFrame() { | 59 isFromFrame() { |
| 75 return true; | 60 return true; |
| 76 } | 61 } |
| 77 | 62 |
| 78 /** | 63 /** |
| 79 * @override | 64 * @override |
| 80 */ | 65 */ |
| 81 displayName() { | 66 displayName() { |
| 82 var entryInfo = this._innerProductEntry(); | 67 return new Common.ParsedURL(this._frame.url).domain() || this._frame.name || '<iframe>'; |
|
dgozman
2017/05/13 00:32:34
Check for isValid().
pfeldman
2017/05/15 14:53:02
This is iframe navigated url, it is always valid.
| |
| 83 return entryInfo ? entryInfo.entry.name : | |
| 84 (new Common.ParsedURL(this._frame.url)).host || this._fra me.name || '<iframe>'; | |
| 85 } | 68 } |
| 86 | 69 |
| 87 /** | 70 /** |
| 88 * @override | 71 * @override |
| 89 * @param {!Element} cell | 72 * @param {!Element} cell |
| 90 * @param {string} columnId | 73 * @param {string} columnId |
| 91 */ | 74 */ |
| 92 renderCell(cell, columnId) { | 75 renderCell(cell, columnId) { |
| 93 super.renderCell(cell, columnId); | 76 super.renderCell(cell, columnId); |
| 94 if (columnId === 'name') { | 77 if (columnId === 'name') { |
| 95 var name = this.displayName(); | 78 var name = this.displayName(); |
| 96 cell.textContent = name; | 79 if (!this._productBadge) |
| 80 this._productBadge = this.parentView().badgePool.badgeForFrame(this._fra me); | |
| 81 cell.appendChild(this._productBadge); | |
| 82 cell.createTextChild(name); | |
| 97 cell.title = name; | 83 cell.title = name; |
| 98 } | 84 } |
| 99 if (columnId === 'product') { | |
| 100 var entryInfo = this._innerProductEntry(); | |
| 101 if (entryInfo) | |
| 102 cell.textContent = entryInfo.entry.name; | |
| 103 } | |
| 104 } | |
| 105 | |
| 106 /** | |
| 107 * @override | |
| 108 * @return {!Promise<?Network.NetworkNode._ProductEntryInfo>} | |
| 109 */ | |
| 110 productEntry() { | |
| 111 return Promise.resolve(this._innerProductEntry()); | |
| 112 } | |
| 113 | |
| 114 /** | |
| 115 * @return {?Network.NetworkNode._ProductEntryInfo} | |
| 116 */ | |
| 117 _innerProductEntry() { | |
| 118 if (this._productInfoEntryCache !== undefined) | |
| 119 return this._productInfoEntryCache; | |
| 120 var productRegistry = this._grouper._productRegistry; | |
| 121 if (!productRegistry) | |
| 122 return null; | |
| 123 this._productInfoEntryCache = Network.NetworkNode.productEntryInfoForFrame(p roductRegistry, this._frame); | |
| 124 return this._productInfoEntryCache; | |
| 125 } | 85 } |
| 126 }; | 86 }; |
| OLD | NEW |