Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(408)

Unified Diff: extensions/renderer/dispatcher.cc

Issue 2770403002: [Extensions Bindings] Remove ScriptContext::DispatchEvent (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « extensions/renderer/dispatcher.h ('k') | extensions/renderer/dispatcher_delegate.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/renderer/dispatcher.cc
diff --git a/extensions/renderer/dispatcher.cc b/extensions/renderer/dispatcher.cc
index eaa442804cb0e99b9fe66a601ae6514494623348..fd17f8900fb67aa79f0a3f389f9dc4144d8b5530 100644
--- a/extensions/renderer/dispatcher.cc
+++ b/extensions/renderer/dispatcher.cc
@@ -360,8 +360,7 @@ void Dispatcher::DidCreateScriptContext(
// Enable natives in startup.
ModuleSystem::NativesEnabledScope natives_enabled_scope(module_system);
- RegisterNativeHandlers(module_system, context,
- bindings_system_->GetRequestSender(),
+ RegisterNativeHandlers(module_system, context, bindings_system_.get(),
v8_schema_registry_.get());
bindings_system_->DidCreateScriptContext(context);
@@ -471,8 +470,7 @@ void Dispatcher::DidInitializeServiceWorkerContextOnWorkerThread(
ModuleSystem::NativesEnabledScope natives_enabled_scope(module_system);
ExtensionBindingsSystem* worker_bindings_system =
WorkerThreadDispatcher::GetBindingsSystem();
- RegisterNativeHandlers(module_system, context,
- worker_bindings_system->GetRequestSender(),
+ RegisterNativeHandlers(module_system, context, worker_bindings_system,
WorkerThreadDispatcher::GetV8SchemaRegistry());
worker_bindings_system->DidCreateScriptContext(context);
@@ -796,11 +794,12 @@ std::vector<std::pair<const char*, int>> Dispatcher::GetJsResources() {
// NOTE: please use the naming convention "foo_natives" for these.
// static
-void Dispatcher::RegisterNativeHandlers(ModuleSystem* module_system,
- ScriptContext* context,
- Dispatcher* dispatcher,
- RequestSender* request_sender,
- V8SchemaRegistry* v8_schema_registry) {
+void Dispatcher::RegisterNativeHandlers(
+ ModuleSystem* module_system,
+ ScriptContext* context,
+ Dispatcher* dispatcher,
+ ExtensionBindingsSystem* bindings_system,
+ V8SchemaRegistry* v8_schema_registry) {
module_system->RegisterNativeHandler(
"chrome",
std::unique_ptr<NativeHandler>(new ChromeNativeHandler(context)));
@@ -832,8 +831,11 @@ void Dispatcher::RegisterNativeHandlers(ModuleSystem* module_system,
"apiDefinitions", std::unique_ptr<NativeHandler>(
new ApiDefinitionsNatives(dispatcher, context)));
module_system->RegisterNativeHandler(
- "sendRequest", std::unique_ptr<NativeHandler>(
- new SendRequestNatives(request_sender, context)));
+ "sendRequest",
+ base::MakeUnique<SendRequestNatives>(
+ // Note: |bindings_system| can be null in unit tests.
+ bindings_system ? bindings_system->GetRequestSender() : nullptr,
+ context));
module_system->RegisterNativeHandler(
"setIcon", std::unique_ptr<NativeHandler>(new SetIconNatives(context)));
module_system->RegisterNativeHandler(
@@ -872,7 +874,7 @@ void Dispatcher::RegisterNativeHandlers(ModuleSystem* module_system,
std::unique_ptr<NativeHandler>(new RuntimeCustomBindings(context)));
module_system->RegisterNativeHandler(
"display_source",
- std::unique_ptr<NativeHandler>(new DisplaySourceCustomBindings(context)));
+ base::MakeUnique<DisplaySourceCustomBindings>(context, bindings_system));
}
bool Dispatcher::OnControlMessageReceived(const IPC::Message& message) {
@@ -1335,11 +1337,12 @@ void Dispatcher::UpdateBindingsForContext(ScriptContext* context) {
}
// NOTE: please use the naming convention "foo_natives" for these.
-void Dispatcher::RegisterNativeHandlers(ModuleSystem* module_system,
- ScriptContext* context,
- RequestSender* request_sender,
- V8SchemaRegistry* v8_schema_registry) {
- RegisterNativeHandlers(module_system, context, this, request_sender,
+void Dispatcher::RegisterNativeHandlers(
+ ModuleSystem* module_system,
+ ScriptContext* context,
+ ExtensionBindingsSystem* bindings_system,
+ V8SchemaRegistry* v8_schema_registry) {
+ RegisterNativeHandlers(module_system, context, this, bindings_system,
v8_schema_registry);
const Extension* extension = context->extension();
int manifest_version = extension ? extension->manifest_version() : 1;
@@ -1356,7 +1359,8 @@ void Dispatcher::RegisterNativeHandlers(ModuleSystem* module_system,
ExtensionsRendererClient::Get()->IsIncognitoProcess(),
is_component_extension, manifest_version, send_request_disabled)));
- delegate_->RegisterNativeHandlers(this, module_system, context);
+ delegate_->RegisterNativeHandlers(this, module_system, bindings_system,
+ context);
}
void Dispatcher::UpdateContentCapabilities(ScriptContext* context) {
« no previous file with comments | « extensions/renderer/dispatcher.h ('k') | extensions/renderer/dispatcher_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698