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..0b19cf6d63bb861d3df3d1bd1d36e333b3dba78e 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,44 @@ bool CompareVersionStrings(const std::string& version1, |
return true; |
} |
+std::string GetSwitchValueFromCommandLine(const std::string& command_line, |
+ const std::string& switch_name) { |
+ 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 --type |
+ // switch, return an empty string. |
+ std::string switch_token = "--"; |
+ switch_token += switch_name; |
grt (UTC plus 2)
2016/06/14 02:20:49
wdyt of searching for "--switch=" here? if switch_
ananta
2016/06/14 03:24:05
Yeah. That makes it much simpler. Thanks. done
|
+ 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 the = operator and then a |
+ // trailing space. If we don't find a space assume that the switch value |
+ // ends at the end of the command line. |
+ size_t equal_to_operator_offset = |
+ command_line_copy.find("=", switch_offset + switch_token.length()); |
+ if (equal_to_operator_offset != std::string::npos) { |
+ size_t switch_value_end_offset = command_line_copy.find_first_of( |
+ GetWhiteSpacesForType<std::string>(), equal_to_operator_offset + 1); |
+ if (switch_value_end_offset == std::string::npos) |
+ switch_value_end_offset = command_line_copy.length() - 1; |
+ |
+ std::string switch_value = command_line_copy.substr( |
+ equal_to_operator_offset + 1, |
+ switch_value_end_offset - equal_to_operator_offset); |
+ TrimT<std::string>(&switch_value); |
+ return switch_value; |
+ } |
+ // We should never get here. This means that the command line is all wrong |
+ // or our parsing failed. |
+ assert(false); |
+ return std::string(); |
+} |
+ |
} // namespace install_static |