OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "shell/context.h" | 5 #include "shell/context.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/base_switches.h" | 9 #include "base/base_switches.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "mojo/common/tracing_impl.h" | 22 #include "mojo/common/tracing_impl.h" |
23 #include "mojo/edk/embedder/embedder.h" | 23 #include "mojo/edk/embedder/embedder.h" |
24 #include "mojo/edk/embedder/simple_platform_support.h" | 24 #include "mojo/edk/embedder/simple_platform_support.h" |
25 #include "mojo/public/cpp/application/application_connection.h" | 25 #include "mojo/public/cpp/application/application_connection.h" |
26 #include "mojo/public/cpp/application/application_delegate.h" | 26 #include "mojo/public/cpp/application/application_delegate.h" |
27 #include "mojo/public/cpp/application/application_impl.h" | 27 #include "mojo/public/cpp/application/application_impl.h" |
28 #include "services/tracing/tracing.mojom.h" | 28 #include "services/tracing/tracing.mojom.h" |
29 #include "shell/application_manager/application_loader.h" | 29 #include "shell/application_manager/application_loader.h" |
30 #include "shell/application_manager/application_manager.h" | 30 #include "shell/application_manager/application_manager.h" |
31 #include "shell/command_line_util.h" | 31 #include "shell/command_line_util.h" |
32 #include "shell/dynamic_application_loader.h" | |
33 #include "shell/external_application_listener.h" | 32 #include "shell/external_application_listener.h" |
34 #include "shell/filename_util.h" | 33 #include "shell/filename_util.h" |
35 #include "shell/in_process_dynamic_service_runner.h" | 34 #include "shell/in_process_dynamic_service_runner.h" |
| 35 #include "shell/native_application_loader.h" |
36 #include "shell/out_of_process_dynamic_service_runner.h" | 36 #include "shell/out_of_process_dynamic_service_runner.h" |
37 #include "shell/switches.h" | 37 #include "shell/switches.h" |
38 #include "url/gurl.h" | 38 #include "url/gurl.h" |
39 | 39 |
40 namespace mojo { | 40 namespace mojo { |
41 namespace shell { | 41 namespace shell { |
42 namespace { | 42 namespace { |
43 | 43 |
44 // Used to ensure we only init once. | 44 // Used to ensure we only init once. |
45 class Setup { | 45 class Setup { |
46 public: | 46 public: |
47 Setup() { | 47 Setup() { |
48 embedder::Init(scoped_ptr<mojo::embedder::PlatformSupport>( | 48 embedder::Init(scoped_ptr<mojo::embedder::PlatformSupport>( |
49 new mojo::embedder::SimplePlatformSupport())); | 49 new mojo::embedder::SimplePlatformSupport())); |
50 } | 50 } |
51 | 51 |
52 ~Setup() {} | 52 ~Setup() {} |
53 | 53 |
54 private: | 54 private: |
55 DISALLOW_COPY_AND_ASSIGN(Setup); | 55 DISALLOW_COPY_AND_ASSIGN(Setup); |
56 }; | 56 }; |
57 | 57 |
58 static base::LazyInstance<Setup>::Leaky setup = LAZY_INSTANCE_INITIALIZER; | 58 static base::LazyInstance<Setup>::Leaky setup = LAZY_INSTANCE_INITIALIZER; |
59 | 59 |
60 void InitContentHandlers(DynamicApplicationLoader* loader, | 60 void InitContentHandlers(NativeApplicationLoader* loader, |
61 base::CommandLine* command_line) { | 61 base::CommandLine* command_line) { |
62 // Default content handlers. | 62 // Default content handlers. |
63 loader->RegisterContentHandler("application/pdf", GURL("mojo:pdf_viewer")); | 63 loader->RegisterContentHandler("application/pdf", GURL("mojo:pdf_viewer")); |
64 loader->RegisterContentHandler("image/png", GURL("mojo:png_viewer")); | 64 loader->RegisterContentHandler("image/png", GURL("mojo:png_viewer")); |
65 loader->RegisterContentHandler("text/html", GURL("mojo:html_viewer")); | 65 loader->RegisterContentHandler("text/html", GURL("mojo:html_viewer")); |
66 | 66 |
67 // Command-line-specified content handlers. | 67 // Command-line-specified content handlers. |
68 std::string handlers_spec = | 68 std::string handlers_spec = |
69 command_line->GetSwitchValueASCII(switches::kContentHandlers); | 69 command_line->GetSwitchValueASCII(switches::kContentHandlers); |
70 if (handlers_spec.empty()) | 70 if (handlers_spec.empty()) |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 base::Bind(&ApplicationManager::RegisterExternalApplication, | 250 base::Bind(&ApplicationManager::RegisterExternalApplication, |
251 base::Unretained(&application_manager_))); | 251 base::Unretained(&application_manager_))); |
252 } | 252 } |
253 | 253 |
254 scoped_ptr<DynamicServiceRunnerFactory> runner_factory; | 254 scoped_ptr<DynamicServiceRunnerFactory> runner_factory; |
255 if (command_line->HasSwitch(switches::kEnableMultiprocess)) | 255 if (command_line->HasSwitch(switches::kEnableMultiprocess)) |
256 runner_factory.reset(new OutOfProcessDynamicServiceRunnerFactory()); | 256 runner_factory.reset(new OutOfProcessDynamicServiceRunnerFactory()); |
257 else | 257 else |
258 runner_factory.reset(new InProcessDynamicServiceRunnerFactory()); | 258 runner_factory.reset(new InProcessDynamicServiceRunnerFactory()); |
259 | 259 |
260 DynamicApplicationLoader* dynamic_application_loader = | 260 scoped_ptr<NativeApplicationLoader> native_application_loader( |
261 new DynamicApplicationLoader(this, runner_factory.Pass()); | 261 new NativeApplicationLoader(this, runner_factory.Pass())); |
262 InitContentHandlers(dynamic_application_loader, command_line); | 262 InitContentHandlers(native_application_loader.get(), command_line); |
263 application_manager_.set_default_loader( | 263 application_manager_.set_native_application_loader( |
264 scoped_ptr<ApplicationLoader>(dynamic_application_loader)); | 264 scoped_ptr<NativeApplicationLoader>(native_application_loader.Pass())); |
265 | 265 |
266 ServiceProviderPtr tracing_service_provider_ptr; | 266 ServiceProviderPtr tracing_service_provider_ptr; |
267 new TracingServiceProvider(GetProxy(&tracing_service_provider_ptr)); | 267 new TracingServiceProvider(GetProxy(&tracing_service_provider_ptr)); |
268 application_manager_.ConnectToApplication( | 268 application_manager_.ConnectToApplication( |
269 GURL("mojo:tracing"), GURL(""), nullptr, | 269 GURL("mojo:tracing"), GURL(""), nullptr, |
270 tracing_service_provider_ptr.Pass()); | 270 tracing_service_provider_ptr.Pass()); |
271 | 271 |
272 if (listener_) | 272 if (listener_) |
273 listener_->WaitForListening(); | 273 listener_->WaitForListening(); |
274 | 274 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 ScopedMessagePipeHandle Context::ConnectToServiceByName( | 313 ScopedMessagePipeHandle Context::ConnectToServiceByName( |
314 const GURL& application_url, | 314 const GURL& application_url, |
315 const std::string& service_name) { | 315 const std::string& service_name) { |
316 app_urls_.insert(application_url); | 316 app_urls_.insert(application_url); |
317 return application_manager_.ConnectToServiceByName(application_url, | 317 return application_manager_.ConnectToServiceByName(application_url, |
318 service_name).Pass(); | 318 service_name).Pass(); |
319 } | 319 } |
320 | 320 |
321 } // namespace shell | 321 } // namespace shell |
322 } // namespace mojo | 322 } // namespace mojo |
OLD | NEW |