| 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..7090007b7fd7aefa1e560e40908ab773d78c7ae6 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->GetJSHooksInterface(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>(
|
|
|