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/channel_info.h"
7 #include "base/strings/string_util.h"
8 #include "build/build_config.h"
9 #include "components/version_info/version_info.h"
15 // Helper function to return both the channel enum and modifier string.
16 // Implements both together to prevent their behavior from diverging, which has
17 // happened multiple times in the past.
18 version_info::Channel
GetChannelImpl(std::string
* modifier_out
) {
19 version_info::Channel channel
= version_info::Channel::UNKNOWN
;
22 char* env
= getenv("CHROME_VERSION_EXTRA");
26 #if defined(GOOGLE_CHROME_BUILD)
27 // Only ever return "", "unknown", "dev" or "beta" in a branded build.
28 if (modifier
== "unstable") // linux version of "dev"
30 if (modifier
== "stable") {
31 channel
= version_info::Channel::STABLE
;
33 } else if (modifier
== "dev") {
34 channel
= version_info::Channel::DEV
;
35 } else if (modifier
== "beta") {
36 channel
= version_info::Channel::BETA
;
43 modifier_out
->swap(modifier
);
50 std::string
GetChannelString() {
52 GetChannelImpl(&modifier
);
56 version_info::Channel
GetChannel() {
57 return GetChannelImpl(nullptr);