forked from Pissandshittium/pissandshittium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchannel_info_fuchsia.cc
83 lines (68 loc) · 2.38 KB
/
channel_info_fuchsia.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// Copyright 2021 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// TODO(crbug.com/1231926): Implement support for update channels.
#include "chrome/common/channel_info.h"
#include "base/check.h"
#include "base/notreached.h"
#include "build/branding_buildflags.h"
#include "components/version_info/version_info.h"
namespace chrome {
namespace {
struct ChannelState {
version_info::Channel channel;
bool is_extended_stable;
};
// Determine the state of the browser based on branding and channel.
// TODO(crbug.com/1253820): Update implementation when channel are implemented.
ChannelState DetermineChannelState() {
#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
NOTIMPLEMENTED_LOG_ONCE();
return {version_info::Channel::STABLE, /*is_extended_stable=*/false};
#else // BUILDFLAG(GOOGLE_CHROME_BRANDING)
return {version_info::Channel::UNKNOWN, /*is_extended_stable=*/false};
#endif // BUILDFLAG(GOOGLE_CHROME_BRANDING)
}
// Returns the channel state for the browser.
ChannelState& GetChannelImpl() {
static ChannelState channel = DetermineChannelState();
return channel;
}
} // namespace
std::string GetChannelName(WithExtendedStable with_extended_stable) {
#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
const auto& channel_state = GetChannelImpl();
switch (channel_state.channel) {
case version_info::Channel::UNKNOWN:
return "unknown";
case version_info::Channel::CANARY:
return "canary";
case version_info::Channel::DEV:
return "dev";
case version_info::Channel::BETA:
return "beta";
case version_info::Channel::STABLE:
if (with_extended_stable && channel_state.is_extended_stable)
return "extended";
return std::string();
}
#else // BUILDFLAG(GOOGLE_CHROME_BRANDING)
return std::string();
#endif // BUILDFLAG(GOOGLE_CHROME_BRANDING)
}
version_info::Channel GetChannel() {
return GetChannelImpl().channel;
}
bool IsExtendedStableChannel() {
return GetChannelImpl().is_extended_stable;
}
#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
void SetChannelForTesting(version_info::Channel channel,
bool is_extended_stable) {
GetChannelImpl() = {channel, is_extended_stable};
}
void ClearChannelForTesting() {
GetChannelImpl() = DetermineChannelState();
}
#endif // BUILDFLAG(GOOGLE_CHROME_BRANDING)
} // namespace chrome