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

Unified Diff: chrome/renderer/resources/extension_process_bindings.js

Issue 342012: Limit chrome.(browser|page)Action.setIcon({imageData:...}) to a (Closed)
Patch Set: Created 11 years, 2 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/resources/extension_process_bindings.js
diff --git a/chrome/renderer/resources/extension_process_bindings.js b/chrome/renderer/resources/extension_process_bindings.js
index 7f6443d002a7db8936119d8f961c354e4f6f4ee8..269c3d6e33aef0069de3b5c5b7344ab0459a087a 100644
--- a/chrome/renderer/resources/extension_process_bindings.js
+++ b/chrome/renderer/resources/extension_process_bindings.js
@@ -347,6 +347,8 @@ var chrome = chrome || {};
var canvas;
function setIconCommon(details, name, parameters) {
+ var EXTENSION_ACTION_SIZE = 19;
Finnur 2009/10/28 04:49:01 nit: EXTENSION_ACTION_IMAGE_SIZE (extension action
+
if ("iconIndex" in details) {
sendRequest(name, [details], parameters);
} else if ("imageData" in details) {
@@ -362,6 +364,14 @@ var chrome = chrome || {};
throw new Error(
"The imageData property must contain an ImageData object.");
}
+
+ if (details.imageData.width > EXTENSION_ACTION_SIZE ||
+ details.imageData.height > EXTENSION_ACTION_SIZE) {
+ throw new Error(
+ "The imageData property must contain an ImageData object that " +
+ "is no larger than 19 pixels square.");
+ }
+
sendCustomRequest(SetExtensionActionIcon, name, [details], parameters);
} else if ("path" in details) {
var img = new Image();
@@ -371,8 +381,10 @@ var chrome = chrome || {};
}
img.onload = function() {
var canvas = document.createElement("canvas");
- canvas.width = img.width > 19 ? 19 : img.width;
- canvas.height = img.height > 19 ? 19 : img.height;
+ canvas.width = img.width > EXTENSION_ACTION_SIZE ?
+ EXTENSION_ACTION_SIZE : img.width;
+ canvas.height = img.height > EXTENSION_ACTION_SIZE ?
+ EXTENSION_ACTION_SIZE : img.height;
var canvas_context = canvas.getContext('2d');
canvas_context.clearRect(0, 0, canvas.width, canvas.height);
« 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