Add ICU message format support
[chromium-blink-merge.git] / chrome / common / channel_info_posix.cc
blobff55d20af0d4d2cd1efd00e1e29c3e912adb38a4
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"
11 namespace chrome {
13 namespace {
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;
20 std::string modifier;
22 char* env = getenv("CHROME_VERSION_EXTRA");
23 if (env)
24 modifier = env;
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"
29 modifier = "dev";
30 if (modifier == "stable") {
31 channel = version_info::Channel::STABLE;
32 modifier = "";
33 } else if (modifier == "dev") {
34 channel = version_info::Channel::DEV;
35 } else if (modifier == "beta") {
36 channel = version_info::Channel::BETA;
37 } else {
38 modifier = "unknown";
40 #endif
42 if (modifier_out)
43 modifier_out->swap(modifier);
45 return channel;
48 } // namespace
50 std::string GetChannelString() {
51 std::string modifier;
52 GetChannelImpl(&modifier);
53 return modifier;
56 version_info::Channel GetChannel() {
57 return GetChannelImpl(nullptr);
60 } // namespace chrome