diff --git a/apps/load_and_launch_browsertest.cc b/apps/load_and_launch_browsertest.cc index af9c7d87501016..bd3511517c1754 100644 --- a/apps/load_and_launch_browsertest.cc +++ b/apps/load_and_launch_browsertest.cc @@ -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" @@ -190,7 +191,7 @@ IN_PROC_BROWSER_TEST_F(LoadAndLaunchExtensionBrowserTest, const std::vector* 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 diff --git a/docs/google_chrome_branded_builds.md b/docs/google_chrome_branded_builds.md index 6decbd76d0cb0f..95a2d76afddf84 100644 --- a/docs/google_chrome_branded_builds.md +++ b/docs/google_chrome_branded_builds.md @@ -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. diff --git a/google_apis/BUILD.gn b/google_apis/BUILD.gn index 9069f08949b867..25b7289599467c 100644 --- a/google_apis/BUILD.gn +++ b/google_apis/BUILD.gn @@ -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", @@ -231,6 +232,7 @@ test("google_apis_unittests") { ":test_support", "//base", "//base/test:test_support", + "//build:branding_buildflags", "//testing/gmock", "//testing/gtest", ] diff --git a/google_apis/google_api_keys.cc b/google_apis/google_api_keys.cc index 85ae25ec9f0656..d01ef89f6a8681 100644 --- a/google_apis/google_api_keys.cc +++ b/google_apis/google_api_keys.cc @@ -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 @@ -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). @@ -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. @@ -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; diff --git a/google_apis/google_api_keys_mac_unittest.mm b/google_apis/google_api_keys_mac_unittest.mm index ae0d4c13e314d3..dc1a3ae4db851e 100644 --- a/google_apis/google_api_keys_mac_unittest.mm +++ b/google_apis/google_api_keys_mac_unittest.mm @@ -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" @@ -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. diff --git a/google_apis/google_api_keys_unittest.cc b/google_apis/google_api_keys_unittest.cc index 77c3c84674fce3..669be144d6dfb6 100644 --- a/google_apis/google_api_keys_unittest.cc +++ b/google_apis/google_api_keys_unittest.cc @@ -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" @@ -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 { @@ -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. @@ -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. @@ -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. diff --git a/gpu/config/BUILD.gn b/gpu/config/BUILD.gn index 32996e88e89219..acaa734e415403 100644 --- a/gpu/config/BUILD.gn +++ b/gpu/config/BUILD.gn @@ -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", diff --git a/gpu/config/gpu_info_collector_win.cc b/gpu/config/gpu_info_collector_win.cc index 111220f8c7a5b1..19d4dc342d8c7d 100644 --- a/gpu/config/gpu_info_collector_win.cc +++ b/gpu/config/gpu_info_collector_win.cc @@ -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" @@ -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, diff --git a/headless/BUILD.gn b/headless/BUILD.gn index b7472745b9e9b2..a202f16e480364 100644 --- a/headless/BUILD.gn +++ b/headless/BUILD.gn @@ -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", @@ -849,6 +850,7 @@ if (is_win) { ] deps = [ ":headless_renderer", + "//build:branding_buildflags", "//content/public/child:child", "//net", "//ui/base", @@ -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", diff --git a/headless/app/headless_shell.cc b/headless/app/headless_shell.cc index 6bfa26992dc67b..e423696fa9685b 100644 --- a/headless/app/headless_shell.cc +++ b/headless/app/headless_shell.cc @@ -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" @@ -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); diff --git a/media/audio/BUILD.gn b/media/audio/BUILD.gn index d8ae83ce63aafd..35fd1d7da0adfb 100644 --- a/media/audio/BUILD.gn +++ b/media/audio/BUILD.gn @@ -279,6 +279,8 @@ source_set("audio") { "pulse/pulse_util.h", ] + deps += [ "//build:branding_buildflags" ] + if (link_pulseaudio) { configs += [ ":libpulse" ] } else { diff --git a/media/audio/pulse/pulse_util.cc b/media/audio/pulse/pulse_util.cc index 97debbdbc07731..66d7149bfecc34 100644 --- a/media/audio/pulse/pulse_util.cc +++ b/media/audio/pulse/pulse_util.cc @@ -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" @@ -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"; diff --git a/net/http/BUILD.gn b/net/http/BUILD.gn index 3799a9fcbe30a3..22ec5deed0136f 100644 --- a/net/http/BUILD.gn +++ b/net/http/BUILD.gn @@ -73,6 +73,7 @@ source_set("transport_security_state_generated_files") { ] deps = [ + "//build:branding_buildflags", "//net:net_deps", "//net:net_public_deps", "//net/dns", diff --git a/net/http/transport_security_state.cc b/net/http/transport_security_state.cc index 275553cd42b393..baa8ec7d7c5bec 100644 --- a/net/http/transport_security_state.cc +++ b/net/http/transport_security_state.cc @@ -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" @@ -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 diff --git a/remoting/host/BUILD.gn b/remoting/host/BUILD.gn index c3ab224b5a08f1..bbd15b2895dfe2 100644 --- a/remoting/host/BUILD.gn +++ b/remoting/host/BUILD.gn @@ -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", diff --git a/remoting/host/host_attributes.cc b/remoting/host/host_attributes.cc index 4922af35ab6a4d..e52f590860e989 100644 --- a/remoting/host/host_attributes.cc +++ b/remoting/host/host_attributes.cc @@ -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; diff --git a/remoting/host/resources_unittest.cc b/remoting/host/resources_unittest.cc index 518550d0be3517..b29f70cb6ec449 100644 --- a/remoting/host/resources_unittest.cc +++ b/remoting/host/resources_unittest.cc @@ -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" @@ -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) diff --git a/remoting/host/token_validator_factory_impl.cc b/remoting/host/token_validator_factory_impl.cc index b209068d4deb2c..3ef1915d9eb41d 100644 --- a/remoting/host/token_validator_factory_impl.cc +++ b/remoting/host/token_validator_factory_impl.cc @@ -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" @@ -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"; diff --git a/ui/base/mpris/BUILD.gn b/ui/base/mpris/BUILD.gn index 7ffb7c04a034cf..3177b4144c2cb9 100644 --- a/ui/base/mpris/BUILD.gn +++ b/ui/base/mpris/BUILD.gn @@ -15,6 +15,7 @@ component("mpris") { deps = [ "//base", + "//build:branding_buildflags", "//components/dbus/thread_linux", "//dbus", ] diff --git a/ui/base/mpris/mpris_service.cc b/ui/base/mpris/mpris_service.cc index f9f4df020bcb2e..da8ef2fb76d710 100644 --- a/ui/base/mpris/mpris_service.cc +++ b/ui/base/mpris/mpris_service.cc @@ -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 diff --git a/ui/base/mpris/mpris_service_impl.cc b/ui/base/mpris/mpris_service_impl.cc index 0ba6bab4ce6889..2f9ee2eddb0a4b 100644 --- a/ui/base/mpris/mpris_service_impl.cc +++ b/ui/base/mpris/mpris_service_impl.cc @@ -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" @@ -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"); diff --git a/ui/base/now_playing/BUILD.gn b/ui/base/now_playing/BUILD.gn index 8dca44bbb21a3b..2e2366a2b5c80c 100644 --- a/ui/base/now_playing/BUILD.gn +++ b/ui/base/now_playing/BUILD.gn @@ -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", @@ -33,6 +35,7 @@ component("now_playing") { deps = [ "//base", + "//build:branding_buildflags", ] libs = [ "Foundation.framework" ] diff --git a/ui/base/now_playing/now_playing_info_center_delegate_cocoa.mm b/ui/base/now_playing/now_playing_info_center_delegate_cocoa.mm index fcec2dea3a7cda..7ee48e2ef69d7f 100644 --- a/ui/base/now_playing/now_playing_info_center_delegate_cocoa.mm +++ b/ui/base/now_playing/now_playing_info_center_delegate_cocoa.mm @@ -7,6 +7,7 @@ #import #include "base/mac/scoped_nsobject.h" +#include "build/branding_buildflags.h" @interface NowPlayingInfoCenterDelegateCocoa () @@ -49,7 +50,7 @@ - (void)initializeNowPlayingInfoValues { forKey:MPNowPlayingInfoPropertyPlaybackRate]; [nowPlayingInfo_ setObject:[NSNumber numberWithDouble:0] forKey:MPMediaItemPropertyPlaybackDuration]; -#if defined(GOOGLE_CHROME_BUILD) +#if BUILDFLAG(GOOGLE_CHROME_BRANDING) [nowPlayingInfo_ setObject:@"Chrome" forKey:MPMediaItemPropertyTitle]; #else [nowPlayingInfo_ setObject:@"Chromium" forKey:MPMediaItemPropertyTitle];