summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
Diffstat (limited to 'chrome')
-rw-r--r--chrome/common/extensions/api/experimental.declarative.json2
-rw-r--r--chrome/common/extensions/docs/build/directory.py17
-rw-r--r--chrome/common/extensions/docs/examples/api/browsingData/basic.zipbin9077 -> 9255 bytes
-rw-r--r--chrome/common/extensions/docs/js/api_page_generator.js27
-rw-r--r--chrome/common/extensions/docs/samples.json3
-rw-r--r--chrome/common/extensions/docs/static/samples.html7
-rw-r--r--chrome/common/extensions/docs/template/api_template.html8
-rw-r--r--chrome/renderer/resources/extensions/event.js30
-rw-r--r--chrome/renderer/resources/extensions/schema_generated_bindings.js27
-rw-r--r--chrome/test/data/extensions/api_test/declarative/api/manifest.json4
10 files changed, 70 insertions, 55 deletions
diff --git a/chrome/common/extensions/api/experimental.declarative.json b/chrome/common/extensions/api/experimental.declarative.json
index f8e315b..c98e33d 100644
--- a/chrome/common/extensions/api/experimental.declarative.json
+++ b/chrome/common/extensions/api/experimental.declarative.json
@@ -1,7 +1,7 @@
[
{
"namespace": "experimental.declarative",
- "nodoc": true,
+ "internal": true,
"types": [
{
"id": "Rule",
diff --git a/chrome/common/extensions/docs/build/directory.py b/chrome/common/extensions/docs/build/directory.py
index 53bb521..316e0d6 100644
--- a/chrome/common/extensions/docs/build/directory.py
+++ b/chrome/common/extensions/docs/build/directory.py
@@ -107,7 +107,8 @@ class ApiManifest(object):
"chrome.tabs.onDetached" : "tabs.html#event-onDetatched"
}
- If the API namespace is defined "nodoc" then an empty dict is returned.
+ If the API namespace is defined "nodoc" or "internal" then an empty dict
+ is returned.
Raises:
Exception: If the key supplied is not a member of _MODULE_DOC_KEYS.
@@ -115,14 +116,14 @@ class ApiManifest(object):
methods = []
api_dict = {}
namespace = module['namespace']
- if module.has_key('nodoc'):
+ if self._disableDocs(module):
return api_dict
if key not in self._MODULE_DOC_KEYS:
raise Exception("key %s must be one of %s" % (key, self._MODULE_DOC_KEYS))
if module.has_key(key):
methods.extend(module[key])
for method in methods:
- if method.has_key('nodoc'):
+ if self._disableDocs(method):
continue
method_name = 'chrome.%s.%s' % (namespace, method['name'])
hashprefix = 'method'
@@ -136,9 +137,15 @@ class ApiManifest(object):
Returns:
The namespace """
- # Exclude modules with a "nodoc" property.
+ # Exclude modules with documentation disabled.
return set(module['namespace'].encode() for module in self._manifest
- if "nodoc" not in module)
+ if not self._disableDocs(module))
+
+ def _disableDocs(self, obj):
+ for key in ['nodoc', 'internal']:
+ if key in obj and obj[key]:
+ return True
+ return False
def getDocumentationLinks(self):
""" Parses the extension API JSON manifest and returns a dict of all
diff --git a/chrome/common/extensions/docs/examples/api/browsingData/basic.zip b/chrome/common/extensions/docs/examples/api/browsingData/basic.zip
index c49c0c5..d1c9cff 100644
--- a/chrome/common/extensions/docs/examples/api/browsingData/basic.zip
+++ b/chrome/common/extensions/docs/examples/api/browsingData/basic.zip
Binary files differ
diff --git a/chrome/common/extensions/docs/js/api_page_generator.js b/chrome/common/extensions/docs/js/api_page_generator.js
index 71ccc11..13f7d85 100644
--- a/chrome/common/extensions/docs/js/api_page_generator.js
+++ b/chrome/common/extensions/docs/js/api_page_generator.js
@@ -260,10 +260,9 @@ function fetchContent(url, onSuccess, onError) {
function renderTemplate() {
schema.forEach(function(mod) {
if (mod.namespace == pageBase) {
- // Do not render page for modules which are marked as "nodoc": true.
- if (mod.nodoc) {
+ // Do not render page for modules which have documentation disabled.
+ if (disableDocs(mod))
return;
- }
// This page is an api page. Setup types and apiDefinition.
module = mod;
apiModuleName = API_MODULE_PREFIX + module.namespace;
@@ -425,7 +424,8 @@ function selectCurrentPageOnLeftNav() {
function stableAPIs() {
return schema.filter(function(module) {
- return !module.nodoc && module.namespace.indexOf('experimental') < 0;
+ return !disableDocs(module) &&
+ module.namespace.indexOf('experimental') < 0;
}).map(function(module) {
return module.namespace;
}).sort();
@@ -433,15 +433,8 @@ function stableAPIs() {
function experimentalAPIs() {
return schema.filter(function(module) {
- return !module.nodoc && module.namespace.indexOf('experimental') == 0;
- }).map(function(module) {
- return module.namespace;
- }).sort();
-}
-
-function devtoolsAPIs() {
- return schema.filter(function(module) {
- return !module.nodoc && module.namespace.indexOf('devtools.') === 0;
+ return !disableDocs(module) &&
+ module.namespace.indexOf('experimental') == 0;
}).map(function(module) {
return module.namespace;
}).sort();
@@ -603,8 +596,8 @@ function getPropertyListFromObject(object) {
}
for (var p in properties) {
var prop = properties[p];
- // Do not render properties marked as "nodoc": true.
- if (prop.nodoc) {
+ // Do not render properties with documentation disabled.
+ if (disableDocs(prop)) {
continue;
}
prop.name = p;
@@ -672,3 +665,7 @@ function sortByName(a, b) {
}
return 0;
}
+
+function disableDocs(obj) {
+ return !!obj.nodoc || !!obj.internal;
+}
diff --git a/chrome/common/extensions/docs/samples.json b/chrome/common/extensions/docs/samples.json
index 189e724..f270885 100644
--- a/chrome/common/extensions/docs/samples.json
+++ b/chrome/common/extensions/docs/samples.json
@@ -68,6 +68,7 @@
"chrome.experimental.devtools.console.addMessage": "experimental.devtools.console.html#method-addMessage",
"chrome.experimental.devtools.console.getMessages": "experimental.devtools.console.html#method-getMessages",
"chrome.experimental.devtools.console.onMessageAdded": "experimental.devtools.console.html#event-onMessageAdded",
+ "chrome.experimental.extension.onInstalled": "experimental.extension.html#event-onInstalled",
"chrome.experimental.infobars.show": "experimental.infobars.html#method-show",
"chrome.experimental.speechInput.isRecording": "experimental.speechInput.html#method-isRecording",
"chrome.experimental.speechInput.onError": "experimental.speechInput.html#event-onError",
@@ -516,7 +517,7 @@
"popup.html",
"popup.js"
],
- "source_hash": "20928606eac79b96493a7eae6f71c5210bbddb09",
+ "source_hash": "be5c852d38ee7b7d21483b2d070a1bdebbf6b27c",
"zip_path": "examples\/api\/browsingData\/basic.zip"
},
{
diff --git a/chrome/common/extensions/docs/static/samples.html b/chrome/common/extensions/docs/static/samples.html
index 0ae778c..2cd56a3 100644
--- a/chrome/common/extensions/docs/static/samples.html
+++ b/chrome/common/extensions/docs/static/samples.html
@@ -14,10 +14,9 @@
pageData.api_mapping = apiMapping;
pageData.api_modules = [];
schema.forEach(function(mod) {
- if (mod.nodoc) {
- return;
- }
- if (mod.namespace.indexOf('experimental') != -1) {
+ if (mod.nodoc ||
+ mod.internal ||
+ mod.namespace.indexOf('experimental') != -1) {
return;
}
pageData.api_modules.push('chrome.' + mod.namespace);
diff --git a/chrome/common/extensions/docs/template/api_template.html b/chrome/common/extensions/docs/template/api_template.html
index d6845f2..ee4afee 100644
--- a/chrome/common/extensions/docs/template/api_template.html
+++ b/chrome/common/extensions/docs/template/api_template.html
@@ -129,7 +129,7 @@
<a jsvalues=".href:'#' + getAnchorName('global', 'methods', $type)">Methods</a>
<ol>
<li jsselect="functions.sort(sortByName)"
- jsdisplay="!($this.nodoc)">
+ jsdisplay="!disableDocs($this)">
<a jscontent="name"
jsvalues=".href:'#' + getAnchorName('method', name, $type)"
href="#method-anchor">methodName</a>
@@ -140,7 +140,7 @@
<a jsvalues=".href:'#' + getAnchorName('global', 'events', $type)">Events</a>
<ol>
<li jsselect="events.sort(sortByName)"
- jsdisplay="!($this.nodoc)">
+ jsdisplay="!disableDocs($this)">
<a jscontent="name"
jsvalues=".href:'#' + getAnchorName('event', name, $type)"
href="#event-anchor">eventName</a>
@@ -382,7 +382,7 @@
<!-- iterates over all functions -->
<div class="apiItem" jsselect="functions.sort(sortByName)"
- jsdisplay="!($this.nodoc)">
+ jsdisplay="!disableDocs($this)">
<a jsvalues=".name:getAnchorName('method', name, $scope)"></a> <!-- method-anchor -->
<h4 jscontent="name">method name</h4>
@@ -459,7 +459,7 @@
<h3 jscontent="$scope ? 'Events of ' + $scope : 'Events'">Events</h3>
<!-- iterates over all events -->
<div class="apiItem" jsselect="$this.events.sort(sortByName)"
- jsdisplay="!($this.nodoc)">
+ jsdisplay="!disableDocs($this)">
<a jsvalues=".name:getAnchorName('event', name, $scope)"></a>
<h4 jscontent="name">event name</h4>
diff --git a/chrome/renderer/resources/extensions/event.js b/chrome/renderer/resources/extensions/event.js
index b1b6967..6272067 100644
--- a/chrome/renderer/resources/extensions/event.js
+++ b/chrome/renderer/resources/extensions/event.js
@@ -246,35 +246,47 @@ var chrome = chrome || {};
this.detach_();
};
+ // 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() {
+ if (chromeHidden.internalAPIs.experimental)
+ return chromeHidden.internalAPIs.experimental.declarative;
+ else
+ return undefined;
+ }
+
chrome.Event.prototype.addRules = function(rules, opt_cb) {
if (!this.eventOptions_.supportsRules)
throw new Error("This event does not support rules.");
- if (!chrome.experimental || !chrome.experimental.declarative) {
- throw new Error("You must have access to the experimental.declarative " +
+ if (!getDeclarativeAPI()) {
+ throw new Error("You must have permission to use the declarative " +
"API to support rules in events");
}
- chrome.experimental.declarative.addRules(this.eventName_, rules, opt_cb);
+ getDeclarativeAPI().addRules(this.eventName_, rules, opt_cb);
}
chrome.Event.prototype.removeRules = function(ruleIdentifiers, opt_cb) {
if (!this.eventOptions_.supportsRules)
throw new Error("This event does not support rules.");
- if (!chrome.experimental || !chrome.experimental.declarative) {
- throw new Error("You must have access to the experimental.declarative " +
+ if (!getDeclarativeAPI()) {
+ throw new Error("You must have permission to use the declarative " +
"API to support rules in events");
}
- chrome.experimental.declarative.removeRules(
+ getDeclarativeAPI().removeRules(
this.eventName_, ruleIdentifiers, opt_cb);
}
chrome.Event.prototype.getRules = function(ruleIdentifiers, cb) {
if (!this.eventOptions_.supportsRules)
throw new Error("This event does not support rules.");
- if (!chrome.experimental || !chrome.experimental.declarative) {
- throw new Error("You must have access to the experimental.declarative " +
+ if (!getDeclarativeAPI()) {
+ throw new Error("You must have permission to use the declarative " +
"API to support rules in events");
}
- chrome.experimental.declarative.getRules(
+ getDeclarativeAPI().getRules(
this.eventName_, ruleIdentifiers, cb);
}
diff --git a/chrome/renderer/resources/extensions/schema_generated_bindings.js b/chrome/renderer/resources/extensions/schema_generated_bindings.js
index 48fb43a..df12690 100644
--- a/chrome/renderer/resources/extensions/schema_generated_bindings.js
+++ b/chrome/renderer/resources/extensions/schema_generated_bindings.js
@@ -15,17 +15,14 @@ var chrome = chrome || {};
var chromeHidden = GetChromeHidden();
- if (!chrome)
- chrome = {};
-
- function apiExists(path) {
- var resolved = chrome;
- path.split(".").forEach(function(next) {
- if (resolved)
- resolved = resolved[next];
- });
- return !!resolved;
- }
+ // The object to generate the bindings for "internal" APIs in, so that
+ // extensions can't directly call them (without access to chromeHidden),
+ // but are still needed for internal mechanisms of extensions (e.g. events).
+ //
+ // This is distinct to the "*Private" APIs which are controlled via
+ // having strict permissions and aren't generated *anywhere* unless needed.
+ var internalAPIs = {};
+ chromeHidden.internalAPIs = internalAPIs;
function forEach(dict, f) {
for (key in dict) {
@@ -385,7 +382,9 @@ var chrome = chrome || {};
if (!isSchemaNodeSupported(apiDef, platform, manifestVersion))
return;
- var module = chrome;
+ // See comment on internalAPIs at the top.
+ var module = apiDef.internal ? internalAPIs : chrome;
+
var namespaces = apiDef.namespace.split('.');
for (var index = 0, name; name = namespaces[index]; index++) {
module[name] = module[name] || {};
@@ -574,12 +573,12 @@ var chrome = chrome || {};
// TOOD(mihaip): remove this alias once the webstore stops calling
// beginInstallWithManifest2.
// See http://crbug.com/100242
- if (apiExists("webstorePrivate")) {
+ if (chrome.webstorePrivate) {
chrome.webstorePrivate.beginInstallWithManifest2 =
chrome.webstorePrivate.beginInstallWithManifest3;
}
- if (apiExists("test"))
+ if (chrome.test)
chrome.test.getApiDefinitions = GetExtensionAPIDefinition;
});
})();
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 680a0e5..d44dba53 100644
--- a/chrome/test/data/extensions/api_test/declarative/api/manifest.json
+++ b/chrome/test/data/extensions/api_test/declarative/api/manifest.json
@@ -1,8 +1,8 @@
{
- "name": "chrome.experimental.declarative",
+ "name": "Declarative apitest",
"version": "0.1",
"manifest_version": 2,
- "description": "end-to-end browser test for chrome.experimental.declarative API",
+ "description": "end-to-end browser test for the declarative API",
"background": {
"scripts": ["background.js"]
},