summaryrefslogtreecommitdiffstats
path: root/chrome/common
diff options
context:
space:
mode:
authorbattre@chromium.org <battre@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-08 10:20:59 +0000
committerbattre@chromium.org <battre@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-08 10:20:59 +0000
commit8ef650e5f2266af9380e20f4d4144009560068ad (patch)
tree36d12363cdb0dff83fd5aaed8d7d58ee43ff7f36 /chrome/common
parent5347ec93bda2df822e02dfbdbae80d5c02126b15 (diff)
downloadchromium_src-8ef650e5f2266af9380e20f4d4144009560068ad.zip
chromium_src-8ef650e5f2266af9380e20f4d4144009560068ad.tar.gz
chromium_src-8ef650e5f2266af9380e20f4d4144009560068ad.tar.bz2
Bindings layer for declarative events API
BUG=112155 TEST=no Review URL: https://chromiumcodereview.appspot.com/9192029 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@120962 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common')
-rw-r--r--chrome/common/common_resources.grd1
-rw-r--r--chrome/common/extensions/api/experimental.declarative.json128
-rw-r--r--chrome/common/extensions/api/extension_api.cc1
-rw-r--r--chrome/common/extensions/api/webRequest.json42
-rw-r--r--chrome/common/extensions/docs/samples.json1
-rw-r--r--chrome/common/extensions/docs/template/api_template.html6
6 files changed, 176 insertions, 3 deletions
diff --git a/chrome/common/common_resources.grd b/chrome/common/common_resources.grd
index 9b460e2..5e2a635 100644
--- a/chrome/common/common_resources.grd
+++ b/chrome/common/common_resources.grd
@@ -23,6 +23,7 @@
<include name="IDR_EXTENSION_API_JSON_EXPERIMENTAL_APP" file="extensions\api\experimental.app.json" type="BINDATA" />
<include name="IDR_EXTENSION_API_JSON_EXPERIMENTAL_BOOKMARKMANAGER" file="extensions\api\experimental.bookmarkManager.json" type="BINDATA" />
<include name="IDR_EXTENSION_API_JSON_EXPERIMENTAL_CLEAR" file="extensions\api\experimental.clear.json" type="BINDATA" />
+ <include name="IDR_EXTENSION_API_JSON_EXPERIMENTAL_DECLARATIVE" file="extensions\api\experimental.declarative.json" type="BINDATA" />
<include name="IDR_EXTENSION_API_JSON_EXPERIMENTAL_DNS" file="extensions\api\experimental.dns.json" type="BINDATA" />
<include name="IDR_EXTENSION_API_JSON_EXPERIMENTAL_DOWNLOADS" file="extensions\api\experimental.downloads.json" type="BINDATA" />
<include name="IDR_EXTENSION_API_JSON_EXPERIMENTAL_EXTENSIONS" file="extensions\api\experimental.extension.json" type="BINDATA" />
diff --git a/chrome/common/extensions/api/experimental.declarative.json b/chrome/common/extensions/api/experimental.declarative.json
new file mode 100644
index 0000000..f8e315b
--- /dev/null
+++ b/chrome/common/extensions/api/experimental.declarative.json
@@ -0,0 +1,128 @@
+[
+ {
+ "namespace": "experimental.declarative",
+ "nodoc": true,
+ "types": [
+ {
+ "id": "Rule",
+ "type": "object",
+ "description": "Description of a declarative rule for handling events.",
+ "properties": {
+ "id": {
+ "type": "string",
+ "optional": true,
+ "description": "Optional identifier that allows referencing this rule."
+ },
+ "conditions": {
+ "type": "array",
+ "items": {"type": "any"},
+ "description": "List of conditions that can trigger the actions."
+ },
+ "actions": {
+ "type": "array",
+ "items": {"type": "any"},
+ "description": "List of actions that are triggered if one of the condtions is fulfilled."
+ },
+ "priority": {
+ "type": "integer",
+ "optional": true,
+ "description": "Optional priority of this rule. Defaults to 100."
+ }
+ }
+ }
+ ],
+ "functions": [
+ {
+ "name": "addRules",
+ "type": "function",
+ "description": "Registers rules to handle events.",
+ "parameters": [
+ {
+ "name": "event",
+ "type": "string",
+ "description": "Name of the event this function affects."
+ },
+ {
+ "name": "rules",
+ "type": "array",
+ "items": {"$ref": "Rule"},
+ "description": "Rules to be registered. These do not replace previously registered rules."
+ },
+ {
+ "name": "callback",
+ "optional": true,
+ "type": "function",
+ "parameters": [
+ {
+ "name": "rules",
+ "type": "array",
+ "items": {"$ref": "Rule"},
+ "description": "Rules that were registered, the optional parameters are filled with values."
+ }
+ ],
+ "description": "Called with registered rules."
+ }
+ ]
+ },
+ {
+ "name": "getRules",
+ "type": "function",
+ "description": "Returns currently registered rules.",
+ "parameters": [
+ {
+ "name": "event",
+ "type": "string",
+ "description": "Name of the event this function affects."
+ },
+ {
+ "name": "ruleIdentifiers",
+ "optional": "true",
+ "type": "array",
+ "items": {"type": "string"},
+ "description": "If an array is passed, only rules with identifiers contained in this array are returned."
+ },
+ {
+ "name": "callback",
+ "type": "function",
+ "parameters": [
+ {
+ "name": "rules",
+ "type": "array",
+ "items": {"$ref": "Rule"},
+ "description": "Rules that were registered, the optional parameters are filled with values."
+ }
+ ],
+ "description": "Called with registered rules."
+ }
+ ]
+ },
+ {
+ "name": "removeRules",
+ "type": "function",
+ "description": "Unregisters currently registered rules.",
+ "parameters": [
+ {
+ "name": "event",
+ "type": "string",
+ "description": "Name of the event this function affects."
+ },
+ {
+ "name": "ruleIdentifiers",
+ "optional": "true",
+ "type": "array",
+ "items": {"type": "string"},
+ "description": "If an array is passed, only rules with identifiers contained in this array are unregistered."
+ },
+ {
+ "name": "callback",
+ "optional": true,
+ "type": "function",
+ "parameters": [],
+ "description": "Called when rules were unregistered."
+ }
+ ]
+ }
+ ]
+ }
+]
+
diff --git a/chrome/common/extensions/api/extension_api.cc b/chrome/common/extensions/api/extension_api.cc
index 226a8b9..df5de4a 100644
--- a/chrome/common/extensions/api/extension_api.cc
+++ b/chrome/common/extensions/api/extension_api.cc
@@ -88,6 +88,7 @@ ExtensionAPI::ExtensionAPI() {
IDR_EXTENSION_API_JSON_EXPERIMENTAL_APP,
IDR_EXTENSION_API_JSON_EXPERIMENTAL_BOOKMARKMANAGER,
IDR_EXTENSION_API_JSON_EXPERIMENTAL_CLEAR,
+ IDR_EXTENSION_API_JSON_EXPERIMENTAL_DECLARATIVE,
IDR_EXTENSION_API_JSON_EXPERIMENTAL_DNS,
IDR_EXTENSION_API_JSON_EXPERIMENTAL_DOWNLOADS,
IDR_EXTENSION_API_JSON_EXPERIMENTAL_EXTENSIONS,
diff --git a/chrome/common/extensions/api/webRequest.json b/chrome/common/extensions/api/webRequest.json
index 40ac446..52e007f9 100644
--- a/chrome/common/extensions/api/webRequest.json
+++ b/chrome/common/extensions/api/webRequest.json
@@ -75,6 +75,38 @@
}
}
}
+ },
+ {
+ "nodoc": true,
+ "id": "RequestMatcher",
+ "type": "object",
+ "description": "Matches network events by various criteria. Experimental junk, do not use!",
+ "properties": {
+ "url": {
+ "type": "string",
+ "description": "Matches for a full URL",
+ "optional": true
+ },
+ "filterType": { "type": "string", "enum": ["net.RequestMatcher"] }
+ }
+ },
+ {
+ "nodoc": true,
+ "id": "CancelRequest",
+ "description": "Declarative event action that cancels a network request. Experimental junk, do not use!",
+ "type": "object",
+ "properties": {
+ "actionType": { "type": "string", "enum": ["net.CancelRequest"] }
+ }
+ },
+ {
+ "nodoc": true,
+ "id": "ModifyRequest",
+ "description": "Declarative event action that modifies a network request. Experimental junk, do not use!",
+ "type": "object",
+ "properties": {
+ "actionType": { "type": "string", "enum": ["net.ModifyRequest"] }
+ }
}
],
"functions": [
@@ -518,6 +550,16 @@
"description": "A set of filters that restricts the events that will be sent to this listener."
}
]
+ },
+ {
+ "name": "onRequest",
+ "nodoc": true,
+ "options": {
+ "supportsListeners": false,
+ "supportsRules": true,
+ "conditions": ["RequestMatcher"],
+ "actions": ["CancelRequest", "ModifyRequest"]
+ }
}
]
}
diff --git a/chrome/common/extensions/docs/samples.json b/chrome/common/extensions/docs/samples.json
index de39af7..3afdde7 100644
--- a/chrome/common/extensions/docs/samples.json
+++ b/chrome/common/extensions/docs/samples.json
@@ -68,7 +68,6 @@
"chrome.experimental.devtools.console.addMessage": "experimental.devtools.console.html#method-addMessage",
"chrome.experimental.devtools.console.getMessages": "experimental.devtools.console.html#method-getMessages",
"chrome.experimental.devtools.console.onMessageAdded": "experimental.devtools.console.html#event-onMessageAdded",
- "chrome.experimental.extension.onInstalled": "experimental.extension.html#event-onInstalled",
"chrome.experimental.infobars.show": "experimental.infobars.html#method-show",
"chrome.experimental.speechInput.isRecording": "experimental.speechInput.html#method-isRecording",
"chrome.experimental.speechInput.onError": "experimental.speechInput.html#event-onError",
diff --git a/chrome/common/extensions/docs/template/api_template.html b/chrome/common/extensions/docs/template/api_template.html
index 8fa2e44..e4144a4 100644
--- a/chrome/common/extensions/docs/template/api_template.html
+++ b/chrome/common/extensions/docs/template/api_template.html
@@ -149,7 +149,8 @@
<li id="typesTocTemplate" jsdisplay="types && types.length > 0">
<a href="#types">Types</a>
<ol>
- <li jsselect="types.sort(sortByName)">
+ <li jsselect="types.sort(sortByName)"
+ jsdisplay="!($this.nodoc)">
<a jscontent="id"
jsvalues=".href:'#type-' + id"
href="#id-anchor">id</a>
@@ -514,7 +515,8 @@
<h3 id="types">Types</h3>
<!-- iterates over all types -->
- <div jsselect="types.sort(sortByName)" class="apiItem">
+ <div jsselect="types.sort(sortByName)" jsdisplay="!($this.nodoc)"
+ class="apiItem">
<a jsvalues=".name:'type-' + id"></a>
<h4 jscontent="id">type name</h4>