Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5271)

Unified Diff: chrome/renderer/resources/extensions/event.js

Issue 9309114: Allow "internal" APIs to be specified in extension API schemas. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/renderer/resources/extensions/event.js
diff --git a/chrome/renderer/resources/extensions/event.js b/chrome/renderer/resources/extensions/event.js
index b1b69675ed8e863f3843868a463e678c0829a88d..6272067e8684dfe394da9ff37d3ebec12c2622d9 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);
}

Powered by Google App Engine
This is Rietveld 408576698