File: channel_info.h

package info (click to toggle)
chromium 139.0.7258.127-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 6,122,068 kB
  • sloc: cpp: 35,100,771; ansic: 7,163,530; javascript: 4,103,002; python: 1,436,920; asm: 946,517; xml: 746,709; pascal: 187,653; perl: 88,691; sh: 88,436; objc: 79,953; sql: 51,488; cs: 44,583; fortran: 24,137; makefile: 22,147; tcl: 15,277; php: 13,980; yacc: 8,984; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (112 lines) | stat: -rw-r--r-- 4,813 bytes parent folder | download | duplicates (6)
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
// Copyright 2011 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_COMMON_CHANNEL_INFO_H_
#define CHROME_COMMON_CHANNEL_INFO_H_

#include <string>

#include "base/types/strong_alias.h"
#include "build/branding_buildflags.h"
#include "build/build_config.h"

#if BUILDFLAG(IS_LINUX)
namespace base {
class Environment;
}
#endif  // BUILDFLAG(IS_LINUX)

namespace version_info {
enum class Channel;
}

namespace chrome {

using WithExtendedStable = base::StrongAlias<class WithExtendedStableTag, bool>;

// Returns a version string containing the version number plus an optional
// channel identifier. For regular stable Chrome installs, this will be
// identical to version_info::GetVersionNumber(). For beta, dev, and canary
// installs, the version number is followed by the channel name. Extended stable
// installs appear identical to regular stable unless `with_extended_stable` is
// true.
// Prefer version_info::GetVersionNumber() if only the version number is needed.
std::string GetVersionString(WithExtendedStable with_extended_stable);

// Returns the name of the browser's update channel. For a branded build, this
// modifier is the channel ("canary", "dev", or "beta", but "" for stable).
//
// Ordinarily, extended stable is reported as "". Specify `with_extended_stable`
// to report extended stable as "extended". In general, this should be used for
// diagnostic strings in UX (e.g., in chrome://version). Whether or not it is
// used in strings sent to services (e.g., in the channel field of crash
// reports) is dependent on the specific service. `with_extended_stable` has no
// effect on Chrome OS Ash or Android due to lack of support for extended stable
// on those configurations.
//
// In branded builds, when the channel cannot be determined, "unknown" will be
// returned. In unbranded builds, the modifier is usually an empty string (""),
// although on Linux, it may vary in certain distributions. To simply test the
// channel, use GetChannel().
std::string GetChannelName(WithExtendedStable with_extended_stable);

// Returns the channel for the installation. In branded builds, this will be
// version_info::Channel::{STABLE,BETA,DEV,CANARY}. In unbranded builds, or
// in branded builds when the channel cannot be determined, this will be
// version_info::Channel::UNKNOWN.
version_info::Channel GetChannel();

// Returns true if this browser is on the extended stable channel. GetChannel()
// will always return version_info::Channel::STABLE when this is true. This
// function unconditionally returns false on Chrome OS Ash and Android due to
// lack of support for extended stable on those configurations.
bool IsExtendedStableChannel();

#if BUILDFLAG(IS_MAC)
// Because the channel information on the Mac is baked into the Info.plist file,
// and that file may change during an update, this function must be called
// early in startup to cache the channel info so that the correct channel info
// can be returned later.
void CacheChannelInfo();

// Maps the name of the channel to version_info::Channel, always returning
// Channel::UNKNOWN for unbranded builds. For branded builds defaults to
// Channel::STABLE, if channel is empty, else matches the name and returns
// {STABLE,BETA,DEV,CANARY, UNKNOWN}.
version_info::Channel GetChannelByName(const std::string& channel);

// Returns whether this is a side-by-side capable copy of Chromium. For
// unbranded builds, this is always true. For branded builds, this may not be
// true for old copies of beta and dev channels that share the same user data
// dir as the stable channel.
bool IsSideBySideCapable();

#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
// Sets/clears a KSChannelID value to be used in determining the browser's
// channel. The functions above will behave as if `channel_id` had been
// discovered as the channel identifier when CacheChannelInfo was called.
// Clearing reverts the change.
void SetChannelIdForTesting(const std::string& channel_id);
void ClearChannelIdForTesting();
#endif  // BUILDFLAG(GOOGLE_CHROME_BRANDING)
#endif  // BUILDFLAG(IS_MAC)

#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC)
// Returns a channel-specific suffix to use when constructing the path of the
// default user data directory, allowing multiple channels to run side-by-side.
// In the stable channel and in unbranded builds, this returns the empty string.
std::string GetChannelSuffixForDataDir();
#endif

#if BUILDFLAG(IS_LINUX)
std::string GetChannelSuffixForExtraFlagsEnvVarName();

// Returns the channel-specific filename of the desktop shortcut used to launch
// the browser.
std::string GetDesktopName(base::Environment* env);
#endif  // BUILDFLAG(IS_LINUX)

}  // namespace chrome

#endif  // CHROME_COMMON_CHANNEL_INFO_H_