OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_H_ | 5 #ifndef EXTENSIONS_RENDERER_API_BINDING_HOOKS_H_ |
6 #define EXTENSIONS_RENDERER_API_BINDING_HOOKS_H_ | 6 #define EXTENSIONS_RENDERER_API_BINDING_HOOKS_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 // Gets the custom-set JS callback for the given method, if one exists. | 63 // Gets the custom-set JS callback for the given method, if one exists. |
64 v8::Local<v8::Function> GetCustomJSCallback(const std::string& method_name, | 64 v8::Local<v8::Function> GetCustomJSCallback(const std::string& method_name, |
65 v8::Local<v8::Context> context); | 65 v8::Local<v8::Context> context); |
66 | 66 |
67 // Creates a new JS event for the given |event_name|, if a custom event is | 67 // Creates a new JS event for the given |event_name|, if a custom event is |
68 // provided. Returns true if an event was created. | 68 // provided. Returns true if an event was created. |
69 bool CreateCustomEvent(v8::Local<v8::Context> context, | 69 bool CreateCustomEvent(v8::Local<v8::Context> context, |
70 const std::string& event_name, | 70 const std::string& event_name, |
71 v8::Local<v8::Value>* event_out); | 71 v8::Local<v8::Value>* event_out); |
72 | 72 |
| 73 // Performs any extra initialization on the template. |
| 74 void InitializeTemplate(v8::Isolate* isolate, |
| 75 v8::Local<v8::ObjectTemplate> object_template, |
| 76 const APITypeReferenceMap& type_refs); |
| 77 |
73 void SetDelegate(std::unique_ptr<APIBindingHooksDelegate> delegate); | 78 void SetDelegate(std::unique_ptr<APIBindingHooksDelegate> delegate); |
74 | 79 |
75 private: | 80 private: |
76 // Updates the |arguments| by running |function| and settings arguments to the | 81 // Updates the |arguments| by running |function| and settings arguments to the |
77 // returned result. | 82 // returned result. |
78 bool UpdateArguments(v8::Local<v8::Function> function, | 83 bool UpdateArguments(v8::Local<v8::Function> function, |
79 v8::Local<v8::Context> context, | 84 v8::Local<v8::Context> context, |
80 std::vector<v8::Local<v8::Value>>* arguments); | 85 std::vector<v8::Local<v8::Value>>* arguments); |
81 | 86 |
82 // The name of the associated API. | 87 // The name of the associated API. |
83 std::string api_name_; | 88 std::string api_name_; |
84 | 89 |
85 // We use synchronous JS execution here because at every point we execute JS, | 90 // We use synchronous JS execution here because at every point we execute JS, |
86 // it's in direct response to JS calling in. There should be no reason that | 91 // it's in direct response to JS calling in. There should be no reason that |
87 // script is disabled. | 92 // script is disabled. |
88 binding::RunJSFunctionSync run_js_; | 93 binding::RunJSFunctionSync run_js_; |
89 | 94 |
90 std::unique_ptr<APIBindingHooksDelegate> delegate_; | 95 std::unique_ptr<APIBindingHooksDelegate> delegate_; |
91 | 96 |
92 DISALLOW_COPY_AND_ASSIGN(APIBindingHooks); | 97 DISALLOW_COPY_AND_ASSIGN(APIBindingHooks); |
93 }; | 98 }; |
94 | 99 |
95 } // namespace extensions | 100 } // namespace extensions |
96 | 101 |
97 #endif // EXTENSIONS_RENDERER_API_BINDING_HOOKS_H_ | 102 #endif // EXTENSIONS_RENDERER_API_BINDING_HOOKS_H_ |
OLD | NEW |