| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "content/browser/mojo/mojo_shell_context.h" | 5 #include "content/browser/mojo/mojo_shell_context.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
| 12 #include "base/single_thread_task_runner.h" | 12 #include "base/single_thread_task_runner.h" |
| 13 #include "base/thread_task_runner_handle.h" | 13 #include "base/thread_task_runner_handle.h" |
| 14 #include "content/browser/gpu/gpu_process_host.h" | 14 #include "content/browser/gpu/gpu_process_host.h" |
| 15 #include "content/common/gpu/gpu_process_launch_causes.h" | 15 #include "content/common/gpu/gpu_process_launch_causes.h" |
| 16 #include "content/common/process_control.mojom.h" | 16 #include "content/common/process_control.mojom.h" |
| 17 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" |
| 18 #include "content/public/browser/content_browser_client.h" | 18 #include "content/public/browser/content_browser_client.h" |
| 19 #include "content/public/browser/utility_process_host.h" | 19 #include "content/public/browser/utility_process_host.h" |
| 20 #include "content/public/browser/utility_process_host_client.h" | 20 #include "content/public/browser/utility_process_host_client.h" |
| 21 #include "content/public/common/content_client.h" | 21 #include "content/public/common/content_client.h" |
| 22 #include "content/public/common/service_registry.h" | 22 #include "content/public/common/service_registry.h" |
| 23 #include "mojo/common/url_type_converters.h" | 23 #include "mojo/common/url_type_converters.h" |
| 24 #include "mojo/public/cpp/bindings/interface_request.h" | 24 #include "mojo/public/cpp/bindings/interface_request.h" |
| 25 #include "mojo/public/cpp/bindings/string.h" | 25 #include "mojo/public/cpp/bindings/string.h" |
| 26 #include "mojo/shell/application_loader.h" | 26 #include "mojo/shell/application_loader.h" |
| 27 #include "mojo/shell/connect_to_application_params.h" | 27 #include "mojo/shell/connect_to_application_params.h" |
| 28 #include "mojo/shell/identity.h" | 28 #include "mojo/shell/identity.h" |
| 29 #include "mojo/shell/package_manager/package_manager_impl.h" | |
| 30 #include "mojo/shell/public/cpp/shell_client.h" | 29 #include "mojo/shell/public/cpp/shell_client.h" |
| 31 #include "mojo/shell/static_application_loader.h" | 30 #include "mojo/shell/static_application_loader.h" |
| 32 | 31 |
| 33 namespace content { | 32 namespace content { |
| 34 | 33 |
| 35 namespace { | 34 namespace { |
| 36 | 35 |
| 37 // An extra set of apps to register on initialization, if set by a test. | 36 // An extra set of apps to register on initialization, if set by a test. |
| 38 const MojoShellContext::StaticApplicationMap* g_applications_for_test; | 37 const MojoShellContext::StaticApplicationMap* g_applications_for_test; |
| 39 | 38 |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 MojoShellContext::proxy_ = LAZY_INSTANCE_INITIALIZER; | 191 MojoShellContext::proxy_ = LAZY_INSTANCE_INITIALIZER; |
| 193 | 192 |
| 194 void MojoShellContext::SetApplicationsForTest( | 193 void MojoShellContext::SetApplicationsForTest( |
| 195 const StaticApplicationMap* apps) { | 194 const StaticApplicationMap* apps) { |
| 196 g_applications_for_test = apps; | 195 g_applications_for_test = apps; |
| 197 } | 196 } |
| 198 | 197 |
| 199 MojoShellContext::MojoShellContext() { | 198 MojoShellContext::MojoShellContext() { |
| 200 proxy_.Get().reset(new Proxy(this)); | 199 proxy_.Get().reset(new Proxy(this)); |
| 201 | 200 |
| 202 // Construct with an empty filepath since mojo: urls can't be registered now | |
| 203 // the url scheme registry is locked. | |
| 204 scoped_ptr<mojo::shell::PackageManagerImpl> package_manager( | |
| 205 new mojo::shell::PackageManagerImpl(base::FilePath(), nullptr, nullptr)); | |
| 206 bool register_mojo_url_schemes = false; | 201 bool register_mojo_url_schemes = false; |
| 207 application_manager_.reset( | 202 application_manager_.reset( |
| 208 new mojo::shell::ApplicationManager(std::move(package_manager), | 203 new mojo::shell::ApplicationManager(register_mojo_url_schemes)); |
| 209 register_mojo_url_schemes)); | |
| 210 | 204 |
| 211 application_manager_->set_default_loader( | 205 application_manager_->set_default_loader( |
| 212 scoped_ptr<mojo::shell::ApplicationLoader>(new DefaultApplicationLoader)); | 206 scoped_ptr<mojo::shell::ApplicationLoader>(new DefaultApplicationLoader)); |
| 213 | 207 |
| 214 StaticApplicationMap apps; | 208 StaticApplicationMap apps; |
| 215 GetContentClient()->browser()->RegisterInProcessMojoApplications(&apps); | 209 GetContentClient()->browser()->RegisterInProcessMojoApplications(&apps); |
| 216 if (g_applications_for_test) { | 210 if (g_applications_for_test) { |
| 217 // Add testing apps to the map, potentially overwriting whatever the | 211 // Add testing apps to the map, potentially overwriting whatever the |
| 218 // browser client registered. | 212 // browser client registered. |
| 219 for (const auto& entry : *g_applications_for_test) | 213 for (const auto& entry : *g_applications_for_test) |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 mojo::shell::GetPermissiveCapabilityFilter())); | 279 mojo::shell::GetPermissiveCapabilityFilter())); |
| 286 params->SetTarget(mojo::shell::Identity(url, std::string(), filter)); | 280 params->SetTarget(mojo::shell::Identity(url, std::string(), filter)); |
| 287 params->set_remote_interfaces(std::move(request)); | 281 params->set_remote_interfaces(std::move(request)); |
| 288 params->set_local_interfaces(std::move(exposed_services)); | 282 params->set_local_interfaces(std::move(exposed_services)); |
| 289 params->set_on_application_end(base::Bind(&base::DoNothing)); | 283 params->set_on_application_end(base::Bind(&base::DoNothing)); |
| 290 params->set_connect_callback(callback); | 284 params->set_connect_callback(callback); |
| 291 application_manager_->ConnectToApplication(std::move(params)); | 285 application_manager_->ConnectToApplication(std::move(params)); |
| 292 } | 286 } |
| 293 | 287 |
| 294 } // namespace content | 288 } // namespace content |
| OLD | NEW |