| Index: extensions/renderer/api_binding_hooks.h
|
| diff --git a/extensions/renderer/api_binding_hooks.h b/extensions/renderer/api_binding_hooks.h
|
| index ffdd1686e1eab72629bc749f30e8cda1bc261413..d6620275017e656fc0182af51f7fdc2d69d78c12 100644
|
| --- a/extensions/renderer/api_binding_hooks.h
|
| +++ b/extensions/renderer/api_binding_hooks.h
|
| @@ -32,6 +32,7 @@ class APIBindingHooks {
|
| // The result of checking for hooks to handle a request.
|
| enum class RequestResult {
|
| HANDLED, // A custom hook handled the request.
|
| + THROWN, // An exception was thrown during parsing or handling.
|
| INVALID_INVOCATION, // The request was called with invalid arguments.
|
| NOT_HANDLED, // The request was not handled.
|
| };
|
| @@ -46,10 +47,11 @@ class APIBindingHooks {
|
| // reference to the callback themselves.
|
| using HandleRequestHook =
|
| base::Callback<RequestResult(const APISignature*,
|
| - gin::Arguments*,
|
| + v8::Local<v8::Context> context,
|
| + std::vector<v8::Local<v8::Value>>*,
|
| const ArgumentSpec::RefMap&)>;
|
|
|
| - explicit APIBindingHooks(const binding::RunJSFunction& run_js);
|
| + explicit APIBindingHooks(const binding::RunJSFunctionSync& run_js);
|
| ~APIBindingHooks();
|
|
|
| // Register a custom binding to handle requests.
|
| @@ -72,7 +74,7 @@ class APIBindingHooks {
|
| const std::string& method_name,
|
| v8::Local<v8::Context> context,
|
| const APISignature* signature,
|
| - gin::Arguments* arguments,
|
| + std::vector<v8::Local<v8::Value>>* arguments,
|
| const ArgumentSpec::RefMap& type_refs);
|
|
|
| // Returns a JS interface that can be used to register hooks.
|
| @@ -80,6 +82,12 @@ class APIBindingHooks {
|
| v8::Local<v8::Context> context);
|
|
|
| private:
|
| + // Updates the |arguments| by running |function| and settings arguments to the
|
| + // returned result.
|
| + bool UpdateArguments(v8::Local<v8::Function> function,
|
| + v8::Local<v8::Context> context,
|
| + std::vector<v8::Local<v8::Value>>* arguments);
|
| +
|
| // Whether we've tried to use any hooks associated with this object.
|
| bool hooks_used_ = false;
|
|
|
| @@ -93,7 +101,10 @@ class APIBindingHooks {
|
| // to make exception stack traces more readable.
|
| v8::Global<v8::String> js_resource_name_;
|
|
|
| - binding::RunJSFunction run_js_;
|
| + // We use synchronous JS execution here because at every point we execute JS,
|
| + // it's in direct response to JS calling in. There should be no reason that
|
| + // script is disabled.
|
| + binding::RunJSFunctionSync run_js_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(APIBindingHooks);
|
| };
|
|
|