| 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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 return hooks.get(); | 117 return hooks.get(); |
| 118 } | 118 } |
| 119 | 119 |
| 120 void APIBindingsSystem::RegisterCustomType(const std::string& type_name, | 120 void APIBindingsSystem::RegisterCustomType(const std::string& type_name, |
| 121 const CustomTypeHandler& function) { | 121 const CustomTypeHandler& function) { |
| 122 DCHECK(custom_types_.find(type_name) == custom_types_.end()) | 122 DCHECK(custom_types_.find(type_name) == custom_types_.end()) |
| 123 << "Custom type already registered: " << type_name; | 123 << "Custom type already registered: " << type_name; |
| 124 custom_types_[type_name] = function; | 124 custom_types_[type_name] = function; |
| 125 } | 125 } |
| 126 | 126 |
| 127 void APIBindingsSystem::WillReleaseContext(v8::Local<v8::Context> context) { |
| 128 event_handler_.InvalidateContext(context); |
| 129 } |
| 130 |
| 127 v8::Local<v8::Object> APIBindingsSystem::CreateCustomType( | 131 v8::Local<v8::Object> APIBindingsSystem::CreateCustomType( |
| 128 v8::Local<v8::Context> context, | 132 v8::Local<v8::Context> context, |
| 129 const std::string& type_name, | 133 const std::string& type_name, |
| 130 const std::string& property_name) { | 134 const std::string& property_name) { |
| 131 auto iter = custom_types_.find(type_name); | 135 auto iter = custom_types_.find(type_name); |
| 132 DCHECK(iter != custom_types_.end()) << "Custom type not found: " << type_name; | 136 DCHECK(iter != custom_types_.end()) << "Custom type not found: " << type_name; |
| 133 return iter->second.Run(context, property_name, &request_handler_, | 137 return iter->second.Run(context, property_name, &request_handler_, |
| 134 &type_reference_map_); | 138 &type_reference_map_); |
| 135 } | 139 } |
| 136 | 140 |
| 137 } // namespace extensions | 141 } // namespace extensions |
| OLD | NEW |