| 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_hooks.h" |
| 9 #include "extensions/renderer/api_binding_types.h" | 9 #include "extensions/renderer/api_binding_types.h" |
| 10 #include "v8/include/v8.h" | 10 #include "v8/include/v8.h" |
| 11 | 11 |
| 12 namespace extensions { | 12 namespace extensions { |
| 13 class APITypeReferenceMap; |
| 13 | 14 |
| 14 // A per-API set of custom hooks to override the default behavior. | 15 // A per-API set of custom hooks to override the default behavior. |
| 15 class APIBindingHooksDelegate { | 16 class APIBindingHooksDelegate { |
| 16 public: | 17 public: |
| 17 virtual ~APIBindingHooksDelegate(); | 18 virtual ~APIBindingHooksDelegate(); |
| 18 | 19 |
| 19 // Allows custom implementations to return a different event object. | 20 // Allows custom implementations to return a different event object. |
| 20 // Populates |event_out| and returns true if a custom implementation should | 21 // Populates |event_out| and returns true if a custom implementation should |
| 21 // be used, otherwise returns false. | 22 // be used, otherwise returns false. |
| 22 virtual bool CreateCustomEvent(v8::Local<v8::Context> context, | 23 virtual bool CreateCustomEvent(v8::Local<v8::Context> context, |
| 23 const binding::RunJSFunctionSync& run_js_sync, | 24 const binding::RunJSFunctionSync& run_js_sync, |
| 24 const std::string& event_name, | 25 const std::string& event_name, |
| 25 v8::Local<v8::Value>* event_out); | 26 v8::Local<v8::Value>* event_out); |
| 26 | 27 |
| 27 // Allows custom implementations to handle a given request. | 28 // Allows custom implementations to handle a given request. |
| 28 virtual APIBindingHooks::RequestResult HandleRequest( | 29 virtual APIBindingHooks::RequestResult HandleRequest( |
| 29 const std::string& method_name, | 30 const std::string& method_name, |
| 30 const APISignature* signature, | 31 const APISignature* signature, |
| 31 v8::Local<v8::Context> context, | 32 v8::Local<v8::Context> context, |
| 32 std::vector<v8::Local<v8::Value>>* arguments, | 33 std::vector<v8::Local<v8::Value>>* arguments, |
| 33 const APITypeReferenceMap& refs); | 34 const APITypeReferenceMap& refs); |
| 35 |
| 36 // Allows custom implementations to add additional properties or types to an |
| 37 // API object. |
| 38 virtual void InitializeTemplate(v8::Isolate* isolate, |
| 39 v8::Local<v8::ObjectTemplate> object_template, |
| 40 const APITypeReferenceMap& type_refs) {} |
| 34 }; | 41 }; |
| 35 | 42 |
| 36 } // namespace extensions | 43 } // namespace extensions |
| 37 | 44 |
| 38 #endif // EXTENSIONS_RENDERER_API_BINDING_HOOKS_DELEGATE_H_ | 45 #endif // EXTENSIONS_RENDERER_API_BINDING_HOOKS_DELEGATE_H_ |
| OLD | NEW |