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

Side by Side Diff: Source/devtools/front_end/ImageView.js

Issue 88103002: [DevTools] Resources: add "copy image as data url" menu item. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Reupload Created 7 years 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 dt.textContent = WebInspector.UIString("URL"); 103 dt.textContent = WebInspector.UIString("URL");
104 infoListElement.appendChild(dt); 104 infoListElement.appendChild(dt);
105 var dd = document.createElement("dd"); 105 var dd = document.createElement("dd");
106 var externalResource = true; 106 var externalResource = true;
107 dd.appendChild(WebInspector.linkifyURLAsNode(this.resource.url, unde fined, undefined, externalResource)); 107 dd.appendChild(WebInspector.linkifyURLAsNode(this.resource.url, unde fined, undefined, externalResource));
108 infoListElement.appendChild(dd); 108 infoListElement.appendChild(dd);
109 109
110 this._container.appendChild(infoListElement); 110 this._container.appendChild(infoListElement);
111 } 111 }
112 imagePreviewElement.addEventListener("load", onImageLoad.bind(this), fal se); 112 imagePreviewElement.addEventListener("load", onImageLoad.bind(this), fal se);
113 this._imagePreviewElement = imagePreviewElement;
113 }, 114 },
114 115
115 _base64ToSize: function(content) 116 _base64ToSize: function(content)
116 { 117 {
117 if (!content.length) 118 if (!content.length)
118 return 0; 119 return 0;
119 var size = (content.length || 0) * 3 / 4; 120 var size = (content.length || 0) * 3 / 4;
120 if (content.length > 0 && content[content.length - 1] === "=") 121 if (content.length > 0 && content[content.length - 1] === "=")
121 size--; 122 size--;
122 if (content.length > 1 && content[content.length - 2] === "=") 123 if (content.length > 1 && content[content.length - 2] === "=")
123 size--; 124 size--;
124 return size; 125 return size;
125 }, 126 },
126 127
127 _contextMenu: function(event) 128 _contextMenu: function(event)
128 { 129 {
129 var contextMenu = new WebInspector.ContextMenu(event); 130 var contextMenu = new WebInspector.ContextMenu(event);
130 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMe nuTitles() ? "Copy image URL" : "Copy Image URL"), this._copyImageURL.bind(this) ); 131 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMe nuTitles() ? "Copy image URL" : "Copy Image URL"), this._copyImageURL.bind(this) );
132 if (this._imagePreviewElement.src)
133 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCa seMenuTitles() ? "Copy image as Data URL" : "Copy Image As Data URL"), this._cop yImageAsDataURL.bind(this));
131 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMe nuTitles() ? "Open image in new tab" : "Open Image in New Tab"), this._openInNew Tab.bind(this)); 134 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMe nuTitles() ? "Open image in new tab" : "Open Image in New Tab"), this._openInNew Tab.bind(this));
132 contextMenu.show(); 135 contextMenu.show();
133 }, 136 },
134 137
138 _copyImageAsDataURL: function()
139 {
140 InspectorFrontendHost.copyText(this._imagePreviewElement.src);
141 },
142
135 _copyImageURL: function() 143 _copyImageURL: function()
136 { 144 {
137 InspectorFrontendHost.copyText(this.resource.url); 145 InspectorFrontendHost.copyText(this.resource.url);
138 }, 146 },
139 147
140 _openInNewTab: function() 148 _openInNewTab: function()
141 { 149 {
142 InspectorFrontendHost.openInNewTab(this.resource.url); 150 InspectorFrontendHost.openInNewTab(this.resource.url);
143 }, 151 },
144 152
145 __proto__: WebInspector.ResourceView.prototype 153 __proto__: WebInspector.ResourceView.prototype
146 } 154 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698