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

Unified Diff: extensions/renderer/api_bindings_system.h

Issue 2704823002: [Extensions Bindings] Add support for custom property types (Closed)
Patch Set: asan fix Created 3 years, 10 months 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_binding_unittest.cc ('k') | extensions/renderer/api_bindings_system.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_;
« no previous file with comments | « extensions/renderer/api_binding_unittest.cc ('k') | extensions/renderer/api_bindings_system.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698