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

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: 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
Index: extensions/renderer/resources/binding.js
diff --git a/extensions/renderer/resources/binding.js b/extensions/renderer/resources/binding.js
index b0c6afa4fa43a8fe01aabdad02a32a4ce1519771..6765a441bb0cdb280b8255fa8c0da3879e79b079 100644
--- a/extensions/renderer/resources/binding.js
+++ b/extensions/renderer/resources/binding.js
@@ -420,10 +420,19 @@ Binding.prototype = {
addProperties(mod, schema);
var availability = GetAvailability(schema.namespace);
- if (!availability.is_available && $Object.keys(mod).length == 0) {
- console.error('chrome.' + schema.namespace + ' is not available: ' +
- availability.message);
- return;
+ if (!availability.is_available) {
+ // The namespace isn't available, but some of its functions may be, so we
+ // still allow access to the API.
+ //
+ // A special case is runtime.lastError which is only occasionally set, so
+ // specifically check that availability.
+ if ($Object.keys(mod).length == 0 &&
+ !(schema.namespace == 'runtime' &&
+ GetAvailability('runtime.lastError').is_available)) {
Ken Rockot(use gerrit already) 2014/07/18 22:33:40 I'm not sure how to make this less confusing, but
not at google - send to devlin 2014/07/18 23:28:35 I was confused when I re-read my own CL. How does
+ console.error('chrome.' + schema.namespace + ' is not available: ' +
+ availability.message);
+ return;
+ }
}
this.runHooks_(mod);

Powered by Google App Engine
This is Rietveld 408576698