Chromium Code Reviews| Index: extensions/renderer/api_bindings_system.cc |
| diff --git a/extensions/renderer/api_bindings_system.cc b/extensions/renderer/api_bindings_system.cc |
| index b90483bcb1ae33ed74a0142f002f31784b217c19..7382d71f0930284a9bfdd42bf2096a04baa1957a 100644 |
| --- a/extensions/renderer/api_bindings_system.cc |
| +++ b/extensions/renderer/api_bindings_system.cc |
| @@ -70,8 +70,10 @@ std::unique_ptr<APIBinding> APIBindingsSystem::CreateNewAPIBinding( |
| return base::MakeUnique<APIBinding>( |
| api_name, function_definitions, type_definitions, event_definitions, |
| - property_definitions, std::move(hooks), &type_reference_map_, |
| - &request_handler_, &event_handler_); |
| + property_definitions, |
| + base::Bind(&APIBindingsSystem::CreateCustomType, base::Unretained(this)), |
| + std::move(hooks), &type_reference_map_, &request_handler_, |
| + &event_handler_); |
| } |
| void APIBindingsSystem::InitializeType(const std::string& type_name) { |
| @@ -115,4 +117,20 @@ APIBindingHooks* APIBindingsSystem::GetHooksForAPI( |
| return hooks.get(); |
| } |
| +void APIBindingsSystem::RegisterCustomType(const std::string& type_name, |
| + const CustomTypeHandler& function) { |
| + DCHECK(custom_types_.find(type_name) == custom_types_.end()); |
|
lazyboy
2017/02/22 03:37:03
nit: << "Custom type already registered, type_name
Devlin
2017/02/22 20:56:45
Done.
|
| + custom_types_[type_name] = function; |
| +} |
| + |
| +v8::Local<v8::Object> APIBindingsSystem::CreateCustomType( |
| + v8::Local<v8::Context> context, |
| + const std::string& type_name, |
| + const std::string& property_name) { |
| + auto iter = custom_types_.find(type_name); |
| + DCHECK(iter != custom_types_.end()); |
|
lazyboy
2017/02/22 03:37:03
nit: << "Custom type not found: " << type_name
Devlin
2017/02/22 20:56:45
Done.
|
| + return iter->second.Run(context, property_name, &request_handler_, |
| + &type_reference_map_); |
| +} |
| + |
| } // namespace extensions |