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

Side by Side Diff: mojo/shell/context.cc

Issue 1070463003: Initialize command line arguments for Mojo apptests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Restoring url-mappings and specifying test apps on the commandline. Created 5 years, 8 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 unified diff | Download patch
OLDNEW
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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 GURL("mojo:network_service"), 77 GURL("mojo:network_service"),
78 context->ResolveShellFileURL("file:network_service.mojo")); 78 context->ResolveShellFileURL("file:network_service.mojo"));
79 79
80 // Command line URL mapping. 80 // Command line URL mapping.
81 std::vector<URLResolver::OriginMapping> origin_mappings = 81 std::vector<URLResolver::OriginMapping> origin_mappings =
82 URLResolver::GetOriginMappings(command_line.argv()); 82 URLResolver::GetOriginMappings(command_line.argv());
83 for (const auto& origin_mapping : origin_mappings) 83 for (const auto& origin_mapping : origin_mappings)
84 resolver->AddOriginMapping(GURL(origin_mapping.origin), 84 resolver->AddOriginMapping(GURL(origin_mapping.origin),
85 GURL(origin_mapping.base_url)); 85 GURL(origin_mapping.base_url));
86 86
87 // TODO(msw): Ensure URL mappings are only used for testing???
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 //printf("MSW mapping: %s -> %s\n", from.possibly_invalid_spec().c_str(), to.possibly_invalid_spec().c_str());
100 if (!from.is_valid() || !to.is_valid())
101 return false;
102
103 resolver->AddURLMapping(from, to);
104 }
105 }
106
87 return true; 107 return true;
88 } 108 }
89 109
90 void InitContentHandlers(ApplicationManager* manager, 110 void InitContentHandlers(ApplicationManager* manager,
91 const base::CommandLine& command_line) { 111 const base::CommandLine& command_line) {
92 // Default content handlers. 112 // Default content handlers.
93 manager->RegisterContentHandler("application/pdf", GURL("mojo:pdf_viewer")); 113 manager->RegisterContentHandler("application/pdf", GURL("mojo:pdf_viewer"));
94 manager->RegisterContentHandler("image/png", GURL("mojo:png_viewer")); 114 manager->RegisterContentHandler("image/png", GURL("mojo:png_viewer"));
95 manager->RegisterContentHandler("text/html", GURL("mojo:html_viewer")); 115 manager->RegisterContentHandler("text/html", GURL("mojo:html_viewer"));
96 116
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 if (app_urls_.empty() && base::MessageLoop::current()->is_running()) { 322 if (app_urls_.empty() && base::MessageLoop::current()->is_running()) {
303 DCHECK_EQ(base::MessageLoop::current()->task_runner(), 323 DCHECK_EQ(base::MessageLoop::current()->task_runner(),
304 task_runners_->shell_runner()); 324 task_runners_->shell_runner());
305 base::MessageLoop::current()->Quit(); 325 base::MessageLoop::current()->Quit();
306 } 326 }
307 } 327 }
308 } 328 }
309 329
310 } // namespace shell 330 } // namespace shell
311 } // namespace mojo 331 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/services/html_viewer/ax_provider_apptest.cc ('k') | mojo/shell/desktop/launcher_process.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698