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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 var Event = require('event_bindings').Event; 5 var Event = require('event_bindings').Event;
6 var forEach = require('utils').forEach; 6 var forEach = require('utils').forEach;
7 var GetAvailability = requireNative('v8_context').GetAvailability; 7 var GetAvailability = requireNative('v8_context').GetAvailability;
8 var logActivity = requireNative('activityLogger'); 8 var logActivity = requireNative('activityLogger');
9 var logging = requireNative('logging'); 9 var logging = requireNative('logging');
10 var process = requireNative('process'); 10 var process = requireNative('process');
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 throw new Error('NOT IMPLEMENTED (extension_api.json error): ' + 412 throw new Error('NOT IMPLEMENTED (extension_api.json error): ' +
413 'Cannot parse values for type "' + type + '"'); 413 'Cannot parse values for type "' + type + '"');
414 } 414 }
415 m[propertyName] = value; 415 m[propertyName] = value;
416 } 416 }
417 }); 417 });
418 }; 418 };
419 419
420 addProperties(mod, schema); 420 addProperties(mod, schema);
421 421
422 var availability = GetAvailability(schema.namespace); 422 // This generate() call is considered successful if any functions,
423 if (!availability.is_available && $Object.keys(mod).length == 0) { 423 // properties, or events were created.
424 var success = ($Object.keys(mod).length > 0);
425
426 // Special case: webViewRequest is a vacuous API which just copies its
427 // implementation from declarativeWebRequest.
428 //
429 // TODO(kalman): This would be unnecessary if we did these checks after the
430 // hooks (i.e. this.runHooks_(mod)). The reason we don't is to be very
431 // conservative with running any JS which might actually be for an API
432 // which isn't available, but this is probably overly cautious given the
433 // C++ is only giving us APIs which are available. FIXME.
434 if (schema.namespace == 'webViewRequest') {
435 success = true;
436 }
437
438 // Special case: runtime.lastError is only occasionally set, so
439 // specifically check its availability.
440 if (schema.namespace == 'runtime' &&
441 GetAvailability('runtime.lastError').is_available) {
442 success = true;
443 }
444
445 if (!success) {
446 var availability = GetAvailability(schema.namespace);
447 // If an API was available it should have been successfully generated.
448 logging.DCHECK(!availability.is_available,
449 schema.namespace + ' was available but not generated');
424 console.error('chrome.' + schema.namespace + ' is not available: ' + 450 console.error('chrome.' + schema.namespace + ' is not available: ' +
425 availability.message); 451 availability.message);
426 return; 452 return;
427 } 453 }
428 454
429 this.runHooks_(mod); 455 this.runHooks_(mod);
430 return mod; 456 return mod;
431 } 457 }
432 }; 458 };
433 459
434 exports.Binding = Binding; 460 exports.Binding = Binding;
OLDNEW
« 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