| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 */ | 27 */ |
| 28 /** | 28 /** |
| 29 * @implements {Common.ContentProvider} | 29 * @implements {Common.ContentProvider} |
| 30 * @unrestricted | 30 * @unrestricted |
| 31 */ | 31 */ |
| 32 SDK.Resource = class extends SDK.SDKObject { | 32 SDK.Resource = class { |
| 33 /** | 33 /** |
| 34 * @param {!SDK.Target} target | 34 * @param {!SDK.ResourceTreeModel} resourceTreeModel |
| 35 * @param {?SDK.NetworkRequest} request | 35 * @param {?SDK.NetworkRequest} request |
| 36 * @param {string} url | 36 * @param {string} url |
| 37 * @param {string} documentURL | 37 * @param {string} documentURL |
| 38 * @param {!Protocol.Page.FrameId} frameId | 38 * @param {!Protocol.Page.FrameId} frameId |
| 39 * @param {!Protocol.Network.LoaderId} loaderId | 39 * @param {!Protocol.Network.LoaderId} loaderId |
| 40 * @param {!Common.ResourceType} type | 40 * @param {!Common.ResourceType} type |
| 41 * @param {string} mimeType | 41 * @param {string} mimeType |
| 42 * @param {?Date} lastModified | 42 * @param {?Date} lastModified |
| 43 * @param {?number} contentSize | 43 * @param {?number} contentSize |
| 44 */ | 44 */ |
| 45 constructor(target, request, url, documentURL, frameId, loaderId, type, mimeTy
pe, lastModified, contentSize) { | 45 constructor( |
| 46 super(target); | 46 resourceTreeModel, request, url, documentURL, frameId, loaderId, type, mim
eType, lastModified, contentSize) { |
| 47 this._resourceTreeModel = resourceTreeModel; |
| 47 this._request = request; | 48 this._request = request; |
| 48 this.url = url; | 49 this.url = url; |
| 49 this._documentURL = documentURL; | 50 this._documentURL = documentURL; |
| 50 this._frameId = frameId; | 51 this._frameId = frameId; |
| 51 this._loaderId = loaderId; | 52 this._loaderId = loaderId; |
| 52 this._type = type || Common.resourceTypes.Other; | 53 this._type = type || Common.resourceTypes.Other; |
| 53 this._mimeType = mimeType; | 54 this._mimeType = mimeType; |
| 54 | 55 |
| 55 this._lastModified = lastModified && lastModified.isValid() ? lastModified :
null; | 56 this._lastModified = lastModified && lastModified.isValid() ? lastModified :
null; |
| 56 this._contentSize = contentSize; | 57 this._contentSize = contentSize; |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 searchInContent(query, caseSensitive, isRegex, callback) { | 217 searchInContent(query, caseSensitive, isRegex, callback) { |
| 217 /** | 218 /** |
| 218 * @param {?Protocol.Error} error | 219 * @param {?Protocol.Error} error |
| 219 * @param {!Array.<!Protocol.Debugger.SearchMatch>} searchMatches | 220 * @param {!Array.<!Protocol.Debugger.SearchMatch>} searchMatches |
| 220 */ | 221 */ |
| 221 function callbackWrapper(error, searchMatches) { | 222 function callbackWrapper(error, searchMatches) { |
| 222 callback(searchMatches || []); | 223 callback(searchMatches || []); |
| 223 } | 224 } |
| 224 | 225 |
| 225 if (this.frameId) { | 226 if (this.frameId) { |
| 226 this.target().pageAgent().searchInResource( | 227 this._resourceTreeModel.target().pageAgent().searchInResource( |
| 227 this.frameId, this.url, query, caseSensitive, isRegex, callbackWrapper
); | 228 this.frameId, this.url, query, caseSensitive, isRegex, callbackWrapper
); |
| 228 } else { | 229 } else { |
| 229 callback([]); | 230 callback([]); |
| 230 } | 231 } |
| 231 } | 232 } |
| 232 | 233 |
| 233 /** | 234 /** |
| 234 * @param {!Element} image | 235 * @param {!Element} image |
| 235 */ | 236 */ |
| 236 populateImageSource(image) { | 237 populateImageSource(image) { |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 } | 305 } |
| 305 | 306 |
| 306 /** | 307 /** |
| 307 * @param {?string} content | 308 * @param {?string} content |
| 308 * @this {SDK.Resource} | 309 * @this {SDK.Resource} |
| 309 */ | 310 */ |
| 310 function requestContentLoaded(content) { | 311 function requestContentLoaded(content) { |
| 311 contentLoaded.call(this, null, content, this.request.contentEncoded); | 312 contentLoaded.call(this, null, content, this.request.contentEncoded); |
| 312 } | 313 } |
| 313 | 314 |
| 314 this.target().pageAgent().getResourceContent(this.frameId, this.url, resourc
eContentLoaded.bind(this)); | 315 this._resourceTreeModel.target().pageAgent().getResourceContent( |
| 316 this.frameId, this.url, resourceContentLoaded.bind(this)); |
| 315 } | 317 } |
| 316 | 318 |
| 317 /** | 319 /** |
| 318 * @return {boolean} | 320 * @return {boolean} |
| 319 */ | 321 */ |
| 320 hasTextContent() { | 322 hasTextContent() { |
| 321 if (this._type.isTextType()) | 323 if (this._type.isTextType()) |
| 322 return true; | 324 return true; |
| 323 if (this._type === Common.resourceTypes.Other) | 325 if (this._type === Common.resourceTypes.Other) |
| 324 return !!this._content && !this._contentEncoded; | 326 return !!this._content && !this._contentEncoded; |
| 325 return false; | 327 return false; |
| 326 } | 328 } |
| 327 }; | 329 }; |
| OLD | NEW |