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 "mojo/shell/context.h" | 5 #include "mojo/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 12 matching lines...) Expand all Loading... |
23 #include "mojo/common/trace_controller_impl.h" | 23 #include "mojo/common/trace_controller_impl.h" |
24 #include "mojo/common/tracing_impl.h" | 24 #include "mojo/common/tracing_impl.h" |
25 #include "mojo/edk/embedder/embedder.h" | 25 #include "mojo/edk/embedder/embedder.h" |
26 #include "mojo/edk/embedder/simple_platform_support.h" | 26 #include "mojo/edk/embedder/simple_platform_support.h" |
27 #include "mojo/public/cpp/application/application_connection.h" | 27 #include "mojo/public/cpp/application/application_connection.h" |
28 #include "mojo/public/cpp/application/application_delegate.h" | 28 #include "mojo/public/cpp/application/application_delegate.h" |
29 #include "mojo/public/cpp/application/application_impl.h" | 29 #include "mojo/public/cpp/application/application_impl.h" |
30 #include "mojo/services/tracing/tracing.mojom.h" | 30 #include "mojo/services/tracing/tracing.mojom.h" |
31 #include "mojo/shell/application_manager/application_loader.h" | 31 #include "mojo/shell/application_manager/application_loader.h" |
32 #include "mojo/shell/application_manager/application_manager.h" | 32 #include "mojo/shell/application_manager/application_manager.h" |
33 #include "mojo/shell/command_line_util.h" | |
34 #include "mojo/shell/filename_util.h" | 33 #include "mojo/shell/filename_util.h" |
35 #include "mojo/shell/in_process_native_runner.h" | 34 #include "mojo/shell/in_process_native_runner.h" |
36 #include "mojo/shell/out_of_process_native_runner.h" | 35 #include "mojo/shell/out_of_process_native_runner.h" |
37 #include "mojo/shell/switches.h" | 36 #include "mojo/shell/switches.h" |
38 #include "url/gurl.h" | 37 #include "url/gurl.h" |
39 | 38 |
40 namespace mojo { | 39 namespace mojo { |
41 namespace shell { | 40 namespace shell { |
42 namespace { | 41 namespace { |
43 | 42 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 GURL("mojo:network_service"), | 77 GURL("mojo:network_service"), |
79 context->ResolveShellFileURL("file:network_service.mojo")); | 78 context->ResolveShellFileURL("file:network_service.mojo")); |
80 | 79 |
81 // Command line URL mapping. | 80 // Command line URL mapping. |
82 std::vector<URLResolver::OriginMapping> origin_mappings = | 81 std::vector<URLResolver::OriginMapping> origin_mappings = |
83 URLResolver::GetOriginMappings(command_line.argv()); | 82 URLResolver::GetOriginMappings(command_line.argv()); |
84 for (const auto& origin_mapping : origin_mappings) | 83 for (const auto& origin_mapping : origin_mappings) |
85 resolver->AddOriginMapping(GURL(origin_mapping.origin), | 84 resolver->AddOriginMapping(GURL(origin_mapping.origin), |
86 GURL(origin_mapping.base_url)); | 85 GURL(origin_mapping.base_url)); |
87 | 86 |
88 if (command_line.HasSwitch(switches::kURLMappings)) { | |
89 const std::string mappings = | |
90 command_line.GetSwitchValueASCII(switches::kURLMappings); | |
91 | |
92 base::StringPairs pairs; | |
93 if (!base::SplitStringIntoKeyValuePairs(mappings, '=', ',', &pairs)) | |
94 return false; | |
95 using StringPair = std::pair<std::string, std::string>; | |
96 for (const StringPair& pair : pairs) { | |
97 const GURL from(pair.first); | |
98 const GURL to = context->ResolveCommandLineURL(pair.second); | |
99 if (!from.is_valid() || !to.is_valid()) | |
100 return false; | |
101 resolver->AddURLMapping(from, to); | |
102 } | |
103 } | |
104 return true; | 87 return true; |
105 } | 88 } |
106 | 89 |
107 void InitContentHandlers(ApplicationManager* manager, | 90 void InitContentHandlers(ApplicationManager* manager, |
108 const base::CommandLine& command_line) { | 91 const base::CommandLine& command_line) { |
109 // Default content handlers. | 92 // Default content handlers. |
110 manager->RegisterContentHandler("application/pdf", GURL("mojo:pdf_viewer")); | 93 manager->RegisterContentHandler("application/pdf", GURL("mojo:pdf_viewer")); |
111 manager->RegisterContentHandler("image/png", GURL("mojo:png_viewer")); | 94 manager->RegisterContentHandler("image/png", GURL("mojo:png_viewer")); |
112 manager->RegisterContentHandler("text/html", GURL("mojo:html_viewer")); | 95 manager->RegisterContentHandler("text/html", GURL("mojo:html_viewer")); |
113 | 96 |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 if (app_urls_.empty() && base::MessageLoop::current()->is_running()) { | 302 if (app_urls_.empty() && base::MessageLoop::current()->is_running()) { |
320 DCHECK_EQ(base::MessageLoop::current()->task_runner(), | 303 DCHECK_EQ(base::MessageLoop::current()->task_runner(), |
321 task_runners_->shell_runner()); | 304 task_runners_->shell_runner()); |
322 base::MessageLoop::current()->Quit(); | 305 base::MessageLoop::current()->Quit(); |
323 } | 306 } |
324 } | 307 } |
325 } | 308 } |
326 | 309 |
327 } // namespace shell | 310 } // namespace shell |
328 } // namespace mojo | 311 } // namespace mojo |
OLD | NEW |