| 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 800 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  811   // Here it means that both versions are equal. |  811   // Here it means that both versions are equal. | 
|  812   *result = 0; |  812   *result = 0; | 
|  813   return true; |  813   return true; | 
|  814 } |  814 } | 
|  815  |  815  | 
|  816 std::string GetSwitchValueFromCommandLine(const std::string& command_line, |  816 std::string GetSwitchValueFromCommandLine(const std::string& command_line, | 
|  817                                           const std::string& switch_name) { |  817                                           const std::string& switch_name) { | 
|  818   assert(!command_line.empty()); |  818   assert(!command_line.empty()); | 
|  819   assert(!switch_name.empty()); |  819   assert(!switch_name.empty()); | 
|  820  |  820  | 
|  821   // We don't handle command lines with quoted strings. For e.g. something like |  | 
|  822   // --ignored=" --type=renderer ", which we used for Google Desktop. |  | 
|  823   if (command_line.find('"') != std::string::npos) { |  | 
|  824     assert(false); |  | 
|  825     return std::string(); |  | 
|  826   } |  | 
|  827  |  | 
|  828   std::string command_line_copy = command_line; |  821   std::string command_line_copy = command_line; | 
|  829   // Remove leading and trailing spaces. |  822   // Remove leading and trailing spaces. | 
|  830   TrimT<std::string>(&command_line_copy); |  823   TrimT<std::string>(&command_line_copy); | 
|  831  |  824  | 
|  832   // Find the switch in the command line. If we don't find the switch, return |  825   // Find the switch in the command line. If we don't find the switch, return | 
|  833   // an empty string. |  826   // an empty string. | 
|  834   std::string switch_token = "--"; |  827   std::string switch_token = "--"; | 
|  835   switch_token += switch_name; |  828   switch_token += switch_name; | 
|  836   switch_token += "="; |  829   switch_token += "="; | 
|  837   size_t switch_offset = command_line_copy.find(switch_token); |  830   size_t switch_offset = command_line_copy.find(switch_token); | 
| (...skipping 18 matching lines...) Expand all  Loading... | 
|  856     switch_value_end_offset = command_line_copy.length(); |  849     switch_value_end_offset = command_line_copy.length(); | 
|  857  |  850  | 
|  858   std::string switch_value = command_line_copy.substr( |  851   std::string switch_value = command_line_copy.substr( | 
|  859       switch_value_start_offset, |  852       switch_value_start_offset, | 
|  860       switch_value_end_offset - (switch_offset + switch_token.length())); |  853       switch_value_end_offset - (switch_offset + switch_token.length())); | 
|  861   TrimT<std::string>(&switch_value); |  854   TrimT<std::string>(&switch_value); | 
|  862   return switch_value; |  855   return switch_value; | 
|  863 } |  856 } | 
|  864  |  857  | 
|  865 }  // namespace install_static |  858 }  // namespace install_static | 
| OLD | NEW |