| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/common/chrome_version_info.h" | 5 #include "chrome/common/chrome_version_info.h" |
| 6 | 6 |
| 7 #include "base/strings/string_util.h" | 7 #include "base/strings/string_util.h" |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 | 9 |
| 10 namespace chrome { | 10 namespace chrome { |
| 11 | 11 |
| 12 namespace { | 12 namespace { |
| 13 | 13 |
| 14 // Helper function to return both the channel enum and modifier string. | 14 // Helper function to return both the channel enum and modifier string. |
| 15 // Implements both together to prevent their behavior from diverging, which has | 15 // Implements both together to prevent their behavior from diverging, which has |
| 16 // happened multiple times in the past. | 16 // happened multiple times in the past. |
| 17 VersionInfo::Channel GetChannelImpl(std::string* modifier_out) { | 17 version_info::Channel GetChannelImpl(std::string* modifier_out) { |
| 18 VersionInfo::Channel channel = VersionInfo::CHANNEL_UNKNOWN; | 18 version_info::Channel channel = version_info::Channel::UNKNOWN; |
| 19 std::string modifier; | 19 std::string modifier; |
| 20 | 20 |
| 21 char* env = getenv("CHROME_VERSION_EXTRA"); | 21 char* env = getenv("CHROME_VERSION_EXTRA"); |
| 22 if (env) | 22 if (env) |
| 23 modifier = env; | 23 modifier = env; |
| 24 | 24 |
| 25 #if defined(GOOGLE_CHROME_BUILD) | 25 #if defined(GOOGLE_CHROME_BUILD) |
| 26 // Only ever return "", "unknown", "dev" or "beta" in a branded build. | 26 // Only ever return "", "unknown", "dev" or "beta" in a branded build. |
| 27 if (modifier == "unstable") // linux version of "dev" | 27 if (modifier == "unstable") // linux version of "dev" |
| 28 modifier = "dev"; | 28 modifier = "dev"; |
| 29 if (modifier == "stable") { | 29 if (modifier == "stable") { |
| 30 channel = VersionInfo::CHANNEL_STABLE; | 30 channel = version_info::Channel::STABLE; |
| 31 modifier = ""; | 31 modifier = ""; |
| 32 } else if (modifier == "dev") { | 32 } else if (modifier == "dev") { |
| 33 channel = VersionInfo::CHANNEL_DEV; | 33 channel = version_info::Channel::DEV; |
| 34 } else if (modifier == "beta") { | 34 } else if (modifier == "beta") { |
| 35 channel = VersionInfo::CHANNEL_BETA; | 35 channel = version_info::Channel::BETA; |
| 36 } else { | 36 } else { |
| 37 modifier = "unknown"; | 37 modifier = "unknown"; |
| 38 } | 38 } |
| 39 #endif | 39 #endif |
| 40 | 40 |
| 41 if (modifier_out) | 41 if (modifier_out) |
| 42 modifier_out->swap(modifier); | 42 modifier_out->swap(modifier); |
| 43 | 43 |
| 44 return channel; | 44 return channel; |
| 45 } | 45 } |
| 46 | 46 |
| 47 } // namespace | 47 } // namespace |
| 48 | 48 |
| 49 // static | 49 // static |
| 50 std::string VersionInfo::GetVersionStringModifier() { | 50 std::string VersionInfo::GetVersionStringModifier() { |
| 51 std::string modifier; | 51 std::string modifier; |
| 52 GetChannelImpl(&modifier); | 52 GetChannelImpl(&modifier); |
| 53 return modifier; | 53 return modifier; |
| 54 } | 54 } |
| 55 | 55 |
| 56 // static | 56 // static |
| 57 VersionInfo::Channel VersionInfo::GetChannel() { | 57 version_info::Channel VersionInfo::GetChannel() { |
| 58 return GetChannelImpl(NULL); | 58 return GetChannelImpl(NULL); |
| 59 } | 59 } |
| 60 | 60 |
| 61 } // namespace chrome | 61 } // namespace chrome |
| OLD | NEW |