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

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

Issue 264046: Update browser actions api to be like new design doc. (Closed)
Patch Set: rebase 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
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 3ca88c477af5ab8e1cd67d1f5637213eb31337e0..c0e94a11ffccba017730805d7bf0421ae820aad9 100644
--- a/chrome/renderer/resources/extension_process_bindings.js
+++ b/chrome/renderer/resources/extension_process_bindings.js
@@ -333,18 +333,32 @@ var chrome = chrome || {};
return GetL10nMessage(message_name, placeholders);
}
- apiFunctions["browserAction.setIcon"].handleRequest =
- function(idOrImageData) {
- if (typeof(idOrImageData) == "number") {
+ apiFunctions["browserAction.setIcon"].handleRequest = function(details) {
+ if ("iconIndex" in details) {
sendRequest(this.name, arguments, this.definition.parameters);
- } else if (typeof(idOrImageData) == "object") {
+ } else if ("imageData" in details) {
+ // Verify that this at least looks like an ImageData element.
+ // Unfortunately, we cannot use instanceof because the ImageData
+ // constructor is not public.
+ //
+ // We do this manually instead of using JSONSchema to avoid having these
+ // properties show up in the doc.
+ if (!("width" in details.imageData) ||
+ !("height" in details.imageData) ||
+ !("data" in details.imageData)) {
+ throw new Error(
+ "The imageData property must contain an ImageData object.");
+ }
sendCustomRequest(SetBrowserActionIcon, "browserAction.setIcon",
- idOrImageData, this.definition.parameters);
+ details, this.definition.parameters);
+ } else {
+ throw new Error(
+ "Either the iconIndex or imageData property must be specified.");
}
}
- setupPageActionEvents(extensionId);
setupBrowserActionEvent(extensionId);
+ setupPageActionEvents(extensionId);
setupToolstripEvents(GetRenderViewId());
});
})();

Powered by Google App Engine
This is Rietveld 408576698