summaryrefslogtreecommitdiffstats
path: root/chrome/renderer/resources
diff options
context:
space:
mode:
authormpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-16 21:53:46 +0000
committermpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-16 21:53:46 +0000
commit744ef17706b3c77d087809ec119bbc2f7bd17c89 (patch)
tree24eb889c256f49dd3d24610b68c5e09b90a5c21d /chrome/renderer/resources
parent0db22afeba278540d2457ebfead171a8a54feb3c (diff)
downloadchromium_src-744ef17706b3c77d087809ec119bbc2f7bd17c89.zip
chromium_src-744ef17706b3c77d087809ec119bbc2f7bd17c89.tar.gz
chromium_src-744ef17706b3c77d087809ec119bbc2f7bd17c89.tar.bz2
Implement new page action API.
Still no actual drawing code for badges, though. BUG=24635 TEST=Load the sample test_page_action extension and click the page action to cycle through various states. Review URL: http://codereview.chromium.org/269079 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29335 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer/resources')
-rw-r--r--chrome/renderer/resources/extension_process_bindings.js32
1 files changed, 19 insertions, 13 deletions
diff --git a/chrome/renderer/resources/extension_process_bindings.js b/chrome/renderer/resources/extension_process_bindings.js
index 2941644..dc81f67 100644
--- a/chrome/renderer/resources/extension_process_bindings.js
+++ b/chrome/renderer/resources/extension_process_bindings.js
@@ -16,7 +16,7 @@ var chrome = chrome || {};
native function OpenChannelToTab();
native function GetRenderViewId();
native function GetL10nMessage();
- native function SetBrowserActionIcon();
+ native function SetExtensionActionIcon();
if (!chrome)
chrome = {};
@@ -177,7 +177,7 @@ var chrome = chrome || {};
var request = prepareRequest(args, argSchemas);
var requestId = GetNextRequestId();
requests[requestId] = request;
- return nativeFunction(functionName, args, requestId,
+ return nativeFunction(functionName, request.args, requestId,
request.callback ? true : false);
}
@@ -202,12 +202,12 @@ var chrome = chrome || {};
chrome.pageAction.onClicked = new chrome.Event(eventName);
}
- // Browser action events send {windowpId}.
- function setupBrowserActionEvent(extensionId) {
- var eventName = "browserAction/" + extensionId;
- chrome.browserAction = chrome.browserAction || {};
- chrome.browserAction.onClicked = new chrome.Event(eventName);
- }
+ // Browser action events send {windowpId}.
+ function setupBrowserActionEvent(extensionId) {
+ var eventName = "browserAction/" + extensionId;
+ chrome.browserAction = chrome.browserAction || {};
+ chrome.browserAction.onClicked = new chrome.Event(eventName);
+ }
function setupToolstripEvents(renderViewId) {
chrome.toolstrip = chrome.toolstrip || {};
@@ -333,9 +333,9 @@ var chrome = chrome || {};
return GetL10nMessage(message_name, placeholders);
}
- apiFunctions["browserAction.setIcon"].handleRequest = function(details) {
+ function setIconCommon(details, name, parameters) {
if ("iconIndex" in details) {
- sendRequest(this.name, arguments, this.definition.parameters);
+ sendRequest(name, [details], parameters);
} else if ("imageData" in details) {
// Verify that this at least looks like an ImageData element.
// Unfortunately, we cannot use instanceof because the ImageData
@@ -349,15 +349,21 @@ var chrome = chrome || {};
throw new Error(
"The imageData property must contain an ImageData object.");
}
-
- sendCustomRequest(SetBrowserActionIcon, "browserAction.setIcon",
- details, this.definition.parameters);
+ sendCustomRequest(SetExtensionActionIcon, name, [details], parameters);
} else {
throw new Error(
"Either the iconIndex or imageData property must be specified.");
}
}
+ apiFunctions["browserAction.setIcon"].handleRequest = function(details) {
+ setIconCommon(details, this.name, this.definition.parameters);
+ };
+
+ apiFunctions["pageAction.setIcon"].handleRequest = function(details) {
+ setIconCommon(details, this.name, this.definition.parameters);
+ };
+
setupBrowserActionEvent(extensionId);
setupPageActionEvents(extensionId);
setupToolstripEvents(GetRenderViewId());