| 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_hooks.h" | 5 #include "extensions/renderer/api_binding_hooks.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 9 #include "base/supports_user_data.h" | 9 #include "base/supports_user_data.h" |
| 10 #include "extensions/renderer/api_binding_hooks_delegate.h" | 10 #include "extensions/renderer/api_binding_hooks_delegate.h" |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 return hook_interface->GetCustomCallback(name, context->GetIsolate()); | 326 return hook_interface->GetCustomCallback(name, context->GetIsolate()); |
| 327 } | 327 } |
| 328 | 328 |
| 329 bool APIBindingHooks::CreateCustomEvent(v8::Local<v8::Context> context, | 329 bool APIBindingHooks::CreateCustomEvent(v8::Local<v8::Context> context, |
| 330 const std::string& event_name, | 330 const std::string& event_name, |
| 331 v8::Local<v8::Value>* event_out) { | 331 v8::Local<v8::Value>* event_out) { |
| 332 return delegate_ && | 332 return delegate_ && |
| 333 delegate_->CreateCustomEvent(context, run_js_, event_name, event_out); | 333 delegate_->CreateCustomEvent(context, run_js_, event_name, event_out); |
| 334 } | 334 } |
| 335 | 335 |
| 336 void APIBindingHooks::InitializeTemplate( |
| 337 v8::Isolate* isolate, |
| 338 v8::Local<v8::ObjectTemplate> object_template, |
| 339 const APITypeReferenceMap& type_refs) { |
| 340 if (delegate_) |
| 341 delegate_->InitializeTemplate(isolate, object_template, type_refs); |
| 342 } |
| 343 |
| 336 void APIBindingHooks::SetDelegate( | 344 void APIBindingHooks::SetDelegate( |
| 337 std::unique_ptr<APIBindingHooksDelegate> delegate) { | 345 std::unique_ptr<APIBindingHooksDelegate> delegate) { |
| 338 delegate_ = std::move(delegate); | 346 delegate_ = std::move(delegate); |
| 339 } | 347 } |
| 340 | 348 |
| 341 bool APIBindingHooks::UpdateArguments( | 349 bool APIBindingHooks::UpdateArguments( |
| 342 v8::Local<v8::Function> function, | 350 v8::Local<v8::Function> function, |
| 343 v8::Local<v8::Context> context, | 351 v8::Local<v8::Context> context, |
| 344 std::vector<v8::Local<v8::Value>>* arguments) { | 352 std::vector<v8::Local<v8::Value>>* arguments) { |
| 345 v8::Global<v8::Value> global_result; | 353 v8::Global<v8::Value> global_result; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 358 if (result.IsEmpty() || | 366 if (result.IsEmpty() || |
| 359 !gin::Converter<std::vector<v8::Local<v8::Value>>>::FromV8( | 367 !gin::Converter<std::vector<v8::Local<v8::Value>>>::FromV8( |
| 360 context->GetIsolate(), result, &new_args)) { | 368 context->GetIsolate(), result, &new_args)) { |
| 361 return false; | 369 return false; |
| 362 } | 370 } |
| 363 arguments->swap(new_args); | 371 arguments->swap(new_args); |
| 364 return true; | 372 return true; |
| 365 } | 373 } |
| 366 | 374 |
| 367 } // namespace extensions | 375 } // namespace extensions |
| OLD | NEW |