summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbattre@chromium.org <battre@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-16 12:35:46 +0000
committerbattre@chromium.org <battre@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-16 12:35:46 +0000
commit8351d697de7c2f1f96a568ded049376538689516 (patch)
treef612d2ef4c68732276d42c4a98a50e10e218b850
parentc1fa6fab56f3009b6672b87cb051edd4136d95d2 (diff)
downloadchromium_src-8351d697de7c2f1f96a568ded049376538689516.zip
chromium_src-8351d697de7c2f1f96a568ded049376538689516.tar.gz
chromium_src-8351d697de7c2f1f96a568ded049376538689516.tar.bz2
Move declarative API into events API
The motivation of this CL is to bring the declarative API and the rest of the events mechanism closer together in the API documentation. To achive this, we move the content of declarative.json and everything related to events from extension.json into the events.json API definition. The new "events" namespace is automatically provided to all extensions. This is a second attempt after http://src.chromium.org/viewvc/chrome?view=rev&revision=137388 failed in ExecuteScriptApiTest.ExecuteScriptInFrame. TBR'ing as this is a tiny change from the previous CL. BUG=126497,112155 TEST=no TBR=aa@chromium.org, kalman@chromium.org Review URL: https://chromiumcodereview.appspot.com/10392127 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@137406 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/extensions/api/declarative/declarative_api.cc10
-rw-r--r--chrome/browser/extensions/api/declarative/declarative_api.h6
-rw-r--r--chrome/browser/extensions/api/declarative/rules_registry.h4
-rw-r--r--chrome/browser/extensions/api/declarative_webrequest/webrequest_action.h2
-rw-r--r--chrome/browser/extensions/api/declarative_webrequest/webrequest_condition_attribute.h2
-rw-r--r--chrome/chrome_renderer.gypi2
-rw-r--r--chrome/common/extensions/api/_permission_features.json6
-rw-r--r--chrome/common/extensions/api/api.gyp2
-rw-r--r--chrome/common/extensions/api/declarative_web_request.json2
-rw-r--r--chrome/common/extensions/api/events.json (renamed from chrome/common/extensions/api/declarative.json)205
-rw-r--r--chrome/common/extensions/api/extension.json18
-rw-r--r--chrome/common/extensions/api/extension_api.cc4
-rw-r--r--chrome/common/extensions/docs/api_index.html2
-rw-r--r--chrome/common/extensions/docs/declarative.html1314
-rw-r--r--chrome/common/extensions/docs/declarativeWebRequest.html6
-rw-r--r--chrome/common/extensions/docs/events.html1164
-rw-r--r--chrome/common/extensions/docs/extension.html137
-rw-r--r--chrome/common/extensions/docs/js/api_page_generator.js2
-rw-r--r--chrome/common/extensions/docs/samples.html4
-rw-r--r--chrome/common/extensions/docs/samples.json10
-rw-r--r--chrome/common/extensions/docs/static/declarative.html140
-rw-r--r--chrome/common/extensions/docs/static/declarativeWebRequest.html4
-rw-r--r--chrome/common/extensions/docs/static/events.html122
-rw-r--r--chrome/common/extensions/extension_permission_set.cc1
-rw-r--r--chrome/common/extensions_api_resources.grd2
-rw-r--r--chrome/renderer/extensions/api_definitions_natives.cc29
-rw-r--r--chrome/renderer/extensions/api_definitions_natives.h5
-rw-r--r--chrome/renderer/extensions/event_unittest.cc5
-rw-r--r--chrome/renderer/extensions/extension_dispatcher.cc3
-rw-r--r--chrome/renderer/renderer_resources.grd2
-rw-r--r--chrome/renderer/resources/extensions/declarative_custom_bindings.js76
-rw-r--r--chrome/renderer/resources/extensions/declarative_webrequest_custom_bindings.js10
-rw-r--r--chrome/renderer/resources/extensions/event.js112
-rw-r--r--chrome/renderer/resources/extensions/schema_generated_bindings.js13
-rw-r--r--chrome/renderer/resources/extensions/utils.js29
-rw-r--r--chrome/renderer/resources/extensions/web_request_custom_bindings.js3
-rw-r--r--chrome/test/data/extensions/api_test/declarative/api/manifest.json2
-rw-r--r--chrome/test/data/extensions/api_test/webrequest/manifest.json2
-rw-r--r--tools/json_schema_compiler/cc_generator.py6
-rw-r--r--tools/json_schema_compiler/h_generator.py6
40 files changed, 1592 insertions, 1882 deletions
diff --git a/chrome/browser/extensions/api/declarative/declarative_api.cc b/chrome/browser/extensions/api/declarative/declarative_api.cc
index 37105c2..3606972 100644
--- a/chrome/browser/extensions/api/declarative/declarative_api.cc
+++ b/chrome/browser/extensions/api/declarative/declarative_api.cc
@@ -11,14 +11,14 @@
#include "chrome/browser/extensions/api/declarative/rules_registry_service.h"
#include "chrome/browser/extensions/extension_system_factory.h"
#include "chrome/browser/profiles/profile.h"
-#include "chrome/common/extensions/api/declarative.h"
+#include "chrome/common/extensions/api/events.h"
#include "content/public/browser/browser_thread.h"
-using extensions::api::declarative::Rule;
+using extensions::api::events::Rule;
-namespace AddRules = extensions::api::declarative::AddRules;
-namespace GetRules = extensions::api::declarative::GetRules;
-namespace RemoveRules = extensions::api::declarative::RemoveRules;
+namespace AddRules = extensions::api::events::Event::AddRules;
+namespace GetRules = extensions::api::events::Event::GetRules;
+namespace RemoveRules = extensions::api::events::Event::RemoveRules;
namespace {
diff --git a/chrome/browser/extensions/api/declarative/declarative_api.h b/chrome/browser/extensions/api/declarative/declarative_api.h
index 00389b8..175dd0f 100644
--- a/chrome/browser/extensions/api/declarative/declarative_api.h
+++ b/chrome/browser/extensions/api/declarative/declarative_api.h
@@ -33,7 +33,7 @@ class RulesFunction : public AsyncExtensionFunction {
class AddRulesFunction : public RulesFunction {
public:
- DECLARE_EXTENSION_FUNCTION_NAME("declarative.addRules");
+ DECLARE_EXTENSION_FUNCTION_NAME("events.addRules");
protected:
virtual ~AddRulesFunction() {}
@@ -44,7 +44,7 @@ class AddRulesFunction : public RulesFunction {
class RemoveRulesFunction : public RulesFunction {
public:
- DECLARE_EXTENSION_FUNCTION_NAME("declarative.removeRules");
+ DECLARE_EXTENSION_FUNCTION_NAME("events.removeRules");
protected:
virtual ~RemoveRulesFunction() {}
@@ -55,7 +55,7 @@ class RemoveRulesFunction : public RulesFunction {
class GetRulesFunction : public RulesFunction {
public:
- DECLARE_EXTENSION_FUNCTION_NAME("declarative.getRules");
+ DECLARE_EXTENSION_FUNCTION_NAME("events.getRules");
protected:
virtual ~GetRulesFunction() {}
diff --git a/chrome/browser/extensions/api/declarative/rules_registry.h b/chrome/browser/extensions/api/declarative/rules_registry.h
index 0ca4d80..9d515e5 100644
--- a/chrome/browser/extensions/api/declarative/rules_registry.h
+++ b/chrome/browser/extensions/api/declarative/rules_registry.h
@@ -11,7 +11,7 @@
#include "base/memory/linked_ptr.h"
#include "base/memory/ref_counted.h"
-#include "chrome/common/extensions/api/declarative.h"
+#include "chrome/common/extensions/api/events.h"
#include "content/public/browser/browser_thread.h"
namespace base {
@@ -37,7 +37,7 @@ class RulesRegistry
: public base::RefCountedThreadSafe<RulesRegistry,
RulesRegistryDeleteTraits> {
public:
- typedef extensions::api::declarative::Rule Rule;
+ typedef extensions::api::events::Rule Rule;
// Registers |rules|, owned by |extension_id| to this RulesRegistry.
// If a concrete RuleRegistry does not support some of the rules,
diff --git a/chrome/browser/extensions/api/declarative_webrequest/webrequest_action.h b/chrome/browser/extensions/api/declarative_webrequest/webrequest_action.h
index 9fb90f6..973a60e 100644
--- a/chrome/browser/extensions/api/declarative_webrequest/webrequest_action.h
+++ b/chrome/browser/extensions/api/declarative_webrequest/webrequest_action.h
@@ -13,7 +13,7 @@
#include "base/compiler_specific.h"
#include "base/memory/linked_ptr.h"
#include "chrome/browser/extensions/api/declarative_webrequest/request_stages.h"
-#include "chrome/common/extensions/api/declarative.h"
+#include "chrome/common/extensions/api/events.h"
#include "googleurl/src/gurl.h"
namespace base {
diff --git a/chrome/browser/extensions/api/declarative_webrequest/webrequest_condition_attribute.h b/chrome/browser/extensions/api/declarative_webrequest/webrequest_condition_attribute.h
index bfaa72f..09da168 100644
--- a/chrome/browser/extensions/api/declarative_webrequest/webrequest_condition_attribute.h
+++ b/chrome/browser/extensions/api/declarative_webrequest/webrequest_condition_attribute.h
@@ -13,7 +13,7 @@
#include "base/memory/linked_ptr.h"
#include "base/memory/scoped_ptr.h"
#include "chrome/browser/extensions/api/declarative_webrequest/request_stages.h"
-#include "chrome/common/extensions/api/declarative.h"
+#include "chrome/common/extensions/api/events.h"
#include "webkit/glue/resource_type.h"
namespace base {
diff --git a/chrome/chrome_renderer.gypi b/chrome/chrome_renderer.gypi
index 7d7aa33..163dc9d 100644
--- a/chrome/chrome_renderer.gypi
+++ b/chrome/chrome_renderer.gypi
@@ -141,7 +141,6 @@
'renderer/resources/extensions/app_custom_bindings.js',
'renderer/resources/extensions/browser_action_custom_bindings.js',
'renderer/resources/extensions/context_menus_custom_bindings.js',
- 'renderer/resources/extensions/declarative_custom_bindings.js',
'renderer/resources/extensions/declarative_webrequest_custom_bindings.js',
'renderer/resources/extensions/devtools_custom_bindings.js',
'renderer/resources/extensions/event.js',
@@ -165,6 +164,7 @@
'renderer/resources/extensions/tts_custom_bindings.js',
'renderer/resources/extensions/tts_engine_custom_bindings.js',
'renderer/resources/extensions/types_custom_bindings.js',
+ 'renderer/resources/extensions/utils.js',
'renderer/resources/extensions/web_request_custom_bindings.js',
'renderer/chrome_content_renderer_client.cc',
'renderer/chrome_content_renderer_client.h',
diff --git a/chrome/common/extensions/api/_permission_features.json b/chrome/common/extensions/api/_permission_features.json
index 4ecd3b4..4b0ce89 100644
--- a/chrome/common/extensions/api/_permission_features.json
+++ b/chrome/common/extensions/api/_permission_features.json
@@ -78,12 +78,6 @@
"channel": "stable",
"extension_types": ["extension", "packaged_app", "platform_app"]
},
- // TODO(battre): Remove "declarative" permission when APIs can be set to
- // dev-only, without having to have a permission. See: crbug.com/120069.
- "declarative": {
- "channel": "dev",
- "extension_types": ["extension", "packaged_app"]
- },
"declarativeWebRequest": {
"channel": "dev",
"extension_types": ["extension", "packaged_app"]
diff --git a/chrome/common/extensions/api/api.gyp b/chrome/common/extensions/api/api.gyp
index 183e55f..5df15e4 100644
--- a/chrome/common/extensions/api/api.gyp
+++ b/chrome/common/extensions/api/api.gyp
@@ -18,7 +18,7 @@
'variables': {
'chromium_code': 1,
'json_schema_files': [
- 'declarative.json',
+ 'events.json',
'experimental_record.json',
'permissions.json',
'storage.json',
diff --git a/chrome/common/extensions/api/declarative_web_request.json b/chrome/common/extensions/api/declarative_web_request.json
index c3d19dd..ea05f2d 100644
--- a/chrome/common/extensions/api/declarative_web_request.json
+++ b/chrome/common/extensions/api/declarative_web_request.json
@@ -13,7 +13,7 @@
"description": "Matches network events by various criteria.",
"properties": {
"url": {
- "$ref": "declarative.UrlFilter",
+ "$ref": "events.UrlFilter",
"description": "Matches if the condition of the UrlFilter are fulfilled for the URL of the request.",
"optional": true
},
diff --git a/chrome/common/extensions/api/declarative.json b/chrome/common/extensions/api/events.json
index bf5ab508..9eac5a2 100644
--- a/chrome/common/extensions/api/declarative.json
+++ b/chrome/common/extensions/api/events.json
@@ -4,11 +4,117 @@
[
{
- "namespace": "declarative",
+ "namespace": "events",
"internal": true,
- "documentation_permissions_required": ["declarative"],
+ "unprivileged": true,
"types": [
{
+ "id": "Event",
+ "type": "object",
+ "description": "An object which allows the addition and removal of listeners for a Chrome event.",
+ "additionalProperties": { "type": "any"},
+ "functions": [
+ // TODO(battre): Add correct signatures.
+ { "name": "addListener", "type": "function", "parameters": [] },
+ { "name": "removeListener", "type": "function", "parameters": [] },
+ { "name": "hasListener", "type": "function", "parameters": [] },
+ { "name": "hasListeners", "type": "function", "parameters": [] },
+ {
+ "name": "addRules",
+ "type": "function",
+ "description": "Registers rules to handle events. Note that you cannot call this function as <code>chrome.declarative.addRules(...)</code>. Instead a function of this signature is provided for event objects supporting the declarative API such as <code>chrome.declarativeWebRequest.onRequest</code>.",
+ "parameters": [
+ {
+ "nodoc": "true",
+ "name": "eventName",
+ "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. Note that you cannot call this function as <code>chrome.declarative.getRules(...)</code>. Instead a function of this signature is provided for event objects supporting the declarative API such as <code>chrome.declarativeWebRequest.onRequest</code>.",
+ "parameters": [
+ {
+ "nodoc": "true",
+ "name": "eventName",
+ "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. Note that you cannot call this function as <code>chrome.declarative.removeRules(...)</code>. Instead a function of this signature is provided for event objects supporting the declarative API such as <code>chrome.declarativeWebRequest.onRequest</code>.",
+ "parameters": [
+ {
+ "nodoc": "true",
+ "name": "eventName",
+ "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."
+ }
+ ]
+ }
+ ]
+ },
+ {
"id": "Rule",
"type": "object",
"description": "Description of a declarative rule for handling events.",
@@ -135,101 +241,6 @@
}
}
}
- ],
- "functions": [
- {
- "name": "addRules",
- "type": "function",
- "description": "Registers rules to handle events. Note that you cannot call this function as <code>chrome.declarative.addRules(...)</code>. Instead a function of this signature is provided for event objects supporting the declarative API such as <code>chrome.declarativeWebRequest.onRequest</code>.",
- "parameters": [
- {
- "nodoc": "true",
- "name": "eventName",
- "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. Note that you cannot call this function as <code>chrome.declarative.getRules(...)</code>. Instead a function of this signature is provided for event objects supporting the declarative API such as <code>chrome.declarativeWebRequest.onRequest</code>.",
- "parameters": [
- {
- "nodoc": "true",
- "name": "eventName",
- "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. Note that you cannot call this function as <code>chrome.declarative.removeRules(...)</code>. Instead a function of this signature is provided for event objects supporting the declarative API such as <code>chrome.declarativeWebRequest.onRequest</code>.",
- "parameters": [
- {
- "nodoc": "true",
- "name": "eventName",
- "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.json b/chrome/common/extensions/api/extension.json
index 1e735ad..4c8b859 100644
--- a/chrome/common/extensions/api/extension.json
+++ b/chrome/common/extensions/api/extension.json
@@ -6,7 +6,7 @@
{
"namespace": "extension",
"nocompile": true,
- "dependencies": [ "tabs" ],
+ "dependencies": [ "events", "tabs" ],
"types": [
{
"id": "MessageSender",
@@ -18,25 +18,13 @@
}
},
{
- "id": "Event",
- "type": "object",
- "description": "An object which allows the addition and removal of listeners for a Chrome event.",
- "properties": {
- "addListener": {"type": "function"},
- "removeListener": {"type": "function"},
- "hasListener": {"type": "function"},
- "hasListeners": {"type": "function"}
- },
- "additionalProperties": { "type": "any"}
- },
- {
"id": "Port",
"type": "object",
"description": "An object which allows two way communication with other pages.",
"properties": {
"name": {"type": "string"},
- "onDisconnect": { "$ref": "Event" },
- "onMessage": { "$ref": "Event" },
+ "onDisconnect": { "$ref": "events.Event" },
+ "onMessage": { "$ref": "events.Event" },
"postMessage": {"type": "function"},
"sender": {
"$ref": "MessageSender",
diff --git a/chrome/common/extensions/api/extension_api.cc b/chrome/common/extensions/api/extension_api.cc
index 834e94b..6e16ab5 100644
--- a/chrome/common/extensions/api/extension_api.cc
+++ b/chrome/common/extensions/api/extension_api.cc
@@ -345,12 +345,12 @@ void ExtensionAPI::InitDefaultConfiguration() {
IDR_EXTENSION_API_JSON_COOKIES));
RegisterSchema("debugger", ReadFromResource(
IDR_EXTENSION_API_JSON_DEBUGGER));
- RegisterSchema("declarative", ReadFromResource(
- IDR_EXTENSION_API_JSON_DECLARATIVE));
RegisterSchema("declarativeWebRequest", ReadFromResource(
IDR_EXTENSION_API_JSON_DECLARATIVE_WEBREQUEST));
RegisterSchema("devtools", ReadFromResource(
IDR_EXTENSION_API_JSON_DEVTOOLS));
+ RegisterSchema("events", ReadFromResource(
+ IDR_EXTENSION_API_JSON_EVENTS));
RegisterSchema("experimental.accessibility", ReadFromResource(
IDR_EXTENSION_API_JSON_EXPERIMENTAL_ACCESSIBILITY));
RegisterSchema("experimental.app", ReadFromResource(
diff --git a/chrome/common/extensions/docs/api_index.html b/chrome/common/extensions/docs/api_index.html
index 098b48d..b0c1118 100644
--- a/chrome/common/extensions/docs/api_index.html
+++ b/chrome/common/extensions/docs/api_index.html
@@ -221,7 +221,7 @@ so that extensions can interact with the browser.
Here are the supported chrome.* APIs:
</p>
<ul>
- <li><a href="alarms.html" js="">alarms</a></li><li><a href="bookmarks.html" js="">bookmarks</a></li><li><a href="browserAction.html" js="">browserAction</a></li><li><a href="browsingData.html" js="">browsingData</a></li><li><a href="contentSettings.html" js="">contentSettings</a></li><li><a href="contextMenus.html" js="">contextMenus</a></li><li><a href="cookies.html" js="">cookies</a></li><li><a href="debugger.html" js="">debugger</a></li><li><a href="declarative.html" js="">declarative</a></li><li><a href="declarativeWebRequest.html" js="">declarativeWebRequest</a></li><li><a href="extension.html" js="">extension</a></li><li><a href="fileBrowserHandler.html" js="">fileBrowserHandler</a></li><li><a href="history.html" js="">history</a></li><li><a href="i18n.html" js="">i18n</a></li><li><a href="idle.html" js="">idle</a></li><li><a href="management.html" js="">management</a></li><li><a href="omnibox.html" js="">omnibox</a></li><li><a href="pageAction.html" js="">pageAction</a></li><li><a href="pageCapture.html" js="">pageCapture</a></li><li><a href="permissions.html" js="">permissions</a></li><li><a href="privacy.html" js="">privacy</a></li><li><a href="proxy.html" js="">proxy</a></li><li><a href="storage.html" js="">storage</a></li><li><a href="tabs.html" js="">tabs</a></li><li><a href="topSites.html" js="">topSites</a></li><li><a href="tts.html" js="">tts</a></li><li><a href="ttsEngine.html" js="">ttsEngine</a></li><li><a href="types.html" js="">types</a></li><li><a href="webNavigation.html" js="">webNavigation</a></li><li><a href="webRequest.html" js="">webRequest</a></li><li><a href="webstore.html" js="">webstore</a></li><li><a href="windows.html" js="">windows</a></li>
+ <li><a href="alarms.html" js="">alarms</a></li><li><a href="bookmarks.html" js="">bookmarks</a></li><li><a href="browserAction.html" js="">browserAction</a></li><li><a href="browsingData.html" js="">browsingData</a></li><li><a href="contentSettings.html" js="">contentSettings</a></li><li><a href="contextMenus.html" js="">contextMenus</a></li><li><a href="cookies.html" js="">cookies</a></li><li><a href="debugger.html" js="">debugger</a></li><li><a href="declarativeWebRequest.html" js="">declarativeWebRequest</a></li><li><a href="events.html" js="">events</a></li><li><a href="extension.html" js="">extension</a></li><li><a href="fileBrowserHandler.html" js="">fileBrowserHandler</a></li><li><a href="history.html" js="">history</a></li><li><a href="i18n.html" js="">i18n</a></li><li><a href="idle.html" js="">idle</a></li><li><a href="management.html" js="">management</a></li><li><a href="omnibox.html" js="">omnibox</a></li><li><a href="pageAction.html" js="">pageAction</a></li><li><a href="pageCapture.html" js="">pageCapture</a></li><li><a href="permissions.html" js="">permissions</a></li><li><a href="privacy.html" js="">privacy</a></li><li><a href="proxy.html" js="">proxy</a></li><li><a href="storage.html" js="">storage</a></li><li><a href="tabs.html" js="">tabs</a></li><li><a href="topSites.html" js="">topSites</a></li><li><a href="tts.html" js="">tts</a></li><li><a href="ttsEngine.html" js="">ttsEngine</a></li><li><a href="types.html" js="">types</a></li><li><a href="webNavigation.html" js="">webNavigation</a></li><li><a href="webRequest.html" js="">webRequest</a></li><li><a href="webstore.html" js="">webstore</a></li><li><a href="windows.html" js="">windows</a></li>
</ul>
<h2 id="experimental">Experimental APIs</h2>
<p>
diff --git a/chrome/common/extensions/docs/declarative.html b/chrome/common/extensions/docs/declarative.html
deleted file mode 100644
index c21a118..0000000
--- a/chrome/common/extensions/docs/declarative.html
+++ /dev/null
@@ -1,1314 +0,0 @@
-<!DOCTYPE html><!-- This page is a placeholder for generated extensions api doc. Note:
- 1) The <head> information in this page is significant, should be uniform
- across api docs and should be edited only with knowledge of the
- templating mechanism.
- 3) All <body>.innerHTML is genereated as an rendering step. If viewed in a
- browser, it will be re-generated from the template, json schema and
- authored overview content.
- 4) The <body>.innerHTML is also generated by an offline step so that this
- page may easily be indexed by search engines.
---><html xmlns="http://www.w3.org/1999/xhtml"><head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
- <link href="css/ApiRefStyles.css" rel="stylesheet" type="text/css">
- <link href="css/print.css" rel="stylesheet" type="text/css" media="print">
- <script type="text/javascript" src="../../../third_party/jstemplate/jstemplate_compiled.js">
- </script>
- <script type="text/javascript" src="../../../../third_party/json_minify/minify-sans-regexp.js">
- </script>
- <script type="text/javascript" src="js/api_page_generator.js"></script>
- <script type="text/javascript" src="js/bootstrap.js"></script>
- <script type="text/javascript" src="js/sidebar.js"></script>
- <meta name="description" content="Documentation for the chrome.declarative module, which is part of the Google Chrome extension APIs."><title>chrome.declarative - Google Chrome Extensions - Google Code</title></head>
- <body> <div id="devModeWarning" class="displayModeWarning">
- You are viewing extension docs in chrome via the 'file:' scheme: are you expecting to see local changes when you refresh? You'll need run chrome with --allow-file-access-from-files.
- </div>
- <div id="branchWarning" class="displayModeWarning">
- <span>WARNING: This is the <span id="branchName">BETA</span> documentation.
- It may not work with the stable release of Chrome.</span>
- <select id="branchChooser">
- <option>Choose a different version...
- </option><option value="">Stable
- </option><option value="beta">Beta
- </option><option value="dev">Dev
- </option><option value="trunk">Trunk
- </option></select>
- </div>
- <div id="unofficialWarning" class="displayModeWarning">
- <span>WARNING: This is unofficial documentation. It may not work with the
- current release of Chrome.</span>
- <button id="goToOfficialDocs">Go to the official docs</button>
- </div>
- <div id="gc-container" class="labs">
- <!-- SUBTEMPLATES: DO NOT MOVE FROM THIS LOCATION -->
- <!-- In particular, sub-templates that recurse, must be used by allowing
- jstemplate to make a copy of the template in this section which
- are not operated on by way of the jsskip="true" -->
- <!-- /SUBTEMPLATES -->
- <a id="top"></a>
- <div id="skipto">
- <a href="#gc-pagecontent">Skip to page content</a>
- <a href="#gc-toc">Skip to main navigation</a>
- </div>
- <!-- API HEADER -->
- <table id="header" width="100%" cellspacing="0" border="0">
- <tbody><tr>
- <td valign="middle"><a href="http://code.google.com/"><img src="images/code_labs_logo.gif" height="43" width="161" alt="Google Code Labs" style="border:0; margin:0;"></a></td>
- <td valign="middle" width="100%" style="padding-left:0.6em;">
- <form action="http://www.google.com/cse" id="cse" style="margin-top:0.5em">
- <div id="gsc-search-box">
- <input type="hidden" name="cx" value="002967670403910741006:61_cvzfqtno">
- <input type="hidden" name="ie" value="UTF-8">
- <input type="text" name="q" value="" size="55">
- <input class="gsc-search-button" type="submit" name="sa" value="Search">
- <br>
- <span class="greytext">e.g. "page action" or "tabs"</span>
- </div>
- </form>
- <script type="text/javascript" src="https://www.google.com/jsapi"></script>
- <script type="text/javascript">google.load("elements", "1", {packages: "transliteration"});</script>
- <script type="text/javascript" src="https://www.google.com/coop/cse/t13n?form=cse&amp;t13n_langs=en"></script>
- <script type="text/javascript" src="https://www.google.com/coop/cse/brand?form=cse&amp;lang=en"></script>
- </td>
- </tr>
- </tbody></table>
- <div id="codesiteContent" class="">
- <a id="gc-topnav-anchor"></a>
- <div id="gc-topnav">
- <h1>Google Chrome Extensions (<a href="http://code.google.com/labs/">Labs</a>)</h1>
- <ul id="home" class="gc-topnav-tabs">
- <li id="home_link">
- <a href="index.html" title="Google Chrome Extensions home page">Home</a>
- </li>
- <li id="docs_link">
- <a href="docs.html" title="Official Google Chrome Extensions documentation">Docs</a>
- </li>
- <li id="faq_link">
- <a href="faq.html" title="Answers to frequently asked questions about Google Chrome Extensions">FAQ</a>
- </li>
- <li id="samples_link">
- <a href="samples.html" title="Sample extensions (with source code)">Samples</a>
- </li>
- <li id="group_link">
- <a href="http://groups.google.com/a/chromium.org/group/chromium-extensions" title="Google Chrome Extensions developer forum">Group</a>
- </li>
- <li id="so_link">
- <a href="http://stackoverflow.com/questions/tagged/google-chrome-extension" title="[google-chrome-extension] tag on Stack Overflow">Questions?</a>
- </li>
- </ul>
- </div> <!-- end gc-topnav -->
- <div class="g-section g-tpl-170">
- <!-- SIDENAV -->
- <div class="g-unit g-first" id="gc-toc">
- <ul>
- <li><a href="getstarted.html">Getting Started</a></li>
- <li><a href="overview.html">Overview</a></li>
- <li><a href="whats_new.html">What's New?</a></li>
- <li><h2><a href="devguide.html">Developer's Guide</a></h2>
- <ul>
- <li>Browser UI
- <ul>
- <li><a href="browserAction.html">Browser Actions</a></li>
- <li><a href="contextMenus.html">Context Menus</a></li>
- <li><a href="notifications.html">Desktop Notifications</a></li>
- <li><a href="omnibox.html">Omnibox</a></li>
- <li><a href="options.html">Options Pages</a></li>
- <li><a href="override.html">Override Pages</a></li>
- <li><a href="pageAction.html">Page Actions</a></li>
- </ul>
- </li>
- <li>Browser Interaction
- <ul>
- <li><a href="bookmarks.html">Bookmarks</a></li>
- <li><a href="cookies.html">Cookies</a></li>
- <li><a href="devtools.html">Developer Tools</a></li>
- <li><a href="events.html">Events</a></li>
- <li><a href="history.html">History</a></li>
- <li><a href="management.html">Management</a></li>
- <li><a href="tabs.html">Tabs</a></li>
- <li><a href="windows.html">Windows</a></li>
- </ul>
- </li>
- <li>Implementation
- <ul>
- <li><a href="a11y.html">Accessibility</a></li>
- <li><a href="background_pages.html">Background Pages</a></li>
- <li><a href="content_scripts.html">Content Scripts</a></li>
- <li><a href="xhr.html">Cross-Origin XHR</a></li>
- <li><a href="i18n.html">Internationalization</a></li>
- <li><a href="messaging.html">Message Passing</a></li>
- <li><a href="permissions.html">Optional Permissions</a></li>
- <li><a href="npapi.html">NPAPI Plugins</a></li>
- </ul>
- </li>
- <li>Finishing
- <ul>
- <li><a href="hosting.html">Hosting</a></li>
- <li><a href="external_extensions.html">Other Deployment Options</a></li>
- </ul>
- </li>
- </ul>
- </li>
- <li><h2><a href="apps.html">Packaged Apps</a></h2></li>
- <li><h2><a href="tutorials.html">Tutorials</a></h2>
- <ul>
- <li><a href="tut_debugging.html">Debugging</a></li>
- <li><a href="tut_analytics.html">Google Analytics</a></li>
- <li><a href="tut_oauth.html">OAuth</a></li>
- </ul>
- </li>
- <li><h2>Reference</h2>
- <ul>
- <li>Formats
- <ul>
- <li><a href="manifest.html">Manifest Files</a></li>
- <li><a href="match_patterns.html">Match Patterns</a></li>
- </ul>
- </li>
- <li><a href="permission_warnings.html">Permission Warnings</a></li>
- <li><a href="api_index.html">chrome.* APIs</a></li>
- <li><a href="api_other.html">Other APIs</a></li>
- </ul>
- </li>
- <li><h2><a href="samples.html">Samples</a></h2></li>
- <div class="line"> </div>
- <li><h2>More</h2>
- <ul>
- <li><a href="http://code.google.com/chrome/webstore/docs/index.html">Chrome Web Store</a></li>
- <li><a href="http://code.google.com/chrome/apps/docs/developers_guide.html">Hosted Apps</a></li>
- <li><a href="themes.html">Themes</a></li>
- </ul>
- </li>
- </ul>
- </div>
- <script>
- initToggles();
- </script>
- <div class="g-unit" id="gc-pagecontent">
- <div id="pageTitle">
- <h1 class="page_title">chrome.declarative</h1>
- </div>
- <!-- TABLE OF CONTENTS -->
- <div id="toc">
- <h2>Contents</h2>
- <ol>
- <li>
- <a href="#notes">Notes</a>
- <ol>
- </ol>
- </li><li>
- <a href="#manifest">Manifest</a>
- <ol>
- </ol>
- </li><li>
- <a href="#rules">Rules</a>
- <ol>
- </ol>
- </li><li>
- <a href="#eventobjects">Event objects</a>
- <ol>
- <li>
- <a href="#addingrules">Adding rules</a>
- </li><li>
- <a href="#removingrules">Removing rules</a>
- </li><li>
- <a href="#retrievingrules">Retrieving rules</a>
- </li>
- </ol>
- </li>
- <li>
- <a href="#apiReference">API reference: chrome.declarative</a>
- <ol>
- <li>
- <a href="#global-methods">Methods</a>
- <ol>
- <li>
- <a href="#method-addRules">addRules</a>
- </li><li>
- <a href="#method-getRules">getRules</a>
- </li><li>
- <a href="#method-removeRules">removeRules</a>
- </li>
- </ol>
- </li>
- <li>
- <a href="#types">Types</a>
- <ol>
- <li>
- <a href="#type-Rule">Rule</a>
- <ol>
- </ol>
- </li><li>
- <a href="#type-UrlFilter">UrlFilter</a>
- <ol>
- </ol>
- </li>
- </ol>
- </li>
- </ol>
- </li>
- </ol>
- </div>
- <!-- /TABLE OF CONTENTS -->
- <!-- Standard content lead-in for experimental API pages -->
- <p class="warning">
- <!-- Standard content lead-in for APIs that are not yet available on
- the stable channel. -->
- <em>Warning:</em> This API is still under development. It is only
- available for Chrome users on the
- <span>
- <strong>dev</strong>
- <a href="http://www.chromium.org/getting-involved/dev-channel">early
- release channel</a>.</span>
- <a href="TODO">Learn more</a>.
- </p>
- <!-- STATIC CONTENT PLACEHOLDER -->
- <div id="static"><!-- BEGIN AUTHORED CONTENT -->
-<h2 id="notes">Notes</h2>
-<p>
-The Declarative API is a framework to define rules consisting of declarative
-conditions and actions. Conditions are evaluated in the browser rather than the
-JavaScript engine which reduces roundtrip latencies and allows for very high
-efficiency.
-</p>
-<p></p>The Declarative API is an abstract foundation for the <a href="declarativeWebRequest.html">Declarative Web Request API</a> and
-possibly further extension APIs in the future. This page describes the
-underlying concepts of all Declarative APIs.
-<p></p>
-<h2 id="manifest">Manifest</h2>
-<p>
-You must declare the "declarative" permission in your extension's manifest
-to use APIs that are based on this API.
-</p>
-<pre>{
- "name": "My extension",
- ...
-<b> "permissions": [
- "declarative",
- ]</b>,
- ...
-}</pre>
-<h2 id="rules">Rules</h2>
-<p>The simplest possible rule consists of one or more conditions and one or more
-actions:</p>
-<pre>var rule = {
- conditions: [ /* my conditions */ ],
- actions: [ /* my actions */ ]
-};
-</pre>
-<p>If any of the conditions is fulfilled, all actions are executed.</p>
-<p>In addition to conditions and actions you may give each rule an identifier,
-which simplifies unregistering previously registered rules, and a priority to
-define precedences among rules. Priorities are only considered if rules conflict
-each other or need to be executed in a specific order.</p>
-<pre>var rule = {
- id: "my rule", // optional, will be generated if not set.
- priority: 100, // optional, defaults to 100.
- conditions: [ /* my conditions */ ],
- actions: [ /* my actions */ ]
-};
-</pre>
-<h2 id="eventobjects">Event objects</h2>
-<p>
-<a href="events.html">Event objects</a> may support rules. These event objects
-don't call a callback function when events happer but test whether any
-registered rule has at least one fulfilled condition and execute the actions
-associated with this rule. Event objects supporting the declarative API have
-three relevant methods: <a href="#method-addRules"><code>addRules()</code></a>,
-<a href="#method-removeRules"><code>removeRules()</code></a>, and
-<a href="#method-getRules"><code>getRules()</code></a>.
-</p>
-<h3 id="addingrules">Adding rules</h3>
-<p>
-To add rules call the <code>addRules()</code> function of the event object. It
-takes an array of rule instances as its first parameter and a callback function
-that is called on completion.
-</p>
-<pre>var rule_list = [rule1, rule2, ...];
-function addRules(rule_list, function callback(details) {...});
-</pre>
-<p>
-If the rules were inserted successfully, the <code>details</code> parameter
-contains an array of inserted rules appearing in the same order as in the passed
-<code>rule_list</code> where the optional parameters <code>id</code> and
-<code>priority</code> were filled with the generated values. If any rule is
-invalid, e.g., because it contained an invalid condition or action, none of the
-rules are added and the <a href="extension.html#property-lastError">lastError</a> variable is set when
-the callback function is called. Each rule in <code>rule_list</code> must
-contain a unique identifier that is not currently used by another rule or an
-empty identifier.
-</p>
-<h3 id="removingrules">Removing rules</h3>
-<p>
-To remove rules call the <code>removeRules()</code> function. It accepts an
-optional array of rule identifiers as its first parameter and a callback
-function as its second parameter.
-</p>
-<pre>var rule_ids = ["id1", "id2", ...];
-function removeRules(rule_ids, function callback() {...});
-</pre>
-<p>
-If <code>rule_ids</code> is an array of identifiers, all rules having
-identifiers listed in the array are removed. If <code>rule_ids</code> lists an
-identifier, that is unknown, this identifier is silently ignored. If
-<code>rule_ids</code> is <code>undefined</code>, all registered rules of this
-extension are removed. The <code>callback()</code> function is called when the
-rules were removed.
-</p>
-<h3 id="retrievingrules">Retrieving rules</h3>
-<p>
-To retrieve a list of currently registered rules, call the
-<code>getRules()</code> function. It accepts an optional array of rule
-identifiers with the same semantics as <code>removeRules</code> and a callback
-function.
-</p><p>
-</p><pre>var rule_ids = ["id1", "id2", ...];
-function getRules(rule_ids, function callback(details) {...});
-</pre>
-<p>
-The <code>details</code> parameter passed to the <code>calback()</code> function
-refers to an array of rules including filled optional parameters.
-</p>
-<!-- END AUTHORED CONTENT -->
-</div>
- <!-- API PAGE -->
- <div class="apiPage">
- <a name="apiReference"></a>
- <h2>API reference: chrome.declarative</h2>
- <!-- PROPERTIES -->
- <!-- /apiGroup -->
- <!-- METHODS -->
- <div id="methodsTemplate" class="apiGroup">
- <a name="global-methods"></a>
- <h3>Methods</h3>
- <!-- iterates over all functions -->
- <div class="apiItem">
- <a name="method-addRules"></a> <!-- method-anchor -->
- <h4>addRules</h4>
- <div class="summary">
- <!-- Note: intentionally longer 80 columns -->
- <span>chrome.declarative.addRules</span>(<span class="null"><span>array of Rule</span>
- <var><span>rules</span></var></span><span class="optional"><span>, </span><span>function</span>
- <var><span>callback</span></var></span>)</div>
- <div class="description">
- <p>Registers rules to handle events. Note that you cannot call this function as <code>chrome.declarative.addRules(...)</code>. Instead a function of this signature is provided for event objects supporting the declarative API such as <code>chrome.declarativeWebRequest.onRequest</code>.</p>
- <!-- PARAMETERS -->
- <h4>Parameters</h4>
- <dl>
- <div>
- <div>
- <dt>
- <var>rules</var>
- <em>
- <!-- TYPE -->
- <div style="display:inline">
- (
- <span id="typeTemplate">
- <span>
- <span>
- array of <span><span>
- <span>
- <a href="declarative.html#type-Rule">Rule</a>
- </span>
- </span></span>
- </span>
- </span>
- </span>
- )
- </div>
- </em>
- </dt>
- <dd>Rules to be registered. These do not replace previously registered rules.</dd>
- <!-- OBJECT PROPERTIES -->
- <!-- OBJECT METHODS -->
- <!-- OBJECT EVENT FIELDS -->
- <!-- FUNCTION PARAMETERS -->
- </div>
- </div><div>
- <div>
- <dt>
- <var>callback</var>
- <em>
- <!-- TYPE -->
- <div style="display:inline">
- (
- <span class="optional">optional</span>
- <span id="typeTemplate">
- <span>
- <span>function</span>
- </span>
- </span>
- )
- </div>
- </em>
- </dt>
- <dd>Called with registered rules.</dd>
- <!-- OBJECT PROPERTIES -->
- <!-- OBJECT METHODS -->
- <!-- OBJECT EVENT FIELDS -->
- <!-- FUNCTION PARAMETERS -->
- </div>
- </div>
- </dl>
- <!-- RETURNS -->
- <dl>
- </dl>
- <!-- CALLBACK -->
- <div>
- <div>
- <h4>Callback function</h4>
- <p>
- If you specify the <em>callback</em> parameter, it should
- specify a function that looks like this:
- </p>
- <!-- Note: intentionally longer 80 columns -->
- <pre>function(<span>array of Rule rules</span>) <span class="subdued">{...}</span>;</pre>
- <dl>
- <div>
- <div>
- <dt>
- <var>rules</var>
- <em>
- <!-- TYPE -->
- <div style="display:inline">
- (
- <span id="typeTemplate">
- <span>
- <span>
- array of <span><span>
- <span>
- <a href="declarative.html#type-Rule">Rule</a>
- </span>
- </span></span>
- </span>
- </span>
- </span>
- )
- </div>
- </em>
- </dt>
- <dd>Rules that were registered, the optional parameters are filled with values.</dd>
- <!-- OBJECT PROPERTIES -->
- <!-- OBJECT METHODS -->
- <!-- OBJECT EVENT FIELDS -->
- <!-- FUNCTION PARAMETERS -->
- </div>
- </div>
- </dl>
- </div>
- </div>
- <!-- MIN_VERSION -->
- </div> <!-- /description -->
- </div><div class="apiItem">
- <a name="method-getRules"></a> <!-- method-anchor -->
- <h4>getRules</h4>
- <div class="summary">
- <!-- Note: intentionally longer 80 columns -->
- <span>chrome.declarative.getRules</span>(<span class="optional"><span>array of string</span>
- <var><span>ruleIdentifiers</span></var></span><span class="null"><span>, </span><span>function</span>
- <var><span>callback</span></var></span>)</div>
- <div class="description">
- <p>Returns currently registered rules. Note that you cannot call this function as <code>chrome.declarative.getRules(...)</code>. Instead a function of this signature is provided for event objects supporting the declarative API such as <code>chrome.declarativeWebRequest.onRequest</code>.</p>
- <!-- PARAMETERS -->
- <h4>Parameters</h4>
- <dl>
- <div>
- <div>
- <dt>
- <var>ruleIdentifiers</var>
- <em>
- <!-- TYPE -->
- <div style="display:inline">
- (
- <span class="optional">optional</span>
- <span id="typeTemplate">
- <span>
- <span>
- array of <span><span>
- <span>
- <span>string</span>
- </span>
- </span></span>
- </span>
- </span>
- </span>
- )
- </div>
- </em>
- </dt>
- <dd>If an array is passed, only rules with identifiers contained in this array are returned.</dd>
- <!-- OBJECT PROPERTIES -->
- <!-- OBJECT METHODS -->
- <!-- OBJECT EVENT FIELDS -->
- <!-- FUNCTION PARAMETERS -->
- </div>
- </div><div>
- <div>
- <dt>
- <var>callback</var>
- <em>
- <!-- TYPE -->
- <div style="display:inline">
- (
- <span id="typeTemplate">
- <span>
- <span>function</span>
- </span>
- </span>
- )
- </div>
- </em>
- </dt>
- <dd>Called with registered rules.</dd>
- <!-- OBJECT PROPERTIES -->
- <!-- OBJECT METHODS -->
- <!-- OBJECT EVENT FIELDS -->
- <!-- FUNCTION PARAMETERS -->
- </div>
- </div>
- </dl>
- <!-- RETURNS -->
- <dl>
- </dl>
- <!-- CALLBACK -->
- <div>
- <div>
- <h4>Callback function</h4>
- <p>
- The callback <em>parameter</em> should specify a function
- that looks like this:
- </p>
- <!-- Note: intentionally longer 80 columns -->
- <pre>function(<span>array of Rule rules</span>) <span class="subdued">{...}</span>;</pre>
- <dl>
- <div>
- <div>
- <dt>
- <var>rules</var>
- <em>
- <!-- TYPE -->
- <div style="display:inline">
- (
- <span id="typeTemplate">
- <span>
- <span>
- array of <span><span>
- <span>
- <a href="declarative.html#type-Rule">Rule</a>
- </span>
- </span></span>
- </span>
- </span>
- </span>
- )
- </div>
- </em>
- </dt>
- <dd>Rules that were registered, the optional parameters are filled with values.</dd>
- <!-- OBJECT PROPERTIES -->
- <!-- OBJECT METHODS -->
- <!-- OBJECT EVENT FIELDS -->
- <!-- FUNCTION PARAMETERS -->
- </div>
- </div>
- </dl>
- </div>
- </div>
- <!-- MIN_VERSION -->
- </div> <!-- /description -->
- </div><div class="apiItem">
- <a name="method-removeRules"></a> <!-- method-anchor -->
- <h4>removeRules</h4>
- <div class="summary">
- <!-- Note: intentionally longer 80 columns -->
- <span>chrome.declarative.removeRules</span>(<span class="optional"><span>array of string</span>
- <var><span>ruleIdentifiers</span></var></span><span class="optional"><span>, </span><span>function</span>
- <var><span>callback</span></var></span>)</div>
- <div class="description">
- <p>Unregisters currently registered rules. Note that you cannot call this function as <code>chrome.declarative.removeRules(...)</code>. Instead a function of this signature is provided for event objects supporting the declarative API such as <code>chrome.declarativeWebRequest.onRequest</code>.</p>
- <!-- PARAMETERS -->
- <h4>Parameters</h4>
- <dl>
- <div>
- <div>
- <dt>
- <var>ruleIdentifiers</var>
- <em>
- <!-- TYPE -->
- <div style="display:inline">
- (
- <span class="optional">optional</span>
- <span id="typeTemplate">
- <span>
- <span>
- array of <span><span>
- <span>
- <span>string</span>
- </span>
- </span></span>
- </span>
- </span>
- </span>
- )
- </div>
- </em>
- </dt>
- <dd>If an array is passed, only rules with identifiers contained in this array are unregistered.</dd>
- <!-- OBJECT PROPERTIES -->
- <!-- OBJECT METHODS -->
- <!-- OBJECT EVENT FIELDS -->
- <!-- FUNCTION PARAMETERS -->
- </div>
- </div><div>
- <div>
- <dt>
- <var>callback</var>
- <em>
- <!-- TYPE -->
- <div style="display:inline">
- (
- <span class="optional">optional</span>
- <span id="typeTemplate">
- <span>
- <span>function</span>
- </span>
- </span>
- )
- </div>
- </em>
- </dt>
- <dd>Called when rules were unregistered.</dd>
- <!-- OBJECT PROPERTIES -->
- <!-- OBJECT METHODS -->
- <!-- OBJECT EVENT FIELDS -->
- <!-- FUNCTION PARAMETERS -->
- </div>
- </div>
- </dl>
- <!-- RETURNS -->
- <dl>
- </dl>
- <!-- CALLBACK -->
- <div>
- <div>
- <h4>Callback function</h4>
- <p>
- If you specify the <em>callback</em> parameter, it should
- specify a function that looks like this:
- </p>
- <!-- Note: intentionally longer 80 columns -->
- <pre>function(<span></span>) <span class="subdued">{...}</span>;</pre>
- <dl>
- </dl>
- </div>
- </div>
- <!-- MIN_VERSION -->
- </div> <!-- /description -->
- </div> <!-- /apiItem -->
- </div> <!-- /apiGroup -->
- <!-- EVENTS -->
- <!-- /apiGroup -->
- <!-- TYPES -->
- <div class="apiGroup">
- <a name="types"></a>
- <h3 id="types">Types</h3>
- <!-- iterates over all types -->
- <div class="apiItem">
- <a name="type-Rule"></a>
- <h4>Rule</h4>
- <div>
- <dt>
- <em>
- <!-- TYPE -->
- <div style="display:inline">
- (
- <span id="typeTemplate">
- <span>
- <span>object</span>
- </span>
- </span>
- )
- </div>
- </em>
- </dt>
- <dd>Description of a declarative rule for handling events.</dd>
- <!-- OBJECT PROPERTIES -->
- <dd>
- <dl>
- <div>
- <div>
- <dt>
- <var>id</var>
- <em>
- <!-- TYPE -->
- <div style="display:inline">
- (
- <span class="optional">optional</span>
- <span id="typeTemplate">
- <span>
- <span>string</span>
- </span>
- </span>
- )
- </div>
- </em>
- </dt>
- <dd>Optional identifier that allows referencing this rule.</dd>
- <!-- OBJECT PROPERTIES -->
- <!-- OBJECT METHODS -->
- <!-- OBJECT EVENT FIELDS -->
- <!-- FUNCTION PARAMETERS -->
- </div>
- </div><div>
- <div>
- <dt>
- <var>conditions</var>
- <em>
- <!-- TYPE -->
- <div style="display:inline">
- (
- <span id="typeTemplate">
- <span>
- <span>
- array of <span><span>
- <span>
- <span>any</span>
- </span>
- </span></span>
- </span>
- </span>
- </span>
- )
- </div>
- </em>
- </dt>
- <dd>List of conditions that can trigger the actions.</dd>
- <!-- OBJECT PROPERTIES -->
- <!-- OBJECT METHODS -->
- <!-- OBJECT EVENT FIELDS -->
- <!-- FUNCTION PARAMETERS -->
- </div>
- </div><div>
- <div>
- <dt>
- <var>actions</var>
- <em>
- <!-- TYPE -->
- <div style="display:inline">
- (
- <span id="typeTemplate">
- <span>
- <span>
- array of <span><span>
- <span>
- <span>any</span>
- </span>
- </span></span>
- </span>
- </span>
- </span>
- )
- </div>
- </em>
- </dt>
- <dd>List of actions that are triggered if one of the condtions is fulfilled.</dd>
- <!-- OBJECT PROPERTIES -->
- <!-- OBJECT METHODS -->
- <!-- OBJECT EVENT FIELDS -->
- <!-- FUNCTION PARAMETERS -->
- </div>
- </div><div>
- <div>
- <dt>
- <var>priority</var>
- <em>
- <!-- TYPE -->
- <div style="display:inline">
- (
- <span class="optional">optional</span>
- <span id="typeTemplate">
- <span>
- <span>integer</span>
- </span>
- </span>
- )
- </div>
- </em>
- </dt>
- <dd>Optional priority of this rule. Defaults to 100.</dd>
- <!-- OBJECT PROPERTIES -->
- <!-- OBJECT METHODS -->
- <!-- OBJECT EVENT FIELDS -->
- <!-- FUNCTION PARAMETERS -->
- </div>
- </div>
- </dl>
- </dd>
- <!-- OBJECT METHODS -->
- <!-- OBJECT EVENT FIELDS -->
- <!-- FUNCTION PARAMETERS -->
- </div>
- </div><div class="apiItem">
- <a name="type-UrlFilter"></a>
- <h4>UrlFilter</h4>
- <div>
- <dt>
- <em>
- <!-- TYPE -->
- <div style="display:inline">
- (
- <span id="typeTemplate">
- <span>
- <span>object</span>
- </span>
- </span>
- )
- </div>
- </em>
- </dt>
- <dd>Filters URLs for various criteria</dd>
- <!-- OBJECT PROPERTIES -->
- <dd>
- <dl>
- <div>
- <div>
- <dt>
- <var>hostContains</var>
- <em>
- <!-- TYPE -->
- <div style="display:inline">
- (
- <span class="optional">optional</span>
- <span id="typeTemplate">
- <span>
- <span>string</span>
- </span>
- </span>
- )
- </div>
- </em>
- </dt>
- <dd>Matches if the host name of the URL contains a specified string.</dd>
- <!-- OBJECT PROPERTIES -->
- <!-- OBJECT METHODS -->
- <!-- OBJECT EVENT FIELDS -->
- <!-- FUNCTION PARAMETERS -->
- </div>
- </div><div>
- <div>
- <dt>
- <var>hostEquals</var>
- <em>
- <!-- TYPE -->
- <div style="display:inline">
- (
- <span class="optional">optional</span>
- <span id="typeTemplate">
- <span>
- <span>string</span>
- </span>
- </span>
- )
- </div>
- </em>
- </dt>
- <dd>Matches if the host name of the URL is equal to a specified string.</dd>
- <!-- OBJECT PROPERTIES -->
- <!-- OBJECT METHODS -->
- <!-- OBJECT EVENT FIELDS -->
- <!-- FUNCTION PARAMETERS -->
- </div>
- </div><div>
- <div>
- <dt>
- <var>hostPrefix</var>
- <em>
- <!-- TYPE -->
- <div style="display:inline">
- (
- <span class="optional">optional</span>
- <span id="typeTemplate">
- <span>
- <span>string</span>
- </span>
- </span>
- )
- </div>
- </em>
- </dt>
- <dd>Matches if the host name of the URL starts with a specified string.</dd>
- <!-- OBJECT PROPERTIES -->
- <!-- OBJECT METHODS -->
- <!-- OBJECT EVENT FIELDS -->
- <!-- FUNCTION PARAMETERS -->
- </div>
- </div><div>
- <div>
- <dt>
- <var>hostSuffix</var>
- <em>
- <!-- TYPE -->
- <div style="display:inline">
- (
- <span class="optional">optional</span>
- <span id="typeTemplate">
- <span>
- <span>string</span>
- </span>
- </span>
- )
- </div>
- </em>
- </dt>
- <dd>Matches if the host name of the URL ends with a specified string.</dd>
- <!-- OBJECT PROPERTIES -->
- <!-- OBJECT METHODS -->
- <!-- OBJECT EVENT FIELDS -->
- <!-- FUNCTION PARAMETERS -->
- </div>
- </div><div>
- <div>
- <dt>
- <var>pathContains</var>
- <em>
- <!-- TYPE -->
- <div style="display:inline">
- (
- <span class="optional">optional</span>
- <span id="typeTemplate">
- <span>
- <span>string</span>
- </span>
- </span>
- )
- </div>
- </em>
- </dt>
- <dd>Matches if the path segment of the URL contains a specified string.</dd>
- <!-- OBJECT PROPERTIES -->
- <!-- OBJECT METHODS -->
- <!-- OBJECT EVENT FIELDS -->
- <!-- FUNCTION PARAMETERS -->
- </div>
- </div><div>
- <div>
- <dt>
- <var>pathEquals</var>
- <em>
- <!-- TYPE -->
- <div style="display:inline">
- (
- <span class="optional">optional</span>
- <span id="typeTemplate">
- <span>
- <span>string</span>
- </span>
- </span>
- )
- </div>
- </em>
- </dt>
- <dd>Matches if the path segment of the URL is equal to a specified string.</dd>
- <!-- OBJECT PROPERTIES -->
- <!-- OBJECT METHODS -->
- <!-- OBJECT EVENT FIELDS -->
- <!-- FUNCTION PARAMETERS -->
- </div>
- </div><div>
- <div>
- <dt>
- <var>pathPrefix</var>
- <em>
- <!-- TYPE -->
- <div style="display:inline">
- (
- <span class="optional">optional</span>
- <span id="typeTemplate">
- <span>
- <span>string</span>
- </span>
- </span>
- )
- </div>
- </em>
- </dt>
- <dd>Matches if the path segment of the URL starts with a specified string.</dd>
- <!-- OBJECT PROPERTIES -->
- <!-- OBJECT METHODS -->
- <!-- OBJECT EVENT FIELDS -->
- <!-- FUNCTION PARAMETERS -->
- </div>
- </div><div>
- <div>
- <dt>
- <var>pathSuffix</var>
- <em>
- <!-- TYPE -->
- <div style="display:inline">
- (
- <span class="optional">optional</span>
- <span id="typeTemplate">
- <span>
- <span>string</span>
- </span>
- </span>
- )
- </div>
- </em>
- </dt>
- <dd>Matches if the path segment of the URL ends with a specified string.</dd>
- <!-- OBJECT PROPERTIES -->
- <!-- OBJECT METHODS -->
- <!-- OBJECT EVENT FIELDS -->
- <!-- FUNCTION PARAMETERS -->
- </div>
- </div><div>
- <div>
- <dt>
- <var>queryEquals</var>
- <em>
- <!-- TYPE -->
- <div style="display:inline">
- (
- <span class="optional">optional</span>
- <span id="typeTemplate">
- <span>
- <span>string</span>
- </span>
- </span>
- )
- </div>
- </em>
- </dt>
- <dd>Matches if the query segment of the URL is equal to a specified string.</dd>
- <!-- OBJECT PROPERTIES -->
- <!-- OBJECT METHODS -->
- <!-- OBJECT EVENT FIELDS -->
- <!-- FUNCTION PARAMETERS -->
- </div>
- </div><div>
- <div>
- <dt>
- <var>queryPrefix</var>
- <em>
- <!-- TYPE -->
- <div style="display:inline">
- (
- <span class="optional">optional</span>
- <span id="typeTemplate">
- <span>
- <span>string</span>
- </span>
- </span>
- )
- </div>
- </em>
- </dt>
- <dd>Matches if the query segment of the URL starts with a specified string.</dd>
- <!-- OBJECT PROPERTIES -->
- <!-- OBJECT METHODS -->
- <!-- OBJECT EVENT FIELDS -->
- <!-- FUNCTION PARAMETERS -->
- </div>
- </div><div>
- <div>
- <dt>
- <var>querySuffix</var>
- <em>
- <!-- TYPE -->
- <div style="display:inline">
- (
- <span class="optional">optional</span>
- <span id="typeTemplate">
- <span>
- <span>string</span>
- </span>
- </span>
- )
- </div>
- </em>
- </dt>
- <dd>Matches if the query segment of the URL ends with a specified string.</dd>
- <!-- OBJECT PROPERTIES -->
- <!-- OBJECT METHODS -->
- <!-- OBJECT EVENT FIELDS -->
- <!-- FUNCTION PARAMETERS -->
- </div>
- </div><div>
- <div>
- <dt>
- <var>urlSuffix</var>
- <em>
- <!-- TYPE -->
- <div style="display:inline">
- (
- <span class="optional">optional</span>
- <span id="typeTemplate">
- <span>
- <span>string</span>
- </span>
- </span>
- )
- </div>
- </em>
- </dt>
- <dd>Matches if the URL ends with a specified string.</dd>
- <!-- OBJECT PROPERTIES -->
- <!-- OBJECT METHODS -->
- <!-- OBJECT EVENT FIELDS -->
- <!-- FUNCTION PARAMETERS -->
- </div>
- </div><div>
- <div>
- <dt>
- <var>urlEquals</var>
- <em>
- <!-- TYPE -->
- <div style="display:inline">
- (
- <span class="optional">optional</span>
- <span id="typeTemplate">
- <span>
- <span>string</span>
- </span>
- </span>
- )
- </div>
- </em>
- </dt>
- <dd>Matches if the URL is equal to a specified string.</dd>
- <!-- OBJECT PROPERTIES -->
- <!-- OBJECT METHODS -->
- <!-- OBJECT EVENT FIELDS -->
- <!-- FUNCTION PARAMETERS -->
- </div>
- </div><div>
- <div>
- <dt>
- <var>urlPrefix</var>
- <em>
- <!-- TYPE -->
- <div style="display:inline">
- (
- <span class="optional">optional</span>
- <span id="typeTemplate">
- <span>
- <span>string</span>
- </span>
- </span>
- )
- </div>
- </em>
- </dt>
- <dd>Matches if the URL starts with a specified string.</dd>
- <!-- OBJECT PROPERTIES -->
- <!-- OBJECT METHODS -->
- <!-- OBJECT EVENT FIELDS -->
- <!-- FUNCTION PARAMETERS -->
- </div>
- </div><div>
- <div>
- <dt>
- <var>schemes</var>
- <em>
- <!-- TYPE -->
- <div style="display:inline">
- (
- <span class="optional">optional</span>
- <span id="typeTemplate">
- <span>
- <span>
- array of <span><span>
- <span>
- <span>string</span>
- </span>
- </span></span>
- </span>
- </span>
- </span>
- )
- </div>
- </em>
- </dt>
- <dd>Matches if the scheme of the URL is equal to any of the schemes specified in the array.</dd>
- <!-- OBJECT PROPERTIES -->
- <!-- OBJECT METHODS -->
- <!-- OBJECT EVENT FIELDS -->
- <!-- FUNCTION PARAMETERS -->
- </div>
- </div><div>
- <div>
- <dt>
- <var>ports</var>
- <em>
- <!-- TYPE -->
- <div style="display:inline">
- (
- <span class="optional">optional</span>
- <span id="typeTemplate">
- <span>
- <span>
- array of <span><span>
- <span>
- <span>integer or array of integer</span>
- </span>
- </span></span>
- </span>
- </span>
- </span>
- )
- </div>
- </em>
- </dt>
- <dd>Matches if the port of the URL is contained in any of the specified port lists. For example <code>[80, 443, [1000, 1200]]</code> matches all requests on port 80, 443 and in the range 1000-1200.</dd>
- <!-- OBJECT PROPERTIES -->
- <!-- OBJECT METHODS -->
- <!-- OBJECT EVENT FIELDS -->
- <!-- FUNCTION PARAMETERS -->
- </div>
- </div>
- </dl>
- </dd>
- <!-- OBJECT METHODS -->
- <!-- OBJECT EVENT FIELDS -->
- <!-- FUNCTION PARAMETERS -->
- </div>
- </div> <!-- /apiItem -->
- </div> <!-- /apiGroup -->
- </div> <!-- /apiPage -->
- </div> <!-- /gc-pagecontent -->
- </div> <!-- /g-section -->
- </div> <!-- /codesiteContent -->
- <div id="gc-footer" --="">
- <div class="text">
- <p>
- Except as otherwise <a href="http://code.google.com/policies.html#restrictions">noted</a>,
- the content of this page is licensed under the <a rel="license" href="http://creativecommons.org/licenses/by/3.0/">Creative Commons
- Attribution 3.0 License</a>, and code samples are licensed under the
- <a rel="license" href="http://code.google.com/google_bsd_license.html">BSD License</a>.
- </p>
- <p>
- ©2011 Google
- </p>
-<!-- begin analytics -->
-<script src="https://www.google-analytics.com/urchin.js" type="text/javascript"></script>
-<script src="https://www.google-analytics.com/ga.js" type="text/javascript"></script>
-<script type="text/javascript">
- // chrome doc tracking
- try {
- var engdocs = _gat._getTracker("YT-10763712-2");
- engdocs._trackPageview();
- } catch(err) {}
- // code.google.com site-wide tracking
- try {
- _uacct="UA-18071-1";
- _uanchor=1;
- _uff=0;
- urchinTracker();
- }
- catch(e) {/* urchinTracker not available. */}
-</script>
-<!-- end analytics -->
- </div>
- </div> <!-- /gc-footer -->
- </div> <!-- /gc-container -->
-</body></html>
diff --git a/chrome/common/extensions/docs/declarativeWebRequest.html b/chrome/common/extensions/docs/declarativeWebRequest.html
index e79ddeb..05bb0db 100644
--- a/chrome/common/extensions/docs/declarativeWebRequest.html
+++ b/chrome/common/extensions/docs/declarativeWebRequest.html
@@ -283,8 +283,8 @@ hosts whose network requests you want to access.
}</pre>
<h2 id="rules">Rules</h2>
<p>
-The Declarative Web Request API follows the concepts of the <a href="declarative.html">Declarative API</a>. You can register rules to the
-<code>chrome.declarativeWebRequest.onRequest</code> event object.
+The Declarative Web Request API follows the concepts of the <a href="events.html#declarative">Declarative API</a>. You can register rules to
+the <code>chrome.declarativeWebRequest.onRequest</code> event object.
</p>
<p>
The Declarative Web Request API supports a single type of match criteria, the
@@ -453,7 +453,7 @@ very fast URL matching algorithm for hundreds of thousands of URLs.
<span class="optional">optional</span>
<span id="typeTemplate">
<span>
- <a>declarative.UrlFilter</a>
+ <a>events.UrlFilter</a>
</span>
</span>
)
diff --git a/chrome/common/extensions/docs/events.html b/chrome/common/extensions/docs/events.html
index 3b67318..bc3dc31 100644
--- a/chrome/common/extensions/docs/events.html
+++ b/chrome/common/extensions/docs/events.html
@@ -18,7 +18,7 @@
<script type="text/javascript" src="js/api_page_generator.js"></script>
<script type="text/javascript" src="js/bootstrap.js"></script>
<script type="text/javascript" src="js/sidebar.js"></script>
- <title>Events - Google Chrome Extensions - Google Code</title></head>
+ <meta name="description" content="Documentation for the chrome.events module, which is part of the Google Chrome extension APIs."><title>chrome.events - Google Chrome Extensions - Google Code</title></head>
<body> <div id="devModeWarning" class="displayModeWarning">
You are viewing extension docs in chrome via the 'file:' scheme: are you expecting to see local changes when you refresh? You'll need run chrome with --allow-file-access-from-files.
</div>
@@ -185,9 +185,79 @@
</script>
<div class="g-unit" id="gc-pagecontent">
<div id="pageTitle">
- <h1 class="page_title">Events</h1>
+ <h1 class="page_title">chrome.events</h1>
</div>
<!-- TABLE OF CONTENTS -->
+ <div id="toc">
+ <h2>Contents</h2>
+ <ol>
+ <li>
+ <a href="#H2-0">
+Methods
+</a>
+ <ol>
+ </ol>
+ </li><li>
+ <a href="#declarative">Declarative Event Handlers</a>
+ <ol>
+ <li>
+ <a href="#rules">Rules</a>
+ </li><li>
+ <a href="#eventobjects">Event objects</a>
+ </li><li>
+ <a href="#addingrules">Adding rules</a>
+ </li><li>
+ <a href="#removingrules">Removing rules</a>
+ </li><li>
+ <a href="#retrievingrules">Retrieving rules</a>
+ </li>
+ </ol>
+ </li>
+ <li>
+ <a href="#apiReference">API reference: chrome.events</a>
+ <ol>
+ <li>
+ <a href="#types">Types</a>
+ <ol>
+ <li>
+ <a href="#type-Event">Event</a>
+ <ol>
+ <li>
+ <a href="#global-Event-methods">Methods</a>
+ <ol>
+ <li>
+ <a href="#method-Event-addListener">addListener</a>
+ </li><li>
+ <a href="#method-Event-addRules">addRules</a>
+ </li><li>
+ <a href="#method-Event-getRules">getRules</a>
+ </li><li>
+ <a href="#method-Event-hasListener">hasListener</a>
+ </li><li>
+ <a href="#method-Event-hasListeners">hasListeners</a>
+ </li><li>
+ <a href="#method-Event-removeListener">removeListener</a>
+ </li><li>
+ <a href="#method-Event-removeRules">removeRules</a>
+ </li>
+ </ol>
+ </li>
+ </ol>
+ </li><li>
+ <a href="#type-Rule">Rule</a>
+ <ol>
+ </ol>
+ </li><li>
+ <a href="#type-UrlFilter">UrlFilter</a>
+ <ol>
+ </ol>
+ </li>
+ </ol>
+ </li>
+ </ol>
+ </li>
+ </ol>
+ </div>
<!-- /TABLE OF CONTENTS -->
<!-- Standard content lead-in for experimental API pages -->
<!-- STATIC CONTENT PLACEHOLDER -->
@@ -220,7 +290,7 @@ you can see that the function has a single parameter:
a <a href="tabs.html#type-Tab">Tab</a> object
that has details about the newly created tab.
</p>
-<h2>
+<a name="H2-0"></a><h2>
Methods
</h2>
<p>
@@ -231,9 +301,1095 @@ void removeListener(function callback(...))
bool hasListener(function callback(...))
</pre>
<!-- [PENDING: explain removeListener and hasListener] -->
+<h2 id="declarative">Declarative Event Handlers</h2>
+<p>
+The declarative event handlers provide a means to define rules consisting of
+declarative conditions and actions. Conditions are evaluated in the browser
+rather than the JavaScript engine which reduces roundtrip latencies and allows
+for very high efficiency.
+</p>
+<p>Declarative event handlers are used for example in the <a href="declarativeWebRequest.html">Declarative Web Request API</a> and possibly
+further extension APIs in the future. This page describes the underlying
+concepts of all declarative event handlers.
+</p>
+<h3 id="rules">Rules</h3>
+<p>The simplest possible rule consists of one or more conditions and one or more
+actions:</p>
+<pre>var rule = {
+ conditions: [ /* my conditions */ ],
+ actions: [ /* my actions */ ]
+};
+</pre>
+<p>If any of the conditions is fulfilled, all actions are executed.</p>
+<p>In addition to conditions and actions you may give each rule an identifier,
+which simplifies unregistering previously registered rules, and a priority to
+define precedences among rules. Priorities are only considered if rules conflict
+each other or need to be executed in a specific order.</p>
+<pre>var rule = {
+ id: "my rule", // optional, will be generated if not set.
+ priority: 100, // optional, defaults to 100.
+ conditions: [ /* my conditions */ ],
+ actions: [ /* my actions */ ]
+};
+</pre>
+<h3 id="eventobjects">Event objects</h3>
+<p>
+<a href="events.html">Event objects</a> may support rules. These event objects
+don't call a callback function when events happer but test whether any
+registered rule has at least one fulfilled condition and execute the actions
+associated with this rule. Event objects supporting the declarative API have
+three relevant methods: <a href="#method-addRules"><code>addRules()</code></a>,
+<a href="#method-removeRules"><code>removeRules()</code></a>, and
+<a href="#method-getRules"><code>getRules()</code></a>.
+</p>
+<h3 id="addingrules">Adding rules</h3>
+<p>
+To add rules call the <code>addRules()</code> function of the event object. It
+takes an array of rule instances as its first parameter and a callback function
+that is called on completion.
+</p>
+<pre>var rule_list = [rule1, rule2, ...];
+function addRules(rule_list, function callback(details) {...});
+</pre>
+<p>
+If the rules were inserted successfully, the <code>details</code> parameter
+contains an array of inserted rules appearing in the same order as in the passed
+<code>rule_list</code> where the optional parameters <code>id</code> and
+<code>priority</code> were filled with the generated values. If any rule is
+invalid, e.g., because it contained an invalid condition or action, none of the
+rules are added and the <a href="extension.html#property-lastError">lastError</a> variable is set when
+the callback function is called. Each rule in <code>rule_list</code> must
+contain a unique identifier that is not currently used by another rule or an
+empty identifier.
+</p>
+<h3 id="removingrules">Removing rules</h3>
+<p>
+To remove rules call the <code>removeRules()</code> function. It accepts an
+optional array of rule identifiers as its first parameter and a callback
+function as its second parameter.
+</p>
+<pre>var rule_ids = ["id1", "id2", ...];
+function removeRules(rule_ids, function callback() {...});
+</pre>
+<p>
+If <code>rule_ids</code> is an array of identifiers, all rules having
+identifiers listed in the array are removed. If <code>rule_ids</code> lists an
+identifier, that is unknown, this identifier is silently ignored. If
+<code>rule_ids</code> is <code>undefined</code>, all registered rules of this
+extension are removed. The <code>callback()</code> function is called when the
+rules were removed.
+</p>
+<h3 id="retrievingrules">Retrieving rules</h3>
+<p>
+To retrieve a list of currently registered rules, call the
+<code>getRules()</code> function. It accepts an optional array of rule
+identifiers with the same semantics as <code>removeRules</code> and a callback
+function.
+</p><p>
+</p><pre>var rule_ids = ["id1", "id2", ...];
+function getRules(rule_ids, function callback(details) {...});
+</pre>
+<p>
+The <code>details</code> parameter passed to the <code>calback()</code> function
+refers to an array of rules including filled optional parameters.
+</p>
</div>
<!-- API PAGE -->
- <!-- /apiPage -->
+ <div class="apiPage">
+ <a name="apiReference"></a>
+ <h2>API reference: chrome.events</h2>
+ <!-- PROPERTIES -->
+ <!-- /apiGroup -->
+ <!-- METHODS -->
+ <!-- /apiGroup -->
+ <!-- EVENTS -->
+ <!-- /apiGroup -->
+ <!-- TYPES -->
+ <div class="apiGroup">
+ <a name="types"></a>
+ <h3 id="types">Types</h3>
+ <!-- iterates over all types -->
+ <div class="apiItem">
+ <a name="type-Event"></a>
+ <h4>Event</h4>
+ <div>
+ <dt>
+ <em>
+ <!-- TYPE -->
+ <div style="display:inline">
+ (
+ <span id="typeTemplate">
+ <span>
+ <span>object</span>
+ </span>
+ </span>
+ )
+ </div>
+ </em>
+ </dt>
+ <dd>An object which allows the addition and removal of listeners for a Chrome event.</dd>
+ <!-- OBJECT PROPERTIES -->
+ <!-- OBJECT METHODS -->
+ <dd>
+ <div class="apiGroup">
+ <a name="global-Event-methods"></a>
+ <h3>Methods of Event</h3>
+ <!-- iterates over all functions -->
+ <div class="apiItem">
+ <a name="method-Event-addListener"></a> <!-- method-anchor -->
+ <h4>addListener</h4>
+ <div class="summary">
+ <!-- Note: intentionally longer 80 columns -->
+ <span>event.addListener</span>()</div>
+ <div class="description">
+ <!-- PARAMETERS -->
+ <dl>
+ </dl>
+ <!-- RETURNS -->
+ <dl>
+ </dl>
+ <!-- CALLBACK -->
+ <!-- MIN_VERSION -->
+ </div> <!-- /description -->
+ </div><div class="apiItem">
+ <a name="method-Event-addRules"></a> <!-- method-anchor -->
+ <h4>addRules</h4>
+ <div class="summary">
+ <!-- Note: intentionally longer 80 columns -->
+ <span>event.addRules</span>(<span class="null"><span>array of Rule</span>
+ <var><span>rules</span></var></span><span class="optional"><span>, </span><span>function</span>
+ <var><span>callback</span></var></span>)</div>
+ <div class="description">
+ <p>Registers rules to handle events. Note that you cannot call this function as <code>chrome.declarative.addRules(...)</code>. Instead a function of this signature is provided for event objects supporting the declarative API such as <code>chrome.declarativeWebRequest.onRequest</code>.</p>
+ <!-- PARAMETERS -->
+ <h4>Parameters</h4>
+ <dl>
+ <div>
+ <div>
+ <dt>
+ <var>rules</var>
+ <em>
+ <!-- TYPE -->
+ <div style="display:inline">
+ (
+ <span id="typeTemplate">
+ <span>
+ <span>
+ array of <span><span>
+ <span>
+ <a href="events.html#type-Rule">Rule</a>
+ </span>
+ </span></span>
+ </span>
+ </span>
+ </span>
+ )
+ </div>
+ </em>
+ </dt>
+ <dd>Rules to be registered. These do not replace previously registered rules.</dd>
+ <!-- OBJECT PROPERTIES -->
+ <!-- OBJECT METHODS -->
+ <!-- OBJECT EVENT FIELDS -->
+ <!-- FUNCTION PARAMETERS -->
+ </div>
+ </div><div>
+ <div>
+ <dt>
+ <var>callback</var>
+ <em>
+ <!-- TYPE -->
+ <div style="display:inline">
+ (
+ <span class="optional">optional</span>
+ <span id="typeTemplate">
+ <span>
+ <span>function</span>
+ </span>
+ </span>
+ )
+ </div>
+ </em>
+ </dt>
+ <dd>Called with registered rules.</dd>
+ <!-- OBJECT PROPERTIES -->
+ <!-- OBJECT METHODS -->
+ <!-- OBJECT EVENT FIELDS -->
+ <!-- FUNCTION PARAMETERS -->
+ </div>
+ </div>
+ </dl>
+ <!-- RETURNS -->
+ <dl>
+ </dl>
+ <!-- CALLBACK -->
+ <div>
+ <div>
+ <h4>Callback function</h4>
+ <p>
+ If you specify the <em>callback</em> parameter, it should
+ specify a function that looks like this:
+ </p>
+ <!-- Note: intentionally longer 80 columns -->
+ <pre>function(<span>array of Rule rules</span>) <span class="subdued">{...}</span>;</pre>
+ <dl>
+ <div>
+ <div>
+ <dt>
+ <var>rules</var>
+ <em>
+ <!-- TYPE -->
+ <div style="display:inline">
+ (
+ <span id="typeTemplate">
+ <span>
+ <span>
+ array of <span><span>
+ <span>
+ <a href="events.html#type-Rule">Rule</a>
+ </span>
+ </span></span>
+ </span>
+ </span>
+ </span>
+ )
+ </div>
+ </em>
+ </dt>
+ <dd>Rules that were registered, the optional parameters are filled with values.</dd>
+ <!-- OBJECT PROPERTIES -->
+ <!-- OBJECT METHODS -->
+ <!-- OBJECT EVENT FIELDS -->
+ <!-- FUNCTION PARAMETERS -->
+ </div>
+ </div>
+ </dl>
+ </div>
+ </div>
+ <!-- MIN_VERSION -->
+ </div> <!-- /description -->
+ </div><div class="apiItem">
+ <a name="method-Event-getRules"></a> <!-- method-anchor -->
+ <h4>getRules</h4>
+ <div class="summary">
+ <!-- Note: intentionally longer 80 columns -->
+ <span>event.getRules</span>(<span class="optional"><span>array of string</span>
+ <var><span>ruleIdentifiers</span></var></span><span class="null"><span>, </span><span>function</span>
+ <var><span>callback</span></var></span>)</div>
+ <div class="description">
+ <p>Returns currently registered rules. Note that you cannot call this function as <code>chrome.declarative.getRules(...)</code>. Instead a function of this signature is provided for event objects supporting the declarative API such as <code>chrome.declarativeWebRequest.onRequest</code>.</p>
+ <!-- PARAMETERS -->
+ <h4>Parameters</h4>
+ <dl>
+ <div>
+ <div>
+ <dt>
+ <var>ruleIdentifiers</var>
+ <em>
+ <!-- TYPE -->
+ <div style="display:inline">
+ (
+ <span class="optional">optional</span>
+ <span id="typeTemplate">
+ <span>
+ <span>
+ array of <span><span>
+ <span>
+ <span>string</span>
+ </span>
+ </span></span>
+ </span>
+ </span>
+ </span>
+ )
+ </div>
+ </em>
+ </dt>
+ <dd>If an array is passed, only rules with identifiers contained in this array are returned.</dd>
+ <!-- OBJECT PROPERTIES -->
+ <!-- OBJECT METHODS -->
+ <!-- OBJECT EVENT FIELDS -->
+ <!-- FUNCTION PARAMETERS -->
+ </div>
+ </div><div>
+ <div>
+ <dt>
+ <var>callback</var>
+ <em>
+ <!-- TYPE -->
+ <div style="display:inline">
+ (
+ <span id="typeTemplate">
+ <span>
+ <span>function</span>
+ </span>
+ </span>
+ )
+ </div>
+ </em>
+ </dt>
+ <dd>Called with registered rules.</dd>
+ <!-- OBJECT PROPERTIES -->
+ <!-- OBJECT METHODS -->
+ <!-- OBJECT EVENT FIELDS -->
+ <!-- FUNCTION PARAMETERS -->
+ </div>
+ </div>
+ </dl>
+ <!-- RETURNS -->
+ <dl>
+ </dl>
+ <!-- CALLBACK -->
+ <div>
+ <div>
+ <h4>Callback function</h4>
+ <p>
+ The callback <em>parameter</em> should specify a function
+ that looks like this:
+ </p>
+ <!-- Note: intentionally longer 80 columns -->
+ <pre>function(<span>array of Rule rules</span>) <span class="subdued">{...}</span>;</pre>
+ <dl>
+ <div>
+ <div>
+ <dt>
+ <var>rules</var>
+ <em>
+ <!-- TYPE -->
+ <div style="display:inline">
+ (
+ <span id="typeTemplate">
+ <span>
+ <span>
+ array of <span><span>
+ <span>
+ <a href="events.html#type-Rule">Rule</a>
+ </span>
+ </span></span>
+ </span>
+ </span>
+ </span>
+ )
+ </div>
+ </em>
+ </dt>
+ <dd>Rules that were registered, the optional parameters are filled with values.</dd>
+ <!-- OBJECT PROPERTIES -->
+ <!-- OBJECT METHODS -->
+ <!-- OBJECT EVENT FIELDS -->
+ <!-- FUNCTION PARAMETERS -->
+ </div>
+ </div>
+ </dl>
+ </div>
+ </div>
+ <!-- MIN_VERSION -->
+ </div> <!-- /description -->
+ </div><div class="apiItem">
+ <a name="method-Event-hasListener"></a> <!-- method-anchor -->
+ <h4>hasListener</h4>
+ <div class="summary">
+ <!-- Note: intentionally longer 80 columns -->
+ <span>event.hasListener</span>()</div>
+ <div class="description">
+ <!-- PARAMETERS -->
+ <dl>
+ </dl>
+ <!-- RETURNS -->
+ <dl>
+ </dl>
+ <!-- CALLBACK -->
+ <!-- MIN_VERSION -->
+ </div> <!-- /description -->
+ </div><div class="apiItem">
+ <a name="method-Event-hasListeners"></a> <!-- method-anchor -->
+ <h4>hasListeners</h4>
+ <div class="summary">
+ <!-- Note: intentionally longer 80 columns -->
+ <span>event.hasListeners</span>()</div>
+ <div class="description">
+ <!-- PARAMETERS -->
+ <dl>
+ </dl>
+ <!-- RETURNS -->
+ <dl>
+ </dl>
+ <!-- CALLBACK -->
+ <!-- MIN_VERSION -->
+ </div> <!-- /description -->
+ </div><div class="apiItem">
+ <a name="method-Event-removeListener"></a> <!-- method-anchor -->
+ <h4>removeListener</h4>
+ <div class="summary">
+ <!-- Note: intentionally longer 80 columns -->
+ <span>event.removeListener</span>()</div>
+ <div class="description">
+ <!-- PARAMETERS -->
+ <dl>
+ </dl>
+ <!-- RETURNS -->
+ <dl>
+ </dl>
+ <!-- CALLBACK -->
+ <!-- MIN_VERSION -->
+ </div> <!-- /description -->
+ </div><div class="apiItem">
+ <a name="method-Event-removeRules"></a> <!-- method-anchor -->
+ <h4>removeRules</h4>
+ <div class="summary">
+ <!-- Note: intentionally longer 80 columns -->
+ <span>event.removeRules</span>(<span class="optional"><span>array of string</span>
+ <var><span>ruleIdentifiers</span></var></span><span class="optional"><span>, </span><span>function</span>
+ <var><span>callback</span></var></span>)</div>
+ <div class="description">
+ <p>Unregisters currently registered rules. Note that you cannot call this function as <code>chrome.declarative.removeRules(...)</code>. Instead a function of this signature is provided for event objects supporting the declarative API such as <code>chrome.declarativeWebRequest.onRequest</code>.</p>
+ <!-- PARAMETERS -->
+ <h4>Parameters</h4>
+ <dl>
+ <div>
+ <div>
+ <dt>
+ <var>ruleIdentifiers</var>
+ <em>
+ <!-- TYPE -->
+ <div style="display:inline">
+ (
+ <span class="optional">optional</span>
+ <span id="typeTemplate">
+ <span>
+ <span>
+ array of <span><span>
+ <span>
+ <span>string</span>
+ </span>
+ </span></span>
+ </span>
+ </span>
+ </span>
+ )
+ </div>
+ </em>
+ </dt>
+ <dd>If an array is passed, only rules with identifiers contained in this array are unregistered.</dd>
+ <!-- OBJECT PROPERTIES -->
+ <!-- OBJECT METHODS -->
+ <!-- OBJECT EVENT FIELDS -->
+ <!-- FUNCTION PARAMETERS -->
+ </div>
+ </div><div>
+ <div>
+ <dt>
+ <var>callback</var>
+ <em>
+ <!-- TYPE -->
+ <div style="display:inline">
+ (
+ <span class="optional">optional</span>
+ <span id="typeTemplate">
+ <span>
+ <span>function</span>
+ </span>
+ </span>
+ )
+ </div>
+ </em>
+ </dt>
+ <dd>Called when rules were unregistered.</dd>
+ <!-- OBJECT PROPERTIES -->
+ <!-- OBJECT METHODS -->
+ <!-- OBJECT EVENT FIELDS -->
+ <!-- FUNCTION PARAMETERS -->
+ </div>
+ </div>
+ </dl>
+ <!-- RETURNS -->
+ <dl>
+ </dl>
+ <!-- CALLBACK -->
+ <div>
+ <div>
+ <h4>Callback function</h4>
+ <p>
+ If you specify the <em>callback</em> parameter, it should
+ specify a function that looks like this:
+ </p>
+ <!-- Note: intentionally longer 80 columns -->
+ <pre>function(<span></span>) <span class="subdued">{...}</span>;</pre>
+ <dl>
+ </dl>
+ </div>
+ </div>
+ <!-- MIN_VERSION -->
+ </div> <!-- /description -->
+ </div> <!-- /apiItem -->
+ </div>
+ </dd>
+ <!-- OBJECT EVENT FIELDS -->
+ <!-- FUNCTION PARAMETERS -->
+ </div>
+ </div><div class="apiItem">
+ <a name="type-Rule"></a>
+ <h4>Rule</h4>
+ <div>
+ <dt>
+ <em>
+ <!-- TYPE -->
+ <div style="display:inline">
+ (
+ <span id="typeTemplate">
+ <span>
+ <span>object</span>
+ </span>
+ </span>
+ )
+ </div>
+ </em>
+ </dt>
+ <dd>Description of a declarative rule for handling events.</dd>
+ <!-- OBJECT PROPERTIES -->
+ <dd>
+ <dl>
+ <div>
+ <div>
+ <dt>
+ <var>id</var>
+ <em>
+ <!-- TYPE -->
+ <div style="display:inline">
+ (
+ <span class="optional">optional</span>
+ <span id="typeTemplate">
+ <span>
+ <span>string</span>
+ </span>
+ </span>
+ )
+ </div>
+ </em>
+ </dt>
+ <dd>Optional identifier that allows referencing this rule.</dd>
+ <!-- OBJECT PROPERTIES -->
+ <!-- OBJECT METHODS -->
+ <!-- OBJECT EVENT FIELDS -->
+ <!-- FUNCTION PARAMETERS -->
+ </div>
+ </div><div>
+ <div>
+ <dt>
+ <var>conditions</var>
+ <em>
+ <!-- TYPE -->
+ <div style="display:inline">
+ (
+ <span id="typeTemplate">
+ <span>
+ <span>
+ array of <span><span>
+ <span>
+ <span>any</span>
+ </span>
+ </span></span>
+ </span>
+ </span>
+ </span>
+ )
+ </div>
+ </em>
+ </dt>
+ <dd>List of conditions that can trigger the actions.</dd>
+ <!-- OBJECT PROPERTIES -->
+ <!-- OBJECT METHODS -->
+ <!-- OBJECT EVENT FIELDS -->
+ <!-- FUNCTION PARAMETERS -->
+ </div>
+ </div><div>
+ <div>
+ <dt>
+ <var>actions</var>
+ <em>
+ <!-- TYPE -->
+ <div style="display:inline">
+ (
+ <span id="typeTemplate">
+ <span>
+ <span>
+ array of <span><span>
+ <span>
+ <span>any</span>
+ </span>
+ </span></span>
+ </span>
+ </span>
+ </span>
+ )
+ </div>
+ </em>
+ </dt>
+ <dd>List of actions that are triggered if one of the condtions is fulfilled.</dd>
+ <!-- OBJECT PROPERTIES -->
+ <!-- OBJECT METHODS -->
+ <!-- OBJECT EVENT FIELDS -->
+ <!-- FUNCTION PARAMETERS -->
+ </div>
+ </div><div>
+ <div>
+ <dt>
+ <var>priority</var>
+ <em>
+ <!-- TYPE -->
+ <div style="display:inline">
+ (
+ <span class="optional">optional</span>
+ <span id="typeTemplate">
+ <span>
+ <span>integer</span>
+ </span>
+ </span>
+ )
+ </div>
+ </em>
+ </dt>
+ <dd>Optional priority of this rule. Defaults to 100.</dd>
+ <!-- OBJECT PROPERTIES -->
+ <!-- OBJECT METHODS -->
+ <!-- OBJECT EVENT FIELDS -->
+ <!-- FUNCTION PARAMETERS -->
+ </div>
+ </div>
+ </dl>
+ </dd>
+ <!-- OBJECT METHODS -->
+ <!-- OBJECT EVENT FIELDS -->
+ <!-- FUNCTION PARAMETERS -->
+ </div>
+ </div><div class="apiItem">
+ <a name="type-UrlFilter"></a>
+ <h4>UrlFilter</h4>
+ <div>
+ <dt>
+ <em>
+ <!-- TYPE -->
+ <div style="display:inline">
+ (
+ <span id="typeTemplate">
+ <span>
+ <span>object</span>
+ </span>
+ </span>
+ )
+ </div>
+ </em>
+ </dt>
+ <dd>Filters URLs for various criteria</dd>
+ <!-- OBJECT PROPERTIES -->
+ <dd>
+ <dl>
+ <div>
+ <div>
+ <dt>
+ <var>hostContains</var>
+ <em>
+ <!-- TYPE -->
+ <div style="display:inline">
+ (
+ <span class="optional">optional</span>
+ <span id="typeTemplate">
+ <span>
+ <span>string</span>
+ </span>
+ </span>
+ )
+ </div>
+ </em>
+ </dt>
+ <dd>Matches if the host name of the URL contains a specified string.</dd>
+ <!-- OBJECT PROPERTIES -->
+ <!-- OBJECT METHODS -->
+ <!-- OBJECT EVENT FIELDS -->
+ <!-- FUNCTION PARAMETERS -->
+ </div>
+ </div><div>
+ <div>
+ <dt>
+ <var>hostEquals</var>
+ <em>
+ <!-- TYPE -->
+ <div style="display:inline">
+ (
+ <span class="optional">optional</span>
+ <span id="typeTemplate">
+ <span>
+ <span>string</span>
+ </span>
+ </span>
+ )
+ </div>
+ </em>
+ </dt>
+ <dd>Matches if the host name of the URL is equal to a specified string.</dd>
+ <!-- OBJECT PROPERTIES -->
+ <!-- OBJECT METHODS -->
+ <!-- OBJECT EVENT FIELDS -->
+ <!-- FUNCTION PARAMETERS -->
+ </div>
+ </div><div>
+ <div>
+ <dt>
+ <var>hostPrefix</var>
+ <em>
+ <!-- TYPE -->
+ <div style="display:inline">
+ (
+ <span class="optional">optional</span>
+ <span id="typeTemplate">
+ <span>
+ <span>string</span>
+ </span>
+ </span>
+ )
+ </div>
+ </em>
+ </dt>
+ <dd>Matches if the host name of the URL starts with a specified string.</dd>
+ <!-- OBJECT PROPERTIES -->
+ <!-- OBJECT METHODS -->
+ <!-- OBJECT EVENT FIELDS -->
+ <!-- FUNCTION PARAMETERS -->
+ </div>
+ </div><div>
+ <div>
+ <dt>
+ <var>hostSuffix</var>
+ <em>
+ <!-- TYPE -->
+ <div style="display:inline">
+ (
+ <span class="optional">optional</span>
+ <span id="typeTemplate">
+ <span>
+ <span>string</span>
+ </span>
+ </span>
+ )
+ </div>
+ </em>
+ </dt>
+ <dd>Matches if the host name of the URL ends with a specified string.</dd>
+ <!-- OBJECT PROPERTIES -->
+ <!-- OBJECT METHODS -->
+ <!-- OBJECT EVENT FIELDS -->
+ <!-- FUNCTION PARAMETERS -->
+ </div>
+ </div><div>
+ <div>
+ <dt>
+ <var>pathContains</var>
+ <em>
+ <!-- TYPE -->
+ <div style="display:inline">
+ (
+ <span class="optional">optional</span>
+ <span id="typeTemplate">
+ <span>
+ <span>string</span>
+ </span>
+ </span>
+ )
+ </div>
+ </em>
+ </dt>
+ <dd>Matches if the path segment of the URL contains a specified string.</dd>
+ <!-- OBJECT PROPERTIES -->
+ <!-- OBJECT METHODS -->
+ <!-- OBJECT EVENT FIELDS -->
+ <!-- FUNCTION PARAMETERS -->
+ </div>
+ </div><div>
+ <div>
+ <dt>
+ <var>pathEquals</var>
+ <em>
+ <!-- TYPE -->
+ <div style="display:inline">
+ (
+ <span class="optional">optional</span>
+ <span id="typeTemplate">
+ <span>
+ <span>string</span>
+ </span>
+ </span>
+ )
+ </div>
+ </em>
+ </dt>
+ <dd>Matches if the path segment of the URL is equal to a specified string.</dd>
+ <!-- OBJECT PROPERTIES -->
+ <!-- OBJECT METHODS -->
+ <!-- OBJECT EVENT FIELDS -->
+ <!-- FUNCTION PARAMETERS -->
+ </div>
+ </div><div>
+ <div>
+ <dt>
+ <var>pathPrefix</var>
+ <em>
+ <!-- TYPE -->
+ <div style="display:inline">
+ (
+ <span class="optional">optional</span>
+ <span id="typeTemplate">
+ <span>
+ <span>string</span>
+ </span>
+ </span>
+ )
+ </div>
+ </em>
+ </dt>
+ <dd>Matches if the path segment of the URL starts with a specified string.</dd>
+ <!-- OBJECT PROPERTIES -->
+ <!-- OBJECT METHODS -->
+ <!-- OBJECT EVENT FIELDS -->
+ <!-- FUNCTION PARAMETERS -->
+ </div>
+ </div><div>
+ <div>
+ <dt>
+ <var>pathSuffix</var>
+ <em>
+ <!-- TYPE -->
+ <div style="display:inline">
+ (
+ <span class="optional">optional</span>
+ <span id="typeTemplate">
+ <span>
+ <span>string</span>
+ </span>
+ </span>
+ )
+ </div>
+ </em>
+ </dt>
+ <dd>Matches if the path segment of the URL ends with a specified string.</dd>
+ <!-- OBJECT PROPERTIES -->
+ <!-- OBJECT METHODS -->
+ <!-- OBJECT EVENT FIELDS -->
+ <!-- FUNCTION PARAMETERS -->
+ </div>
+ </div><div>
+ <div>
+ <dt>
+ <var>queryEquals</var>
+ <em>
+ <!-- TYPE -->
+ <div style="display:inline">
+ (
+ <span class="optional">optional</span>
+ <span id="typeTemplate">
+ <span>
+ <span>string</span>
+ </span>
+ </span>
+ )
+ </div>
+ </em>
+ </dt>
+ <dd>Matches if the query segment of the URL is equal to a specified string.</dd>
+ <!-- OBJECT PROPERTIES -->
+ <!-- OBJECT METHODS -->
+ <!-- OBJECT EVENT FIELDS -->
+ <!-- FUNCTION PARAMETERS -->
+ </div>
+ </div><div>
+ <div>
+ <dt>
+ <var>queryPrefix</var>
+ <em>
+ <!-- TYPE -->
+ <div style="display:inline">
+ (
+ <span class="optional">optional</span>
+ <span id="typeTemplate">
+ <span>
+ <span>string</span>
+ </span>
+ </span>
+ )
+ </div>
+ </em>
+ </dt>
+ <dd>Matches if the query segment of the URL starts with a specified string.</dd>
+ <!-- OBJECT PROPERTIES -->
+ <!-- OBJECT METHODS -->
+ <!-- OBJECT EVENT FIELDS -->
+ <!-- FUNCTION PARAMETERS -->
+ </div>
+ </div><div>
+ <div>
+ <dt>
+ <var>querySuffix</var>
+ <em>
+ <!-- TYPE -->
+ <div style="display:inline">
+ (
+ <span class="optional">optional</span>
+ <span id="typeTemplate">
+ <span>
+ <span>string</span>
+ </span>
+ </span>
+ )
+ </div>
+ </em>
+ </dt>
+ <dd>Matches if the query segment of the URL ends with a specified string.</dd>
+ <!-- OBJECT PROPERTIES -->
+ <!-- OBJECT METHODS -->
+ <!-- OBJECT EVENT FIELDS -->
+ <!-- FUNCTION PARAMETERS -->
+ </div>
+ </div><div>
+ <div>
+ <dt>
+ <var>urlSuffix</var>
+ <em>
+ <!-- TYPE -->
+ <div style="display:inline">
+ (
+ <span class="optional">optional</span>
+ <span id="typeTemplate">
+ <span>
+ <span>string</span>
+ </span>
+ </span>
+ )
+ </div>
+ </em>
+ </dt>
+ <dd>Matches if the URL ends with a specified string.</dd>
+ <!-- OBJECT PROPERTIES -->
+ <!-- OBJECT METHODS -->
+ <!-- OBJECT EVENT FIELDS -->
+ <!-- FUNCTION PARAMETERS -->
+ </div>
+ </div><div>
+ <div>
+ <dt>
+ <var>urlEquals</var>
+ <em>
+ <!-- TYPE -->
+ <div style="display:inline">
+ (
+ <span class="optional">optional</span>
+ <span id="typeTemplate">
+ <span>
+ <span>string</span>
+ </span>
+ </span>
+ )
+ </div>
+ </em>
+ </dt>
+ <dd>Matches if the URL is equal to a specified string.</dd>
+ <!-- OBJECT PROPERTIES -->
+ <!-- OBJECT METHODS -->
+ <!-- OBJECT EVENT FIELDS -->
+ <!-- FUNCTION PARAMETERS -->
+ </div>
+ </div><div>
+ <div>
+ <dt>
+ <var>urlPrefix</var>
+ <em>
+ <!-- TYPE -->
+ <div style="display:inline">
+ (
+ <span class="optional">optional</span>
+ <span id="typeTemplate">
+ <span>
+ <span>string</span>
+ </span>
+ </span>
+ )
+ </div>
+ </em>
+ </dt>
+ <dd>Matches if the URL starts with a specified string.</dd>
+ <!-- OBJECT PROPERTIES -->
+ <!-- OBJECT METHODS -->
+ <!-- OBJECT EVENT FIELDS -->
+ <!-- FUNCTION PARAMETERS -->
+ </div>
+ </div><div>
+ <div>
+ <dt>
+ <var>schemes</var>
+ <em>
+ <!-- TYPE -->
+ <div style="display:inline">
+ (
+ <span class="optional">optional</span>
+ <span id="typeTemplate">
+ <span>
+ <span>
+ array of <span><span>
+ <span>
+ <span>string</span>
+ </span>
+ </span></span>
+ </span>
+ </span>
+ </span>
+ )
+ </div>
+ </em>
+ </dt>
+ <dd>Matches if the scheme of the URL is equal to any of the schemes specified in the array.</dd>
+ <!-- OBJECT PROPERTIES -->
+ <!-- OBJECT METHODS -->
+ <!-- OBJECT EVENT FIELDS -->
+ <!-- FUNCTION PARAMETERS -->
+ </div>
+ </div><div>
+ <div>
+ <dt>
+ <var>ports</var>
+ <em>
+ <!-- TYPE -->
+ <div style="display:inline">
+ (
+ <span class="optional">optional</span>
+ <span id="typeTemplate">
+ <span>
+ <span>
+ array of <span><span>
+ <span>
+ <span>integer or array of integer</span>
+ </span>
+ </span></span>
+ </span>
+ </span>
+ </span>
+ )
+ </div>
+ </em>
+ </dt>
+ <dd>Matches if the port of the URL is contained in any of the specified port lists. For example <code>[80, 443, [1000, 1200]]</code> matches all requests on port 80, 443 and in the range 1000-1200.</dd>
+ <!-- OBJECT PROPERTIES -->
+ <!-- OBJECT METHODS -->
+ <!-- OBJECT EVENT FIELDS -->
+ <!-- FUNCTION PARAMETERS -->
+ </div>
+ </div>
+ </dl>
+ </dd>
+ <!-- OBJECT METHODS -->
+ <!-- OBJECT EVENT FIELDS -->
+ <!-- FUNCTION PARAMETERS -->
+ </div>
+ </div> <!-- /apiItem -->
+ </div> <!-- /apiGroup -->
+ </div> <!-- /apiPage -->
</div> <!-- /gc-pagecontent -->
</div> <!-- /g-section -->
</div> <!-- /codesiteContent -->
diff --git a/chrome/common/extensions/docs/extension.html b/chrome/common/extensions/docs/extension.html
index 4c19a17..9f6e9e5 100644
--- a/chrome/common/extensions/docs/extension.html
+++ b/chrome/common/extensions/docs/extension.html
@@ -253,10 +253,6 @@
<ol>
</ol>
</li><li>
- <a href="#type-Event">Event</a>
- <ol>
- </ol>
- </li><li>
<a href="#type-Port">Port</a>
<ol>
</ol>
@@ -1649,135 +1645,6 @@ For details, see
<!-- FUNCTION PARAMETERS -->
</div>
</div><div class="apiItem">
- <a name="type-Event"></a>
- <h4>Event</h4>
- <div>
- <dt>
- <em>
- <!-- TYPE -->
- <div style="display:inline">
- (
- <span id="typeTemplate">
- <span>
- <span>object</span>
- </span>
- </span>
- )
- </div>
- </em>
- </dt>
- <dd>An object which allows the addition and removal of listeners for a Chrome event.</dd>
- <!-- OBJECT PROPERTIES -->
- <dd>
- <dl>
- <div>
- <div>
- <dt>
- <var>addListener</var>
- <em>
- <!-- TYPE -->
- <div style="display:inline">
- (
- <span id="typeTemplate">
- <span>
- <span>function</span>
- </span>
- </span>
- )
- </div>
- </em>
- </dt>
- <dd class="todo">
- Undocumented.
- </dd>
- <!-- OBJECT PROPERTIES -->
- <!-- OBJECT METHODS -->
- <!-- OBJECT EVENT FIELDS -->
- <!-- FUNCTION PARAMETERS -->
- </div>
- </div><div>
- <div>
- <dt>
- <var>removeListener</var>
- <em>
- <!-- TYPE -->
- <div style="display:inline">
- (
- <span id="typeTemplate">
- <span>
- <span>function</span>
- </span>
- </span>
- )
- </div>
- </em>
- </dt>
- <dd class="todo">
- Undocumented.
- </dd>
- <!-- OBJECT PROPERTIES -->
- <!-- OBJECT METHODS -->
- <!-- OBJECT EVENT FIELDS -->
- <!-- FUNCTION PARAMETERS -->
- </div>
- </div><div>
- <div>
- <dt>
- <var>hasListener</var>
- <em>
- <!-- TYPE -->
- <div style="display:inline">
- (
- <span id="typeTemplate">
- <span>
- <span>function</span>
- </span>
- </span>
- )
- </div>
- </em>
- </dt>
- <dd class="todo">
- Undocumented.
- </dd>
- <!-- OBJECT PROPERTIES -->
- <!-- OBJECT METHODS -->
- <!-- OBJECT EVENT FIELDS -->
- <!-- FUNCTION PARAMETERS -->
- </div>
- </div><div>
- <div>
- <dt>
- <var>hasListeners</var>
- <em>
- <!-- TYPE -->
- <div style="display:inline">
- (
- <span id="typeTemplate">
- <span>
- <span>function</span>
- </span>
- </span>
- )
- </div>
- </em>
- </dt>
- <dd class="todo">
- Undocumented.
- </dd>
- <!-- OBJECT PROPERTIES -->
- <!-- OBJECT METHODS -->
- <!-- OBJECT EVENT FIELDS -->
- <!-- FUNCTION PARAMETERS -->
- </div>
- </div>
- </dl>
- </dd>
- <!-- OBJECT METHODS -->
- <!-- OBJECT EVENT FIELDS -->
- <!-- FUNCTION PARAMETERS -->
- </div>
- </div><div class="apiItem">
<a name="type-Port"></a>
<h4>Port</h4>
<div>
@@ -1834,7 +1701,7 @@ For details, see
(
<span id="typeTemplate">
<span>
- <a href="extension.html#type-Event">Event</a>
+ <a href="events.html#type-Event">Event</a>
</span>
</span>
)
@@ -1859,7 +1726,7 @@ For details, see
(
<span id="typeTemplate">
<span>
- <a href="extension.html#type-Event">Event</a>
+ <a href="events.html#type-Event">Event</a>
</span>
</span>
)
diff --git a/chrome/common/extensions/docs/js/api_page_generator.js b/chrome/common/extensions/docs/js/api_page_generator.js
index b6a4de9..55f3bba 100644
--- a/chrome/common/extensions/docs/js/api_page_generator.js
+++ b/chrome/common/extensions/docs/js/api_page_generator.js
@@ -30,9 +30,9 @@ var MODULE_SCHEMAS = [
'../api/context_menus.json',
'../api/cookies.json',
'../api/debugger.json',
- '../api/declarative.json',
'../api/declarative_web_request.json',
'../api/devtools.json',
+ '../api/events.json',
'../api/experimental_accessibility.json',
'../api/experimental_app.json',
'../api/experimental_bookmark_manager.json',
diff --git a/chrome/common/extensions/docs/samples.html b/chrome/common/extensions/docs/samples.html
index 20e92e5..34164ef 100644
--- a/chrome/common/extensions/docs/samples.html
+++ b/chrome/common/extensions/docs/samples.html
@@ -292,10 +292,10 @@
</span><span>
<a href="javascript:void(0);" onclick="setFilter('chrome.debugger', this)">chrome.debugger</a><span>, </span>
</span><span>
- <a href="javascript:void(0);" onclick="setFilter('chrome.declarative', this)">chrome.declarative</a><span>, </span>
- </span><span>
<a href="javascript:void(0);" onclick="setFilter('chrome.declarativeWebRequest', this)">chrome.declarativeWebRequest</a><span>, </span>
</span><span>
+ <a href="javascript:void(0);" onclick="setFilter('chrome.events', this)">chrome.events</a><span>, </span>
+ </span><span>
<a href="javascript:void(0);" onclick="setFilter('chrome.experimental', this)">chrome.experimental</a><span>, </span>
</span><span>
<a href="javascript:void(0);" onclick="setFilter('chrome.extension', this)">chrome.extension</a><span>, </span>
diff --git a/chrome/common/extensions/docs/samples.json b/chrome/common/extensions/docs/samples.json
index 35a3d2d..21aee87 100644
--- a/chrome/common/extensions/docs/samples.json
+++ b/chrome/common/extensions/docs/samples.json
@@ -66,9 +66,6 @@
"chrome.debugger.onDetach": "debugger.html#event-onDetach",
"chrome.debugger.onEvent": "debugger.html#event-onEvent",
"chrome.debugger.sendCommand": "debugger.html#method-sendCommand",
- "chrome.declarative.addRules": "declarative.html#method-addRules",
- "chrome.declarative.getRules": "declarative.html#method-getRules",
- "chrome.declarative.removeRules": "declarative.html#method-removeRules",
"chrome.declarativeWebRequest.onRequest": "declarativeWebRequest.html#event-onRequest",
"chrome.devtools.inspectedWindow.Resource.getContent": "devtools.inspectedWindow.html#method-Resource-getContent",
"chrome.devtools.inspectedWindow.Resource.setContent": "devtools.inspectedWindow.html#method-Resource-setContent",
@@ -97,6 +94,13 @@
"chrome.devtools.panels.ExtensionSidebarPane.setPage": "devtools.panels.html#method-ExtensionSidebarPane-setPage",
"chrome.devtools.panels.create": "devtools.panels.html#method-create",
"chrome.devtools.panels.setOpenResourceHandler": "devtools.panels.html#method-setOpenResourceHandler",
+ "chrome.events.Event.addListener": "events.html#method-Event-addListener",
+ "chrome.events.Event.addRules": "events.html#method-Event-addRules",
+ "chrome.events.Event.getRules": "events.html#method-Event-getRules",
+ "chrome.events.Event.hasListener": "events.html#method-Event-hasListener",
+ "chrome.events.Event.hasListeners": "events.html#method-Event-hasListeners",
+ "chrome.events.Event.removeListener": "events.html#method-Event-removeListener",
+ "chrome.events.Event.removeRules": "events.html#method-Event-removeRules",
"chrome.experimental.app.clearAllNotifications": "experimental.app.html#method-clearAllNotifications",
"chrome.experimental.app.notify": "experimental.app.html#method-notify",
"chrome.experimental.bluetooth.connect": "experimental.bluetooth.html#method-connect",
diff --git a/chrome/common/extensions/docs/static/declarative.html b/chrome/common/extensions/docs/static/declarative.html
deleted file mode 100644
index 87bcd42..0000000
--- a/chrome/common/extensions/docs/static/declarative.html
+++ /dev/null
@@ -1,140 +0,0 @@
-<!-- BEGIN AUTHORED CONTENT -->
-
-<h2 id="notes">Notes</h2>
-
-<p>
-The Declarative API is a framework to define rules consisting of declarative
-conditions and actions. Conditions are evaluated in the browser rather than the
-JavaScript engine which reduces roundtrip latencies and allows for very high
-efficiency.
-</p>
-
-</p>The Declarative API is an abstract foundation for the <a
- href="declarativeWebRequest.html">Declarative Web Request API</a> and
-possibly further extension APIs in the future. This page describes the
-underlying concepts of all Declarative APIs.
-</p>
-
-<h2 id="manifest">Manifest</h2>
-
-<p>
-You must declare the "declarative" permission in your extension's manifest
-to use APIs that are based on this API.
-</p>
-
-<pre>{
- "name": "My extension",
- ...
-<b> "permissions": [
- "declarative",
- ]</b>,
- ...
-}</pre>
-
-<h2 id="rules">Rules</h2>
-
-<p>The simplest possible rule consists of one or more conditions and one or more
-actions:</p>
-<pre>
-var rule = {
- conditions: [ /* my conditions */ ],
- actions: [ /* my actions */ ]
-};
-</pre>
-
-<p>If any of the conditions is fulfilled, all actions are executed.</p>
-
-<p>In addition to conditions and actions you may give each rule an identifier,
-which simplifies unregistering previously registered rules, and a priority to
-define precedences among rules. Priorities are only considered if rules conflict
-each other or need to be executed in a specific order.</p>
-
-<pre>
-var rule = {
- id: "my rule", // optional, will be generated if not set.
- priority: 100, // optional, defaults to 100.
- conditions: [ /* my conditions */ ],
- actions: [ /* my actions */ ]
-};
-</pre>
-
-<h2 id="eventobjects">Event objects</h2>
-
-<p>
-<a href="events.html">Event objects</a> may support rules. These event objects
-don't call a callback function when events happer but test whether any
-registered rule has at least one fulfilled condition and execute the actions
-associated with this rule. Event objects supporting the declarative API have
-three relevant methods: <a href="#method-addRules"><code>addRules()</code></a>,
-<a href="#method-removeRules"><code>removeRules()</code></a>, and
-<a href="#method-getRules"><code>getRules()</code></a>.
-</p>
-
-<h3 id="addingrules">Adding rules</h3>
-
-<p>
-To add rules call the <code>addRules()</code> function of the event object. It
-takes an array of rule instances as its first parameter and a callback function
-that is called on completion.
-</p>
-
-<pre>
-var rule_list = [rule1, rule2, ...];
-function addRules(rule_list, function callback(details) {...});
-</pre>
-
-<p>
-If the rules were inserted successfully, the <code>details</code> parameter
-contains an array of inserted rules appearing in the same order as in the passed
-<code>rule_list</code> where the optional parameters <code>id</code> and
-<code>priority</code> were filled with the generated values. If any rule is
-invalid, e.g., because it contained an invalid condition or action, none of the
-rules are added and the <a
- href="extension.html#property-lastError">lastError</a> variable is set when
-the callback function is called. Each rule in <code>rule_list</code> must
-contain a unique identifier that is not currently used by another rule or an
-empty identifier.
-</p>
-
-<h3 id="removingrules">Removing rules</h3>
-
-<p>
-To remove rules call the <code>removeRules()</code> function. It accepts an
-optional array of rule identifiers as its first parameter and a callback
-function as its second parameter.
-</p>
-
-<pre>
-var rule_ids = ["id1", "id2", ...];
-function removeRules(rule_ids, function callback() {...});
-</pre>
-
-<p>
-If <code>rule_ids</code> is an array of identifiers, all rules having
-identifiers listed in the array are removed. If <code>rule_ids</code> lists an
-identifier, that is unknown, this identifier is silently ignored. If
-<code>rule_ids</code> is <code>undefined</code>, all registered rules of this
-extension are removed. The <code>callback()</code> function is called when the
-rules were removed.
-</p>
-
-<h3 id="retrievingrules">Retrieving rules</h3>
-
-<p>
-To retrieve a list of currently registered rules, call the
-<code>getRules()</code> function. It accepts an optional array of rule
-identifiers with the same semantics as <code>removeRules</code> and a callback
-function.
-<p>
-
-<pre>
-var rule_ids = ["id1", "id2", ...];
-function getRules(rule_ids, function callback(details) {...});
-</pre>
-
-<p>
-The <code>details</code> parameter passed to the <code>calback()</code> function
-refers to an array of rules including filled optional parameters.
-</p>
-
-<!-- END AUTHORED CONTENT -->
diff --git a/chrome/common/extensions/docs/static/declarativeWebRequest.html b/chrome/common/extensions/docs/static/declarativeWebRequest.html
index 5b7f621..f99ca01 100644
--- a/chrome/common/extensions/docs/static/declarativeWebRequest.html
+++ b/chrome/common/extensions/docs/static/declarativeWebRequest.html
@@ -35,8 +35,8 @@ hosts whose network requests you want to access.
<p>
The Declarative Web Request API follows the concepts of the <a
- href="declarative.html">Declarative API</a>. You can register rules to the
-<code>chrome.declarativeWebRequest.onRequest</code> event object.
+ href="events.html#declarative">Declarative API</a>. You can register rules to
+the <code>chrome.declarativeWebRequest.onRequest</code> event object.
</p>
<p>
diff --git a/chrome/common/extensions/docs/static/events.html b/chrome/common/extensions/docs/static/events.html
index dfb5089..d734653 100644
--- a/chrome/common/extensions/docs/static/events.html
+++ b/chrome/common/extensions/docs/static/events.html
@@ -46,3 +46,125 @@ bool hasListener(function callback(...))
</pre>
<!-- [PENDING: explain removeListener and hasListener] -->
+
+
+<h2 id="declarative">Declarative Event Handlers</h2>
+
+<p>
+The declarative event handlers provide a means to define rules consisting of
+declarative conditions and actions. Conditions are evaluated in the browser
+rather than the JavaScript engine which reduces roundtrip latencies and allows
+for very high efficiency.
+</p>
+
+<p>Declarative event handlers are used for example in the <a
+ href="declarativeWebRequest.html">Declarative Web Request API</a> and possibly
+further extension APIs in the future. This page describes the underlying
+concepts of all declarative event handlers.
+</p>
+
+<h3 id="rules">Rules</h3>
+
+<p>The simplest possible rule consists of one or more conditions and one or more
+actions:</p>
+<pre>
+var rule = {
+ conditions: [ /* my conditions */ ],
+ actions: [ /* my actions */ ]
+};
+</pre>
+
+<p>If any of the conditions is fulfilled, all actions are executed.</p>
+
+<p>In addition to conditions and actions you may give each rule an identifier,
+which simplifies unregistering previously registered rules, and a priority to
+define precedences among rules. Priorities are only considered if rules conflict
+each other or need to be executed in a specific order.</p>
+
+<pre>
+var rule = {
+ id: "my rule", // optional, will be generated if not set.
+ priority: 100, // optional, defaults to 100.
+ conditions: [ /* my conditions */ ],
+ actions: [ /* my actions */ ]
+};
+</pre>
+
+<h3 id="eventobjects">Event objects</h3>
+
+<p>
+<a href="events.html">Event objects</a> may support rules. These event objects
+don't call a callback function when events happer but test whether any
+registered rule has at least one fulfilled condition and execute the actions
+associated with this rule. Event objects supporting the declarative API have
+three relevant methods: <a href="#method-addRules"><code>addRules()</code></a>,
+<a href="#method-removeRules"><code>removeRules()</code></a>, and
+<a href="#method-getRules"><code>getRules()</code></a>.
+</p>
+
+<h3 id="addingrules">Adding rules</h3>
+
+<p>
+To add rules call the <code>addRules()</code> function of the event object. It
+takes an array of rule instances as its first parameter and a callback function
+that is called on completion.
+</p>
+
+<pre>
+var rule_list = [rule1, rule2, ...];
+function addRules(rule_list, function callback(details) {...});
+</pre>
+
+<p>
+If the rules were inserted successfully, the <code>details</code> parameter
+contains an array of inserted rules appearing in the same order as in the passed
+<code>rule_list</code> where the optional parameters <code>id</code> and
+<code>priority</code> were filled with the generated values. If any rule is
+invalid, e.g., because it contained an invalid condition or action, none of the
+rules are added and the <a
+ href="extension.html#property-lastError">lastError</a> variable is set when
+the callback function is called. Each rule in <code>rule_list</code> must
+contain a unique identifier that is not currently used by another rule or an
+empty identifier.
+</p>
+
+<h3 id="removingrules">Removing rules</h3>
+
+<p>
+To remove rules call the <code>removeRules()</code> function. It accepts an
+optional array of rule identifiers as its first parameter and a callback
+function as its second parameter.
+</p>
+
+<pre>
+var rule_ids = ["id1", "id2", ...];
+function removeRules(rule_ids, function callback() {...});
+</pre>
+
+<p>
+If <code>rule_ids</code> is an array of identifiers, all rules having
+identifiers listed in the array are removed. If <code>rule_ids</code> lists an
+identifier, that is unknown, this identifier is silently ignored. If
+<code>rule_ids</code> is <code>undefined</code>, all registered rules of this
+extension are removed. The <code>callback()</code> function is called when the
+rules were removed.
+</p>
+
+<h3 id="retrievingrules">Retrieving rules</h3>
+
+<p>
+To retrieve a list of currently registered rules, call the
+<code>getRules()</code> function. It accepts an optional array of rule
+identifiers with the same semantics as <code>removeRules</code> and a callback
+function.
+<p>
+
+<pre>
+var rule_ids = ["id1", "id2", ...];
+function getRules(rule_ids, function callback(details) {...});
+</pre>
+
+<p>
+The <code>details</code> parameter passed to the <code>calback()</code> function
+refers to an array of rules including filled optional parameters.
+</p>
diff --git a/chrome/common/extensions/extension_permission_set.cc b/chrome/common/extensions/extension_permission_set.cc
index cf2e40f..3d570d6b 100644
--- a/chrome/common/extensions/extension_permission_set.cc
+++ b/chrome/common/extensions/extension_permission_set.cc
@@ -45,6 +45,7 @@ const char* kNonPermissionModuleNames[] = {
"app",
"browserAction",
"devtools",
+ "events",
"extension",
"i18n",
"omnibox",
diff --git a/chrome/common/extensions_api_resources.grd b/chrome/common/extensions_api_resources.grd
index 3d9d812..93534a1 100644
--- a/chrome/common/extensions_api_resources.grd
+++ b/chrome/common/extensions_api_resources.grd
@@ -19,10 +19,10 @@
<include name="IDR_EXTENSION_API_JSON_CONTEXTMENUS" file="extensions\api\context_menus.json" type="BINDATA" />
<include name="IDR_EXTENSION_API_JSON_COOKIES" file="extensions\api\cookies.json" type="BINDATA" />
<include name="IDR_EXTENSION_API_JSON_DEBUGGER" file="extensions\api\debugger.json" type="BINDATA" />
- <include name="IDR_EXTENSION_API_JSON_DECLARATIVE" file="extensions\api\declarative.json" type="BINDATA" />
<include name="IDR_EXTENSION_API_JSON_DECLARATIVE_WEBREQUEST" file="extensions\api\declarative_web_request.json" type="BINDATA" />
<include name="IDR_EXTENSION_API_JSON_DEVTOOLS" file="extensions\api\devtools.json" type="BINDATA" />
<include name="IDR_EXTENSION_API_JSON_ECHOPRIVATE" file="extensions\api\echo_private.json" type="BINDATA" />
+ <include name="IDR_EXTENSION_API_JSON_EVENTS" file="extensions\api\events.json" type="BINDATA" />
<include name="IDR_EXTENSION_API_JSON_EXPERIMENTAL_ACCESSIBILITY" file="extensions\api\experimental_accessibility.json" type="BINDATA" />
<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_bookmark_manager.json" type="BINDATA" />
diff --git a/chrome/renderer/extensions/api_definitions_natives.cc b/chrome/renderer/extensions/api_definitions_natives.cc
index bc8b4b0..2bcbc28 100644
--- a/chrome/renderer/extensions/api_definitions_natives.cc
+++ b/chrome/renderer/extensions/api_definitions_natives.cc
@@ -4,6 +4,12 @@
#include "chrome/renderer/extensions/api_definitions_natives.h"
+#include <algorithm>
+
+namespace {
+const char kInvalidExtensionNamespace[] = "Invalid extension namespace";
+}
+
namespace extensions {
ApiDefinitionsNatives::ApiDefinitionsNatives(
@@ -19,8 +25,29 @@ v8::Handle<v8::Value> ApiDefinitionsNatives::GetExtensionAPIDefinition(
ChromeV8Context* v8_context =
extension_dispatcher()->v8_context_set().GetCurrent();
CHECK(v8_context);
+
+ std::set<std::string> available_apis(v8_context->GetAvailableExtensionAPIs());
+ if (args.Length() == 0) {
+ return extension_dispatcher()->v8_schema_registry()->GetSchemas(
+ available_apis);
+ }
+ // Build set of APIs requested by the user.
+ std::set<std::string> requested_apis;
+ for (int i = 0; i < args.Length(); ++i) {
+ if (!args[i]->IsString()) {
+ v8::ThrowException(v8::String::New(kInvalidExtensionNamespace));
+ return v8::Undefined();
+ }
+ requested_apis.insert(*v8::String::Utf8Value(args[i]->ToString()));
+ }
+
+ // Filter those that are unknown.
+ std::set<std::string> apis_to_check;
+ std::set_intersection(requested_apis.begin(), requested_apis.end(),
+ available_apis.begin(), available_apis.end(),
+ std::inserter(apis_to_check, apis_to_check.begin()));
return extension_dispatcher()->v8_schema_registry()->GetSchemas(
- v8_context->GetAvailableExtensionAPIs());
+ apis_to_check);
}
} // namespace extensions
diff --git a/chrome/renderer/extensions/api_definitions_natives.h b/chrome/renderer/extensions/api_definitions_natives.h
index 48a9abe..269728b 100644
--- a/chrome/renderer/extensions/api_definitions_natives.h
+++ b/chrome/renderer/extensions/api_definitions_natives.h
@@ -19,8 +19,9 @@ class ApiDefinitionsNatives : public ChromeV8Extension {
explicit ApiDefinitionsNatives(ExtensionDispatcher* extension_dispatcher);
private:
- // Takes no arguments and returns the list of schemas that are available to
- // the calling context.
+ // Returns the list of schemas that are available to the calling context
+ // and have their names listed in |args|. If |args| is empty, returns the list
+ // of all schemas that are available to the calling context.
v8::Handle<v8::Value> GetExtensionAPIDefinition(const v8::Arguments& args);
DISALLOW_COPY_AND_ASSIGN(ApiDefinitionsNatives);
diff --git a/chrome/renderer/extensions/event_unittest.cc b/chrome/renderer/extensions/event_unittest.cc
index ca1d9b04..61fa9ca 100644
--- a/chrome/renderer/extensions/event_unittest.cc
+++ b/chrome/renderer/extensions/event_unittest.cc
@@ -14,6 +14,7 @@ class EventUnittest : public ModuleSystemTest {
module_system_->RunString("chrome = {};", "setup-chrome");
RegisterModule("event", IDR_EVENT_BINDINGS_JS);
+ RegisterModule("utils", IDR_UTILS_JS);
// Mock out the native handler for event_bindings. These mocks will fail if
// any invariants maintained by the real event_bindings are broken.
@@ -31,6 +32,10 @@ class EventUnittest : public ModuleSystemTest {
OverrideNativeHandler("chrome_hidden",
"var chromeHidden = {};"
"exports.GetChromeHidden = function() { return chromeHidden; };");
+ OverrideNativeHandler("sendRequest",
+ "exports.sendRequest = function() {};");
+ OverrideNativeHandler("apiDefinitions",
+ "exports.GetExtensionAPIDefinition = function() {};");
}
};
diff --git a/chrome/renderer/extensions/extension_dispatcher.cc b/chrome/renderer/extensions/extension_dispatcher.cc
index 1d96259..32c0b1d 100644
--- a/chrome/renderer/extensions/extension_dispatcher.cc
+++ b/chrome/renderer/extensions/extension_dispatcher.cc
@@ -508,6 +508,7 @@ void ExtensionDispatcher::PopulateSourceMap() {
// Libraries.
source_map_.RegisterSource("sendRequest", IDR_SEND_REQUEST_JS);
source_map_.RegisterSource("setIcon", IDR_SET_ICON_JS);
+ source_map_.RegisterSource("utils", IDR_UTILS_JS);
// Custom bindings.
source_map_.RegisterSource("app", IDR_APP_CUSTOM_BINDINGS_JS);
@@ -517,8 +518,6 @@ void ExtensionDispatcher::PopulateSourceMap() {
IDR_CONTENT_SETTINGS_CUSTOM_BINDINGS_JS);
source_map_.RegisterSource("contextMenus",
IDR_CONTEXT_MENUS_CUSTOM_BINDINGS_JS);
- source_map_.RegisterSource("declarative",
- IDR_DECLARATIVE_CUSTOM_BINDINGS_JS);
source_map_.RegisterSource("declarativeWebRequest",
IDR_DECLARATIVE_WEBREQUEST_CUSTOM_BINDINGS_JS);
source_map_.RegisterSource("devtools", IDR_DEVTOOLS_CUSTOM_BINDINGS_JS);
diff --git a/chrome/renderer/renderer_resources.grd b/chrome/renderer/renderer_resources.grd
index e1d41e7..86594ee 100644
--- a/chrome/renderer/renderer_resources.grd
+++ b/chrome/renderer/renderer_resources.grd
@@ -32,6 +32,7 @@ without changes to the corresponding grd file. fb9 -->
<!-- Libraries. -->
<include name="IDR_SEND_REQUEST_JS" file="resources\extensions\send_request.js" type="BINDATA" />
<include name="IDR_SET_ICON_JS" file="resources\extensions\set_icon.js" type="BINDATA" />
+ <include name="IDR_UTILS_JS" file="resources\extensions\utils.js" type="BINDATA" />
<!-- Custom bindings for extension APIs. -->
<if expr="pp_ifdef('enable_extensions')">
@@ -39,7 +40,6 @@ without changes to the corresponding grd file. fb9 -->
<include name="IDR_BROWSER_ACTION_CUSTOM_BINDINGS_JS" file="resources\extensions\browser_action_custom_bindings.js" type="BINDATA" />
<include name="IDR_CONTENT_SETTINGS_CUSTOM_BINDINGS_JS" file="resources\extensions\content_settings_custom_bindings.js" type="BINDATA" />
<include name="IDR_CONTEXT_MENUS_CUSTOM_BINDINGS_JS" file="resources\extensions\context_menus_custom_bindings.js" type="BINDATA" />
- <include name="IDR_DECLARATIVE_CUSTOM_BINDINGS_JS" file="resources\extensions\declarative_custom_bindings.js" type="BINDATA" />
<include name="IDR_DECLARATIVE_WEBREQUEST_CUSTOM_BINDINGS_JS" file="resources\extensions\declarative_webrequest_custom_bindings.js" type="BINDATA" />
<include name="IDR_DEVTOOLS_CUSTOM_BINDINGS_JS" file="resources\extensions\devtools_custom_bindings.js" type="BINDATA" />
<include name="IDR_EXPERIMENTAL_OFFSCREENTABS_CUSTOM_BINDINGS_JS" file="resources\extensions\experimental.offscreenTabs_custom_bindings.js" type="BINDATA" />
diff --git a/chrome/renderer/resources/extensions/declarative_custom_bindings.js b/chrome/renderer/resources/extensions/declarative_custom_bindings.js
deleted file mode 100644
index 0342775..0000000
--- a/chrome/renderer/resources/extensions/declarative_custom_bindings.js
+++ /dev/null
@@ -1,76 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Custom bindings for the declarative API.
-
-var chromeHidden = requireNative('chrome_hidden').GetChromeHidden();
-var sendRequest = require('sendRequest').sendRequest;
-
-chromeHidden.registerCustomHook('declarative',
- function(bindingsAPI) {
- var apiFunctions = bindingsAPI.apiFunctions;
- var apiDefinitions = bindingsAPI.apiDefinitions;
- var cachedEventOptions = {};
-
- function getEventOptions(qualifiedEventName) {
- if (cachedEventOptions[qualifiedEventName])
- return cachedEventOptions[qualifiedEventName];
-
- // Parse qualifiedEventName into namespace and event name.
- var lastSeparator = qualifiedEventName.lastIndexOf('.');
- var eventName = qualifiedEventName.substr(lastSeparator + 1);
- var namespace = qualifiedEventName.substr(0, lastSeparator);
-
- // Lookup schema definition.
- var filterNamespace = function(val) {return val.namespace === namespace;};
- var apiSchema = apiDefinitions.filter(filterNamespace)[0];
- var filterEventName = function (val) {return val.name === eventName;};
- var eventSchema = apiSchema.events.filter(filterEventName)[0];
-
- cachedEventOptions[qualifiedEventName] = eventSchema.options;
- return eventSchema.options;
- }
-
- // Takes a list of JSON datatype identifiers and returns a schema fragment
- // that verifies that a JSON object corresponds to an array of only these
- // data types.
- function buildArrayOfChoicesSchema(typesList) {
- return {
- 'type': 'array',
- 'items': {
- 'choices': typesList.map(function(el) {return {'$ref': el};})
- }
- };
- }
-
- // Validate conditions and actions against specific schemas of this
- // event object type.
- // |rules| is an array of JSON objects that follow the Rule type of the
- // declarative extension APIs. |conditions| is an array of JSON type
- // identifiers that are allowed to occur in the conditions attribute of each
- // rule. Likewise, |actions| is an array of JSON type identifiers that are
- // allowed to occur in the actions attribute of each rule.
- function validateRules(rules, conditions, actions) {
- var conditionsSchema = buildArrayOfChoicesSchema(conditions);
- var actionsSchema = buildArrayOfChoicesSchema(actions);
- rules.forEach(function(rule) {
- chromeHidden.validate([rule.conditions], [conditionsSchema]);
- chromeHidden.validate([rule.actions], [actionsSchema]);
- })
- }
-
- apiFunctions.setHandleRequest('addRules',
- function(eventName, rules, opt_callback) {
- var eventOptions = getEventOptions(eventName);
- if (!eventOptions.conditions || !eventOptions.actions) {
- throw new Error('Event ' + eventName + ' misses conditions or ' +
- 'actions in the API specification.');
- }
- validateRules(rules,
- eventOptions.conditions,
- eventOptions.actions);
- sendRequest(this.name, [eventName, rules, opt_callback],
- this.definition.parameters);
- });
-});
diff --git a/chrome/renderer/resources/extensions/declarative_webrequest_custom_bindings.js b/chrome/renderer/resources/extensions/declarative_webrequest_custom_bindings.js
index 27b70c4..03a6eec 100644
--- a/chrome/renderer/resources/extensions/declarative_webrequest_custom_bindings.js
+++ b/chrome/renderer/resources/extensions/declarative_webrequest_custom_bindings.js
@@ -5,16 +5,14 @@
// Custom bindings for the declarativeWebRequest API.
var chromeHidden = requireNative('chrome_hidden').GetChromeHidden();
+var utils = require('utils');
chromeHidden.registerCustomHook('declarativeWebRequest', function(api) {
// Returns the schema definition of type |typeId| defined in |namespace|.
function getSchema(namespace, typeId) {
- var filterNamespace = function(val) {return val.namespace === namespace;};
- var apiSchema = api.apiDefinitions.filter(filterNamespace)[0];
- var filterTypeId = function (val) {
- return val.id === namespace + "." + typeId;
- };
- var resultSchema = apiSchema.types.filter(filterTypeId)[0];
+ var apiSchema = utils.lookup(api.apiDefinitions, 'namespace', namespace);
+ var resultSchema = utils.lookup(
+ apiSchema.types, 'id', namespace + '.' + typeId);
return resultSchema;
}
diff --git a/chrome/renderer/resources/extensions/event.js b/chrome/renderer/resources/extensions/event.js
index 81c465b..8961ce5 100644
--- a/chrome/renderer/resources/extensions/event.js
+++ b/chrome/renderer/resources/extensions/event.js
@@ -5,8 +5,36 @@
var eventBindingsNatives = requireNative('event_bindings');
var AttachEvent = eventBindingsNatives.AttachEvent;
var DetachEvent = eventBindingsNatives.DetachEvent;
+ var sendRequest = require('sendRequest').sendRequest;
+ var utils = require('utils');
var chromeHidden = requireNative('chrome_hidden').GetChromeHidden();
+ var GetExtensionAPIDefinition =
+ requireNative('apiDefinitions').GetExtensionAPIDefinition;
+
+ // Schemas for the rule-style functions on the events API that
+ // only need to be generated occasionally, so populate them lazily.
+ var ruleFunctionSchemas = {
+ // These values are set lazily:
+ // addRules: {},
+ // getRules: {},
+ // removeRules: {}
+ };
+
+ // This function ensures that |ruleFunctionSchemas| is populated.
+ function ensureRuleSchemasLoaded() {
+ if (ruleFunctionSchemas.addRules)
+ return;
+ var eventsSchema = GetExtensionAPIDefinition("events")[0];
+ var eventType = utils.lookup(eventsSchema.types, 'id', 'events.Event');
+
+ ruleFunctionSchemas.addRules =
+ utils.lookup(eventType.functions, 'name', 'addRules');
+ ruleFunctionSchemas.getRules =
+ utils.lookup(eventType.functions, 'name', 'getRules');
+ ruleFunctionSchemas.removeRules =
+ utils.lookup(eventType.functions, 'name', 'removeRules');
+ }
// Local implementation of JSON.parse & JSON.stringify that protect us
// from being clobbered by an extension.
@@ -68,12 +96,13 @@
if (this.eventOptions_.supportsRules && !opt_eventName)
throw new Error("Events that support rules require an event name.");
- // Validate event parameters if we are in debug.
+ // Validate event arguments (the data that is passed to the callbacks)
+ // if we are in debug.
if (opt_argSchemas &&
chromeHidden.validateCallbacks &&
chromeHidden.validate) {
- this.validate_ = function(args) {
+ this.validateEventArgs_ = function(args) {
try {
chromeHidden.validate(args, opt_argSchemas);
} catch (exception) {
@@ -82,7 +111,7 @@
}
};
} else {
- this.validate_ = function() {}
+ this.validateEventArgs_ = function() {}
}
};
@@ -192,7 +221,7 @@
if (!this.eventOptions_.supportsListeners)
throw new Error("This event does not support listeners.");
var args = Array.prototype.slice.call(arguments);
- var validationErrors = this.validate_(args);
+ var validationErrors = this.validateEventArgs_(args);
if (validationErrors) {
return {validationErrors: validationErrors};
}
@@ -246,49 +275,72 @@
chrome.Event.prototype.destroy_ = function() {
this.listeners_ = [];
- this.validate_ = [];
+ this.validateEventArgs_ = [];
this.detach_(false);
};
- // Gets the declarative API object, or undefined if this extension doesn't
- // have access to it.
- //
- // This is defined as a function (rather than a variable) because it isn't
- // accessible until the schema bindings have been generated.
- function getDeclarativeAPI() {
- return chromeHidden.internalAPIs.declarative;
- }
-
chrome.Event.prototype.addRules = function(rules, opt_cb) {
if (!this.eventOptions_.supportsRules)
throw new Error("This event does not support rules.");
- if (!getDeclarativeAPI()) {
- throw new Error("You must have permission to use the declarative " +
- "API to support rules in events");
+
+ // Takes a list of JSON datatype identifiers and returns a schema fragment
+ // that verifies that a JSON object corresponds to an array of only these
+ // data types.
+ function buildArrayOfChoicesSchema(typesList) {
+ return {
+ 'type': 'array',
+ 'items': {
+ 'choices': typesList.map(function(el) {return {'$ref': el};})
+ }
+ };
+ };
+
+ // Validate conditions and actions against specific schemas of this
+ // event object type.
+ // |rules| is an array of JSON objects that follow the Rule type of the
+ // declarative extension APIs. |conditions| is an array of JSON type
+ // identifiers that are allowed to occur in the conditions attribute of each
+ // rule. Likewise, |actions| is an array of JSON type identifiers that are
+ // allowed to occur in the actions attribute of each rule.
+ function validateRules(rules, conditions, actions) {
+ var conditionsSchema = buildArrayOfChoicesSchema(conditions);
+ var actionsSchema = buildArrayOfChoicesSchema(actions);
+ rules.forEach(function(rule) {
+ chromeHidden.validate([rule.conditions], [conditionsSchema]);
+ chromeHidden.validate([rule.actions], [actionsSchema]);
+ })
+ };
+
+ if (!this.eventOptions_.conditions || !this.eventOptions_.actions) {
+ throw new Error('Event ' + this.eventName_ + ' misses conditions or ' +
+ 'actions in the API specification.');
}
- getDeclarativeAPI().addRules(this.eventName_, rules, opt_cb);
+
+ validateRules(rules,
+ this.eventOptions_.conditions,
+ this.eventOptions_.actions);
+
+ ensureRuleSchemasLoaded();
+ sendRequest("events.addRules", [this.eventName_, rules, opt_cb],
+ ruleFunctionSchemas.addRules.parameters);
}
chrome.Event.prototype.removeRules = function(ruleIdentifiers, opt_cb) {
if (!this.eventOptions_.supportsRules)
throw new Error("This event does not support rules.");
- if (!getDeclarativeAPI()) {
- throw new Error("You must have permission to use the declarative " +
- "API to support rules in events");
- }
- getDeclarativeAPI().removeRules(
- this.eventName_, ruleIdentifiers, opt_cb);
+ ensureRuleSchemasLoaded();
+ sendRequest("events.removeRules",
+ [this.eventName_, ruleIdentifiers, opt_cb],
+ ruleFunctionSchemas.removeRules.parameters);
}
chrome.Event.prototype.getRules = function(ruleIdentifiers, cb) {
if (!this.eventOptions_.supportsRules)
throw new Error("This event does not support rules.");
- if (!getDeclarativeAPI()) {
- throw new Error("You must have permission to use the declarative " +
- "API to support rules in events");
- }
- getDeclarativeAPI().getRules(
- this.eventName_, ruleIdentifiers, cb);
+ ensureRuleSchemasLoaded();
+ sendRequest("events.getRules",
+ [this.eventName_, ruleIdentifiers, cb],
+ ruleFunctionSchemas.getRules.parameters);
}
// Special load events: we don't use the DOM unload because that slows
diff --git a/chrome/renderer/resources/extensions/schema_generated_bindings.js b/chrome/renderer/resources/extensions/schema_generated_bindings.js
index 66c193a..d28c7d5 100644
--- a/chrome/renderer/resources/extensions/schema_generated_bindings.js
+++ b/chrome/renderer/resources/extensions/schema_generated_bindings.js
@@ -5,11 +5,15 @@
// This script contains privileged chrome extension related javascript APIs.
// It is loaded by pages whose URL has the chrome-extension protocol.
+ // TODO(battre): cleanup the usage of packages everywhere, as described here
+ // http://codereview.chromium.org/10392008/diff/38/chrome/renderer/resources/extensions/schema_generated_bindings.js
+
require('json_schema');
require('event_bindings');
var GetExtensionAPIDefinition =
requireNative('apiDefinitions').GetExtensionAPIDefinition;
var sendRequest = require('sendRequest').sendRequest;
+ var utils = require('utils');
var chromeHidden = requireNative('chrome_hidden').GetChromeHidden();
@@ -22,13 +26,6 @@
var internalAPIs = {};
chromeHidden.internalAPIs = internalAPIs;
- function forEach(dict, f) {
- for (key in dict) {
- if (dict.hasOwnProperty(key))
- f(key, dict[key]);
- }
- }
-
// Validate arguments.
var schemaValidator = new chromeHidden.JSONSchemaValidator();
chromeHidden.validate = function(args, parameterSchemas) {
@@ -510,7 +507,7 @@
if (!properties)
return;
- forEach(properties, function(propertyName, propertyDef) {
+ utils.forEach(properties, function(propertyName, propertyDef) {
if (propertyName in m)
return; // TODO(kalman): be strict like functions/events somehow.
if (!isSchemaNodeSupported(propertyDef, platform, manifestVersion))
diff --git a/chrome/renderer/resources/extensions/utils.js b/chrome/renderer/resources/extensions/utils.js
new file mode 100644
index 0000000..47d8277
--- /dev/null
+++ b/chrome/renderer/resources/extensions/utils.js
@@ -0,0 +1,29 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+function forEach(dict, f) {
+ for (key in dict) {
+ if (dict.hasOwnProperty(key))
+ f(key, dict[key]);
+ }
+}
+
+// Assuming |array_of_dictionaries| is structured like this:
+// [{id: 1, ... }, {id: 2, ...}, ...], you can use
+// lookup(array_of_dictionaries, 'id', 2) to get the dictionary with id == 2.
+function lookup(array_of_dictionaries, field, value) {
+ var filter = function (dict) {return dict[field] == value;};
+ var matches = array_of_dictionaries.filter(filter);
+ if (matches.length == 0) {
+ return undefined;
+ } else if (matches.length == 1) {
+ return matches[0]
+ } else {
+ throw new Error("Failed lookup of field '" + field + "' with value '" +
+ value + "'");
+ }
+}
+
+exports.forEach = forEach;
+exports.lookup = lookup;
diff --git a/chrome/renderer/resources/extensions/web_request_custom_bindings.js b/chrome/renderer/resources/extensions/web_request_custom_bindings.js
index a0e00e8..527af0c 100644
--- a/chrome/renderer/resources/extensions/web_request_custom_bindings.js
+++ b/chrome/renderer/resources/extensions/web_request_custom_bindings.js
@@ -32,9 +32,10 @@ function WebRequestEvent(eventName, opt_argSchemas, opt_extraArgSchemas,
this.eventOptions_ = opt_eventOptions ||
{'supportsListeners': true, 'supportsRules': false};
- if (this.eventOptions_.supportsRules)
+ if (this.eventOptions_.supportsRules) {
this.eventForRules_ =
new chrome.Event(eventName, opt_argSchemas, opt_eventOptions);
+ }
};
// Test if the given callback is registered for this event.
diff --git a/chrome/test/data/extensions/api_test/declarative/api/manifest.json b/chrome/test/data/extensions/api_test/declarative/api/manifest.json
index d01c88a..3e0f3fd 100644
--- a/chrome/test/data/extensions/api_test/declarative/api/manifest.json
+++ b/chrome/test/data/extensions/api_test/declarative/api/manifest.json
@@ -7,6 +7,6 @@
"scripts": ["background.js"]
},
"permissions": [
- "declarative", "declarativeWebRequest"
+ "declarativeWebRequest"
]
}
diff --git a/chrome/test/data/extensions/api_test/webrequest/manifest.json b/chrome/test/data/extensions/api_test/webrequest/manifest.json
index 8c7c8c1..7f2a046 100644
--- a/chrome/test/data/extensions/api_test/webrequest/manifest.json
+++ b/chrome/test/data/extensions/api_test/webrequest/manifest.json
@@ -4,7 +4,7 @@
"manifest_version": 2,
"description": "Tests the webRequest API.",
"permissions": ["webRequest", "webRequestBlocking", "tabs",
- "declarative", "declarativeWebRequest", "http://*.a.com/*"],
+ "declarativeWebRequest", "http://*.a.com/*"],
"web_accessible_resources": [
"simpleLoad/a.html",
"complexLoad/a.html",
diff --git a/tools/json_schema_compiler/cc_generator.py b/tools/json_schema_compiler/cc_generator.py
index dbe797a..d5d7021 100644
--- a/tools/json_schema_compiler/cc_generator.py
+++ b/tools/json_schema_compiler/cc_generator.py
@@ -100,12 +100,6 @@ class CCGenerator(object):
c = Code()
if type_.functions:
- # Types with functions are not instantiable in C++ because they are
- # handled in pure Javascript and hence have no properties or
- # additionalProperties.
- if type_.properties:
- raise NotImplementedError('\n'.join(model.GetModelHierarchy(type_)) +
- '\nCannot generate both functions and properties on a type')
for function in type_.functions.values():
(c.Concat(
self._GenerateFunction(
diff --git a/tools/json_schema_compiler/h_generator.py b/tools/json_schema_compiler/h_generator.py
index a028813..72877f1 100644
--- a/tools/json_schema_compiler/h_generator.py
+++ b/tools/json_schema_compiler/h_generator.py
@@ -161,12 +161,6 @@ class HGenerator(object):
c = Code()
if type_.functions:
- # Types with functions are not instantiable in C++ because they are
- # handled in pure Javascript and hence have no properties or
- # additionalProperties.
- if type_.properties:
- raise NotImplementedError('\n'.join(model.GetModelHierarchy(type_)) +
- '\nCannot generate both functions and properties on a type')
c.Sblock('namespace %(classname)s {')
for function in type_.functions.values():
(c.Concat(self._GenerateFunction(function))