diff options
-rw-r--r-- | chrome/installer/util/install_util.cc | 17 | ||||
-rw-r--r-- | chrome/installer/util/install_util_unittest.cc | 53 | ||||
-rw-r--r-- | chrome/installer/util/util_constants.cc | 4 | ||||
-rw-r--r-- | chrome/installer/util/util_constants.h | 6 |
4 files changed, 72 insertions, 8 deletions
diff --git a/chrome/installer/util/install_util.cc b/chrome/installer/util/install_util.cc index e36fa43..15a9dab 100644 --- a/chrome/installer/util/install_util.cc +++ b/chrome/installer/util/install_util.cc @@ -195,8 +195,21 @@ void InstallUtil::UpdateInstallerStage(bool system_install, LONG result = state_key.Open(root, state_key_path.c_str(), KEY_QUERY_VALUE | KEY_SET_VALUE); if (result == ERROR_SUCCESS) { - // TODO(grt): switch to using Google Update's new InstallerExtraCode1 value - // once it exists. In the meantime, encode the stage into the channel name. + if (stage == installer::NO_STAGE) { + result = state_key.DeleteValue(installer::kInstallerExtraCode1); + LOG_IF(ERROR, result != ERROR_SUCCESS && result != ERROR_FILE_NOT_FOUND) + << "Failed deleting installer stage from " << state_key_path + << "; result: " << result; + } else { + const DWORD extra_code_1 = static_cast<DWORD>(stage); + result = state_key.WriteValue(installer::kInstallerExtraCode1, + extra_code_1); + LOG_IF(ERROR, result != ERROR_SUCCESS) + << "Failed writing installer stage to " << state_key_path + << "; result: " << result; + } + // TODO(grt): Remove code below here once we're convinced that our use of + // Google Update's new InstallerExtraCode1 value is good. installer::ChannelInfo channel_info; // This will return false if the "ap" value isn't present, which is fine. channel_info.Initialize(state_key); diff --git a/chrome/installer/util/install_util_unittest.cc b/chrome/installer/util/install_util_unittest.cc index c5654f1..b579746 100644 --- a/chrome/installer/util/install_util_unittest.cc +++ b/chrome/installer/util/install_util_unittest.cc @@ -69,7 +69,7 @@ TEST_F(InstallUtilTest, GetCurrentDate) { } } -TEST_F(InstallUtilTest, UpdateInstallerStage) { +TEST_F(InstallUtilTest, UpdateInstallerStageAP) { const bool system_level = false; const HKEY root = system_level ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; std::wstring state_key_path(L"PhonyClientState"); @@ -119,6 +119,57 @@ TEST_F(InstallUtilTest, UpdateInstallerStage) { TempRegKeyOverride::DeleteAllTempKeys(); } +TEST_F(InstallUtilTest, UpdateInstallerStage) { + const bool system_level = false; + const HKEY root = system_level ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; + std::wstring state_key_path(L"PhonyClientState"); + + // Update the stage when there's no "InstallerExtraCode1" value. + { + TempRegKeyOverride override(root, L"root_inst_res"); + RegKey(root, state_key_path.c_str(), KEY_SET_VALUE) + .DeleteValue(installer::kInstallerExtraCode1); + InstallUtil::UpdateInstallerStage(system_level, state_key_path, + installer::BUILDING); + DWORD value; + EXPECT_EQ(ERROR_SUCCESS, + RegKey(root, state_key_path.c_str(), KEY_QUERY_VALUE) + .ReadValueDW(installer::kInstallerExtraCode1, &value)); + EXPECT_EQ(static_cast<DWORD>(installer::BUILDING), value); + } + TempRegKeyOverride::DeleteAllTempKeys(); + + // Update the stage when there is an "InstallerExtraCode1" value. + { + TempRegKeyOverride override(root, L"root_inst_res"); + RegKey(root, state_key_path.c_str(), KEY_SET_VALUE) + .WriteValue(installer::kInstallerExtraCode1, + static_cast<DWORD>(installer::UNPACKING)); + InstallUtil::UpdateInstallerStage(system_level, state_key_path, + installer::BUILDING); + DWORD value; + EXPECT_EQ(ERROR_SUCCESS, + RegKey(root, state_key_path.c_str(), KEY_QUERY_VALUE) + .ReadValueDW(installer::kInstallerExtraCode1, &value)); + EXPECT_EQ(static_cast<DWORD>(installer::BUILDING), value); + } + TempRegKeyOverride::DeleteAllTempKeys(); + + // Clear the stage. + { + TempRegKeyOverride override(root, L"root_inst_res"); + RegKey(root, state_key_path.c_str(), KEY_SET_VALUE) + .WriteValue(installer::kInstallerExtraCode1, static_cast<DWORD>(5)); + InstallUtil::UpdateInstallerStage(system_level, state_key_path, + installer::NO_STAGE); + DWORD value; + EXPECT_EQ(ERROR_FILE_NOT_FOUND, + RegKey(root, state_key_path.c_str(), KEY_QUERY_VALUE) + .ReadValueDW(installer::kInstallerExtraCode1, &value)); + } + TempRegKeyOverride::DeleteAllTempKeys(); +} + TEST_F(InstallUtilTest, DeleteRegistryKeyIf) { const HKEY root = HKEY_CURRENT_USER; std::wstring parent_key_path(L"SomeKey\\ToDelete"); diff --git a/chrome/installer/util/util_constants.cc b/chrome/installer/util/util_constants.cc index 63baee9..c65b1de 100644 --- a/chrome/installer/util/util_constants.cc +++ b/chrome/installer/util/util_constants.cc @@ -182,13 +182,13 @@ const wchar_t kUninstallArgumentsField[] = L"UninstallArguments"; const wchar_t kUninstallDisplayNameField[] = L"DisplayName"; const char kUninstallMetricsName[] = "uninstall_metrics"; const wchar_t kUninstallInstallationDate[] = L"installation_date"; -const wchar_t kInstallerResult[] = L"InstallerResult"; const wchar_t kInstallerError[] = L"InstallerError"; +const wchar_t kInstallerExtraCode1[] = L"InstallerExtraCode1"; +const wchar_t kInstallerResult[] = L"InstallerResult"; const wchar_t kInstallerResultUIString[] = L"InstallerResultUIString"; const wchar_t kInstallerSuccessLaunchCmdLine[] = L"InstallerSuccessLaunchCmdLine"; -const wchar_t kOptionCeee[] = L"ceee"; const wchar_t kOptionMultiInstall[] = L"multi-install"; const wchar_t kOptionReadyMode[] = L"ready-mode"; diff --git a/chrome/installer/util/util_constants.h b/chrome/installer/util/util_constants.h index cb183f0..3aced6c 100644 --- a/chrome/installer/util/util_constants.h +++ b/chrome/installer/util/util_constants.h @@ -186,14 +186,14 @@ extern const wchar_t kUninstallInstallationDate[]; extern const char kUninstallMetricsName[]; extern const wchar_t kUninstallStringField[]; -// Used by InstallUtil::WriteInstallerResult. -extern const wchar_t kInstallerResult[]; +// Google Update installer result API extern const wchar_t kInstallerError[]; +extern const wchar_t kInstallerExtraCode1[]; +extern const wchar_t kInstallerResult[]; extern const wchar_t kInstallerResultUIString[]; extern const wchar_t kInstallerSuccessLaunchCmdLine[]; // Product options. -extern const wchar_t kOptionCeee[]; extern const wchar_t kOptionMultiInstall[]; extern const wchar_t kOptionReadyMode[]; |