From 980641651d4c082177b135fae3d1f718eaa10310 Mon Sep 17 00:00:00 2001 From: "asargent@chromium.org" Date: Fri, 4 Jun 2010 16:38:30 +0000 Subject: Fix extension context menu API onclick handlers. I believe the following CL had accidentally broken them: http://src.chromium.org/viewvc/chrome?view=rev&revision=47972 I haven't yet added end-to-end tests for the context menu API that would catch problems like this, but I just created a bug for that (crbug.com/45811) and made the bug for bringing the API out of experimental blocked on it. I also fixed a small >80 chars style nit in this CL. BUG=45741 TEST=The onclick handler for an extension-added context menu item should now be called. See the bug for a minimal code snippet to put into a background page for this. Review URL: http://codereview.chromium.org/2626001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@48936 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/renderer/resources/extension_process_bindings.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'chrome/renderer') diff --git a/chrome/renderer/resources/extension_process_bindings.js b/chrome/renderer/resources/extension_process_bindings.js index 8955daf..0bf0591 100644 --- a/chrome/renderer/resources/extension_process_bindings.js +++ b/chrome/renderer/resources/extension_process_bindings.js @@ -570,7 +570,8 @@ var chrome = chrome || {}; delete details.path; details.imageData = canvas_context.getImageData(0, 0, canvas.width, canvas.height); - sendCustomRequest(SetExtensionActionIcon, name, [details], parameters); + sendCustomRequest(SetExtensionActionIcon, name, [details], + parameters); } img.src = details.path; } else { @@ -596,9 +597,10 @@ var chrome = chrome || {}; } // Set up the onclick handler if we were passed one in the request. - if (request.args.onclick) { + var onclick = request.args.length ? request.args[0].onclick : null; + if (onclick) { var menuItemId = chromeHidden.JSON.parse(response); - chromeHidden.contextMenuHandlers[menuItemId] = request.args.onclick; + chromeHidden.contextMenuHandlers[menuItemId] = onclick; } }; -- cgit v1.1