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

Unified Diff: Source/devtools/front_end/sdk/Resource.js

Issue 471433004: DevTools: Split out the "workspace" and "bindings" modules from "sdk" (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Remove marker interfaces and WI.SourceMapping Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: Source/devtools/front_end/sdk/Resource.js
diff --git a/Source/devtools/front_end/sdk/Resource.js b/Source/devtools/front_end/sdk/Resource.js
index 2a6637fb3a2c3a1603b95424a4b2a6c406d78d4a..3a044ee2152c0168692bb04b4b059089a7b0be76 100644
--- a/Source/devtools/front_end/sdk/Resource.js
+++ b/Source/devtools/front_end/sdk/Resource.js
@@ -64,6 +64,21 @@ WebInspector.Resource.Events = {
MessagesCleared: "messages-cleared",
}
+/**
+ * @param {?string} content
+ * @param {string} mimeType
+ * @param {boolean} contentEncoded
+ * @return {?string}
+ */
+WebInspector.Resource.contentAsDataURL = function(content, mimeType, contentEncoded)
+{
+ const maxDataUrlSize = 1024 * 1024;
+ if (content === null || content.length > maxDataUrlSize)
+ return null;
+
+ return "data:" + mimeType + (contentEncoded ? ";base64," : ",") + content;
+}
+
WebInspector.Resource.prototype = {
/**
* @return {?WebInspector.NetworkRequest}
@@ -290,7 +305,7 @@ WebInspector.Resource.prototype = {
*/
function onResourceContent(content)
{
- var imageSrc = WebInspector.contentAsDataURL(this._content, this.mimeType, this._contentEncoded);
+ var imageSrc = WebInspector.Resource.contentAsDataURL(this._content, this.mimeType, this._contentEncoded);
if (imageSrc === null)
imageSrc = this.url;
image.src = imageSrc;

Powered by Google App Engine
This is Rietveld 408576698