summaryrefslogtreecommitdiffstats
path: root/chrome/common/extensions
diff options
context:
space:
mode:
authorasargent@chromium.org <asargent@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-23 06:52:41 +0000
committerasargent@chromium.org <asargent@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-23 06:52:41 +0000
commit2e3b520ff4318342b027ea8aa303e5981ea9ce79 (patch)
treef2eba7cf4a7d6179033d9cc0f4bba5981984ec55 /chrome/common/extensions
parentd11a34ba95bc98cf2c4b6caa2ce6ed469ae229ce (diff)
downloadchromium_src-2e3b520ff4318342b027ea8aa303e5981ea9ce79.zip
chromium_src-2e3b520ff4318342b027ea8aa303e5981ea9ce79.tar.gz
chromium_src-2e3b520ff4318342b027ea8aa303e5981ea9ce79.tar.bz2
Initial version of an experimental Extensions Context Menu API.
The proposal for the API is documented at: http://dev.chromium.org/developers/design-documents/extensions/context-menu-api Notable limitations in this initial implementation: -No reliable way to get at the unique, actual node clicked on in contexts like IMAGE/LINK/etc. We'll need to fix this in the long run - see the API proposal page for some notes on this. -No update or deleteAll methods ; the only way you can change items is to delete by id and re-add. -We aren't yet matching the UI goal of having the extension items at the top level include the extension icon on the left. This will require a refactoring of RenderViewContextMenu to steal some of the code from the bookmarks bar context menus, which can display favicons. -The only kind of parent->child menu that currently works is if you have a single top-level parent, and only one level of children. (This is because of how RenderViewContextMenu currently works) -No browser tests that the menu items actually get drawn (will wait on those until the above mentioned refactor is complete), or API tests (the API may change a bit based on feedback, at which point I'll write more tests). -Unit tests need to cover some more cases. BUG=32363 TEST=Should be able to create context menus with this API. Review URL: http://codereview.chromium.org/1042003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42321 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/extensions')
-rwxr-xr-xchrome/common/extensions/api/extension_api.json89
1 files changed, 89 insertions, 0 deletions
diff --git a/chrome/common/extensions/api/extension_api.json b/chrome/common/extensions/api/extension_api.json
index b354018..ca67e5a 100755
--- a/chrome/common/extensions/api/extension_api.json
+++ b/chrome/common/extensions/api/extension_api.json
@@ -2354,6 +2354,95 @@
"events": []
},
{
+ "namespace": "experimental.contextMenu",
+ "types": [],
+ "functions": [
+ {
+ "name": "create",
+ "type": "function",
+ "description": "An API to add items to context menus.",
+ "parameters": [
+ {
+ "type": "object",
+ "name": "createProperties",
+ "properties": {
+ "type": {
+ "type": "string",
+ "optional": true,
+ "description": "The type of menu item - one of 'NORMAL', 'CHECKBOX', 'RADIO', or 'SEPARATOR'. Defaults to 'NORMAL' if not specified."
+ },
+ "title": {
+ "type": "string",
+ "optional": "true",
+ "description": "This must be specified unless type is 'SEPARATOR'."
+ },
+ "checked": {
+ "type": "boolean",
+ "optional": true,
+ "description": " For items of type CHECKBOX or RADIO, should this be selected (RADIO) or checked (CHECKBOX)? Only one RADIO item can be selected at a time in a given group of RADIO items, with the last one to have checked == true winning."
+ },
+ "contexts": {
+ "type": "array",
+ "items": {"type": "string"},
+ "minItems": 1,
+ "optional": true,
+ "description": "List of contexts this menu item will appear in. Legal values are: 'ALL', 'PAGE', 'SELECTION', 'LINK', 'EDITABLE', 'IMAGE', 'VIDEO', and 'AUDIO'. Defaults to ['PAGE']."
+ },
+ "enabledContexts": {
+ "type": "array",
+ "optional": true,
+ "items": {"type": "string"},
+ "minItems": 1,
+ "description": "By default the values you pass for the contexts parameter make an item both shown and selectable in those contexts. If you want to limit the contexts where an item is selectable (i.e. not greyed out), you put the ones you want selectable in enabledContexts and any not listed will be shown but disabled. So, for example, if you wanted an item to appear for links and images but only be enabled for links, you would set 'contexts' : ['LINK', 'IMAGE'] and 'enabledContexts' : ['LINK']."
+ },
+ "onclick": {
+ "type": "function",
+ "optional": true,
+ "description": "Function to be called back when your menu item or one of its children is clicked."
+ },
+ "parentId": {
+ "type": "integer",
+ "optional": true,
+ "description": "The id of a parent menu item - this makes the item a child of a previously added item."
+ }
+ }
+ },
+ {
+ "type": "function",
+ "name": "callback",
+ "optional": true,
+ "parameters": [
+ {
+ "name": "menuItemId",
+ "type": "integer",
+ "description": "The id of the newly created context menu item."
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "name": "remove",
+ "type": "function",
+ "description": "Remove a context menu item.",
+ "parameters": [
+ {
+ "type": "integer",
+ "name": "menuItemId",
+ "description": "The id of the context menu item to remove."
+ },
+ {
+ "type": "function",
+ "name": "callback",
+ "optional": true,
+ "parameters": [],
+ "description": "Called when the context menu has been removed."
+ }
+ ]
+ }
+ ]
+ },
+ {
"namespace": "experimental.metrics",
"nodoc": true,
"types": [