Commit f2c32196 authored by Nico Weber's avatar Nico Weber Committed by Commit Bot

win: Convert kUseGoogleUpdateIntegration to a buildflag.

- Suppresses several -Wunreachable-code warnings
- Makes it clearer this is a build-time constant
- Removes half a use of GOOGLE_CHROME_BUILD in a .h file

No intended behavior change.

Bug: 346399,961769
Change-Id: Idb574bc2bb8e55e9b060f7fd743242904b291725
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2120269
Auto-Submit: Nico Weber <thakis@chromium.org>
Reviewed-by: default avatarGreg Thompson <grt@chromium.org>
Commit-Queue: Nico Weber <thakis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#753612}
parent c68de024
...@@ -5559,10 +5559,8 @@ source_set("active_use_util") { ...@@ -5559,10 +5559,8 @@ source_set("active_use_util") {
deps = [ deps = [
"//base", "//base",
"//chrome/common:constants", "//chrome/common:constants",
"//chrome/install_static:buildflags",
] ]
if (is_win) {
deps += [ "//chrome/install_static:install_static_util" ]
}
} }
source_set("theme_properties") { source_set("theme_properties") {
......
...@@ -7,15 +7,12 @@ ...@@ -7,15 +7,12 @@
#include "base/command_line.h" #include "base/command_line.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_switches.h"
#include "chrome/install_static/buildflags.h"
#if defined(OS_WIN)
#include "chrome/install_static/install_modes.h"
#endif
bool ShouldRecordActiveUse(const base::CommandLine& command_line) { bool ShouldRecordActiveUse(const base::CommandLine& command_line) {
#if defined(OS_WIN) #if defined(OS_WIN) && !BUILDFLAG(USE_GOOGLE_UPDATE_INTEGRATION)
if (!install_static::kUseGoogleUpdateIntegration)
return false; return false;
#endif #else
return command_line.GetSwitchValueNative(switches::kTryChromeAgain).empty(); return command_line.GetSwitchValueNative(switches::kTryChromeAgain).empty();
#endif
} }
...@@ -2,15 +2,25 @@ ...@@ -2,15 +2,25 @@
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
import("//build/buildflag_header.gni")
import("//build/config/chrome_build.gni") import("//build/config/chrome_build.gni")
import("//testing/test.gni") import("//testing/test.gni")
assert(is_win) buildflag_header("buildflags") {
header = "buildflags.h"
if (is_chrome_branded && is_win) {
flags = [ "USE_GOOGLE_UPDATE_INTEGRATION=1" ]
} else {
flags = [ "USE_GOOGLE_UPDATE_INTEGRATION=0" ]
}
}
# This file only contains utility functions which must only depend on kernel32. if (is_win) {
# Please don't add dependencies on other system libraries. # This file contains utility functions that only depend on kernel32.
static_library("install_static_util") { # Please don't add dependencies on other system libraries.
static_library("install_static_util") {
deps = [ deps = [
":buildflags",
"//build:branding_buildflags", "//build:branding_buildflags",
"//components/nacl/common:buildflags", "//components/nacl/common:buildflags",
"//components/version_info:channel", "//components/version_info:channel",
...@@ -55,26 +65,26 @@ static_library("install_static_util") { ...@@ -55,26 +65,26 @@ static_library("install_static_util") {
# TODO(jschuh): crbug.com/167187 fix size_t to int truncations. # TODO(jschuh): crbug.com/167187 fix size_t to int truncations.
"//build/config/compiler:no_size_t_to_int_warning", "//build/config/compiler:no_size_t_to_int_warning",
] ]
} }
# A source set for use by the module in a process that creates the process-wide # A source set for use by the module in a process that creates the
# InstallDetails instance (i.e., chrome_elf.dll). # process-wide InstallDetails instance (i.e., chrome_elf.dll).
source_set("primary_module") { source_set("primary_module") {
sources = [ "get_install_details_payload.cc" ] sources = [ "get_install_details_payload.cc" ]
} }
# A source set for use by modules in a process that fetch the process-wide # A source set for use by modules in a process that fetch the process-wide
# InstallDetails instance from the primary module by way of # InstallDetails instance from the primary module by way of
# GetInstallDetailsPayload (i.e., chrome.exe and chrome.dll). # GetInstallDetailsPayload (i.e., chrome.exe and chrome.dll).
source_set("secondary_module") { source_set("secondary_module") {
sources = [ sources = [
"initialize_from_primary_module.cc", "initialize_from_primary_module.cc",
"initialize_from_primary_module.h", "initialize_from_primary_module.h",
] ]
deps = [ ":install_static_util" ] deps = [ ":install_static_util" ]
} }
test("install_static_unittests") { test("install_static_unittests") {
output_name = "install_static_unittests" output_name = "install_static_unittests"
sources = [ sources = [
"install_details_unittest.cc", "install_details_unittest.cc",
...@@ -85,6 +95,7 @@ test("install_static_unittests") { ...@@ -85,6 +95,7 @@ test("install_static_unittests") {
] ]
include_dirs = [ "$target_gen_dir" ] include_dirs = [ "$target_gen_dir" ]
deps = [ deps = [
":buildflags",
"//base", "//base",
"//base/test:run_all_unittests", "//base/test:run_all_unittests",
"//base/test:test_support", "//base/test:test_support",
...@@ -94,4 +105,5 @@ test("install_static_unittests") { ...@@ -94,4 +105,5 @@ test("install_static_unittests") {
"//testing/gmock", "//testing/gmock",
"//testing/gtest", "//testing/gtest",
] ]
}
} }
...@@ -9,10 +9,6 @@ ...@@ -9,10 +9,6 @@
namespace install_static { namespace install_static {
enum : bool {
kUseGoogleUpdateIntegration = false,
};
// Note: This list of indices must be kept in sync with the brand-specific // Note: This list of indices must be kept in sync with the brand-specific
// resource strings in chrome/installer/util/prebuild/create_string_rc. // resource strings in chrome/installer/util/prebuild/create_string_rc.
enum InstallConstantIndex { enum InstallConstantIndex {
......
...@@ -9,10 +9,6 @@ ...@@ -9,10 +9,6 @@
namespace install_static { namespace install_static {
enum : bool {
kUseGoogleUpdateIntegration = true,
};
// Note: This list of indices must be kept in sync with the brand-specific // Note: This list of indices must be kept in sync with the brand-specific
// resource strings in chrome/installer/util/prebuild/create_string_rc. // resource strings in chrome/installer/util/prebuild/create_string_rc.
enum InstallConstantIndex { enum InstallConstantIndex {
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
#include <string> #include <string>
#include "base/macros.h" #include "base/macros.h"
#include "chrome/install_static/install_modes.h" #include "chrome/install_static/buildflags.h"
#include "components/version_info/version_info_values.h" #include "components/version_info/version_info_values.h"
#include "testing/gmock/include/gmock/gmock.h" #include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
...@@ -23,13 +23,13 @@ class FakeInstallDetails : public InstallDetails { ...@@ -23,13 +23,13 @@ class FakeInstallDetails : public InstallDetails {
constants.install_suffix = L""; constants.install_suffix = L"";
constants.default_channel_name = L""; constants.default_channel_name = L"";
constants.supported_multi_install = true; constants.supported_multi_install = true;
if (kUseGoogleUpdateIntegration) { #if BUILDFLAG(USE_GOOGLE_UPDATE_INTEGRATION)
constants.app_guid = L"testguid"; constants.app_guid = L"testguid";
constants.channel_strategy = ChannelStrategy::FIXED; constants.channel_strategy = ChannelStrategy::FIXED;
} else { #else
constants.app_guid = L""; constants.app_guid = L"";
constants.channel_strategy = ChannelStrategy::UNSUPPORTED; constants.channel_strategy = ChannelStrategy::UNSUPPORTED;
} #endif
payload.size = sizeof(payload); payload.size = sizeof(payload);
payload.product_version = product_version.c_str(); payload.product_version = product_version.c_str();
payload.mode = &constants; payload.mode = &constants;
...@@ -56,25 +56,25 @@ class FakeInstallDetails : public InstallDetails { ...@@ -56,25 +56,25 @@ class FakeInstallDetails : public InstallDetails {
TEST(InstallDetailsTest, GetClientStateKeyPath) { TEST(InstallDetailsTest, GetClientStateKeyPath) {
FakeInstallDetails details; FakeInstallDetails details;
if (kUseGoogleUpdateIntegration) { #if BUILDFLAG(USE_GOOGLE_UPDATE_INTEGRATION)
constants.app_guid = L"testguid";
EXPECT_THAT(details.GetClientStateKeyPath(), EXPECT_THAT(details.GetClientStateKeyPath(),
StrEq(L"Software\\Google\\Update\\ClientState\\testguid")); StrEq(L"Software\\Google\\Update\\ClientState\\testguid"));
} else { #else
EXPECT_THAT(details.GetClientStateKeyPath(), EXPECT_THAT(details.GetClientStateKeyPath(),
StrEq(std::wstring(L"Software\\").append(kProductPathName))); StrEq(std::wstring(L"Software\\").append(kProductPathName)));
} #endif
} }
TEST(InstallDetailsTest, GetClientStateMediumKeyPath) { TEST(InstallDetailsTest, GetClientStateMediumKeyPath) {
FakeInstallDetails details; FakeInstallDetails details;
if (kUseGoogleUpdateIntegration) { #if BUILDFLAG(USE_GOOGLE_UPDATE_INTEGRATION)
EXPECT_THAT( EXPECT_THAT(details.GetClientStateMediumKeyPath(),
details.GetClientStateMediumKeyPath(),
StrEq(L"Software\\Google\\Update\\ClientStateMedium\\testguid")); StrEq(L"Software\\Google\\Update\\ClientStateMedium\\testguid"));
} else { #else
EXPECT_THAT(details.GetClientStateKeyPath(), EXPECT_THAT(details.GetClientStateKeyPath(),
StrEq(std::wstring(L"Software\\").append(kProductPathName))); StrEq(std::wstring(L"Software\\").append(kProductPathName)));
} #endif
} }
TEST(InstallDetailsTest, VersionMismatch) { TEST(InstallDetailsTest, VersionMismatch) {
......
...@@ -4,14 +4,13 @@ ...@@ -4,14 +4,13 @@
#include "chrome/install_static/install_modes.h" #include "chrome/install_static/install_modes.h"
#include "chrome/install_static/buildflags.h"
namespace install_static { namespace install_static {
namespace { namespace {
std::wstring GetUnregisteredKeyPathForProduct(const wchar_t* product) { #if BUILDFLAG(USE_GOOGLE_UPDATE_INTEGRATION)
return std::wstring(L"Software\\").append(product);
}
std::wstring GetClientsKeyPathForApp(const wchar_t* app_guid) { std::wstring GetClientsKeyPathForApp(const wchar_t* app_guid) {
return std::wstring(L"Software\\Google\\Update\\Clients\\").append(app_guid); return std::wstring(L"Software\\Google\\Update\\Clients\\").append(app_guid);
} }
...@@ -25,43 +24,60 @@ std::wstring GetClientStateMediumKeyPathForApp(const wchar_t* app_guid) { ...@@ -25,43 +24,60 @@ std::wstring GetClientStateMediumKeyPathForApp(const wchar_t* app_guid) {
return std::wstring(L"Software\\Google\\Update\\ClientStateMedium\\") return std::wstring(L"Software\\Google\\Update\\ClientStateMedium\\")
.append(app_guid); .append(app_guid);
} }
#else
std::wstring GetUnregisteredKeyPathForProduct(const wchar_t* product) {
return std::wstring(L"Software\\").append(product);
}
#endif
} // namespace } // namespace
std::wstring GetClientsKeyPath(const wchar_t* app_guid) { std::wstring GetClientsKeyPath(const wchar_t* app_guid) {
if (!kUseGoogleUpdateIntegration) #if !BUILDFLAG(USE_GOOGLE_UPDATE_INTEGRATION)
return GetUnregisteredKeyPathForProduct(kProductPathName); return GetUnregisteredKeyPathForProduct(kProductPathName);
#else
return GetClientsKeyPathForApp(app_guid); return GetClientsKeyPathForApp(app_guid);
#endif
} }
std::wstring GetClientStateKeyPath(const wchar_t* app_guid) { std::wstring GetClientStateKeyPath(const wchar_t* app_guid) {
if (!kUseGoogleUpdateIntegration) #if !BUILDFLAG(USE_GOOGLE_UPDATE_INTEGRATION)
return GetUnregisteredKeyPathForProduct(kProductPathName); return GetUnregisteredKeyPathForProduct(kProductPathName);
#else
return GetClientStateKeyPathForApp(app_guid); return GetClientStateKeyPathForApp(app_guid);
#endif
} }
std::wstring GetBinariesClientsKeyPath() { std::wstring GetBinariesClientsKeyPath() {
if (!kUseGoogleUpdateIntegration) #if !BUILDFLAG(USE_GOOGLE_UPDATE_INTEGRATION)
return GetUnregisteredKeyPathForProduct(kBinariesPathName); return GetUnregisteredKeyPathForProduct(kBinariesPathName);
#else
return GetClientsKeyPathForApp(kBinariesAppGuid); return GetClientsKeyPathForApp(kBinariesAppGuid);
#endif
} }
std::wstring GetBinariesClientStateKeyPath() { std::wstring GetBinariesClientStateKeyPath() {
if (!kUseGoogleUpdateIntegration) #if !BUILDFLAG(USE_GOOGLE_UPDATE_INTEGRATION)
return GetUnregisteredKeyPathForProduct(kBinariesPathName); return GetUnregisteredKeyPathForProduct(kBinariesPathName);
#else
return GetClientStateKeyPathForApp(kBinariesAppGuid); return GetClientStateKeyPathForApp(kBinariesAppGuid);
#endif
} }
std::wstring GetClientStateMediumKeyPath(const wchar_t* app_guid) { std::wstring GetClientStateMediumKeyPath(const wchar_t* app_guid) {
if (!kUseGoogleUpdateIntegration) #if !BUILDFLAG(USE_GOOGLE_UPDATE_INTEGRATION)
return GetUnregisteredKeyPathForProduct(kProductPathName); return GetUnregisteredKeyPathForProduct(kProductPathName);
#else
return GetClientStateMediumKeyPathForApp(app_guid); return GetClientStateMediumKeyPathForApp(app_guid);
#endif
} }
std::wstring GetBinariesClientStateMediumKeyPath() { std::wstring GetBinariesClientStateMediumKeyPath() {
if (!kUseGoogleUpdateIntegration) #if !BUILDFLAG(USE_GOOGLE_UPDATE_INTEGRATION)
return GetUnregisteredKeyPathForProduct(kBinariesPathName); return GetUnregisteredKeyPathForProduct(kBinariesPathName);
#else
return GetClientStateMediumKeyPathForApp(kBinariesAppGuid); return GetClientStateMediumKeyPathForApp(kBinariesAppGuid);
#endif
} }
} // namespace install_static } // namespace install_static
...@@ -37,9 +37,6 @@ ...@@ -37,9 +37,6 @@
// array. // array.
// - NUM_INSTALL_MODES: the total numer of modes (i.e., the numer of items in // - NUM_INSTALL_MODES: the total numer of modes (i.e., the numer of items in
// kInstallModes. // kInstallModes.
// - kUseGoogleUpdateIntegration: true or false indicating whether or not the
// brand uses Chrome's integration with Google Update. Google Chrome does,
// while Chromium does not.
#if defined(GOOGLE_CHROME_BUILD) #if defined(GOOGLE_CHROME_BUILD)
#include "chrome/install_static/google_chrome_install_modes.h" #include "chrome/install_static/google_chrome_install_modes.h"
#else #else
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <cguid.h> #include <cguid.h>
#include <ctype.h> #include <ctype.h>
#include "chrome/install_static/buildflags.h"
#include "testing/gmock/include/gmock/gmock.h" #include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
...@@ -66,10 +67,11 @@ TEST(InstallModes, VerifyModes) { ...@@ -66,10 +67,11 @@ TEST(InstallModes, VerifyModes) {
ASSERT_THAT(mode.logo_suffix, StrNe(L"")); ASSERT_THAT(mode.logo_suffix, StrNe(L""));
// The modes must have an appguid if Google Update integration is supported. // The modes must have an appguid if Google Update integration is supported.
if (kUseGoogleUpdateIntegration) #if BUILDFLAG(USE_GOOGLE_UPDATE_INTEGRATION)
ASSERT_THAT(mode.app_guid, StrNe(L"")); ASSERT_THAT(mode.app_guid, StrNe(L""));
else #else
ASSERT_THAT(mode.app_guid, StrEq(L"")); ASSERT_THAT(mode.app_guid, StrEq(L""));
#endif
// Every mode must have a base app name. // Every mode must have a base app name.
ASSERT_THAT(mode.base_app_name, StrNe(L"")); ASSERT_THAT(mode.base_app_name, StrNe(L""));
...@@ -102,94 +104,95 @@ TEST(InstallModes, VerifyModes) { ...@@ -102,94 +104,95 @@ TEST(InstallModes, VerifyModes) {
// Every mode must have an elevator IID. // Every mode must have an elevator IID.
ASSERT_THAT(mode.elevator_iid, Ne(CLSID_NULL)); ASSERT_THAT(mode.elevator_iid, Ne(CLSID_NULL));
// UNSUPPORTED and kUseGoogleUpdateIntegration are mutually exclusive. // UNSUPPORTED and USE_GOOGLE_UPDATE_INTEGRATION are mutually exclusive.
if (kUseGoogleUpdateIntegration) #if BUILDFLAG(USE_GOOGLE_UPDATE_INTEGRATION)
ASSERT_THAT(mode.channel_strategy, Ne(ChannelStrategy::UNSUPPORTED)); ASSERT_THAT(mode.channel_strategy, Ne(ChannelStrategy::UNSUPPORTED));
else #else
ASSERT_THAT(mode.channel_strategy, Eq(ChannelStrategy::UNSUPPORTED)); ASSERT_THAT(mode.channel_strategy, Eq(ChannelStrategy::UNSUPPORTED));
#endif
} }
} }
TEST(InstallModes, VerifyBrand) { TEST(InstallModes, VerifyBrand) {
if (kUseGoogleUpdateIntegration) { #if BUILDFLAG(USE_GOOGLE_UPDATE_INTEGRATION)
// Binaries were registered via an app guid with Google Update integration. // Binaries were registered via an app guid with Google Update integration.
ASSERT_THAT(kBinariesAppGuid, StrNe(L"")); ASSERT_THAT(kBinariesAppGuid, StrNe(L""));
ASSERT_THAT(kBinariesPathName, StrEq(L"")); ASSERT_THAT(kBinariesPathName, StrEq(L""));
} else { #else
// Binaries were registered via a different path name without. // Binaries were registered via a different path name without.
ASSERT_THAT(kBinariesAppGuid, StrEq(L"")); ASSERT_THAT(kBinariesAppGuid, StrEq(L""));
ASSERT_THAT(kBinariesPathName, StrNe(L"")); ASSERT_THAT(kBinariesPathName, StrNe(L""));
} #endif
} }
TEST(InstallModes, GetClientsKeyPath) { TEST(InstallModes, GetClientsKeyPath) {
constexpr wchar_t kAppGuid[] = L"test"; constexpr wchar_t kAppGuid[] = L"test";
if (kUseGoogleUpdateIntegration) { #if BUILDFLAG(USE_GOOGLE_UPDATE_INTEGRATION)
ASSERT_THAT(GetClientsKeyPath(kAppGuid), ASSERT_THAT(GetClientsKeyPath(kAppGuid),
StrEq(L"Software\\Google\\Update\\Clients\\test")); StrEq(L"Software\\Google\\Update\\Clients\\test"));
} else { #else
ASSERT_THAT(GetClientsKeyPath(kAppGuid), ASSERT_THAT(GetClientsKeyPath(kAppGuid),
StrEq(std::wstring(L"Software\\").append(kProductPathName))); StrEq(std::wstring(L"Software\\").append(kProductPathName)));
} #endif
} }
TEST(InstallModes, GetClientStateKeyPath) { TEST(InstallModes, GetClientStateKeyPath) {
constexpr wchar_t kAppGuid[] = L"test"; constexpr wchar_t kAppGuid[] = L"test";
if (kUseGoogleUpdateIntegration) { #if BUILDFLAG(USE_GOOGLE_UPDATE_INTEGRATION)
ASSERT_THAT(GetClientStateKeyPath(kAppGuid), ASSERT_THAT(GetClientStateKeyPath(kAppGuid),
StrEq(L"Software\\Google\\Update\\ClientState\\test")); StrEq(L"Software\\Google\\Update\\ClientState\\test"));
} else { #else
ASSERT_THAT(GetClientStateKeyPath(kAppGuid), ASSERT_THAT(GetClientStateKeyPath(kAppGuid),
StrEq(std::wstring(L"Software\\").append(kProductPathName))); StrEq(std::wstring(L"Software\\").append(kProductPathName)));
} #endif
} }
TEST(InstallModes, GetBinariesClientsKeyPath) { TEST(InstallModes, GetBinariesClientsKeyPath) {
if (kUseGoogleUpdateIntegration) { #if BUILDFLAG(USE_GOOGLE_UPDATE_INTEGRATION)
ASSERT_THAT(GetBinariesClientsKeyPath(), ASSERT_THAT(GetBinariesClientsKeyPath(),
StrEq(std::wstring(L"Software\\Google\\Update\\Clients\\") StrEq(std::wstring(L"Software\\Google\\Update\\Clients\\")
.append(kBinariesAppGuid))); .append(kBinariesAppGuid)));
} else { #else
ASSERT_THAT(GetBinariesClientsKeyPath(), ASSERT_THAT(GetBinariesClientsKeyPath(),
StrEq(std::wstring(L"Software\\").append(kBinariesPathName))); StrEq(std::wstring(L"Software\\").append(kBinariesPathName)));
} #endif
} }
TEST(InstallModes, GetBinariesClientStateKeyPath) { TEST(InstallModes, GetBinariesClientStateKeyPath) {
if (kUseGoogleUpdateIntegration) { #if BUILDFLAG(USE_GOOGLE_UPDATE_INTEGRATION)
ASSERT_THAT(GetBinariesClientStateKeyPath(), ASSERT_THAT(GetBinariesClientStateKeyPath(),
StrEq(std::wstring(L"Software\\Google\\Update\\ClientState\\") StrEq(std::wstring(L"Software\\Google\\Update\\ClientState\\")
.append(kBinariesAppGuid))); .append(kBinariesAppGuid)));
} else { #else
ASSERT_THAT(GetBinariesClientStateKeyPath(), ASSERT_THAT(GetBinariesClientStateKeyPath(),
StrEq(std::wstring(L"Software\\").append(kBinariesPathName))); StrEq(std::wstring(L"Software\\").append(kBinariesPathName)));
} #endif
} }
TEST(InstallModes, GetClientStateMediumKeyPath) { TEST(InstallModes, GetClientStateMediumKeyPath) {
constexpr wchar_t kAppGuid[] = L"test"; constexpr wchar_t kAppGuid[] = L"test";
if (kUseGoogleUpdateIntegration) { #if BUILDFLAG(USE_GOOGLE_UPDATE_INTEGRATION)
ASSERT_THAT(GetClientStateMediumKeyPath(kAppGuid), ASSERT_THAT(GetClientStateMediumKeyPath(kAppGuid),
StrEq(L"Software\\Google\\Update\\ClientStateMedium\\test")); StrEq(L"Software\\Google\\Update\\ClientStateMedium\\test"));
} else { #else
ASSERT_THAT(GetClientStateMediumKeyPath(kAppGuid), ASSERT_THAT(GetClientStateMediumKeyPath(kAppGuid),
StrEq(std::wstring(L"Software\\").append(kProductPathName))); StrEq(std::wstring(L"Software\\").append(kProductPathName)));
} #endif
} }
TEST(InstallModes, GetBinariesClientStateMediumKeyPath) { TEST(InstallModes, GetBinariesClientStateMediumKeyPath) {
if (kUseGoogleUpdateIntegration) { #if BUILDFLAG(USE_GOOGLE_UPDATE_INTEGRATION)
ASSERT_THAT( ASSERT_THAT(
GetBinariesClientStateMediumKeyPath(), GetBinariesClientStateMediumKeyPath(),
StrEq(std::wstring(L"Software\\Google\\Update\\ClientStateMedium\\") StrEq(std::wstring(L"Software\\Google\\Update\\ClientStateMedium\\")
.append(kBinariesAppGuid))); .append(kBinariesAppGuid)));
} else { #else
ASSERT_THAT(GetBinariesClientStateMediumKeyPath(), ASSERT_THAT(GetBinariesClientStateMediumKeyPath(),
StrEq(std::wstring(L"Software\\").append(kBinariesPathName))); StrEq(std::wstring(L"Software\\").append(kBinariesPathName)));
} #endif
} }
} // namespace install_static } // namespace install_static
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "build/branding_buildflags.h" #include "build/branding_buildflags.h"
#include "chrome/chrome_elf/nt_registry/nt_registry.h" #include "chrome/chrome_elf/nt_registry/nt_registry.h"
#include "chrome/install_static/buildflags.h"
#include "chrome/install_static/install_details.h" #include "chrome/install_static/install_details.h"
#include "chrome/install_static/install_modes.h" #include "chrome/install_static/install_modes.h"
#include "chrome/install_static/policy_path_parser.h" #include "chrome/install_static/policy_path_parser.h"
...@@ -60,6 +61,7 @@ const wchar_t kUtilityProcess[] = L"utility"; ...@@ -60,6 +61,7 @@ const wchar_t kUtilityProcess[] = L"utility";
namespace { namespace {
#if BUILDFLAG(USE_GOOGLE_UPDATE_INTEGRATION)
// TODO(ananta) // TODO(ananta)
// http://crbug.com/604923 // http://crbug.com/604923
// The constants defined in this file are also defined in chrome/installer and // The constants defined in this file are also defined in chrome/installer and
...@@ -68,13 +70,16 @@ namespace { ...@@ -68,13 +70,16 @@ namespace {
constexpr wchar_t kChromeChannelDev[] = L"dev"; constexpr wchar_t kChromeChannelDev[] = L"dev";
constexpr wchar_t kChromeChannelBeta[] = L"beta"; constexpr wchar_t kChromeChannelBeta[] = L"beta";
constexpr wchar_t kChromeChannelStableExplicit[] = L"stable"; constexpr wchar_t kChromeChannelStableExplicit[] = L"stable";
#endif
// TODO(ananta) // TODO(ananta)
// http://crbug.com/604923 // http://crbug.com/604923
// These constants are defined in the chrome/installer directory as well. We // These constants are defined in the chrome/installer directory as well. We
// need to unify them. // need to unify them.
#if BUILDFLAG(USE_GOOGLE_UPDATE_INTEGRATION)
constexpr wchar_t kRegValueAp[] = L"ap"; constexpr wchar_t kRegValueAp[] = L"ap";
constexpr wchar_t kRegValueName[] = L"name"; constexpr wchar_t kRegValueName[] = L"name";
#endif
constexpr wchar_t kRegValueUsageStats[] = L"usagestats"; constexpr wchar_t kRegValueUsageStats[] = L"usagestats";
constexpr wchar_t kMetricsReportingEnabled[] = L"MetricsReportingEnabled"; constexpr wchar_t kMetricsReportingEnabled[] = L"MetricsReportingEnabled";
...@@ -273,12 +278,11 @@ std::vector<StringType> TokenizeStringT( ...@@ -273,12 +278,11 @@ std::vector<StringType> TokenizeStringT(
return tokens; return tokens;
} }
#if BUILDFLAG(USE_GOOGLE_UPDATE_INTEGRATION)
// Returns Chrome's update channel name based on the contents of the given "ap" // Returns Chrome's update channel name based on the contents of the given "ap"
// value from Chrome's ClientState key. // value from Chrome's ClientState key.
std::wstring ChannelFromAdditionalParameters(const InstallConstants& mode, std::wstring ChannelFromAdditionalParameters(const InstallConstants& mode,
const std::wstring& ap_value) { const std::wstring& ap_value) {
assert(kUseGoogleUpdateIntegration);
static constexpr wchar_t kChromeChannelBetaPattern[] = L"1?1-*"; static constexpr wchar_t kChromeChannelBetaPattern[] = L"1?1-*";
static constexpr wchar_t kChromeChannelBetaX64Pattern[] = L"*x64-beta*"; static constexpr wchar_t kChromeChannelBetaX64Pattern[] = L"*x64-beta*";
static constexpr wchar_t kChromeChannelDevPattern[] = L"2?0-d*"; static constexpr wchar_t kChromeChannelDevPattern[] = L"2?0-d*";
...@@ -307,6 +311,7 @@ std::wstring ChannelFromAdditionalParameters(const InstallConstants& mode, ...@@ -307,6 +311,7 @@ std::wstring ChannelFromAdditionalParameters(const InstallConstants& mode,
// rules in the update configs. // rules in the update configs.
return std::wstring(); return std::wstring();
} }
#endif
// Converts a process type specified as a string to the ProcessType enum. // Converts a process type specified as a string to the ProcessType enum.
ProcessType GetProcessType(const std::wstring& process_type) { ProcessType GetProcessType(const std::wstring& process_type) {
...@@ -926,9 +931,9 @@ std::wstring DetermineChannel(const InstallConstants& mode, ...@@ -926,9 +931,9 @@ std::wstring DetermineChannel(const InstallConstants& mode,
bool from_binaries, bool from_binaries,
std::wstring* update_ap, std::wstring* update_ap,
std::wstring* update_cohort_name) { std::wstring* update_cohort_name) {
if (!kUseGoogleUpdateIntegration) #if !BUILDFLAG(USE_GOOGLE_UPDATE_INTEGRATION)
return std::wstring(); return std::wstring();
#else
// Read the "ap" value and cache it if requested. // Read the "ap" value and cache it if requested.
std::wstring client_state(from_binaries std::wstring client_state(from_binaries
? GetBinariesClientStateKeyPath() ? GetBinariesClientStateKeyPath()
...@@ -958,6 +963,7 @@ std::wstring DetermineChannel(const InstallConstants& mode, ...@@ -958,6 +963,7 @@ std::wstring DetermineChannel(const InstallConstants& mode,
} }
return std::wstring(); return std::wstring();
#endif
} }
} // namespace install_static } // namespace install_static
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "base/win/win_util.h" #include "base/win/win_util.h"
#include "build/branding_buildflags.h" #include "build/branding_buildflags.h"
#include "chrome/chrome_elf/nt_registry/nt_registry.h" #include "chrome/chrome_elf/nt_registry/nt_registry.h"
#include "chrome/install_static/buildflags.h"
#include "chrome/install_static/install_details.h" #include "chrome/install_static/install_details.h"
#include "chrome/install_static/install_modes.h" #include "chrome/install_static/install_modes.h"
#include "chrome/install_static/test/scoped_install_details.h" #include "chrome/install_static/test/scoped_install_details.h"
...@@ -338,15 +339,15 @@ class InstallStaticUtilTest ...@@ -338,15 +339,15 @@ class InstallStaticUtilTest
EXPECT_TRUE(!medium || system_level_); EXPECT_TRUE(!medium || system_level_);
std::wstring result(L"Software\\"); std::wstring result(L"Software\\");
if (kUseGoogleUpdateIntegration) { #if BUILDFLAG(USE_GOOGLE_UPDATE_INTEGRATION)
result.append(L"Google\\Update\\ClientState"); result.append(L"Google\\Update\\ClientState");
if (medium) if (medium)
result.append(L"Medium"); result.append(L"Medium");
result.push_back(L'\\'); result.push_back(L'\\');
result.append(mode_->app_guid); result.append(mode_->app_guid);
} else { #else
result.append(kProductPathName); result.append(kProductPathName);
} #endif
return result; return result;
} }
...@@ -431,12 +432,9 @@ TEST_P(InstallStaticUtilTest, GetUninstallRegistryPath) { ...@@ -431,12 +432,9 @@ TEST_P(InstallStaticUtilTest, GetUninstallRegistryPath) {
TEST_P(InstallStaticUtilTest, GetAppGuid) { TEST_P(InstallStaticUtilTest, GetAppGuid) {
// For brands that do not integrate with Omaha/Google Update, the app guid is // For brands that do not integrate with Omaha/Google Update, the app guid is
// an empty string. // an empty string.
if (!kUseGoogleUpdateIntegration) { #if !BUILDFLAG(USE_GOOGLE_UPDATE_INTEGRATION)
EXPECT_STREQ(L"", GetAppGuid()); EXPECT_STREQ(L"", GetAppGuid());
return; #elif BUILDFLAG(GOOGLE_CHROME_BRANDING)
}
#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
// The app guids for the brand's install modes; parallel to kInstallModes. // The app guids for the brand's install modes; parallel to kInstallModes.
static constexpr const wchar_t* kAppGuids[] = { static constexpr const wchar_t* kAppGuids[] = {
L"{8A69D345-D564-463c-AFF1-A69D9E530F96}", // Google Chrome. L"{8A69D345-D564-463c-AFF1-A69D9E530F96}", // Google Chrome.
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "base/win/windows_version.h" #include "base/win/windows_version.h"
#include "build/branding_buildflags.h" #include "build/branding_buildflags.h"
#include "chrome/chrome_elf/nt_registry/nt_registry.h" #include "chrome/chrome_elf/nt_registry/nt_registry.h"
#include "chrome/install_static/buildflags.h"
#include "chrome/install_static/install_constants.h" #include "chrome/install_static/install_constants.h"
#include "chrome/install_static/install_details.h" #include "chrome/install_static/install_details.h"
#include "chrome/install_static/install_modes.h" #include "chrome/install_static/install_modes.h"
...@@ -228,12 +229,12 @@ class MakeProductDetailsTest : public testing::TestWithParam<TestData> { ...@@ -228,12 +229,12 @@ class MakeProductDetailsTest : public testing::TestWithParam<TestData> {
// Returns the registry path for the product's ClientState key. // Returns the registry path for the product's ClientState key.
std::wstring GetClientStateKeyPath() { std::wstring GetClientStateKeyPath() {
std::wstring result(L"Software\\"); std::wstring result(L"Software\\");
if (kUseGoogleUpdateIntegration) { #if BUILDFLAG(USE_GOOGLE_UPDATE_INTEGRATION)
result.append(L"Google\\Update\\ClientState\\"); result.append(L"Google\\Update\\ClientState\\");
result.append(kInstallModes[test_data().index].app_guid); result.append(kInstallModes[test_data().index].app_guid);
} else { #else
result.append(kProductPathName); result.append(kProductPathName);
} #endif
return result; return result;
} }
...@@ -322,9 +323,7 @@ TEST_P(MakeProductDetailsTest, AdditionalParametersChannels) { ...@@ -322,9 +323,7 @@ TEST_P(MakeProductDetailsTest, AdditionalParametersChannels) {
// Test that the "ap" value is cached during initialization. // Test that the "ap" value is cached during initialization.
TEST_P(MakeProductDetailsTest, UpdateAp) { TEST_P(MakeProductDetailsTest, UpdateAp) {
// This test is only valid for brands that integrate with Google Update. // This test is only valid for brands that integrate with Google Update.
if (!kUseGoogleUpdateIntegration) #if BUILDFLAG(USE_GOOGLE_UPDATE_INTEGRATION)
return;
// With no value in the registry, the ap value should be empty. // With no value in the registry, the ap value should be empty.
{ {
std::unique_ptr<PrimaryInstallDetails> details( std::unique_ptr<PrimaryInstallDetails> details(
...@@ -340,14 +339,13 @@ TEST_P(MakeProductDetailsTest, UpdateAp) { ...@@ -340,14 +339,13 @@ TEST_P(MakeProductDetailsTest, UpdateAp) {
MakeProductDetails(test_data().path)); MakeProductDetails(test_data().path));
EXPECT_THAT(details->update_ap(), StrEq(kCrookedMoon)); EXPECT_THAT(details->update_ap(), StrEq(kCrookedMoon));
} }
#endif
} }
// Test that the cohort name is cached during initialization. // Test that the cohort name is cached during initialization.
TEST_P(MakeProductDetailsTest, UpdateCohortName) { TEST_P(MakeProductDetailsTest, UpdateCohortName) {
// This test is only valid for brands that integrate with Google Update. // This test is only valid for brands that integrate with Google Update.
if (!kUseGoogleUpdateIntegration) #if BUILDFLAG(USE_GOOGLE_UPDATE_INTEGRATION)
return;
// With no value in the registry, the cohort name should be empty. // With no value in the registry, the cohort name should be empty.
{ {
std::unique_ptr<PrimaryInstallDetails> details( std::unique_ptr<PrimaryInstallDetails> details(
...@@ -363,6 +361,7 @@ TEST_P(MakeProductDetailsTest, UpdateCohortName) { ...@@ -363,6 +361,7 @@ TEST_P(MakeProductDetailsTest, UpdateCohortName) {
MakeProductDetails(test_data().path)); MakeProductDetails(test_data().path));
EXPECT_THAT(details->update_cohort_name(), StrEq(kPhony)); EXPECT_THAT(details->update_cohort_name(), StrEq(kPhony));
} }
#endif
} }
INSTANTIATE_TEST_SUITE_P(All, INSTANTIATE_TEST_SUITE_P(All,
......
...@@ -96,6 +96,7 @@ if (is_win) { ...@@ -96,6 +96,7 @@ if (is_win) {
"//build:branding_buildflags", "//build:branding_buildflags",
"//chrome/common:constants", "//chrome/common:constants",
"//chrome/common:version_header", "//chrome/common:version_header",
"//chrome/install_static:buildflags",
"//chrome/install_static:install_static_util", "//chrome/install_static:install_static_util",
"//components/base32", "//components/base32",
"//components/crash/core/app", "//components/crash/core/app",
...@@ -145,6 +146,7 @@ if (is_win) { ...@@ -145,6 +146,7 @@ if (is_win) {
"//build:branding_buildflags", "//build:branding_buildflags",
"//chrome/common:constants", "//chrome/common:constants",
"//chrome/common:version_header", "//chrome/common:version_header",
"//chrome/install_static:buildflags",
"//chrome/install_static:install_static_util", "//chrome/install_static:install_static_util",
"//chrome/install_static/test:test_support", "//chrome/install_static/test:test_support",
"//chrome/installer/mini_installer:unit_tests", "//chrome/installer/mini_installer:unit_tests",
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include "base/win/win_util.h" #include "base/win/win_util.h"
#include "base/win/windows_version.h" #include "base/win/windows_version.h"
#include "build/branding_buildflags.h" #include "build/branding_buildflags.h"
#include "chrome/install_static/buildflags.h"
#include "chrome/install_static/install_details.h" #include "chrome/install_static/install_details.h"
#include "chrome/install_static/install_modes.h" #include "chrome/install_static/install_modes.h"
#include "chrome/install_static/install_util.h" #include "chrome/install_static/install_util.h"
...@@ -871,13 +872,14 @@ bool AppendPostInstallTasks(const InstallerState& installer_state, ...@@ -871,13 +872,14 @@ bool AppendPostInstallTasks(const InstallerState& installer_state,
// installs. This is ordinarily done by Google Update prior to running // installs. This is ordinarily done by Google Update prior to running
// Chrome's installer. Do it here as well so that the key exists for manual // Chrome's installer. Do it here as well so that the key exists for manual
// installs. // installs.
if (install_static::kUseGoogleUpdateIntegration && #if BUILDFLAG(USE_GOOGLE_UPDATE_INTEGRATION)
installer_state.system_install()) { if (installer_state.system_install()) {
const base::string16 path = install_static::GetClientStateMediumKeyPath(); const base::string16 path = install_static::GetClientStateMediumKeyPath();
post_install_task_list post_install_task_list
->AddCreateRegKeyWorkItem(HKEY_LOCAL_MACHINE, path, KEY_WOW64_32KEY) ->AddCreateRegKeyWorkItem(HKEY_LOCAL_MACHINE, path, KEY_WOW64_32KEY)
->set_best_effort(true); ->set_best_effort(true);
} }
#endif
return true; return true;
} }
......
...@@ -11,8 +11,8 @@ ...@@ -11,8 +11,8 @@
#include "base/test/test_reg_util_win.h" #include "base/test/test_reg_util_win.h"
#include "build/branding_buildflags.h" #include "build/branding_buildflags.h"
#include "chrome/chrome_elf/nt_registry/nt_registry.h" #include "chrome/chrome_elf/nt_registry/nt_registry.h"
#include "chrome/install_static/buildflags.h"
#include "chrome/install_static/install_details.h" #include "chrome/install_static/install_details.h"
#include "chrome/install_static/install_modes.h"
#include "chrome/installer/util/master_preferences.h" #include "chrome/installer/util/master_preferences.h"
#include "testing/gmock/include/gmock/gmock.h" #include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
...@@ -273,12 +273,12 @@ class MakeInstallDetailsTest : public testing::TestWithParam<TestData> { ...@@ -273,12 +273,12 @@ class MakeInstallDetailsTest : public testing::TestWithParam<TestData> {
ASSERT_NO_FATAL_FAILURE(SetUninstallArguments( ASSERT_NO_FATAL_FAILURE(SetUninstallArguments(
root_key_, install_static::kInstallModes[test_data_.index].app_guid, root_key_, install_static::kInstallModes[test_data_.index].app_guid,
test_data_.uninstall_args)); test_data_.uninstall_args));
if (install_static::kUseGoogleUpdateIntegration) { #if BUILDFLAG(USE_GOOGLE_UPDATE_INTEGRATION)
ASSERT_NO_FATAL_FAILURE(SetProductAp( ASSERT_NO_FATAL_FAILURE(SetProductAp(
root_key_, install_static::kInstallModes[test_data_.index].app_guid, root_key_, install_static::kInstallModes[test_data_.index].app_guid,
test_data_.product_ap)); test_data_.product_ap));
ASSERT_NO_FATAL_FAILURE(SetBinariesAp(root_key_, test_data_.binaries_ap)); ASSERT_NO_FATAL_FAILURE(SetBinariesAp(root_key_, test_data_.binaries_ap));
} #endif
} }
void TearDown() override { void TearDown() override {
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
#include "build/build_config.h" #include "build/build_config.h"
#include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_switches.h"
#include "chrome/common/chrome_version.h" #include "chrome/common/chrome_version.h"
#include "chrome/install_static/install_modes.h" #include "chrome/install_static/buildflags.h"
#include "chrome/install_static/install_util.h" #include "chrome/install_static/install_util.h"
#include "chrome/installer/setup/installer_state.h" #include "chrome/installer/setup/installer_state.h"
#include "chrome/installer/setup/setup_constants.h" #include "chrome/installer/setup/setup_constants.h"
...@@ -47,18 +47,22 @@ namespace installer { ...@@ -47,18 +47,22 @@ namespace installer {
namespace { namespace {
#if BUILDFLAG(USE_GOOGLE_UPDATE_INTEGRATION)
// The study currently being conducted. // The study currently being conducted.
constexpr ExperimentStorage::Study kCurrentStudy = ExperimentStorage::kStudyOne; constexpr ExperimentStorage::Study kCurrentStudy = ExperimentStorage::kStudyOne;
#endif
// The primary group for study number two. // The primary group for study number two.
constexpr int kStudyTwoGroup = 0; constexpr int kStudyTwoGroup = 0;
// Test switches. // Test switches.
constexpr char kExperimentEnableForTesting[] = "experiment-enable-for-testing";
constexpr char kExperimentEnterpriseBypass[] = "experiment-enterprise-bypass";
constexpr char kExperimentParticipation[] = "experiment-participation"; constexpr char kExperimentParticipation[] = "experiment-participation";
constexpr char kExperimentRetryDelay[] = "experiment-retry-delay"; constexpr char kExperimentRetryDelay[] = "experiment-retry-delay";
#if BUILDFLAG(USE_GOOGLE_UPDATE_INTEGRATION)
constexpr char kExperimentEnableForTesting[] = "experiment-enable-for-testing";
constexpr char kExperimentEnterpriseBypass[] = "experiment-enterprise-bypass";
// Returns true if the experiment is enabled for testing. // Returns true if the experiment is enabled for testing.
bool IsExperimentEnabledForTesting() { bool IsExperimentEnabledForTesting() {
return base::CommandLine::ForCurrentProcess()->HasSwitch( return base::CommandLine::ForCurrentProcess()->HasSwitch(
...@@ -75,6 +79,7 @@ bool IsEnterpriseInstall(const InstallerState& installer_state) { ...@@ -75,6 +79,7 @@ bool IsEnterpriseInstall(const InstallerState& installer_state) {
} }
return installer_state.is_msi() || IsDomainJoined(); return installer_state.is_msi() || IsDomainJoined();
} }
#endif
// Returns the delay to be used between presentation retries. The default (five // Returns the delay to be used between presentation retries. The default (five
// minutes) can be overidden via --experiment-retry-delay=SECONDS. // minutes) can be overidden via --experiment-retry-delay=SECONDS.
...@@ -215,9 +220,9 @@ bool WaitForPresentation( ...@@ -215,9 +220,9 @@ bool WaitForPresentation(
// Execution may be in the context of the system or a user on it, and no // Execution may be in the context of the system or a user on it, and no
// guarantee is made regarding the setup singleton. // guarantee is made regarding the setup singleton.
bool ShouldRunUserExperiment(const InstallerState& installer_state) { bool ShouldRunUserExperiment(const InstallerState& installer_state) {
if (!install_static::kUseGoogleUpdateIntegration) #if !BUILDFLAG(USE_GOOGLE_UPDATE_INTEGRATION)
return false; return false;
#else
if (!install_static::SupportsRetentionExperiments()) if (!install_static::SupportsRetentionExperiments())
return false; return false;
...@@ -250,6 +255,7 @@ bool ShouldRunUserExperiment(const InstallerState& installer_state) { ...@@ -250,6 +255,7 @@ bool ShouldRunUserExperiment(const InstallerState& installer_state) {
return false; return false;
return true; return true;
#endif
} }
// Execution is from the context of the installer immediately following a // Execution is from the context of the installer immediately following a
...@@ -502,8 +508,7 @@ bool IsUpdateRenamePending() { ...@@ -502,8 +508,7 @@ bool IsUpdateRenamePending() {
// Consider an update to be pending if an "opv" value is present in the // Consider an update to be pending if an "opv" value is present in the
// registry or if Chrome's version as registered with Omaha doesn't match the // registry or if Chrome's version as registered with Omaha doesn't match the
// current version. // current version.
base::string16 clients_key_path = base::string16 clients_key_path = install_static::GetClientsKeyPath();
install_static::GetClientsKeyPath(install_static::GetAppGuid());
const HKEY root = install_static::IsSystemInstall() ? HKEY_LOCAL_MACHINE const HKEY root = install_static::IsSystemInstall() ? HKEY_LOCAL_MACHINE
: HKEY_CURRENT_USER; : HKEY_CURRENT_USER;
base::win::RegKey clients_key; base::win::RegKey clients_key;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment