Chromium Code Reviews| 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; |
| } |
| }; |