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

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

Issue 14494013: Allow API functions and events to have entries in _api_features.json (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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/binding.js
diff --git a/chrome/renderer/resources/extensions/binding.js b/chrome/renderer/resources/extensions/binding.js
index c7b299a825742573594eb137f2b6892c50a0f07f..febf072f92d971b9e1d2cc17ad915e933530fd62 100644
--- a/chrome/renderer/resources/extensions/binding.js
+++ b/chrome/renderer/resources/extensions/binding.js
@@ -211,15 +211,8 @@ Binding.prototype = {
return undefined;
}
- var availability = GetAvailability(schema.namespace);
- if (!availability.is_available) {
- console.error('chrome.' + schema.namespace + ' is not available: ' +
- availability.message);
- return undefined;
- }
-
- // See comment on internalAPIs at the top.
var mod = {};
+ var hasEventOrFunction = false;
var namespaces = schema.namespace.split('.');
for (var index = 0, name; name = namespaces[index]; index++) {
@@ -279,6 +272,14 @@ Binding.prototype = {
apiFunction.definition = functionDef;
apiFunction.name = schema.namespace + '.' + functionDef.name;
+ if (!GetAvailability(apiFunction.name).is_available) {
+ this.apiFunctions_.registerUnavailable(functionDef.name);
+ addUnprivilegedAccessGetter(mod, functionDef.name);
+ return;
+ }
+
+ hasEventOrFunction = true;
not at google - send to devlin 2013/04/27 01:02:43 we may actually want to implement most of this in
cduvall 2013/05/01 02:51:47 All the C++ is just to make sure that the bindings
not at google - send to devlin 2013/05/01 20:47:04 yep - sorry I was misreading this a bit. cool.
+
// TODO(aa): It would be best to run this in a unit test, but in order
// to do that we would need to better factor this code so that it
// doesn't depend on so much v8::Extension machinery.
@@ -343,6 +344,12 @@ Binding.prototype = {
var eventName = schema.namespace + "." + eventDef.name;
var options = eventDef.options || {};
+ if (!GetAvailability(eventName).is_available) {
+ addUnprivilegedAccessGetter(mod, eventDef.name);
+ return;
+ }
+
+ hasEventOrFunction = true;
if (eventDef.filters && eventDef.filters.length > 0)
options.supportsFilters = true;
@@ -414,6 +421,14 @@ Binding.prototype = {
addProperties(mod, schema);
this.runHooks_(mod);
+
+ var availability = GetAvailability(schema.namespace);
+ if (!availability.is_available && !hasEventOrFunction) {
not at google - send to devlin 2013/04/27 01:02:43 You should be able to calculate hasEventOrFunction
cduvall 2013/05/01 02:51:47 Done.
+ console.error('chrome.' + schema.namespace + ' is not available: ' +
+ availability.message);
+ return;
+ }
+
return mod;
}
};

Powered by Google App Engine
This is Rietveld 408576698