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

Unified Diff: extensions/renderer/api_bindings_system.cc

Issue 2575173002: [Extensions Bindings] Add a bridge to use current custom bindings (Closed)
Patch Set: . Created 4 years 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/api_bindings_system.h ('k') | extensions/renderer/api_bindings_system_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/renderer/api_bindings_system.cc
diff --git a/extensions/renderer/api_bindings_system.cc b/extensions/renderer/api_bindings_system.cc
index 8ab880bb4b3739cba8f9176e179ba3e7349e9d63..5db72a0235820aedf249eff43f77c974d0ec20b1 100644
--- a/extensions/renderer/api_bindings_system.cc
+++ b/extensions/renderer/api_bindings_system.cc
@@ -29,10 +29,13 @@ v8::Local<v8::Object> APIBindingsSystem::CreateAPIInstance(
const std::string& api_name,
v8::Local<v8::Context> context,
v8::Isolate* isolate,
- const APIBinding::AvailabilityCallback& is_available) {
+ const APIBinding::AvailabilityCallback& is_available,
+ v8::Local<v8::Object>* hooks_interface_out) {
std::unique_ptr<APIBinding>& binding = api_bindings_[api_name];
if (!binding)
binding = CreateNewAPIBinding(api_name);
+ if (hooks_interface_out)
+ *hooks_interface_out = binding->GetJSHookInterface(context);
return binding->CreateInstance(
context, isolate, &event_handler_, is_available);
}
@@ -49,12 +52,17 @@ std::unique_ptr<APIBinding> APIBindingsSystem::CreateNewAPIBinding(
const base::ListValue* event_definitions = nullptr;
api_schema.GetList("events", &event_definitions);
- // Find the hooks for the API, if any exist.
+ // Find the hooks for the API. If none exist, an empty set will be created so
+ // we can use JS custom bindings.
+ // TODO(devlin): Once all legacy custom bindings are converted, we don't have
+ // to unconditionally pass in binding hooks.
std::unique_ptr<APIBindingHooks> hooks;
auto iter = binding_hooks_.find(api_name);
if (iter != binding_hooks_.end()) {
hooks = std::move(iter->second);
binding_hooks_.erase(iter);
+ } else {
+ hooks = base::MakeUnique<APIBindingHooks>(call_js_);
}
return base::MakeUnique<APIBinding>(
« no previous file with comments | « extensions/renderer/api_bindings_system.h ('k') | extensions/renderer/api_bindings_system_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698