Chromium Code Reviews| 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 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 474 if (!success.IsJust() || !success.FromJust()) { | 474 if (!success.IsJust() || !success.FromJust()) { |
| 475 LOG(ERROR) << "Failed to create API on Chrome object."; | 475 LOG(ERROR) << "Failed to create API on Chrome object."; |
| 476 return; | 476 return; |
| 477 } | 477 } |
| 478 } | 478 } |
| 479 } | 479 } |
| 480 | 480 |
| 481 void NativeExtensionBindingsSystem::DispatchEventInContext( | 481 void NativeExtensionBindingsSystem::DispatchEventInContext( |
| 482 const std::string& event_name, | 482 const std::string& event_name, |
| 483 const base::ListValue* event_args, | 483 const base::ListValue* event_args, |
| 484 const base::DictionaryValue* filtering_info_dict, | 484 const EventFilteringInfo* filtering_info, |
| 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 api_system_.FireEventInContext( |
| 489 if (filtering_info_dict) | 489 event_name, context->v8_context(), *event_args, |
| 490 filter = EventFilteringInfo(*filtering_info_dict); | 490 filtering_info ? *filtering_info : EventFilteringInfo()); |
|
lazyboy
2017/06/15 17:12:23
Is there a reason FireEventInContext doesn't take
Devlin
2017/06/15 18:01:06
Nope, it probably should. I noticed that too, and
lazyboy
2017/06/15 18:06:43
Separate CL sounds good! Thanks.
| |
| 491 api_system_.FireEventInContext(event_name, context->v8_context(), *event_args, | |
| 492 filter); | |
| 493 } | 491 } |
| 494 | 492 |
| 495 bool NativeExtensionBindingsSystem::HasEventListenerInContext( | 493 bool NativeExtensionBindingsSystem::HasEventListenerInContext( |
| 496 const std::string& event_name, | 494 const std::string& event_name, |
| 497 ScriptContext* context) { | 495 ScriptContext* context) { |
| 498 v8::HandleScope handle_scope(context->isolate()); | 496 v8::HandleScope handle_scope(context->isolate()); |
| 499 return api_system_.event_handler()->HasListenerForEvent( | 497 return api_system_.event_handler()->HasListenerForEvent( |
| 500 event_name, context->v8_context()); | 498 event_name, context->v8_context()); |
| 501 } | 499 } |
| 502 | 500 |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 697 v8::Local<v8::Value>* binding_util_out) { | 695 v8::Local<v8::Value>* binding_util_out) { |
| 698 gin::Handle<APIBindingJSUtil> handle = gin::CreateHandle( | 696 gin::Handle<APIBindingJSUtil> handle = gin::CreateHandle( |
| 699 context->GetIsolate(), | 697 context->GetIsolate(), |
| 700 new APIBindingJSUtil( | 698 new APIBindingJSUtil( |
| 701 api_system_.type_reference_map(), api_system_.request_handler(), | 699 api_system_.type_reference_map(), api_system_.request_handler(), |
| 702 api_system_.event_handler(), base::Bind(&CallJsFunction))); | 700 api_system_.event_handler(), base::Bind(&CallJsFunction))); |
| 703 *binding_util_out = handle.ToV8(); | 701 *binding_util_out = handle.ToV8(); |
| 704 } | 702 } |
| 705 | 703 |
| 706 } // namespace extensions | 704 } // namespace extensions |
| OLD | NEW |