| 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/native_extension_bindings_system.h" | 5 #include "extensions/renderer/native_extension_bindings_system.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "content/public/common/console_message_level.h" | 9 #include "content/public/common/console_message_level.h" |
| 10 #include "content/public/common/content_switches.h" | 10 #include "content/public/common/content_switches.h" |
| (...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 ScriptContext* context) { | 481 ScriptContext* context) { |
| 482 v8::HandleScope handle_scope(context->isolate()); | 482 v8::HandleScope handle_scope(context->isolate()); |
| 483 v8::Context::Scope context_scope(context->v8_context()); | 483 v8::Context::Scope context_scope(context->v8_context()); |
| 484 EventFilteringInfo filter; | 484 EventFilteringInfo filter; |
| 485 if (filtering_info_dict) | 485 if (filtering_info_dict) |
| 486 filter = EventFilteringInfo(*filtering_info_dict); | 486 filter = EventFilteringInfo(*filtering_info_dict); |
| 487 api_system_.FireEventInContext(event_name, context->v8_context(), *event_args, | 487 api_system_.FireEventInContext(event_name, context->v8_context(), *event_args, |
| 488 filter); | 488 filter); |
| 489 } | 489 } |
| 490 | 490 |
| 491 bool NativeExtensionBindingsSystem::HasEventListenerInContext( |
| 492 const std::string& event_name, |
| 493 ScriptContext* context) { |
| 494 v8::HandleScope handle_scope(context->isolate()); |
| 495 return api_system_.event_handler()->HasListenerForEvent( |
| 496 event_name, context->v8_context()); |
| 497 } |
| 498 |
| 491 void NativeExtensionBindingsSystem::HandleResponse( | 499 void NativeExtensionBindingsSystem::HandleResponse( |
| 492 int request_id, | 500 int request_id, |
| 493 bool success, | 501 bool success, |
| 494 const base::ListValue& response, | 502 const base::ListValue& response, |
| 495 const std::string& error) { | 503 const std::string& error) { |
| 496 // Some API calls result in failure, but don't set an error. Use a generic and | 504 // Some API calls result in failure, but don't set an error. Use a generic and |
| 497 // unhelpful error string. | 505 // unhelpful error string. |
| 498 // TODO(devlin): Track these down and fix them. See crbug.com/648275. | 506 // TODO(devlin): Track these down and fix them. See crbug.com/648275. |
| 499 api_system_.CompleteRequest( | 507 api_system_.CompleteRequest( |
| 500 request_id, response, | 508 request_id, response, |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 685 v8::Local<v8::Value>* binding_util_out) { | 693 v8::Local<v8::Value>* binding_util_out) { |
| 686 gin::Handle<APIBindingJSUtil> handle = gin::CreateHandle( | 694 gin::Handle<APIBindingJSUtil> handle = gin::CreateHandle( |
| 687 context->GetIsolate(), | 695 context->GetIsolate(), |
| 688 new APIBindingJSUtil( | 696 new APIBindingJSUtil( |
| 689 api_system_.type_reference_map(), api_system_.request_handler(), | 697 api_system_.type_reference_map(), api_system_.request_handler(), |
| 690 api_system_.event_handler(), base::Bind(&CallJsFunction))); | 698 api_system_.event_handler(), base::Bind(&CallJsFunction))); |
| 691 *binding_util_out = handle.ToV8(); | 699 *binding_util_out = handle.ToV8(); |
| 692 } | 700 } |
| 693 | 701 |
| 694 } // namespace extensions | 702 } // namespace extensions |
| OLD | NEW |