Index: mojo/shell/context.cc |
diff --git a/mojo/shell/context.cc b/mojo/shell/context.cc |
index fc56476f819ea3392cb56a58ddb5b08aa9d4b71b..032d392ea154cee84708737bda5bd13b2a5431ce 100644 |
--- a/mojo/shell/context.cc |
+++ b/mojo/shell/context.cc |
@@ -84,6 +84,26 @@ bool ConfigureURLMappings(const base::CommandLine& command_line, |
resolver->AddOriginMapping(GURL(origin_mapping.origin), |
GURL(origin_mapping.base_url)); |
+ // TODO(msw): Ensure URL mappings are only used for testing??? |
+ if (command_line.HasSwitch(switches::kURLMappings)) { |
+ const std::string mappings = |
+ command_line.GetSwitchValueASCII(switches::kURLMappings); |
+ |
+ base::StringPairs pairs; |
+ if (!base::SplitStringIntoKeyValuePairs(mappings, '=', ',', &pairs)) |
+ return false; |
+ using StringPair = std::pair<std::string, std::string>; |
+ for (const StringPair& pair : pairs) { |
+ const GURL from(pair.first); |
+ const GURL to = context->ResolveCommandLineURL(pair.second); |
+ //printf("MSW mapping: %s -> %s\n", from.possibly_invalid_spec().c_str(), to.possibly_invalid_spec().c_str()); |
+ if (!from.is_valid() || !to.is_valid()) |
+ return false; |
+ |
+ resolver->AddURLMapping(from, to); |
+ } |
+ } |
+ |
return true; |
} |