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