OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef EXTENSIONS_RENDERER_API_BINDING_HOOKS_DELEGATE_H_ | 5 #ifndef EXTENSIONS_RENDERER_API_BINDING_HOOKS_DELEGATE_H_ |
6 #define EXTENSIONS_RENDERER_API_BINDING_HOOKS_DELEGATE_H_ | 6 #define EXTENSIONS_RENDERER_API_BINDING_HOOKS_DELEGATE_H_ |
7 | 7 |
| 8 #include "extensions/renderer/api_binding_hooks.h" |
8 #include "extensions/renderer/api_binding_types.h" | 9 #include "extensions/renderer/api_binding_types.h" |
9 #include "v8/include/v8.h" | 10 #include "v8/include/v8.h" |
10 | 11 |
11 namespace extensions { | 12 namespace extensions { |
12 | 13 |
13 // A per-API set of custom hooks to override the default behavior. | 14 // A per-API set of custom hooks to override the default behavior. |
14 class APIBindingHooksDelegate { | 15 class APIBindingHooksDelegate { |
15 public: | 16 public: |
16 virtual ~APIBindingHooksDelegate(); | 17 virtual ~APIBindingHooksDelegate(); |
17 | 18 |
18 // Allows custom implementations to return a different event object. | 19 // Allows custom implementations to return a different event object. |
19 // Populates |event_out| and returns true if a custom implementation should | 20 // Populates |event_out| and returns true if a custom implementation should |
20 // be used, otherwise returns false. | 21 // be used, otherwise returns false. |
21 virtual bool CreateCustomEvent(v8::Local<v8::Context> context, | 22 virtual bool CreateCustomEvent(v8::Local<v8::Context> context, |
22 const binding::RunJSFunctionSync& run_js_sync, | 23 const binding::RunJSFunctionSync& run_js_sync, |
23 const std::string& event_name, | 24 const std::string& event_name, |
24 v8::Local<v8::Value>* event_out); | 25 v8::Local<v8::Value>* event_out); |
25 | 26 |
26 // TODO(devlin): Add a virtual HandleRequest() method. | 27 // Allows custom implementations to handle a given request. |
| 28 virtual APIBindingHooks::RequestResult HandleRequest( |
| 29 const std::string& method_name, |
| 30 const APISignature* signature, |
| 31 v8::Local<v8::Context> context, |
| 32 std::vector<v8::Local<v8::Value>>* arguments, |
| 33 const APITypeReferenceMap& refs); |
27 }; | 34 }; |
28 | 35 |
29 } // namespace extensions | 36 } // namespace extensions |
30 | 37 |
31 #endif // EXTENSIONS_RENDERER_API_BINDING_HOOKS_DELEGATE_H_ | 38 #endif // EXTENSIONS_RENDERER_API_BINDING_HOOKS_DELEGATE_H_ |
OLD | NEW |