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 #include "extensions/renderer/api_bindings_system.h" | 5 #include "extensions/renderer/api_bindings_system.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "extensions/renderer/api_binding_hooks.h" | 10 #include "extensions/renderer/api_binding_hooks.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 event_handler_(call_js, event_listeners_changed), | 24 event_handler_(call_js, event_listeners_changed), |
25 call_js_(call_js), | 25 call_js_(call_js), |
26 call_js_sync_(call_js_sync), | 26 call_js_sync_(call_js_sync), |
27 get_api_schema_(get_api_schema) {} | 27 get_api_schema_(get_api_schema) {} |
28 | 28 |
29 APIBindingsSystem::~APIBindingsSystem() {} | 29 APIBindingsSystem::~APIBindingsSystem() {} |
30 | 30 |
31 v8::Local<v8::Object> APIBindingsSystem::CreateAPIInstance( | 31 v8::Local<v8::Object> APIBindingsSystem::CreateAPIInstance( |
32 const std::string& api_name, | 32 const std::string& api_name, |
33 v8::Local<v8::Context> context, | 33 v8::Local<v8::Context> context, |
34 v8::Isolate* isolate, | |
35 const APIBinding::AvailabilityCallback& is_available, | 34 const APIBinding::AvailabilityCallback& is_available, |
36 APIBindingHooks** hooks_out) { | 35 APIBindingHooks** hooks_out) { |
37 std::unique_ptr<APIBinding>& binding = api_bindings_[api_name]; | 36 std::unique_ptr<APIBinding>& binding = api_bindings_[api_name]; |
38 if (!binding) | 37 if (!binding) |
39 binding = CreateNewAPIBinding(api_name); | 38 binding = CreateNewAPIBinding(api_name); |
40 if (hooks_out) | 39 if (hooks_out) |
41 *hooks_out = binding->hooks(); | 40 *hooks_out = binding->hooks(); |
42 return binding->CreateInstance(context, isolate, is_available); | 41 return binding->CreateInstance(context, is_available); |
43 } | 42 } |
44 | 43 |
45 std::unique_ptr<APIBinding> APIBindingsSystem::CreateNewAPIBinding( | 44 std::unique_ptr<APIBinding> APIBindingsSystem::CreateNewAPIBinding( |
46 const std::string& api_name) { | 45 const std::string& api_name) { |
47 const base::DictionaryValue& api_schema = get_api_schema_.Run(api_name); | 46 const base::DictionaryValue& api_schema = get_api_schema_.Run(api_name); |
48 | 47 |
49 const base::ListValue* function_definitions = nullptr; | 48 const base::ListValue* function_definitions = nullptr; |
50 api_schema.GetList("functions", &function_definitions); | 49 api_schema.GetList("functions", &function_definitions); |
51 const base::ListValue* type_definitions = nullptr; | 50 const base::ListValue* type_definitions = nullptr; |
52 api_schema.GetList("types", &type_definitions); | 51 api_schema.GetList("types", &type_definitions); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 const std::string& property_name, | 135 const std::string& property_name, |
137 const base::ListValue* property_values) { | 136 const base::ListValue* property_values) { |
138 auto iter = custom_types_.find(type_name); | 137 auto iter = custom_types_.find(type_name); |
139 DCHECK(iter != custom_types_.end()) << "Custom type not found: " << type_name; | 138 DCHECK(iter != custom_types_.end()) << "Custom type not found: " << type_name; |
140 return iter->second.Run(context, property_name, property_values, | 139 return iter->second.Run(context, property_name, property_values, |
141 &request_handler_, &event_handler_, | 140 &request_handler_, &event_handler_, |
142 &type_reference_map_); | 141 &type_reference_map_); |
143 } | 142 } |
144 | 143 |
145 } // namespace extensions | 144 } // namespace extensions |
OLD | NEW |