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