OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/install_static/install_util.h" | 5 #include "chrome/install_static/install_util.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 #include <assert.h> | 8 #include <assert.h> |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <iostream> | 10 #include <iostream> |
(...skipping 889 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
900 // Here it means that both versions are equal. | 900 // Here it means that both versions are equal. |
901 *result = 0; | 901 *result = 0; |
902 return true; | 902 return true; |
903 } | 903 } |
904 | 904 |
905 std::string GetSwitchValueFromCommandLine(const std::string& command_line, | 905 std::string GetSwitchValueFromCommandLine(const std::string& command_line, |
906 const std::string& switch_name) { | 906 const std::string& switch_name) { |
907 assert(!command_line.empty()); | 907 assert(!command_line.empty()); |
908 assert(!switch_name.empty()); | 908 assert(!switch_name.empty()); |
909 | 909 |
910 // We don't handle command lines with quoted strings. For e.g. something like | |
911 // --ignored=" --type=renderer ", which we used for Google Desktop. | |
912 if (command_line.find('"') != std::string::npos) { | |
913 assert(false); | |
914 return std::string(); | |
915 } | |
916 | |
917 std::string command_line_copy = command_line; | 910 std::string command_line_copy = command_line; |
918 // Remove leading and trailing spaces. | 911 // Remove leading and trailing spaces. |
919 TrimT<std::string>(&command_line_copy); | 912 TrimT<std::string>(&command_line_copy); |
920 | 913 |
921 // Find the switch in the command line. If we don't find the switch, return | 914 // Find the switch in the command line. If we don't find the switch, return |
922 // an empty string. | 915 // an empty string. |
923 std::string switch_token = "--"; | 916 std::string switch_token = "--"; |
924 switch_token += switch_name; | 917 switch_token += switch_name; |
925 switch_token += "="; | 918 switch_token += "="; |
926 size_t switch_offset = command_line_copy.find(switch_token); | 919 size_t switch_offset = command_line_copy.find(switch_token); |
(...skipping 18 matching lines...) Expand all Loading... |
945 switch_value_end_offset = command_line_copy.length(); | 938 switch_value_end_offset = command_line_copy.length(); |
946 | 939 |
947 std::string switch_value = command_line_copy.substr( | 940 std::string switch_value = command_line_copy.substr( |
948 switch_value_start_offset, | 941 switch_value_start_offset, |
949 switch_value_end_offset - (switch_offset + switch_token.length())); | 942 switch_value_end_offset - (switch_offset + switch_token.length())); |
950 TrimT<std::string>(&switch_value); | 943 TrimT<std::string>(&switch_value); |
951 return switch_value; | 944 return switch_value; |
952 } | 945 } |
953 | 946 |
954 } // namespace install_static | 947 } // namespace install_static |
OLD | NEW |