Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(16)

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/sdk/Resource.js

Issue 2851913002: [DevTools] Do not expose agents on Target
Patch Set: storage and tests.js Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 14 matching lines...) Expand all
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 { 32 SDK.Resource = class {
33 /** 33 /**
34 * @param {!SDK.ResourceTreeModel} resourceTreeModel 34 * @param {!SDK.ResourceTreeModel} resourceTreeModel
35 * @param {!Protocol.PageAgent} pageAgent
35 * @param {?SDK.NetworkRequest} request 36 * @param {?SDK.NetworkRequest} request
36 * @param {string} url 37 * @param {string} url
37 * @param {string} documentURL 38 * @param {string} documentURL
38 * @param {!Protocol.Page.FrameId} frameId 39 * @param {!Protocol.Page.FrameId} frameId
39 * @param {!Protocol.Network.LoaderId} loaderId 40 * @param {!Protocol.Network.LoaderId} loaderId
40 * @param {!Common.ResourceType} type 41 * @param {!Common.ResourceType} type
41 * @param {string} mimeType 42 * @param {string} mimeType
42 * @param {?Date} lastModified 43 * @param {?Date} lastModified
43 * @param {?number} contentSize 44 * @param {?number} contentSize
44 */ 45 */
45 constructor( 46 constructor(
46 resourceTreeModel, request, url, documentURL, frameId, loaderId, type, mim eType, lastModified, contentSize) { 47 resourceTreeModel, pageAgent, request, url, documentURL, frameId, loaderId , type, mimeType, lastModified,
48 contentSize) {
47 this._resourceTreeModel = resourceTreeModel; 49 this._resourceTreeModel = resourceTreeModel;
50 this._pageAgent = pageAgent;
48 this._request = request; 51 this._request = request;
49 this.url = url; 52 this.url = url;
50 this._documentURL = documentURL; 53 this._documentURL = documentURL;
51 this._frameId = frameId; 54 this._frameId = frameId;
52 this._loaderId = loaderId; 55 this._loaderId = loaderId;
53 this._type = type || Common.resourceTypes.Other; 56 this._type = type || Common.resourceTypes.Other;
54 this._mimeType = mimeType; 57 this._mimeType = mimeType;
55 58
56 this._lastModified = lastModified && lastModified.isValid() ? lastModified : null; 59 this._lastModified = lastModified && lastModified.isValid() ? lastModified : null;
57 this._contentSize = contentSize; 60 this._contentSize = contentSize;
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 */ 219 */
217 searchInContent(query, caseSensitive, isRegex, callback) { 220 searchInContent(query, caseSensitive, isRegex, callback) {
218 /** 221 /**
219 * @param {?Protocol.Error} error 222 * @param {?Protocol.Error} error
220 * @param {!Array.<!Protocol.Debugger.SearchMatch>} searchMatches 223 * @param {!Array.<!Protocol.Debugger.SearchMatch>} searchMatches
221 */ 224 */
222 function callbackWrapper(error, searchMatches) { 225 function callbackWrapper(error, searchMatches) {
223 callback(searchMatches || []); 226 callback(searchMatches || []);
224 } 227 }
225 228
226 if (this.frameId) { 229 if (this.frameId)
227 this._resourceTreeModel.target().pageAgent().searchInResource( 230 this._pageAgent.searchInResource(this.frameId, this.url, query, caseSensit ive, isRegex, callbackWrapper);
228 this.frameId, this.url, query, caseSensitive, isRegex, callbackWrapper ); 231 else
229 } else {
230 callback([]); 232 callback([]);
231 }
232 } 233 }
233 234
234 /** 235 /**
235 * @param {!Element} image 236 * @param {!Element} image
236 */ 237 */
237 populateImageSource(image) { 238 populateImageSource(image) {
238 /** 239 /**
239 * @param {?string} content 240 * @param {?string} content
240 * @this {SDK.Resource} 241 * @this {SDK.Resource}
241 */ 242 */
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 } 306 }
306 307
307 /** 308 /**
308 * @param {?string} content 309 * @param {?string} content
309 * @this {SDK.Resource} 310 * @this {SDK.Resource}
310 */ 311 */
311 function requestContentLoaded(content) { 312 function requestContentLoaded(content) {
312 contentLoaded.call(this, null, content, this.request.contentEncoded); 313 contentLoaded.call(this, null, content, this.request.contentEncoded);
313 } 314 }
314 315
315 this._resourceTreeModel.target().pageAgent().getResourceContent( 316 this._pageAgent.getResourceContent(this.frameId, this.url, resourceContentLo aded.bind(this));
316 this.frameId, this.url, resourceContentLoaded.bind(this));
317 } 317 }
318 318
319 /** 319 /**
320 * @return {boolean} 320 * @return {boolean}
321 */ 321 */
322 hasTextContent() { 322 hasTextContent() {
323 if (this._type.isTextType()) 323 if (this._type.isTextType())
324 return true; 324 return true;
325 if (this._type === Common.resourceTypes.Other) 325 if (this._type === Common.resourceTypes.Other)
326 return !!this._content && !this._contentEncoded; 326 return !!this._content && !this._contentEncoded;
327 return false; 327 return false;
328 } 328 }
329 }; 329 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698