| 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/bindings/api_bindings_system.h" | 5 #include "extensions/renderer/bindings/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/bindings/api_binding_hooks.h" | 10 #include "extensions/renderer/bindings/api_binding_hooks.h" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 // close enough to the same cost. Additionally, this happens lazily on API | 83 // close enough to the same cost. Additionally, this happens lazily on API |
| 84 // use, and relatively few APIs specify types from another API. Finally, this | 84 // use, and relatively few APIs specify types from another API. Finally, this |
| 85 // will also go away if/when we generate all these specifications. | 85 // will also go away if/when we generate all these specifications. |
| 86 std::string::size_type dot = type_name.rfind('.'); | 86 std::string::size_type dot = type_name.rfind('.'); |
| 87 // The type name should be fully qualified (include the API name). | 87 // The type name should be fully qualified (include the API name). |
| 88 DCHECK_NE(std::string::npos, dot) << type_name; | 88 DCHECK_NE(std::string::npos, dot) << type_name; |
| 89 DCHECK_LT(dot, type_name.size() - 1); | 89 DCHECK_LT(dot, type_name.size() - 1); |
| 90 std::string api_name = type_name.substr(0, dot); | 90 std::string api_name = type_name.substr(0, dot); |
| 91 // If we've already instantiated the binding, the type should have been in | 91 // If we've already instantiated the binding, the type should have been in |
| 92 // there. | 92 // there. |
| 93 DCHECK(api_bindings_.find(api_name) == api_bindings_.end()); | 93 DCHECK(api_bindings_.find(api_name) == api_bindings_.end()) << api_name; |
| 94 | 94 |
| 95 api_bindings_[api_name] = CreateNewAPIBinding(api_name); | 95 api_bindings_[api_name] = CreateNewAPIBinding(api_name); |
| 96 } | 96 } |
| 97 | 97 |
| 98 void APIBindingsSystem::CompleteRequest(int request_id, | 98 void APIBindingsSystem::CompleteRequest(int request_id, |
| 99 const base::ListValue& response, | 99 const base::ListValue& response, |
| 100 const std::string& error) { | 100 const std::string& error) { |
| 101 request_handler_.CompleteRequest(request_id, response, error); | 101 request_handler_.CompleteRequest(request_id, response, error); |
| 102 } | 102 } |
| 103 | 103 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 const std::string& property_name, | 136 const std::string& property_name, |
| 137 const base::ListValue* property_values) { | 137 const base::ListValue* property_values) { |
| 138 auto iter = custom_types_.find(type_name); | 138 auto iter = custom_types_.find(type_name); |
| 139 DCHECK(iter != custom_types_.end()) << "Custom type not found: " << type_name; | 139 DCHECK(iter != custom_types_.end()) << "Custom type not found: " << type_name; |
| 140 return iter->second.Run(isolate, property_name, property_values, | 140 return iter->second.Run(isolate, property_name, property_values, |
| 141 &request_handler_, &event_handler_, | 141 &request_handler_, &event_handler_, |
| 142 &type_reference_map_, &access_checker_); | 142 &type_reference_map_, &access_checker_); |
| 143 } | 143 } |
| 144 | 144 |
| 145 } // namespace extensions | 145 } // namespace extensions |
| OLD | NEW |