Chromium Code Reviews| Index: chrome/install_static/install_util.cc |
| diff --git a/chrome/install_static/install_util.cc b/chrome/install_static/install_util.cc |
| index a58b26efcb71ac7bc64a652b2730149d28371b94..1e4f3c7ecf5ebf24de9ab160416f5cedaaba7a98 100644 |
| --- a/chrome/install_static/install_util.cc |
| +++ b/chrome/install_static/install_util.cc |
| @@ -66,6 +66,8 @@ const char kGpuProcess[] = "gpu-process"; |
| const char kPpapiPluginProcess[] = "ppapi"; |
| const char kRendererProcess[] = "renderer"; |
| const char kUtilityProcess[] = "utility"; |
| +const char kProcessType[] = "type"; |
| +const char kCrashpadHandler[] = "crashpad-handler"; |
| namespace { |
| @@ -900,4 +902,38 @@ bool CompareVersionStrings(const std::string& version1, |
| return true; |
| } |
| +std::string GetSwitchValueFromCommandLine(const std::string& command_line, |
| + const std::string& switch_name) { |
|
scottmg
2016/06/14 15:58:48
I guess this will fail in the same way as Google D
ananta
2016/06/14 19:13:15
Added a check for that with an assert
|
| + assert(!command_line.empty()); |
| + assert(!switch_name.empty()); |
| + |
| + std::string command_line_copy = command_line; |
| + // Remove leading and trailing spaces. |
| + TrimT<std::string>(&command_line_copy); |
| + |
| + // Find the switch in the command line. If we don't find the switch, return |
| + // an empty string. |
| + std::string switch_token = "--"; |
| + switch_token += switch_name; |
| + switch_token += "="; |
| + size_t switch_offset = command_line_copy.find(switch_token); |
| + if (switch_offset == std::string::npos) |
| + return std::string(); |
| + |
| + // The format is "--<switch name>=blah". Look for a space after the |
| + // "--<switch name>=" string. If we don't find a space assume that the switch |
| + // value ends at the end of the command line. |
| + size_t switch_value_end_offset = |
| + command_line_copy.find_first_of(GetWhiteSpacesForType<std::string>(), |
| + switch_offset + switch_token.length()); |
| + if (switch_value_end_offset == std::string::npos) |
| + switch_value_end_offset = command_line_copy.length(); |
| + |
| + std::string switch_value = command_line_copy.substr( |
| + switch_offset + switch_token.length(), |
| + switch_value_end_offset - (switch_offset + switch_token.length())); |
| + TrimT<std::string>(&switch_value); |
| + return switch_value; |
| +} |
| + |
| } // namespace install_static |