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 26 matching lines...) Expand all Loading... |
37 v8::Isolate* isolate, | 37 v8::Isolate* isolate, |
38 const std::string& property_name, | 38 const std::string& property_name, |
39 const base::ListValue* property_values, | 39 const base::ListValue* property_values, |
40 APIRequestHandler* request_handler, | 40 APIRequestHandler* request_handler, |
41 APIEventHandler* event_handler, | 41 APIEventHandler* event_handler, |
42 APITypeReferenceMap* type_refs)>; | 42 APITypeReferenceMap* type_refs)>; |
43 | 43 |
44 APIBindingsSystem(const binding::RunJSFunction& call_js, | 44 APIBindingsSystem(const binding::RunJSFunction& call_js, |
45 const binding::RunJSFunctionSync& call_js_sync, | 45 const binding::RunJSFunctionSync& call_js_sync, |
46 const GetAPISchemaMethod& get_api_schema, | 46 const GetAPISchemaMethod& get_api_schema, |
| 47 const APIBinding::AvailabilityCallback& is_available, |
47 const APIRequestHandler::SendRequestMethod& send_request, | 48 const APIRequestHandler::SendRequestMethod& send_request, |
48 const APIEventHandler::EventListenersChangedMethod& | 49 const APIEventHandler::EventListenersChangedMethod& |
49 event_listeners_changed, | 50 event_listeners_changed, |
50 APILastError last_error); | 51 APILastError last_error); |
51 ~APIBindingsSystem(); | 52 ~APIBindingsSystem(); |
52 | 53 |
53 // Returns a new v8::Object representing the api specified by |api_name|. | 54 // Returns a new v8::Object representing the api specified by |api_name|. |
54 v8::Local<v8::Object> CreateAPIInstance( | 55 v8::Local<v8::Object> CreateAPIInstance( |
55 const std::string& api_name, | 56 const std::string& api_name, |
56 v8::Local<v8::Context> context, | 57 v8::Local<v8::Context> context, |
57 const APIBinding::AvailabilityCallback& is_available, | |
58 APIBindingHooks** hooks_out); | 58 APIBindingHooks** hooks_out); |
59 | 59 |
60 // Responds to the request with the given |request_id|, calling the callback | 60 // Responds to the request with the given |request_id|, calling the callback |
61 // with |response|. If |error| is non-empty, sets the last error. | 61 // with |response|. If |error| is non-empty, sets the last error. |
62 void CompleteRequest(int request_id, | 62 void CompleteRequest(int request_id, |
63 const base::ListValue& response, | 63 const base::ListValue& response, |
64 const std::string& error); | 64 const std::string& error); |
65 | 65 |
66 // Notifies the APIEventHandler to fire the corresponding event, notifying | 66 // Notifies the APIEventHandler to fire the corresponding event, notifying |
67 // listeners. | 67 // listeners. |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 std::map<std::string, CustomTypeHandler> custom_types_; | 128 std::map<std::string, CustomTypeHandler> custom_types_; |
129 | 129 |
130 binding::RunJSFunction call_js_; | 130 binding::RunJSFunction call_js_; |
131 | 131 |
132 binding::RunJSFunctionSync call_js_sync_; | 132 binding::RunJSFunctionSync call_js_sync_; |
133 | 133 |
134 // The method to retrieve the DictionaryValue describing a given extension | 134 // The method to retrieve the DictionaryValue describing a given extension |
135 // API. Curried in for testing purposes so we can use fake APIs. | 135 // API. Curried in for testing purposes so we can use fake APIs. |
136 GetAPISchemaMethod get_api_schema_; | 136 GetAPISchemaMethod get_api_schema_; |
137 | 137 |
| 138 APIBinding::AvailabilityCallback is_available_; |
| 139 |
138 DISALLOW_COPY_AND_ASSIGN(APIBindingsSystem); | 140 DISALLOW_COPY_AND_ASSIGN(APIBindingsSystem); |
139 }; | 141 }; |
140 | 142 |
141 } // namespace | 143 } // namespace |
142 | 144 |
143 #endif // EXTENSIONS_RENDERER_API_BINDINGS_SYSTEM_H_ | 145 #endif // EXTENSIONS_RENDERER_API_BINDINGS_SYSTEM_H_ |
OLD | NEW |