| Index: extensions/renderer/api_binding_hooks.h
|
| diff --git a/extensions/renderer/api_binding_hooks.h b/extensions/renderer/api_binding_hooks.h
|
| index 37f41fc467ff0e065c8634db92f4761a7db77f61..815e6a36ddd667dd830b2f1201a9c2f0737fdcd6 100644
|
| --- a/extensions/renderer/api_binding_hooks.h
|
| +++ b/extensions/renderer/api_binding_hooks.h
|
| @@ -38,21 +38,36 @@ class APIBindingHooks {
|
| using HandleRequestHook =
|
| base::Callback<void(const binding::APISignature*, gin::Arguments*)>;
|
|
|
| - APIBindingHooks();
|
| + explicit APIBindingHooks(const binding::RunJSFunction& run_js);
|
| ~APIBindingHooks();
|
|
|
| // Register a custom binding to handle requests.
|
| void RegisterHandleRequest(const std::string& method_name,
|
| const HandleRequestHook& hook);
|
|
|
| + // Registers a JS script to be compiled and run in order to initialize any JS
|
| + // hooks within a v8 context.
|
| + void RegisterJsSource(v8::Global<v8::String> source);
|
| +
|
| + // Initializes JS hooks within a context.
|
| + void InitializeInContext(v8::Local<v8::Context> context,
|
| + const std::string& api_name);
|
| +
|
| // Returns the custom hook for the given method, or a null callback if none
|
| // exists.
|
| - HandleRequestHook GetHandleRequest(const std::string& method_name);
|
| + HandleRequestHook GetHandleRequest(const std::string& api_name,
|
| + const std::string& method_name,
|
| + v8::Local<v8::Context> context);
|
|
|
| private:
|
| // All registered request handlers.
|
| std::map<std::string, HandleRequestHook> request_hooks_;
|
|
|
| + // The script to run to initialize JS hooks, if any.
|
| + v8::Global<v8::String> js_hooks_source_;
|
| +
|
| + binding::RunJSFunction run_js_;
|
| +
|
| DISALLOW_COPY_AND_ASSIGN(APIBindingHooks);
|
| };
|
|
|
|
|