| 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_binding.h" | 5 #include "extensions/renderer/api_binding.h" |
| 6 #include "base/bind.h" | 6 #include "base/bind.h" |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 if (!binding_hooks_) { | 157 if (!binding_hooks_) { |
| 158 binding_hooks_ = base::MakeUnique<APIBindingHooks>( | 158 binding_hooks_ = base::MakeUnique<APIBindingHooks>( |
| 159 kBindingName, binding::RunJSFunctionSync()); | 159 kBindingName, binding::RunJSFunctionSync()); |
| 160 } | 160 } |
| 161 if (binding_hooks_delegate_) | 161 if (binding_hooks_delegate_) |
| 162 binding_hooks_->SetDelegate(std::move(binding_hooks_delegate_)); | 162 binding_hooks_->SetDelegate(std::move(binding_hooks_delegate_)); |
| 163 if (!availability_callback_) | 163 if (!availability_callback_) |
| 164 availability_callback_ = base::Bind(&AllowAllFeatures); | 164 availability_callback_ = base::Bind(&AllowAllFeatures); |
| 165 event_handler_ = base::MakeUnique<APIEventHandler>( | 165 event_handler_ = base::MakeUnique<APIEventHandler>( |
| 166 base::Bind(&RunFunctionOnGlobalAndIgnoreResult), | 166 base::Bind(&RunFunctionOnGlobalAndIgnoreResult), |
| 167 base::Bind(&RunFunctionOnGlobalAndReturnHandle), |
| 167 base::Bind(&OnEventListenersChanged)); | 168 base::Bind(&OnEventListenersChanged)); |
| 168 binding_ = base::MakeUnique<APIBinding>( | 169 binding_ = base::MakeUnique<APIBinding>( |
| 169 kBindingName, binding_functions_.get(), binding_types_.get(), | 170 kBindingName, binding_functions_.get(), binding_types_.get(), |
| 170 binding_events_.get(), binding_properties_.get(), create_custom_type_, | 171 binding_events_.get(), binding_properties_.get(), create_custom_type_, |
| 171 availability_callback_, std::move(binding_hooks_), &type_refs_, | 172 availability_callback_, std::move(binding_hooks_), &type_refs_, |
| 172 request_handler_.get(), event_handler_.get()); | 173 request_handler_.get(), event_handler_.get()); |
| 173 EXPECT_EQ(!binding_types_.get(), type_refs_.empty()); | 174 EXPECT_EQ(!binding_types_.get(), type_refs_.empty()); |
| 174 } | 175 } |
| 175 | 176 |
| 176 void ExpectPass(v8::Local<v8::Object> object, | 177 void ExpectPass(v8::Local<v8::Object> object, |
| (...skipping 1090 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1267 | 1268 |
| 1268 // The extra property should be present on the binding object. | 1269 // The extra property should be present on the binding object. |
| 1269 EXPECT_EQ("42", GetStringPropertyFromObject(binding_object, context, | 1270 EXPECT_EQ("42", GetStringPropertyFromObject(binding_object, context, |
| 1270 "hookedProperty")); | 1271 "hookedProperty")); |
| 1271 // Sanity check: other values should still be there. | 1272 // Sanity check: other values should still be there. |
| 1272 EXPECT_EQ("function", | 1273 EXPECT_EQ("function", |
| 1273 GetStringPropertyFromObject(binding_object, context, "oneString")); | 1274 GetStringPropertyFromObject(binding_object, context, "oneString")); |
| 1274 } | 1275 } |
| 1275 | 1276 |
| 1276 } // namespace extensions | 1277 } // namespace extensions |
| OLD | NEW |