Index: extensions/renderer/api_bindings_system.h |
diff --git a/extensions/renderer/api_bindings_system.h b/extensions/renderer/api_bindings_system.h |
index a21da2e1443bda3065f43decda18feb0d197de84..c8f6e72310332847e3c523ecb802d234571d11e2 100644 |
--- a/extensions/renderer/api_bindings_system.h |
+++ b/extensions/renderer/api_bindings_system.h |
@@ -33,6 +33,11 @@ class APIBindingsSystem { |
public: |
using GetAPISchemaMethod = |
base::Callback<const base::DictionaryValue&(const std::string&)>; |
+ using CustomTypeHandler = |
+ base::Callback<v8::Local<v8::Object>(v8::Local<v8::Context> context, |
+ const std::string& property_name, |
+ APIRequestHandler* request_handler, |
+ APITypeReferenceMap* type_refs)>; |
APIBindingsSystem(const binding::RunJSFunction& call_js, |
const binding::RunJSFunctionSync& call_js_sync, |
@@ -72,6 +77,12 @@ class APIBindingsSystem { |
// efficient to register multiple hooks for the same API. |
APIBindingHooks* GetHooksForAPI(const std::string& api_name); |
+ // Registers the handler for creating a custom type with the given |
+ // |type_name|, where |type_name| is the fully-qualified type (e.g. |
+ // storage.StorageArea). |
+ void RegisterCustomType(const std::string& type_name, |
+ const CustomTypeHandler& function); |
+ |
private: |
// Creates a new APIBinding for the given |api_name|. |
std::unique_ptr<APIBinding> CreateNewAPIBinding(const std::string& api_name); |
@@ -80,6 +91,11 @@ class APIBindingsSystem { |
// type. |
void InitializeType(const std::string& name); |
+ // Handles creating the type for the specified property. |
+ v8::Local<v8::Object> CreateCustomType(v8::Local<v8::Context> context, |
+ const std::string& type_name, |
+ const std::string& property_name); |
+ |
// The map of cached API reference types. |
APITypeReferenceMap type_reference_map_; |
@@ -98,6 +114,8 @@ class APIBindingsSystem { |
// performance concern? |
std::map<std::string, std::unique_ptr<APIBindingHooks>> binding_hooks_; |
+ std::map<std::string, CustomTypeHandler> custom_types_; |
+ |
binding::RunJSFunction call_js_; |
binding::RunJSFunctionSync call_js_sync_; |