| 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" |
| 33 #include "mojo/shell/filename_util.h" | 34 #include "mojo/shell/filename_util.h" |
| 34 #include "mojo/shell/in_process_native_runner.h" | 35 #include "mojo/shell/in_process_native_runner.h" |
| 35 #include "mojo/shell/out_of_process_native_runner.h" | 36 #include "mojo/shell/out_of_process_native_runner.h" |
| 36 #include "mojo/shell/switches.h" | 37 #include "mojo/shell/switches.h" |
| 37 #include "url/gurl.h" | 38 #include "url/gurl.h" |
| 38 | 39 |
| 39 namespace mojo { | 40 namespace mojo { |
| 40 namespace shell { | 41 namespace shell { |
| 41 namespace { | 42 namespace { |
| 42 | 43 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 GURL("mojo:network_service"), | 78 GURL("mojo:network_service"), |
| 78 context->ResolveShellFileURL("file:network_service.mojo")); | 79 context->ResolveShellFileURL("file:network_service.mojo")); |
| 79 | 80 |
| 80 // Command line URL mapping. | 81 // Command line URL mapping. |
| 81 std::vector<URLResolver::OriginMapping> origin_mappings = | 82 std::vector<URLResolver::OriginMapping> origin_mappings = |
| 82 URLResolver::GetOriginMappings(command_line.argv()); | 83 URLResolver::GetOriginMappings(command_line.argv()); |
| 83 for (const auto& origin_mapping : origin_mappings) | 84 for (const auto& origin_mapping : origin_mappings) |
| 84 resolver->AddOriginMapping(GURL(origin_mapping.origin), | 85 resolver->AddOriginMapping(GURL(origin_mapping.origin), |
| 85 GURL(origin_mapping.base_url)); | 86 GURL(origin_mapping.base_url)); |
| 86 | 87 |
| 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 } |
| 87 return true; | 104 return true; |
| 88 } | 105 } |
| 89 | 106 |
| 90 void InitContentHandlers(ApplicationManager* manager, | 107 void InitContentHandlers(ApplicationManager* manager, |
| 91 const base::CommandLine& command_line) { | 108 const base::CommandLine& command_line) { |
| 92 // Default content handlers. | 109 // Default content handlers. |
| 93 manager->RegisterContentHandler("application/pdf", GURL("mojo:pdf_viewer")); | 110 manager->RegisterContentHandler("application/pdf", GURL("mojo:pdf_viewer")); |
| 94 manager->RegisterContentHandler("image/png", GURL("mojo:png_viewer")); | 111 manager->RegisterContentHandler("image/png", GURL("mojo:png_viewer")); |
| 95 manager->RegisterContentHandler("text/html", GURL("mojo:html_viewer")); | 112 manager->RegisterContentHandler("text/html", GURL("mojo:html_viewer")); |
| 96 | 113 |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 if (app_urls_.empty() && base::MessageLoop::current()->is_running()) { | 319 if (app_urls_.empty() && base::MessageLoop::current()->is_running()) { |
| 303 DCHECK_EQ(base::MessageLoop::current()->task_runner(), | 320 DCHECK_EQ(base::MessageLoop::current()->task_runner(), |
| 304 task_runners_->shell_runner()); | 321 task_runners_->shell_runner()); |
| 305 base::MessageLoop::current()->Quit(); | 322 base::MessageLoop::current()->Quit(); |
| 306 } | 323 } |
| 307 } | 324 } |
| 308 } | 325 } |
| 309 | 326 |
| 310 } // namespace shell | 327 } // namespace shell |
| 311 } // namespace mojo | 328 } // namespace mojo |
| OLD | NEW |