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..02680c4d05e1b2c2197d6b44b1b9a22103c8db9b 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,21 @@ 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()) |
+ << "Custom type already registered: " << type_name; |
+ 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()) << "Custom type not found: " << type_name; |
+ return iter->second.Run(context, property_name, &request_handler_, |
+ &type_reference_map_); |
+} |
+ |
} // namespace extensions |