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

Unified Diff: extensions/renderer/api_bindings_system.h

Issue 2552343006: [Extensions Binding] Allow for registering custom hooks (Closed)
Patch Set: . Created 4 years 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 e40b898bcee5c215150694c27dd9ba494f2477f1..57ce4e705aa812396b111d4881595f99bbdd7901 100644
--- a/extensions/renderer/api_bindings_system.h
+++ b/extensions/renderer/api_bindings_system.h
@@ -70,6 +70,15 @@ class APIBindingsSystem {
v8::Local<v8::Context> context,
const base::ListValue& response);
+ // Returns the APIBindingHooks object for the given api to allow for
+ // registering custom hooks. These must be registered *before* the
+ // binding is instantiated.
+ // TODO(devlin): It's a little weird that we don't just expose a
+ // RegisterHooks-type method. Depending on how complex the hook interface
+ // is, maybe we should rethink this. Downside would be that it's less
+ // efficient to register multiple hooks for the same API.
+ APIBindingHooks* GetHooksForAPI(const std::string& api_name);
+
private:
// Creates a new APIBinding for the given |api_name|.
std::unique_ptr<APIBinding> CreateNewAPIBinding(const std::string& api_name);
@@ -95,6 +104,11 @@ class APIBindingsSystem {
// created lazily.
std::map<std::string, std::unique_ptr<APIBinding>> api_bindings_;
+ // A map from api_name -> APIBindingHooks for registering custom hooks.
+ // TODO(devlin): This map is pretty pointer-y. Is that going to be a
+ // performance concern?
+ std::map<std::string, std::unique_ptr<APIBindingHooks>> binding_hooks_;
+
// The method to retrieve the DictionaryValue describing a given extension
// API. Curried in for testing purposes so we can use fake APIs.
GetAPISchemaMethod get_api_schema_;
« 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