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_BINDINGS_SYSTEM_H_ | 5 #ifndef EXTENSIONS_RENDERER_API_BINDINGS_SYSTEM_H_ |
6 #define EXTENSIONS_RENDERER_API_BINDINGS_SYSTEM_H_ | 6 #define EXTENSIONS_RENDERER_API_BINDINGS_SYSTEM_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <memory> | 9 #include <memory> |
10 #include <string> | 10 #include <string> |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 bool has_user_gesture = false; | 42 bool has_user_gesture = false; |
43 std::unique_ptr<base::ListValue> arguments; | 43 std::unique_ptr<base::ListValue> arguments; |
44 }; | 44 }; |
45 | 45 |
46 using GetAPISchemaMethod = | 46 using GetAPISchemaMethod = |
47 base::Callback<const base::DictionaryValue&(const std::string&)>; | 47 base::Callback<const base::DictionaryValue&(const std::string&)>; |
48 using SendRequestMethod = | 48 using SendRequestMethod = |
49 base::Callback<void(std::unique_ptr<Request>, v8::Local<v8::Context>)>; | 49 base::Callback<void(std::unique_ptr<Request>, v8::Local<v8::Context>)>; |
50 | 50 |
51 APIBindingsSystem(const binding::RunJSFunction& call_js, | 51 APIBindingsSystem(const binding::RunJSFunction& call_js, |
| 52 const binding::RunJSFunctionSync& call_js_sync, |
52 const GetAPISchemaMethod& get_api_schema, | 53 const GetAPISchemaMethod& get_api_schema, |
53 const SendRequestMethod& send_request); | 54 const SendRequestMethod& send_request); |
54 ~APIBindingsSystem(); | 55 ~APIBindingsSystem(); |
55 | 56 |
56 // Returns a new v8::Object representing the api specified by |api_name|. | 57 // Returns a new v8::Object representing the api specified by |api_name|. |
57 v8::Local<v8::Object> CreateAPIInstance( | 58 v8::Local<v8::Object> CreateAPIInstance( |
58 const std::string& api_name, | 59 const std::string& api_name, |
59 v8::Local<v8::Context> context, | 60 v8::Local<v8::Context> context, |
60 v8::Isolate* isolate, | 61 v8::Isolate* isolate, |
61 const APIBinding::AvailabilityCallback& is_available, | 62 const APIBinding::AvailabilityCallback& is_available, |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 // created lazily. | 106 // created lazily. |
106 std::map<std::string, std::unique_ptr<APIBinding>> api_bindings_; | 107 std::map<std::string, std::unique_ptr<APIBinding>> api_bindings_; |
107 | 108 |
108 // A map from api_name -> APIBindingHooks for registering custom hooks. | 109 // A map from api_name -> APIBindingHooks for registering custom hooks. |
109 // TODO(devlin): This map is pretty pointer-y. Is that going to be a | 110 // TODO(devlin): This map is pretty pointer-y. Is that going to be a |
110 // performance concern? | 111 // performance concern? |
111 std::map<std::string, std::unique_ptr<APIBindingHooks>> binding_hooks_; | 112 std::map<std::string, std::unique_ptr<APIBindingHooks>> binding_hooks_; |
112 | 113 |
113 binding::RunJSFunction call_js_; | 114 binding::RunJSFunction call_js_; |
114 | 115 |
| 116 binding::RunJSFunctionSync call_js_sync_; |
| 117 |
115 // The method to retrieve the DictionaryValue describing a given extension | 118 // The method to retrieve the DictionaryValue describing a given extension |
116 // API. Curried in for testing purposes so we can use fake APIs. | 119 // API. Curried in for testing purposes so we can use fake APIs. |
117 GetAPISchemaMethod get_api_schema_; | 120 GetAPISchemaMethod get_api_schema_; |
118 | 121 |
119 // The method to call when a new API call is triggered. Curried in for testing | 122 // The method to call when a new API call is triggered. Curried in for testing |
120 // purposes. Typically, this would send an IPC to the browser to begin the | 123 // purposes. Typically, this would send an IPC to the browser to begin the |
121 // function work. | 124 // function work. |
122 SendRequestMethod send_request_; | 125 SendRequestMethod send_request_; |
123 | 126 |
124 DISALLOW_COPY_AND_ASSIGN(APIBindingsSystem); | 127 DISALLOW_COPY_AND_ASSIGN(APIBindingsSystem); |
125 }; | 128 }; |
126 | 129 |
127 } // namespace | 130 } // namespace |
128 | 131 |
129 #endif // EXTENSIONS_RENDERER_API_BINDINGS_SYSTEM_H_ | 132 #endif // EXTENSIONS_RENDERER_API_BINDINGS_SYSTEM_H_ |
OLD | NEW |