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

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

Issue 404883002: Allow extension APIs to be called from WebUI. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: android compile Created 6 years, 5 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
« no previous file with comments | « extensions/renderer/dispatcher.cc ('k') | extensions/renderer/resources/runtime_custom_bindings.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/renderer/resources/binding.js
diff --git a/extensions/renderer/resources/binding.js b/extensions/renderer/resources/binding.js
index b0c6afa4fa43a8fe01aabdad02a32a4ce1519771..eb858d7501610531af7e330dba2b381780dbae94 100644
--- a/extensions/renderer/resources/binding.js
+++ b/extensions/renderer/resources/binding.js
@@ -419,10 +419,36 @@ Binding.prototype = {
addProperties(mod, schema);
- var availability = GetAvailability(schema.namespace);
- if (!availability.is_available && $Object.keys(mod).length == 0) {
+ // This generate() call is considered successful if any functions,
+ // properties, or events were created.
+ var success = ($Object.keys(mod).length > 0);
+
+ // Special case: webViewRequest is a vacuous API which just copies its
+ // implementation from declarativeWebRequest.
+ //
+ // TODO(kalman): This would be unnecessary if we did these checks after the
+ // hooks (i.e. this.runHooks_(mod)). The reason we don't is to be very
+ // conservative with running any JS which might actually be for an API
+ // which isn't available, but this is probably overly cautious given the
+ // C++ is only giving us APIs which are available. FIXME.
+ if (schema.namespace == 'webViewRequest') {
+ success = true;
+ }
+
+ // Special case: runtime.lastError is only occasionally set, so
+ // specifically check its availability.
+ if (schema.namespace == 'runtime' &&
+ GetAvailability('runtime.lastError').is_available) {
+ success = true;
+ }
+
+ if (!success) {
+ var availability = GetAvailability(schema.namespace);
+ // If an API was available it should have been successfully generated.
+ logging.DCHECK(!availability.is_available,
+ schema.namespace + ' was available but not generated');
console.error('chrome.' + schema.namespace + ' is not available: ' +
- availability.message);
+ availability.message);
return;
}
« no previous file with comments | « extensions/renderer/dispatcher.cc ('k') | extensions/renderer/resources/runtime_custom_bindings.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698