Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Research In Motion Limited. All rights reserved. | 2 * Copyright (C) 2012 Research In Motion Limited. All rights reserved. |
| 3 * | 3 * |
| 4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
| 5 * modify it under the terms of the GNU Lesser General Public | 5 * modify it under the terms of the GNU Lesser General Public |
| 6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
| 7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
| 8 * | 8 * |
| 9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 50 this._timeComparator = | 50 this._timeComparator = |
| 51 /** @type {function(!Network.ResourceWebSocketFrameNode, !Network.Resour ceWebSocketFrameNode):number} */ ( | 51 /** @type {function(!Network.ResourceWebSocketFrameNode, !Network.Resour ceWebSocketFrameNode):number} */ ( |
| 52 Network.ResourceWebSocketFrameNodeTimeComparator); | 52 Network.ResourceWebSocketFrameNodeTimeComparator); |
| 53 this._dataGrid.sortNodes(this._timeComparator, false); | 53 this._dataGrid.sortNodes(this._timeComparator, false); |
| 54 this._dataGrid.markColumnAsSortedBy('time', DataGrid.DataGrid.Order.Ascendin g); | 54 this._dataGrid.markColumnAsSortedBy('time', DataGrid.DataGrid.Order.Ascendin g); |
| 55 this._dataGrid.addEventListener(DataGrid.DataGrid.Events.SortingChanged, thi s._sortItems, this); | 55 this._dataGrid.addEventListener(DataGrid.DataGrid.Events.SortingChanged, thi s._sortItems, this); |
| 56 | 56 |
| 57 this._dataGrid.setName('ResourceWebSocketFrameView'); | 57 this._dataGrid.setName('ResourceWebSocketFrameView'); |
| 58 this._dataGrid.addEventListener(DataGrid.DataGrid.Events.SelectedNode, this. _onFrameSelected, this); | 58 this._dataGrid.addEventListener(DataGrid.DataGrid.Events.SelectedNode, this. _onFrameSelected, this); |
| 59 this._dataGrid.addEventListener(DataGrid.DataGrid.Events.DeselectedNode, thi s._onFrameDeselected, this); | 59 this._dataGrid.addEventListener(DataGrid.DataGrid.Events.DeselectedNode, thi s._onFrameDeselected, this); |
| 60 this._splitWidget.setMainWidget(this._dataGrid.asWidget()); | |
| 61 | 60 |
| 62 var view = new UI.EmptyWidget('Select frame to browse its content.'); | 61 this._deleteAllButton = new UI.ToolbarButton(Common.UIString('Clear All'), ' largeicon-clear'); |
| 63 this._splitWidget.setSidebarWidget(view); | 62 this._deleteAllButton.addEventListener(UI.ToolbarButton.Events.Click, this._ onDeleteAllButtonClick, this); |
| 63 this._filterTextInput = new UI.ToolbarInput(Common.UIString('Filter'), 0, 0, true); | |
|
allada
2017/04/10 19:39:15
Lets use UI.FilterBar instead, it will handle much
| |
| 64 this._filterTextInput.addEventListener(UI.ToolbarInput.Event.TextChanged, th is._onFilterTextInputChanged, this); | |
| 65 | |
| 66 var combobox = new UI.ToolbarComboBox(this._onFilterTypeComboboxChanged.bind (this)); | |
| 67 combobox.addOption(combobox.createOption(Common.UIString('All'), '', '')); | |
|
allada
2017/04/10 19:39:15
Lets instead use FilterBar's ability to show UI.Na
| |
| 68 combobox.addOption(combobox.createOption(Common.UIString('Send'), '', 'send' )); | |
| 69 combobox.addOption(combobox.createOption(Common.UIString('Receive'), '', 're ceive')); | |
| 70 this._filterTypeCombobox = combobox; | |
| 71 | |
| 72 var toolbarItems = [this._deleteAllButton, this._filterTextInput, this._filt erTypeCombobox]; | |
|
allada
2017/04/10 19:39:15
I am thinking maybe have the delete/clear button a
| |
| 73 this._mainToolbar = new UI.Toolbar(''); | |
| 74 for (var item of toolbarItems) | |
| 75 this._mainToolbar.appendToolbarItem(item); | |
| 76 | |
| 77 var mainContainer = new UI.VBox(); | |
| 78 mainContainer.element.appendChild(this._mainToolbar.element); | |
| 79 this._dataGrid.asWidget().show(mainContainer.element); | |
| 80 this._splitWidget.setMainWidget(mainContainer); | |
| 81 | |
| 82 this._frameEmptyWidget = new UI.EmptyWidget('Select frame to browse its cont ent.'); | |
| 83 this._splitWidget.setSidebarWidget(this._frameEmptyWidget); | |
| 64 | 84 |
| 65 /** @type {?Network.ResourceWebSocketFrameNode} */ | 85 /** @type {?Network.ResourceWebSocketFrameNode} */ |
| 66 this._selectedNode = null; | 86 this._selectedNode = null; |
| 67 | 87 |
| 68 /** | 88 /** |
| 69 * @param {!UI.ContextMenu} contextMenu | 89 * @param {!UI.ContextMenu} contextMenu |
| 70 * @param {!DataGrid.DataGridNode} node | 90 * @param {!DataGrid.DataGridNode} node |
| 71 */ | 91 */ |
| 72 function onRowContextMenu(contextMenu, node) { | 92 function onRowContextMenu(contextMenu, node) { |
| 73 contextMenu.appendItem( | 93 contextMenu.appendItem( |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 100 */ | 120 */ |
| 101 willHide() { | 121 willHide() { |
| 102 this._request.removeEventListener(SDK.NetworkRequest.Events.WebsocketFrameAd ded, this._frameAdded, this); | 122 this._request.removeEventListener(SDK.NetworkRequest.Events.WebsocketFrameAd ded, this._frameAdded, this); |
| 103 } | 123 } |
| 104 | 124 |
| 105 /** | 125 /** |
| 106 * @param {!Common.Event} event | 126 * @param {!Common.Event} event |
| 107 */ | 127 */ |
| 108 _frameAdded(event) { | 128 _frameAdded(event) { |
| 109 var frame = /** @type {!SDK.NetworkRequest.WebSocketFrame} */ (event.data); | 129 var frame = /** @type {!SDK.NetworkRequest.WebSocketFrame} */ (event.data); |
| 130 if (!this._frameFilter(frame)) | |
| 131 return; | |
| 110 this._dataGrid.insertChild(new Network.ResourceWebSocketFrameNode(this._requ est.url(), frame)); | 132 this._dataGrid.insertChild(new Network.ResourceWebSocketFrameNode(this._requ est.url(), frame)); |
| 111 } | 133 } |
| 112 | 134 |
| 113 /** | 135 /** |
| 136 * @param {!SDK.NetworkRequest.WebSocketFrame} frame | |
| 137 */ | |
| 138 _frameFilter(frame) { | |
| 139 var matchText = true; | |
| 140 if (this._filterRegex) | |
| 141 matchText = this._filterRegex.test(frame.text); | |
| 142 var matchType = true; | |
| 143 if (this._filterType) | |
| 144 matchType = this._filterType === frame.type; | |
| 145 return matchText && matchType; | |
| 146 } | |
| 147 | |
| 148 /** | |
| 149 * @param {!Common.Event} event | |
| 150 */ | |
| 151 _onDeleteAllButtonClick(event) { | |
| 152 this._request.clearFrames(); | |
| 153 this.refresh(); | |
| 154 } | |
| 155 | |
| 156 /** | |
| 157 * @param {!Common.Event} event | |
| 158 */ | |
| 159 _onFilterTextInputChanged(event) { | |
| 160 var text = /** @type {?string} */ (event.data); | |
| 161 this._filterRegex = text ? new RegExp(text.escapeForRegExp(), 'i') : null; | |
| 162 this.refresh(); | |
| 163 } | |
| 164 | |
| 165 _onFilterTypeComboboxChanged() { | |
| 166 this._filterType = this._filterTypeCombobox.selectedOption().value; | |
| 167 this.refresh(); | |
| 168 } | |
| 169 | |
| 170 /** | |
| 114 * @param {!Common.Event} event | 171 * @param {!Common.Event} event |
| 115 */ | 172 */ |
| 116 _onFrameSelected(event) { | 173 _onFrameSelected(event) { |
| 117 var selectedNode = /** @type {!Network.ResourceWebSocketFrameNode} */ (event .data); | 174 var selectedNode = /** @type {!Network.ResourceWebSocketFrameNode} */ (event .data); |
| 118 this._currentSelectedNode = selectedNode; | 175 this._currentSelectedNode = selectedNode; |
| 119 var contentProvider = selectedNode.contentProvider(); | 176 var contentProvider = selectedNode.contentProvider(); |
| 120 contentProvider.requestContent().then(contentHandler.bind(this)); | 177 contentProvider.requestContent().then(contentHandler.bind(this)); |
| 121 | 178 |
| 122 /** | 179 /** |
| 123 * @param {(string|null)} content | 180 * @param {(string|null)} content |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 141 else | 198 else |
| 142 this._splitWidget.setSidebarWidget(new SourceFrame.ResourceSourceFrame(c ontentProvider)); | 199 this._splitWidget.setSidebarWidget(new SourceFrame.ResourceSourceFrame(c ontentProvider)); |
| 143 } | 200 } |
| 144 } | 201 } |
| 145 | 202 |
| 146 /** | 203 /** |
| 147 * @param {!Common.Event} event | 204 * @param {!Common.Event} event |
| 148 */ | 205 */ |
| 149 _onFrameDeselected(event) { | 206 _onFrameDeselected(event) { |
| 150 this._currentSelectedNode = null; | 207 this._currentSelectedNode = null; |
| 208 this._splitWidget.setSidebarWidget(this._frameEmptyWidget); | |
| 151 } | 209 } |
| 152 | 210 |
| 153 refresh() { | 211 refresh() { |
| 154 this._dataGrid.rootNode().removeChildren(); | 212 this._dataGrid.rootNode().removeChildren(); |
| 155 var frames = this._request.frames(); | 213 var frames = this._request.frames().filter(this._frameFilter.bind(this)); |
| 156 for (var i = 0; i < frames.length; ++i) | 214 for (var i = 0; i < frames.length; ++i) |
| 157 this._dataGrid.insertChild(new Network.ResourceWebSocketFrameNode(this._re quest.url(), frames[i])); | 215 this._dataGrid.insertChild(new Network.ResourceWebSocketFrameNode(this._re quest.url(), frames[i])); |
| 158 } | 216 } |
| 159 | 217 |
| 160 _sortItems() { | 218 _sortItems() { |
| 161 this._dataGrid.sortNodes(this._timeComparator, !this._dataGrid.isSortOrderAs cending()); | 219 this._dataGrid.sortNodes(this._timeComparator, !this._dataGrid.isSortOrderAs cending()); |
| 162 } | 220 } |
| 163 }; | 221 }; |
| 164 | 222 |
| 165 /** @enum {number} */ | 223 /** @enum {number} */ |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 246 }; | 304 }; |
| 247 | 305 |
| 248 /** | 306 /** |
| 249 * @param {!Network.ResourceWebSocketFrameNode} a | 307 * @param {!Network.ResourceWebSocketFrameNode} a |
| 250 * @param {!Network.ResourceWebSocketFrameNode} b | 308 * @param {!Network.ResourceWebSocketFrameNode} b |
| 251 * @return {number} | 309 * @return {number} |
| 252 */ | 310 */ |
| 253 Network.ResourceWebSocketFrameNodeTimeComparator = function(a, b) { | 311 Network.ResourceWebSocketFrameNodeTimeComparator = function(a, b) { |
| 254 return a._frame.time - b._frame.time; | 312 return a._frame.time - b._frame.time; |
| 255 }; | 313 }; |
| OLD | NEW |