Chromium Code Reviews| Index: mojo/shell/desktop/mojo_main.cc |
| diff --git a/mojo/shell/desktop/mojo_main.cc b/mojo/shell/desktop/mojo_main.cc |
| index 02be823e8ef4475412f11d99d1cf8c7a6c6e1591..9133d862fffebf77ef7aae61d8f8a328492571a3 100644 |
| --- a/mojo/shell/desktop/mojo_main.cc |
| +++ b/mojo/shell/desktop/mojo_main.cc |
| @@ -105,6 +105,22 @@ bool ConfigureURLMappings(const std::string& mappings, |
| return true; |
| } |
| +const std::string kArgsForSwitches[] = { |
| + "-" + std::string(switches::kArgsFor), |
| + "--" + std::string(switches::kArgsFor), |
| +}; |
|
abarth-chromium
2014/10/28 16:26:11
This looks like a static initializer. Presumably
hansmuller
2014/10/28 16:42:04
The kArgsForSwitches constant is stack allocated n
|
| + |
| +bool isArgsFor(const std::string& arg, std::string* value) { |
| + for (size_t i = 0; i < arraysize(kArgsForSwitches); i++) { |
| + std::string argsfor_switch(kArgsForSwitches[i]); |
| + if (arg.compare(0, argsfor_switch.size(), argsfor_switch) == 0) { |
| + *value = arg.substr(argsfor_switch.size() + 1, std::string::npos); |
| + return true; |
| + } |
| + } |
| + return false; |
| +} |
| + |
| } // namespace |
| int main(int argc, char** argv) { |
| @@ -157,9 +173,13 @@ int main(int argc, char** argv) { |
| return 0; |
| } |
| - for (const auto& kv : command_line.GetSwitches()) { |
| - if (kv.first == switches::kArgsFor) |
| - GetAppURLAndSetArgs(kv.second, &shell_context); |
| + // The mojo_shell --args-for command-line switch is handled specially |
| + // because it can appear more than once. The base::CommandLine class |
| + // collapses multiple occurrences of the same switch. |
| + for(int i = 1; i < argc; i++) { |
| + std::string argsForValue; |
| + if (isArgsFor(argv[i], &argsForValue)) |
| + GetAppURLAndSetArgs(argsForValue, &shell_context); |
| } |
| message_loop.PostTask(FROM_HERE, base::Bind(RunApps, &shell_context)); |