| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 * @constructor | 6 * @constructor |
| 7 * @extends {WebInspector.VBox} | 7 * @extends {WebInspector.VBox} |
| 8 * @param {!WebInspector.ServiceWorkerCacheModel} model | 8 * @param {!WebInspector.ServiceWorkerCacheModel} model |
| 9 * @param {!WebInspector.ServiceWorkerCacheModel.Cache} cache | 9 * @param {!WebInspector.ServiceWorkerCacheModel.Cache} cache |
| 10 */ | 10 */ |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 /** | 34 /** |
| 35 * @return {!WebInspector.DataGrid} | 35 * @return {!WebInspector.DataGrid} |
| 36 */ | 36 */ |
| 37 _createDataGrid: function() | 37 _createDataGrid: function() |
| 38 { | 38 { |
| 39 var columns = []; | 39 var columns = []; |
| 40 columns.push({id: "number", title: WebInspector.UIString("#"), width: "5
0px"}); | 40 columns.push({id: "number", title: WebInspector.UIString("#"), width: "5
0px"}); |
| 41 columns.push({id: "request", title: WebInspector.UIString("Request")}); | 41 columns.push({id: "request", title: WebInspector.UIString("Request")}); |
| 42 columns.push({id: "response", title: WebInspector.UIString("Response")})
; | 42 columns.push({id: "response", title: WebInspector.UIString("Response")})
; |
| 43 | 43 |
| 44 var dataGrid = new WebInspector.DataGrid(columns); | 44 var dataGrid = new WebInspector.DataGrid(columns, undefined, this._delet
eButtonClicked.bind(this), this._updateData.bind(this, true)); |
| 45 return dataGrid; | 45 return dataGrid; |
| 46 }, | 46 }, |
| 47 | 47 |
| 48 _createEditorToolbar: function() | 48 _createEditorToolbar: function() |
| 49 { | 49 { |
| 50 var editorToolbar = new WebInspector.Toolbar(this.element); | 50 var editorToolbar = new WebInspector.Toolbar(this.element); |
| 51 editorToolbar.element.classList.add("data-view-toolbar"); | 51 editorToolbar.element.classList.add("data-view-toolbar"); |
| 52 | 52 |
| 53 this._pageBackButton = new WebInspector.ToolbarButton(WebInspector.UIStr
ing("Show previous page."), "play-backwards-toolbar-item"); | 53 this._pageBackButton = new WebInspector.ToolbarButton(WebInspector.UIStr
ing("Show previous page."), "play-backwards-toolbar-item"); |
| 54 this._pageBackButton.addEventListener("click", this._pageBackButtonClick
ed, this); | 54 this._pageBackButton.addEventListener("click", this._pageBackButtonClick
ed, this); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 66 this._updateData(false); | 66 this._updateData(false); |
| 67 }, | 67 }, |
| 68 | 68 |
| 69 _pageForwardButtonClicked: function() | 69 _pageForwardButtonClicked: function() |
| 70 { | 70 { |
| 71 this._skipCount = this._skipCount + this._pageSize; | 71 this._skipCount = this._skipCount + this._pageSize; |
| 72 this._updateData(false); | 72 this._updateData(false); |
| 73 }, | 73 }, |
| 74 | 74 |
| 75 /** | 75 /** |
| 76 * @param {!WebInspector.DataGridNode} node |
| 77 */ |
| 78 _deleteButtonClicked: function(node) |
| 79 { |
| 80 this._model.deleteCacheEntry(this._cache, node.data["request"], node.rem
ove.bind(node)); |
| 81 }, |
| 82 |
| 83 /** |
| 76 * @param {!WebInspector.ServiceWorkerCacheModel.Cache} cache | 84 * @param {!WebInspector.ServiceWorkerCacheModel.Cache} cache |
| 77 */ | 85 */ |
| 78 update: function(cache) | 86 update: function(cache) |
| 79 { | 87 { |
| 80 this._cache = cache; | 88 this._cache = cache; |
| 81 | 89 |
| 82 if (this._dataGrid) | 90 if (this._dataGrid) |
| 83 this._dataGrid.detach(); | 91 this._dataGrid.detach(); |
| 84 this._dataGrid = this._createDataGrid(); | 92 this._dataGrid = this._createDataGrid(); |
| 85 this._dataGrid.show(this.element); | 93 this._dataGrid.show(this.element); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 } | 163 } |
| 156 | 164 |
| 157 /** | 165 /** |
| 158 * @constructor | 166 * @constructor |
| 159 * @extends {WebInspector.DataGridNode} | 167 * @extends {WebInspector.DataGridNode} |
| 160 * @param {!Object.<string, *>} data | 168 * @param {!Object.<string, *>} data |
| 161 */ | 169 */ |
| 162 WebInspector.SWCacheDataGridNode = function(data) | 170 WebInspector.SWCacheDataGridNode = function(data) |
| 163 { | 171 { |
| 164 WebInspector.DataGridNode.call(this, data, false); | 172 WebInspector.DataGridNode.call(this, data, false); |
| 165 this.selectable = false; | 173 this.selectable = true; |
| 166 } | 174 } |
| 167 | 175 |
| 168 WebInspector.SWCacheDataGridNode.prototype = { | 176 WebInspector.SWCacheDataGridNode.prototype = { |
| 169 /** | 177 /** |
| 170 * @override | 178 * @override |
| 171 * @return {!Element} | 179 * @return {!Element} |
| 172 */ | 180 */ |
| 173 createCell: function(columnIdentifier) | 181 createCell: function(columnIdentifier) |
| 174 { | 182 { |
| 175 var cell = WebInspector.DataGridNode.prototype.createCell.call(this, col
umnIdentifier); | 183 var cell = WebInspector.DataGridNode.prototype.createCell.call(this, col
umnIdentifier); |
| 176 var value = this.data[columnIdentifier]; | 184 var value = this.data[columnIdentifier]; |
| 177 | 185 |
| 178 switch (columnIdentifier) { | 186 switch (columnIdentifier) { |
| 179 case "request": | 187 case "request": |
| 180 case "response": | 188 case "response": |
| 181 cell.removeChildren(); | 189 cell.removeChildren(); |
| 182 this._formatValue(cell, value); | 190 this._formatValue(cell, value); |
| 183 break; | 191 break; |
| 184 default: | 192 default: |
| 185 } | 193 } |
| 186 | 194 |
| 187 return cell; | 195 return cell; |
| 188 }, | 196 }, |
| 189 | 197 |
| 190 _formatValue: function(cell, value) | 198 _formatValue: function(cell, value) |
| 191 { | 199 { |
| 192 var valueElement = WebInspector.ObjectPropertiesSection.createValueEleme
nt(value, false, cell); | 200 cell.classList.add("source-code"); |
| 193 valueElement.classList.add("source-code"); | 201 cell.classList.add("primitive-value"); |
| 194 if (value.type === "object") { | 202 cell.appendChild(createTextNode(value)); |
| 195 var section = new WebInspector.ObjectPropertiesSection(value, valueE
lement); | |
| 196 section.editable = false; | |
| 197 section.skipProto(); | |
| 198 cell.appendChild(section.element); | |
| 199 } else { | |
| 200 valueElement.classList.add("primitive-value"); | |
| 201 cell.appendChild(valueElement); | |
| 202 } | |
| 203 }, | 203 }, |
| 204 | 204 |
| 205 __proto__: WebInspector.DataGridNode.prototype | 205 __proto__: WebInspector.DataGridNode.prototype |
| 206 } | 206 } |
| OLD | NEW |