Skip to content

Commit

Permalink
Use BUILDFLAG(GOOGLE_CHROME_BRANDING) more.
Browse files Browse the repository at this point in the history
No behavior change.

TBR=tedchoc

Bug: 961769
Change-Id: Ic8d0cdfdaf5afb65b1ede5c83d15dddbbda8d144
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1724663
Reviewed-by: Nico Weber <thakis@chromium.org>
Reviewed-by: Robert Sesek <rsesek@chromium.org>
Commit-Queue: Nico Weber <thakis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#681941}
  • Loading branch information
nico authored and Commit Bot committed Jul 29, 2019
1 parent 13a2718 commit cda4ff5
Show file tree
Hide file tree
Showing 23 changed files with 58 additions and 24 deletions.
3 changes: 2 additions & 1 deletion apps/load_and_launch_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "base/stl_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/test_timeouts.h"
#include "build/branding_buildflags.h"
#include "build/build_config.h"
#include "chrome/browser/apps/platform_apps/app_browsertest_util.h"
#include "chrome/browser/extensions/extension_browsertest.h"
Expand Down Expand Up @@ -190,7 +191,7 @@ IN_PROC_BROWSER_TEST_F(LoadAndLaunchExtensionBrowserTest,
const std::vector<base::string16>* errors =
extensions::LoadErrorReporter::GetInstance()->GetErrors();

#if defined(GOOGLE_CHROME_BUILD)
#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
// The error is skipped on official builds.
EXPECT_TRUE(errors->empty());
#else
Expand Down
2 changes: 1 addition & 1 deletion docs/google_chrome_branded_builds.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ license.

Therefore, if you want to add a trademarked resource, check it into the
internal repository, and pick a resource based on the branding
(`is_chrome_branded` in GN, `#if defined(GOOGLE_CHROME_BUILD)` in cpp). If
(`is_chrome_branded` in GN, `#if BUILDFLAG(GOOGLE_CHROME_BRANDING)` in cpp). If
possible, check an open source version into Chromium, so the feature
continues to work as expected in the open source build.

Expand Down
2 changes: 2 additions & 0 deletions google_apis/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ template("google_apis_tmpl") {
deps = [
"//base",
"//base/third_party/dynamic_annotations",
"//build:branding_buildflags",
"//crypto",
"//mojo/public/cpp/bindings:struct_traits",
"//services/network/public/cpp",
Expand Down Expand Up @@ -231,6 +232,7 @@ test("google_apis_unittests") {
":test_support",
"//base",
"//base/test:test_support",
"//build:branding_buildflags",
"//testing/gmock",
"//testing/gtest",
]
Expand Down
9 changes: 5 additions & 4 deletions google_apis/google_api_keys.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@
#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/strings/stringize_macros.h"
#include "build/branding_buildflags.h"
#include "google_apis/gaia/gaia_switches.h"

#if defined(OS_MACOSX)
#include "google_apis/google_api_keys_mac.h"
#endif

#if defined(GOOGLE_CHROME_BUILD) || defined(USE_OFFICIAL_GOOGLE_API_KEYS)
#if BUILDFLAG(GOOGLE_CHROME_BRANDING) || defined(USE_OFFICIAL_GOOGLE_API_KEYS)
#include "google_apis/internal/google_chrome_api_keys.h"
#include "google_apis/internal/metrics_signing_key.h"
#endif
Expand Down Expand Up @@ -252,7 +253,7 @@ class APIKeyCache {
}
#endif

#if !defined(GOOGLE_CHROME_BUILD)
#if !BUILDFLAG(GOOGLE_CHROME_BRANDING)
// Don't allow using the environment to override API keys for official
// Google Chrome builds. There have been reports of mangled environments
// affecting users (crbug.com/710575).
Expand All @@ -270,7 +271,7 @@ class APIKeyCache {
}

if (key_value == DUMMY_API_TOKEN) {
#if defined(GOOGLE_CHROME_BUILD)
#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
// No key should be unset in an official build except the
// GOOGLE_DEFAULT_* keys. The default keys don't trigger this
// check as their "unset" value is not DUMMY_API_TOKEN.
Expand Down Expand Up @@ -362,7 +363,7 @@ std::string GetSpdyProxyAuthValue() {
}

bool IsGoogleChromeAPIKeyUsed() {
#if defined(GOOGLE_CHROME_BUILD) || defined(USE_OFFICIAL_GOOGLE_API_KEYS)
#if BUILDFLAG(GOOGLE_CHROME_BRANDING) || defined(USE_OFFICIAL_GOOGLE_API_KEYS)
return true;
#else
return false;
Expand Down
6 changes: 5 additions & 1 deletion google_apis/google_api_keys_mac_unittest.mm
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#include "base/mac/bundle_locations.h"
#include "base/macros.h"
#include "build/branding_buildflags.h"
#include "build/build_config.h"
#include "google_apis/gaia/gaia_switches.h"
#include "testing/gtest/include/gtest/gtest.h"
Expand All @@ -37,7 +38,10 @@

// After this test, for the remainder of this compilation unit, we
// need official keys to not be used.
#undef GOOGLE_CHROME_BUILD
#undef BUILDFLAG_INTERNAL_CHROMIUM_BRANDING
#undef BUILDFLAG_INTERNAL_GOOGLE_CHROME_BRANDING
#define BUILDFLAG_INTERNAL_CHROMIUM_BRANDING() (1)
#define BUILDFLAG_INTERNAL_GOOGLE_CHROME_BRANDING() (0)
#undef USE_OFFICIAL_GOOGLE_API_KEYS

// Override some keys using both preprocessor defines and Info.plist entries.
Expand Down
15 changes: 10 additions & 5 deletions google_apis/google_api_keys_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "google_apis/google_api_keys_unittest.h"

#include "base/stl_util.h"
#include "build/branding_buildflags.h"
#include "build/build_config.h"
#include "google_apis/gaia/gaia_switches.h"

Expand Down Expand Up @@ -88,7 +89,7 @@ void GoogleAPIKeysTest::TearDown() {
// This is the default baked-in value for OAuth IDs and secrets.
static const char kDummyToken[] = "dummytoken";

#if defined(GOOGLE_CHROME_BUILD) || defined(USE_OFFICIAL_GOOGLE_API_KEYS)
#if BUILDFLAG(GOOGLE_CHROME_BRANDING) || defined(USE_OFFICIAL_GOOGLE_API_KEYS)
// Test official build behavior, since we are in a checkout where this
// is possible.
namespace official_build {
Expand Down Expand Up @@ -186,11 +187,15 @@ TEST_F(GoogleAPIKeysTest, OfficialKeys) {
EXPECT_NE(DUMMY_API_TOKEN, secret_remoting_host);
EXPECT_NE(kDummyToken, secret_remoting_host);
}
#endif // defined(GOOGLE_CHROME_BUILD) || defined(USE_OFFICIAL_GOOGLE_API_KEYS)
#endif // BUILDFLAG(GOOGLE_CHROME_BRANDING) ||
// defined(USE_OFFICIAL_GOOGLE_API_KEYS)

// After this test, for the remainder of this compilation unit, we
// need official keys to not be used.
#undef GOOGLE_CHROME_BUILD
#undef BUILDFLAG_INTERNAL_CHROMIUM_BRANDING
#undef BUILDFLAG_INTERNAL_GOOGLE_CHROME_BRANDING
#define BUILDFLAG_INTERNAL_CHROMIUM_BRANDING() (1)
#define BUILDFLAG_INTERNAL_GOOGLE_CHROME_BRANDING() (0)
#undef USE_OFFICIAL_GOOGLE_API_KEYS

// Test the set of keys temporarily baked into Chromium by default.
Expand Down Expand Up @@ -398,7 +403,7 @@ TEST_F(GoogleAPIKeysTest, OverrideAllKeys) {
EXPECT_EQ("SECRET_REMOTING_HOST", secret_remoting_host);
}

#if !defined(GOOGLE_CHROME_BUILD)
#if !BUILDFLAG(GOOGLE_CHROME_BRANDING)

// Override all keys using both preprocessor defines and environment
// variables. The environment variables should win.
Expand Down Expand Up @@ -488,7 +493,7 @@ TEST_F(GoogleAPIKeysTest, OverrideAllKeysUsingEnvironment) {
EXPECT_EQ("env-SECRET_REMOTING_HOST", secret_remoting_host);
}

#endif // !defined(GOOGLE_CHROME_BUILD)
#endif // !BUILDFLAG(GOOGLE_CHROME_BRANDING)

#if defined(OS_IOS)
// Override all keys using both preprocessor defines and setters.
Expand Down
1 change: 1 addition & 0 deletions gpu/config/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ jumbo_source_set("config_sources") {
deps = [
":process_json",
"//base",
"//build:branding_buildflags",
"//gpu/ipc/common:gpu_preferences_interface",
"//media:media_buildflags",
"//third_party/re2",
Expand Down
3 changes: 2 additions & 1 deletion gpu/config/gpu_info_collector_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include "base/threading/thread.h"
#include "base/trace_event/trace_event.h"
#include "base/win/scoped_com_initializer.h"
#include "build/branding_buildflags.h"
#include "gpu/config/nvml_info.h"
#include "third_party/vulkan/include/vulkan/vulkan.h"

Expand Down Expand Up @@ -158,7 +159,7 @@ std::string GetDeviceFileTimeProperty(DEVINST dev_inst,

} // namespace

#if defined(GOOGLE_CHROME_BUILD) && defined(OFFICIAL_BUILD)
#if BUILDFLAG(GOOGLE_CHROME_BRANDING) && defined(OFFICIAL_BUILD)
// This function has a real implementation for official builds that can
// be found in src/third_party/amd.
bool GetAMDSwitchableInfo(bool* is_switchable,
Expand Down
3 changes: 3 additions & 0 deletions headless/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -813,6 +813,7 @@ if (is_win) {
]
deps = [
":headless_non_renderer",
"//build:branding_buildflags",
"//components/services/pdf_compositor/public/cpp:manifest",
"//components/services/pdf_compositor/public/mojom",
"//content:sandbox_helper_win",
Expand Down Expand Up @@ -849,6 +850,7 @@ if (is_win) {
]
deps = [
":headless_renderer",
"//build:branding_buildflags",
"//content/public/child:child",
"//net",
"//ui/base",
Expand Down Expand Up @@ -895,6 +897,7 @@ jumbo_static_library("headless_shell_lib") {

deps = [
":headless_renderer",
"//build:branding_buildflags",
"//components/os_crypt",
"//components/security_state/content",
"//components/services/pdf_compositor/public/cpp:manifest",
Expand Down
3 changes: 2 additions & 1 deletion headless/app/headless_shell.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "base/strings/utf_string_conversions.h"
#include "base/task/post_task.h"
#include "base/task_runner_util.h"
#include "build/branding_buildflags.h"
#include "build/build_config.h"
#include "cc/base/switches.h"
#include "components/os_crypt/os_crypt_switches.h"
Expand Down Expand Up @@ -672,7 +673,7 @@ int HeadlessShellMain(int argc, const char** argv) {
return EXIT_FAILURE;

// Crash reporting in headless mode is enabled by default in official builds.
#if defined(GOOGLE_CHROME_BUILD)
#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
builder.SetCrashReporterEnabled(true);
base::FilePath dumps_path;
base::PathService::Get(base::DIR_TEMP, &dumps_path);
Expand Down
2 changes: 2 additions & 0 deletions media/audio/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,8 @@ source_set("audio") {
"pulse/pulse_util.h",
]

deps += [ "//build:branding_buildflags" ]

if (link_pulseaudio) {
configs += [ ":libpulse" ]
} else {
Expand Down
3 changes: 2 additions & 1 deletion media/audio/pulse/pulse_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "base/logging.h"
#include "base/macros.h"
#include "base/memory/ptr_util.h"
#include "build/branding_buildflags.h"
#include "media/audio/audio_device_description.h"
#include "media/base/audio_timestamp_helper.h"

Expand All @@ -30,7 +31,7 @@ namespace pulse {

namespace {

#if defined(GOOGLE_CHROME_BUILD)
#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
static const char kBrowserDisplayName[] = "google-chrome";
#else
static const char kBrowserDisplayName[] = "chromium-browser";
Expand Down
1 change: 1 addition & 0 deletions net/http/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ source_set("transport_security_state_generated_files") {
]

deps = [
"//build:branding_buildflags",
"//net:net_deps",
"//net:net_public_deps",
"//net/dns",
Expand Down
3 changes: 2 additions & 1 deletion net/http/transport_security_state.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "base/time/time.h"
#include "base/time/time_to_iso8601.h"
#include "base/values.h"
#include "build/branding_buildflags.h"
#include "build/build_config.h"
#include "crypto/sha2.h"
#include "net/base/hash_value.h"
Expand Down Expand Up @@ -411,7 +412,7 @@ TransportSecurityState::TransportSecurityState()
sent_expect_ct_reports_cache_(kMaxReportCacheEntries) {
// Static pinning is only enabled for official builds to make sure that
// others don't end up with pins that cannot be easily updated.
#if !defined(GOOGLE_CHROME_BUILD) || defined(OS_ANDROID) || defined(OS_IOS)
#if !BUILDFLAG(GOOGLE_CHROME_BRANDING) || defined(OS_ANDROID) || defined(OS_IOS)
enable_static_pins_ = false;
enable_static_expect_ct_ = false;
#endif
Expand Down
1 change: 1 addition & 0 deletions remoting/host/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,7 @@ source_set("unit_tests") {
deps = [
":common",
":test_support",
"//build:branding_buildflags",
"//remoting/host/file_transfer:unit_tests",
"//remoting/host/it2me:common",
"//remoting/host/native_messaging",
Expand Down
2 changes: 1 addition & 1 deletion remoting/host/host_attributes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ inline constexpr bool IsDebug() {
}

inline constexpr bool IsChromeBranded() {
#if defined(GOOGLE_CHROME_BUILD)
#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
return true;
#elif BUILDFLAG(CHROMIUM_BRANDING)
return false;
Expand Down
7 changes: 4 additions & 3 deletions remoting/host/resources_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "remoting/host/resources.h"

#include "build/branding_buildflags.h"
#include "build/build_config.h"
#include "remoting/base/string_resources.h"
#include "testing/gtest/include/gtest/gtest.h"
Expand All @@ -25,11 +26,11 @@ class ResourcesTest : public testing::Test {
// TODO(alexeypa): Reenable the test once http://crbug.com/269143 (ChromeOS) and
// http://crbug.com/268043 (MacOS) are fixed.
TEST_F(ResourcesTest, DISABLED_ProductName) {
#if defined(GOOGLE_CHROME_BUILD)
#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
std::string expected_product_name = "Chrome Remote Desktop";
#else // defined(GOOGLE_CHROME_BUILD)
#else // BUILDFLAG(GOOGLE_CHROME_BRANDING)
std::string expected_product_name = "Chromoting";
#endif // !defined(GOOGLE_CHROME_BUILD)
#endif // BUILDFLAGdefined(GOOGLE_CRANDING)

// Chrome-style i18n is not used on Windows or Android.
#if defined(OS_WIN) || defined(OS_ANDROID)
Expand Down
3 changes: 2 additions & 1 deletion remoting/host/token_validator_factory_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "base/strings/string_util.h"
#include "base/strings/stringize_macros.h"
#include "base/values.h"
#include "build/branding_buildflags.h"
#include "crypto/random.h"
#include "net/base/elements_upload_data_stream.h"
#include "net/base/escape.h"
Expand Down Expand Up @@ -91,7 +92,7 @@ void TokenValidatorImpl::StartValidateRequest(const std::string& token) {
third_party_auth_config_.token_validation_url, net::DEFAULT_PRIORITY,
this, MISSING_TRAFFIC_ANNOTATION);

#if defined(GOOGLE_CHROME_BUILD)
#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
std::string app_name = "Chrome Remote Desktop";
#else
std::string app_name = "Chromoting";
Expand Down
1 change: 1 addition & 0 deletions ui/base/mpris/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ component("mpris") {

deps = [
"//base",
"//build:branding_buildflags",
"//components/dbus/thread_linux",
"//dbus",
]
Expand Down
3 changes: 2 additions & 1 deletion ui/base/mpris/mpris_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@

#include "ui/base/mpris/mpris_service.h"

#include "build/branding_buildflags.h"
#include "ui/base/mpris/mpris_service_impl.h"

namespace mpris {

#if defined(GOOGLE_CHROME_BUILD)
#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
const char kMprisAPIServiceNamePrefix[] =
"org.mpris.MediaPlayer2.chrome.instance";
#else
Expand Down
3 changes: 2 additions & 1 deletion ui/base/mpris/mpris_service_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "base/process/process.h"
#include "base/unguessable_token.h"
#include "base/values.h"
#include "build/branding_buildflags.h"
#include "components/dbus/thread_linux/dbus_thread_linux.h"
#include "dbus/bus.h"
#include "dbus/exported_object.h"
Expand Down Expand Up @@ -123,7 +124,7 @@ void MprisServiceImpl::InitializeProperties() {
media_player2_properties_["CanRaise"] = base::Value(false);
media_player2_properties_["HasTrackList"] = base::Value(false);

#if defined(GOOGLE_CHROME_BUILD)
#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
media_player2_properties_["Identity"] = base::Value("Chrome");
#else
media_player2_properties_["Identity"] = base::Value("Chromium");
Expand Down
3 changes: 3 additions & 0 deletions ui/base/now_playing/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

assert(is_mac, "This code is macOS-only.")

config("media_player_weak_link") {
ldflags = [
"-weak_framework",
Expand Down Expand Up @@ -33,6 +35,7 @@ component("now_playing") {

deps = [
"//base",
"//build:branding_buildflags",
]

libs = [ "Foundation.framework" ]
Expand Down
Loading

0 comments on commit cda4ff5

Please sign in to comment.