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_H_ | 5 #ifndef EXTENSIONS_RENDERER_API_BINDING_H_ |
6 #define EXTENSIONS_RENDERER_API_BINDING_H_ | 6 #define EXTENSIONS_RENDERER_API_BINDING_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <memory> | 9 #include <memory> |
10 #include <string> | 10 #include <string> |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 ArgumentSpec::RefMap* type_refs); | 68 ArgumentSpec::RefMap* type_refs); |
69 ~APIBinding(); | 69 ~APIBinding(); |
70 | 70 |
71 // Returns a new v8::Object for the API this APIBinding represents. | 71 // Returns a new v8::Object for the API this APIBinding represents. |
72 v8::Local<v8::Object> CreateInstance( | 72 v8::Local<v8::Object> CreateInstance( |
73 v8::Local<v8::Context> context, | 73 v8::Local<v8::Context> context, |
74 v8::Isolate* isolate, | 74 v8::Isolate* isolate, |
75 APIEventHandler* event_handler, | 75 APIEventHandler* event_handler, |
76 const AvailabilityCallback& is_available); | 76 const AvailabilityCallback& is_available); |
77 | 77 |
| 78 // Returns the JS interface to use when registering hooks with legacy custom |
| 79 // bindings. |
| 80 v8::Local<v8::Object> GetJSHookInterface(v8::Local<v8::Context> context); |
| 81 |
78 private: | 82 private: |
79 // Handles a call an API method with the given |name| and matches the | 83 // Handles a call an API method with the given |name| and matches the |
80 // arguments against |signature|. | 84 // arguments against |signature|. |
81 void HandleCall(const std::string& name, | 85 void HandleCall(const std::string& name, |
82 const APISignature* signature, | 86 const APISignature* signature, |
83 gin::Arguments* args); | 87 gin::Arguments* args); |
84 | 88 |
85 // The root name of the API, e.g. "tabs" for chrome.tabs. | 89 // The root name of the API, e.g. "tabs" for chrome.tabs. |
86 std::string api_name_; | 90 std::string api_name_; |
87 | 91 |
88 // A map from method name to expected signature. | 92 // A map from method name to expected signature. |
89 std::map<std::string, std::unique_ptr<APISignature>> signatures_; | 93 std::map<std::string, std::unique_ptr<APISignature>> signatures_; |
90 | 94 |
91 // The names of all events associated with this API. | 95 // The names of all events associated with this API. |
92 std::vector<std::string> event_names_; | 96 std::vector<std::string> event_names_; |
93 | 97 |
94 // The callback to use when an API is invoked with valid arguments. | 98 // The callback to use when an API is invoked with valid arguments. |
95 APIMethodCallback method_callback_; | 99 APIMethodCallback method_callback_; |
96 | 100 |
97 // The registered hooks for this API. Null if there are no registered custom | 101 // The registered hooks for this API. |
98 // hooks. | |
99 std::unique_ptr<APIBindingHooks> binding_hooks_; | 102 std::unique_ptr<APIBindingHooks> binding_hooks_; |
100 | 103 |
101 // The reference map for all known types; required to outlive this object. | 104 // The reference map for all known types; required to outlive this object. |
102 const ArgumentSpec::RefMap* type_refs_; | 105 const ArgumentSpec::RefMap* type_refs_; |
103 | 106 |
104 base::WeakPtrFactory<APIBinding> weak_factory_; | 107 base::WeakPtrFactory<APIBinding> weak_factory_; |
105 | 108 |
106 DISALLOW_COPY_AND_ASSIGN(APIBinding); | 109 DISALLOW_COPY_AND_ASSIGN(APIBinding); |
107 }; | 110 }; |
108 | 111 |
109 } // namespace extensions | 112 } // namespace extensions |
110 | 113 |
111 #endif // EXTENSIONS_RENDERER_API_BINDING_H_ | 114 #endif // EXTENSIONS_RENDERER_API_BINDING_H_ |
OLD | NEW |