| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "base/version.h" | 5 #include "base/version.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/string_number_conversions.h" | 8 #include "base/string_number_conversions.h" |
| 9 #include "base/string_split.h" | 9 #include "base/string_split.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| 11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
| 12 | 12 |
| 13 // static | 13 // static |
| 14 Version* Version::GetVersionFromString(const std::wstring& version_str) { |
| 15 if (!IsStringASCII(version_str)) |
| 16 return NULL; |
| 17 return GetVersionFromString(WideToUTF8(version_str)); |
| 18 } |
| 19 |
| 20 // static |
| 14 Version* Version::GetVersionFromString(const std::string& version_str) { | 21 Version* Version::GetVersionFromString(const std::string& version_str) { |
| 15 Version* vers = new Version(); | 22 Version* vers = new Version(); |
| 16 if (vers->InitFromString(version_str)) { | 23 if (vers->InitFromString(version_str)) { |
| 17 DCHECK(vers->is_valid_); | 24 DCHECK(vers->is_valid_); |
| 18 return vers; | 25 return vers; |
| 19 } | 26 } |
| 20 delete vers; | 27 delete vers; |
| 21 return NULL; | 28 return NULL; |
| 22 } | 29 } |
| 23 | 30 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 return false; | 90 return false; |
| 84 // This throws out things like +3, or 032. | 91 // This throws out things like +3, or 032. |
| 85 if (base::IntToString(num) != *i) | 92 if (base::IntToString(num) != *i) |
| 86 return false; | 93 return false; |
| 87 uint16 component = static_cast<uint16>(num); | 94 uint16 component = static_cast<uint16>(num); |
| 88 components_.push_back(component); | 95 components_.push_back(component); |
| 89 } | 96 } |
| 90 is_valid_ = true; | 97 is_valid_ = true; |
| 91 return true; | 98 return true; |
| 92 } | 99 } |
| OLD | NEW |