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

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

Issue 242150: Implement browserAction.setIcon(ImageData) for extensions. (Closed)
Patch Set: common function 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 710dad8eb38e37b3848d93439c590e869c2b709d..6dfa25a419162baad04a3ceb6c0eab1bfcdac46a 100644
--- a/chrome/renderer/resources/extension_process_bindings.js
+++ b/chrome/renderer/resources/extension_process_bindings.js
@@ -21,6 +21,7 @@ var chrome = chrome || {};
native function OpenChannelToTab();
native function GetRenderViewId();
native function GetL10nMessage();
+ native function SetBrowserActionIcon();
if (!chrome)
chrome = {};
@@ -175,6 +176,16 @@ var chrome = chrome || {};
request.callback ? true : false);
}
+ // Send a special API request that is not JSON stringifiable, and optionally
+ // register a callback.
+ function sendCustomRequest(nativeFunction, functionName, args, argSchemas) {
+ var request = prepareRequest(args, argSchemas);
+ var requestId = GetNextRequestId();
+ requests[requestId] = request;
+ return nativeFunction(functionName, args, requestId,
+ request.callback ? true : false);
+ }
+
function bind(obj, func) {
return function() {
return func.apply(obj, arguments);
@@ -329,6 +340,16 @@ var chrome = chrome || {};
return GetL10nMessage(message_name, placeholders);
}
+ apiFunctions["browserAction.setIcon"].handleRequest =
+ function(idOrImageData) {
+ if (typeof(idOrImageData) == "number") {
+ sendRequest(this.name, arguments, this.definition.parameters);
+ } else if (typeof(idOrImageData) == "object") {
+ sendCustomRequest(SetBrowserActionIcon, "browserAction.setIcon",
+ idOrImageData, this.definition.parameters);
+ }
+ }
+
setupPageActionEvents(extensionId);
setupBrowserActionEvent(extensionId);
setupToolstripEvents(GetRenderViewId());

Powered by Google App Engine
This is Rietveld 408576698