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
3 // found in the LICENSE file.
5 #include "chrome/common/chrome_version_info.h"
7 #include "base/strings/string_util.h"
8 #include "build/build_config.h"
14 // Helper function to return both the channel enum and modifier string.
15 // Implements both together to prevent their behavior from diverging, which has
16 // happened multiple times in the past.
17 VersionInfo::Channel
GetChannelImpl(std::string
* modifier_out
) {
18 VersionInfo::Channel channel
= VersionInfo::CHANNEL_UNKNOWN
;
21 char* env
= getenv("CHROME_VERSION_EXTRA");
25 #if defined(GOOGLE_CHROME_BUILD)
26 // Only ever return "", "unknown", "dev" or "beta" in a branded build.
27 if (modifier
== "unstable") // linux version of "dev"
29 if (modifier
== "stable") {
30 channel
= VersionInfo::CHANNEL_STABLE
;
32 } else if (modifier
== "dev") {
33 channel
= VersionInfo::CHANNEL_DEV
;
34 } else if (modifier
== "beta") {
35 channel
= VersionInfo::CHANNEL_BETA
;
42 modifier_out
->swap(modifier
);
50 std::string
VersionInfo::GetVersionStringModifier() {
52 GetChannelImpl(&modifier
);
57 VersionInfo::Channel
VersionInfo::GetChannel() {
58 return GetChannelImpl(NULL
);