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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 this._pendingContentCallbacks = []; | 57 this._pendingContentCallbacks = []; |
58 if (this._request && !this._request.finished) | 58 if (this._request && !this._request.finished) |
59 this._request.addEventListener(WebInspector.NetworkRequest.Events.Finish
edLoading, this._requestFinished, this); | 59 this._request.addEventListener(WebInspector.NetworkRequest.Events.Finish
edLoading, this._requestFinished, this); |
60 } | 60 } |
61 | 61 |
62 WebInspector.Resource.Events = { | 62 WebInspector.Resource.Events = { |
63 MessageAdded: "message-added", | 63 MessageAdded: "message-added", |
64 MessagesCleared: "messages-cleared", | 64 MessagesCleared: "messages-cleared", |
65 } | 65 } |
66 | 66 |
| 67 /** |
| 68 * @param {?string} content |
| 69 * @param {string} mimeType |
| 70 * @param {boolean} contentEncoded |
| 71 * @return {?string} |
| 72 */ |
| 73 WebInspector.Resource.contentAsDataURL = function(content, mimeType, contentEnco
ded) |
| 74 { |
| 75 const maxDataUrlSize = 1024 * 1024; |
| 76 if (content === null || content.length > maxDataUrlSize) |
| 77 return null; |
| 78 |
| 79 return "data:" + mimeType + (contentEncoded ? ";base64," : ",") + content; |
| 80 } |
| 81 |
67 WebInspector.Resource.prototype = { | 82 WebInspector.Resource.prototype = { |
68 /** | 83 /** |
69 * @return {?WebInspector.NetworkRequest} | 84 * @return {?WebInspector.NetworkRequest} |
70 */ | 85 */ |
71 get request() | 86 get request() |
72 { | 87 { |
73 return this._request; | 88 return this._request; |
74 }, | 89 }, |
75 | 90 |
76 /** | 91 /** |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 * @param {!Element} image | 298 * @param {!Element} image |
284 */ | 299 */ |
285 populateImageSource: function(image) | 300 populateImageSource: function(image) |
286 { | 301 { |
287 /** | 302 /** |
288 * @param {?string} content | 303 * @param {?string} content |
289 * @this {WebInspector.Resource} | 304 * @this {WebInspector.Resource} |
290 */ | 305 */ |
291 function onResourceContent(content) | 306 function onResourceContent(content) |
292 { | 307 { |
293 var imageSrc = WebInspector.contentAsDataURL(this._content, this.mim
eType, this._contentEncoded); | 308 var imageSrc = WebInspector.Resource.contentAsDataURL(this._content,
this.mimeType, this._contentEncoded); |
294 if (imageSrc === null) | 309 if (imageSrc === null) |
295 imageSrc = this.url; | 310 imageSrc = this.url; |
296 image.src = imageSrc; | 311 image.src = imageSrc; |
297 } | 312 } |
298 | 313 |
299 this.requestContent(onResourceContent.bind(this)); | 314 this.requestContent(onResourceContent.bind(this)); |
300 }, | 315 }, |
301 | 316 |
302 _requestFinished: function() | 317 _requestFinished: function() |
303 { | 318 { |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 * @return {boolean} | 391 * @return {boolean} |
377 */ | 392 */ |
378 isHidden: function() | 393 isHidden: function() |
379 { | 394 { |
380 return !!this._isHidden; | 395 return !!this._isHidden; |
381 }, | 396 }, |
382 | 397 |
383 __proto__: WebInspector.SDKObject.prototype | 398 __proto__: WebInspector.SDKObject.prototype |
384 } | 399 } |
385 | 400 |
OLD | NEW |