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 |
910 std::string command_line_copy = command_line; | 917 std::string command_line_copy = command_line; |
911 // Remove leading and trailing spaces. | 918 // Remove leading and trailing spaces. |
912 TrimT<std::string>(&command_line_copy); | 919 TrimT<std::string>(&command_line_copy); |
913 | 920 |
914 // Find the switch in the command line. If we don't find the switch, return | 921 // Find the switch in the command line. If we don't find the switch, return |
915 // an empty string. | 922 // an empty string. |
916 std::string switch_token = "--"; | 923 std::string switch_token = "--"; |
917 switch_token += switch_name; | 924 switch_token += switch_name; |
918 switch_token += "="; | 925 switch_token += "="; |
919 size_t switch_offset = command_line_copy.find(switch_token); | 926 size_t switch_offset = command_line_copy.find(switch_token); |
(...skipping 18 matching lines...) Expand all Loading... |
938 switch_value_end_offset = command_line_copy.length(); | 945 switch_value_end_offset = command_line_copy.length(); |
939 | 946 |
940 std::string switch_value = command_line_copy.substr( | 947 std::string switch_value = command_line_copy.substr( |
941 switch_value_start_offset, | 948 switch_value_start_offset, |
942 switch_value_end_offset - (switch_offset + switch_token.length())); | 949 switch_value_end_offset - (switch_offset + switch_token.length())); |
943 TrimT<std::string>(&switch_value); | 950 TrimT<std::string>(&switch_value); |
944 return switch_value; | 951 return switch_value; |
945 } | 952 } |
946 | 953 |
947 } // namespace install_static | 954 } // namespace install_static |
OLD | NEW |