| 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 | |
| 21 Version* Version::GetVersionFromString(const std::string& version_str) { | 14 Version* Version::GetVersionFromString(const std::string& version_str) { |
| 22 Version* vers = new Version(); | 15 Version* vers = new Version(); |
| 23 if (vers->InitFromString(version_str)) { | 16 if (vers->InitFromString(version_str)) { |
| 24 DCHECK(vers->is_valid_); | 17 DCHECK(vers->is_valid_); |
| 25 return vers; | 18 return vers; |
| 26 } | 19 } |
| 27 delete vers; | 20 delete vers; |
| 28 return NULL; | 21 return NULL; |
| 29 } | 22 } |
| 30 | 23 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 return false; | 83 return false; |
| 91 // This throws out things like +3, or 032. | 84 // This throws out things like +3, or 032. |
| 92 if (base::IntToString(num) != *i) | 85 if (base::IntToString(num) != *i) |
| 93 return false; | 86 return false; |
| 94 uint16 component = static_cast<uint16>(num); | 87 uint16 component = static_cast<uint16>(num); |
| 95 components_.push_back(component); | 88 components_.push_back(component); |
| 96 } | 89 } |
| 97 is_valid_ = true; | 90 is_valid_ = true; |
| 98 return true; | 91 return true; |
| 99 } | 92 } |
| OLD | NEW |