diff options
author | Ben Murdoch <benm@google.com> | 2014-07-20 18:25:52 -0700 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2014-07-20 18:25:52 -0700 |
commit | 116680a4aac90f2aa7413d9095a592090648e557 (patch) | |
tree | f7c6fed0e63d6a2804243d4a31a752dca39fb076 /chrome/installer | |
parent | 1f14a4515e04c9ffc9bac4dd1e2f68611626b800 (diff) | |
download | chromium_org-116680a4aac90f2aa7413d9095a592090648e557.tar.gz |
Merge from Chromium at DEPS revision 284076
This commit was generated by merge_to_master.py.
Change-Id: I9a279485b02fe7ceddcd32d992a714ff132e99ae
Diffstat (limited to 'chrome/installer')
31 files changed, 382 insertions, 254 deletions
diff --git a/chrome/installer/gcapi/gcapi.cc b/chrome/installer/gcapi/gcapi.cc index 3d73af0ba6..0606988ab8 100644 --- a/chrome/installer/gcapi/gcapi.cc +++ b/chrome/installer/gcapi/gcapi.cc @@ -602,7 +602,7 @@ int __stdcall GoogleChromeDaysSinceLastRun() { kChromeRegClientStateKey, KEY_QUERY_VALUE | KEY_WOW64_32KEY); if (client_state.Valid()) { - std::wstring last_run; + base::string16 last_run; int64 last_run_value = 0; if (client_state.ReadValue(google_update::kRegLastRunTimeField, &last_run) == ERROR_SUCCESS && @@ -715,7 +715,7 @@ BOOL __stdcall CanOfferRelaunch(const wchar_t** partner_brandcode_list, // b) the installed brandcode should belong to that partner (in // brandcode_list); - std::wstring installed_brandcode; + base::string16 installed_brandcode; bool valid_brandcode = false; if (GoogleUpdateSettings::GetBrand(&installed_brandcode)) { for (int i = 0; i < partner_brandcode_list_length; ++i) { diff --git a/chrome/installer/linux/debian/build.sh b/chrome/installer/linux/debian/build.sh index 9431844dc4..9f5c02ca3b 100755 --- a/chrome/installer/linux/debian/build.sh +++ b/chrome/installer/linux/debian/build.sh @@ -275,12 +275,13 @@ echo "$DPKG_SHLIB_DEPS" | sed 's/, /\n/g' | \ # Compare the expected dependency list to the generate list. BAD_DIFF=0 -diff "$SCRIPTDIR/expected_deps" actual || BAD_DIFF=1 +diff "$SCRIPTDIR/expected_deps_$TARGETARCH" actual || BAD_DIFF=1 if [ $BAD_DIFF -ne 0 ] && [ -z "${IGNORE_DEPS_CHANGES:-}" ]; then echo echo "ERROR: Shared library dependencies changed!" echo "If this is intentional, please update:" - echo "chrome/installer/linux/debian/expected_deps" + echo "chrome/installer/linux/debian/expected_deps_ia32" + echo "chrome/installer/linux/debian/expected_deps_x64" echo exit $BAD_DIFF fi diff --git a/chrome/installer/linux/debian/expected_deps b/chrome/installer/linux/debian/expected_deps_ia32 index ec92bc99f9..ec92bc99f9 100644 --- a/chrome/installer/linux/debian/expected_deps +++ b/chrome/installer/linux/debian/expected_deps_ia32 diff --git a/chrome/installer/linux/debian/expected_deps_x64 b/chrome/installer/linux/debian/expected_deps_x64 new file mode 100644 index 0000000000..b0d25f00e4 --- /dev/null +++ b/chrome/installer/linux/debian/expected_deps_x64 @@ -0,0 +1,30 @@ +gconf-service +libasound2 (>= 1.0.23) +libc6 (>= 2.11) +libcairo2 (>= 1.6.0) +libcap2 (>= 2.10) +libcups2 (>= 1.4.0) +libdbus-1-3 (>= 1.2.14) +libexpat1 (>= 1.95.8) +libfontconfig1 (>= 2.8.0) +libfreetype6 (>= 2.3.9) +libgconf-2-4 (>= 2.31.1) +libgdk-pixbuf2.0-0 (>= 2.22.0) +libglib2.0-0 (>= 2.28.0) +libgtk2.0-0 (>= 2.24.0) +libnspr4 (>= 1.8.0.10) +libnss3 (>= 3.14.3) +libpango1.0-0 (>= 1.22.0) +libstdc++6 (>= 4.6) +libudev0 (>= 147) +libx11-6 (>= 2:1.4.99.1) +libxcomposite1 (>= 1:0.3-1) +libxcursor1 (>> 1.1.2) +libxdamage1 (>= 1:1.1) +libxext6 +libxfixes3 (>= 1:5.0) +libxi6 (>= 2:1.2.99.4) +libxrandr2 (>= 2:1.2.99.2) +libxrender1 +libxss1 +libxtst6 diff --git a/chrome/installer/linux/rpm/expected_deps_i386 b/chrome/installer/linux/rpm/expected_deps_i386 index d301086314..8d05e4d5b5 100644 --- a/chrome/installer/linux/rpm/expected_deps_i386 +++ b/chrome/installer/linux/rpm/expected_deps_i386 @@ -17,7 +17,6 @@ libc.so.6(GLIBC_2.3.4) libc.so.6(GLIBC_2.4) libc.so.6(GLIBC_2.6) libc.so.6(GLIBC_2.7) -libc.so.6(GLIBC_2.8) libc.so.6(GLIBC_2.9) libcups.so.2 libdbus-1.so.3 @@ -28,8 +27,7 @@ libexpat.so.1 libfontconfig.so.1 libfreetype.so.6 libgcc_s.so.1 -libgcc_s.so.1(GCC_3.4) -libgcc_s.so.1(GCC_4.0.0) +libgcc_s.so.1(GCC_3.0) libgcc_s.so.1(GLIBC_2.0) libgconf-2.so.4 libgdk_pixbuf-2.0.so.0 @@ -62,7 +60,6 @@ libstdc++.so.6(GLIBCXX_3.4) libstdc++.so.6(GLIBCXX_3.4.10) libstdc++.so.6(GLIBCXX_3.4.11) libstdc++.so.6(GLIBCXX_3.4.15) -libstdc++.so.6(GLIBCXX_3.4.5) libstdc++.so.6(GLIBCXX_3.4.9) libX11.so.6 libXcomposite.so.1 diff --git a/chrome/installer/linux/rpm/expected_deps_x86_64 b/chrome/installer/linux/rpm/expected_deps_x86_64 index e5b53979d7..c96cfc1024 100644 --- a/chrome/installer/linux/rpm/expected_deps_x86_64 +++ b/chrome/installer/linux/rpm/expected_deps_x86_64 @@ -13,7 +13,6 @@ libc.so.6(GLIBC_2.3)(64bit) libc.so.6(GLIBC_2.4)(64bit) libc.so.6(GLIBC_2.6)(64bit) libc.so.6(GLIBC_2.7)(64bit) -libc.so.6(GLIBC_2.8)(64bit) libc.so.6(GLIBC_2.9)(64bit) libcups.so.2()(64bit) libdbus-1.so.3()(64bit) @@ -22,9 +21,6 @@ libdl.so.2(GLIBC_2.2.5)(64bit) libexpat.so.1()(64bit) libfontconfig.so.1()(64bit) libfreetype.so.6()(64bit) -libgcc_s.so.1()(64bit) -libgcc_s.so.1(GCC_3.4)(64bit) -libgcc_s.so.1(GCC_4.0.0)(64bit) libgconf-2.so.4()(64bit) libgdk_pixbuf-2.0.so.0()(64bit) libgdk-x11-2.0.so.0()(64bit) @@ -51,7 +47,6 @@ libstdc++.so.6()(64bit) libstdc++.so.6(GLIBCXX_3.4.10)(64bit) libstdc++.so.6(GLIBCXX_3.4.11)(64bit) libstdc++.so.6(GLIBCXX_3.4.15)(64bit) -libstdc++.so.6(GLIBCXX_3.4.5)(64bit) libstdc++.so.6(GLIBCXX_3.4)(64bit) libstdc++.so.6(GLIBCXX_3.4.9)(64bit) libX11.so.6()(64bit) diff --git a/chrome/installer/mini_installer.gyp b/chrome/installer/mini_installer.gyp index bb92eb25b9..115e84767d 100644 --- a/chrome/installer/mini_installer.gyp +++ b/chrome/installer/mini_installer.gyp @@ -39,10 +39,12 @@ 'mini_installer/configuration.h', 'mini_installer/decompress.cc', 'mini_installer/decompress.h', + 'mini_installer/exit_code.h', 'mini_installer/mini_installer.cc', - 'mini_installer/mini_installer.h', 'mini_installer/mini_installer.ico', 'mini_installer/mini_installer.rc', + 'mini_installer/mini_installer_constants.cc', + 'mini_installer/mini_installer_constants.h', 'mini_installer/mini_installer_exe_version.rc.version', 'mini_installer/mini_installer_resource.h', 'mini_installer/mini_string.cc', diff --git a/chrome/installer/mini_installer.gypi b/chrome/installer/mini_installer.gypi index 755b4358bd..c43a3394d3 100644 --- a/chrome/installer/mini_installer.gypi +++ b/chrome/installer/mini_installer.gypi @@ -22,10 +22,12 @@ 'mini_installer/configuration.h', 'mini_installer/decompress.cc', 'mini_installer/decompress.h', + 'mini_installer/exit_code.h', 'mini_installer/mini_installer.cc', - 'mini_installer/mini_installer.h', 'mini_installer/mini_installer.ico', 'mini_installer/mini_installer.rc', + 'mini_installer/mini_installer_constants.cc', + 'mini_installer/mini_installer_constants.h', 'mini_installer/mini_installer_exe_version.rc.version', 'mini_installer/mini_installer_resource.h', 'mini_installer/mini_string.cc', diff --git a/chrome/installer/mini_installer/exit_code.h b/chrome/installer/mini_installer/exit_code.h new file mode 100644 index 0000000000..38469e7368 --- /dev/null +++ b/chrome/installer/mini_installer/exit_code.h @@ -0,0 +1,25 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_INSTALLER_MINI_INSTALLER_EXIT_CODE_H_ +#define CHROME_INSTALLER_MINI_INSTALLER_EXIT_CODE_H_ + +namespace mini_installer { + +// mini_installer process exit codes (the underlying type is uint32_t). +enum ExitCode { + SUCCESS_EXIT_CODE = 0, + GENERIC_ERROR = 1, + // The next three generic values are here for historic reasons. New additions + // should have values strictly greater than them. This is to prevent + // collisions with setup.exe's installer::InstallStatus enum since the two are + // surfaced similarly by Google Update. + GENERIC_INITIALIZATION_FAILURE = 101, + GENERIC_UNPACKING_FAILURE = 102, + GENERIC_SETUP_FAILURE = 103, +}; + +} // namespace mini_installer + +#endif // CHROME_INSTALLER_MINI_INSTALLER_EXIT_CODE_H_ diff --git a/chrome/installer/mini_installer/mini_installer.cc b/chrome/installer/mini_installer/mini_installer.cc index 8709455309..da3cf91d5a 100644 --- a/chrome/installer/mini_installer/mini_installer.cc +++ b/chrome/installer/mini_installer/mini_installer.cc @@ -27,12 +27,14 @@ #include "chrome/installer/mini_installer/appid.h" #include "chrome/installer/mini_installer/configuration.h" #include "chrome/installer/mini_installer/decompress.h" -#include "chrome/installer/mini_installer/mini_installer.h" +#include "chrome/installer/mini_installer/exit_code.h" +#include "chrome/installer/mini_installer/mini_installer_constants.h" #include "chrome/installer/mini_installer/mini_string.h" #include "chrome/installer/mini_installer/pe_resource.h" namespace mini_installer { +typedef DWORD ProcessExitCode; typedef StackString<MAX_PATH> PathString; typedef StackString<MAX_PATH * 4> CommandString; @@ -143,7 +145,7 @@ bool ReadValueFromRegistry(HKEY root_key, const wchar_t *sub_key, bool OpenClientStateKey(HKEY root_key, const wchar_t* app_guid, REGSAM access, RegKey* key) { PathString client_state_key; - return client_state_key.assign(kApRegistryKeyBase) && + return client_state_key.assign(kClientStateKeyBase) && client_state_key.append(app_guid) && (key->Open(root_key, client_state_key.get(), @@ -184,7 +186,7 @@ void SetInstallerFlags(const Configuration& configuration) { if (configuration.is_multi_install()) { if (OpenClientStateKey(root_key, app_guid, key_access, &key)) { // The product has a client state key. See if it's a single-install. - ret = key.ReadValue(kApRegistryValueName, value.get(), value.capacity()); + ret = key.ReadValue(kApRegistryValue, value.get(), value.capacity()); if (ret != ERROR_FILE_NOT_FOUND && (ret != ERROR_SUCCESS || FindTagInStr(value.get(), kMultiInstallTag, NULL))) { @@ -204,7 +206,7 @@ void SetInstallerFlags(const Configuration& configuration) { return; value.clear(); - ret = key.ReadValue(kApRegistryValueName, value.get(), value.capacity()); + ret = key.ReadValue(kApRegistryValue, value.get(), value.capacity()); } // The conditions below are handling two cases: @@ -218,7 +220,7 @@ void SetInstallerFlags(const Configuration& configuration) { if (!StrEndsWith(value.get(), kFullInstallerSuffix) && value.append(kFullInstallerSuffix)) { - key.WriteValue(kApRegistryValueName, value.get()); + key.WriteValue(kApRegistryValue, value.get()); } } } @@ -232,7 +234,7 @@ bool GetSetupExePathForGuidFromRegistry(bool system_level, const HKEY root_key = system_level ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; RegKey key; return OpenClientStateKey(root_key, app_guid, KEY_QUERY_VALUE, &key) && - (key.ReadValue(kUninstallRegistryValueName, path, size) == ERROR_SUCCESS); + (key.ReadValue(kUninstallRegistryValue, path, size) == ERROR_SUCCESS); } // Gets the setup.exe path from Registry by looking the value of Uninstall @@ -269,10 +271,11 @@ bool GetSetupExePathFromRegistry(const Configuration& configuration, return false; } -// Calls CreateProcess with good default parameters and waits for the process -// to terminate returning the process exit code. +// Calls CreateProcess with good default parameters and waits for the process to +// terminate returning the process exit code. |exit_code|, if non-NULL, is +// populated with the process exit code. bool RunProcessAndWait(const wchar_t* exe_path, wchar_t* cmdline, - int* exit_code) { + ProcessExitCode* exit_code) { STARTUPINFOW si = {sizeof(si)}; PROCESS_INFORMATION pi = {0}; if (!::CreateProcess(exe_path, cmdline, NULL, NULL, FALSE, CREATE_NO_WINDOW, @@ -287,10 +290,8 @@ bool RunProcessAndWait(const wchar_t* exe_path, wchar_t* cmdline, if (WAIT_OBJECT_0 != wr) { ret = false; } else if (exit_code) { - if (!::GetExitCodeProcess(pi.hProcess, - reinterpret_cast<DWORD*>(exit_code))) { + if (!::GetExitCodeProcess(pi.hProcess, exit_code)) ret = false; - } } ::CloseHandle(pi.hProcess); @@ -352,7 +353,7 @@ BOOL CALLBACK OnResourceFound(HMODULE module, const wchar_t* type, !resource.WriteToDisk(full_path.get())) return FALSE; - if (StrStartsWith(name, kChromePrefix)) { + if (StrStartsWith(name, kChromeArchivePrefix)) { if (!ctx->chrome_resource_path->assign(full_path.get())) return FALSE; } else if (StrStartsWith(name, kSetupPrefix)) { @@ -382,7 +383,7 @@ bool UnpackBinaryResources(const Configuration& configuration, HMODULE module, // Generate the setup.exe path where we patch/uncompress setup resource. PathString setup_dest_path; if (!setup_dest_path.assign(base_path) || - !setup_dest_path.append(kSetupName)) + !setup_dest_path.append(kSetupExe)) return false; // Prepare the input to OnResourceFound method that needs a location where @@ -408,10 +409,11 @@ bool UnpackBinaryResources(const Configuration& configuration, HMODULE module, bool success = true; if (!GetSetupExePathFromRegistry(configuration, cmd_line.get(), cmd_line.capacity()) || + !cmd_line.append(L" --") || !cmd_line.append(kCmdUpdateSetupExe) || !cmd_line.append(L"=\"") || !cmd_line.append(setup_path->get()) || - !cmd_line.append(L"\"") || + !cmd_line.append(L"\" --") || !cmd_line.append(kCmdNewSetupExe) || !cmd_line.append(L"=\"") || !cmd_line.append(setup_dest_path.get()) || @@ -425,10 +427,10 @@ bool UnpackBinaryResources(const Configuration& configuration, HMODULE module, // installer results for consumption by Google Update. AppendCommandLineFlags(configuration, &cmd_line); - int exit_code = 0; + ProcessExitCode exit_code = SUCCESS_EXIT_CODE; if (success && (!RunProcessAndWait(NULL, cmd_line.get(), &exit_code) || - exit_code != ERROR_SUCCESS)) { + exit_code != SUCCESS_EXIT_CODE)) { success = false; } @@ -487,7 +489,7 @@ bool UnpackBinaryResources(const Configuration& configuration, HMODULE module, // Executes setup.exe, waits for it to finish and returns the exit code. bool RunSetup(const Configuration& configuration, const wchar_t* archive_path, - const wchar_t* setup_path, int* exit_code) { + const wchar_t* setup_path, ProcessExitCode* exit_code) { // There could be three full paths in the command line for setup.exe (path // to exe itself, path to archive and path to log file), so we declare // total size as three + one additional to hold command line options. @@ -505,7 +507,8 @@ bool RunSetup(const Configuration& configuration, const wchar_t* archive_path, } // Append the command line param for chrome archive file - if (!cmd_line.append(kCmdInstallArchive) || + if (!cmd_line.append(L" --") || + !cmd_line.append(kCmdInstallArchive) || !cmd_line.append(L"=\"") || !cmd_line.append(archive_path) || !cmd_line.append(L"\"")) @@ -714,14 +717,14 @@ void DeleteOldChromeTempDirectories() { // required actions taken. The installer must exit and return the returned // |exit_code|. bool ProcessNonInstallOperations(const Configuration& configuration, - int* exit_code) { + ProcessExitCode* exit_code) { bool ret = false; switch (configuration.operation()) { case Configuration::CLEANUP: // Cleanup has already taken place in DeleteOldChromeTempDirectories at // this point, so just tell our caller to exit early. - *exit_code = 0; + *exit_code = SUCCESS_EXIT_CODE; ret = true; break; @@ -741,8 +744,7 @@ bool ProcessNonInstallOperations(const Configuration& configuration, bool ShouldDeleteExtractedFiles() { wchar_t value[2] = {0}; if (ReadValueFromRegistry(HKEY_CURRENT_USER, kCleanupRegistryKey, - kCleanupRegistryValueName, value, - arraysize(value)) && + kCleanupRegistryValue, value, arraysize(value)) && value[0] == L'0') { return false; } @@ -752,7 +754,7 @@ bool ShouldDeleteExtractedFiles() { // Main function. First gets a working dir, unpacks the resources and finally // executes setup.exe to do the install/upgrade. -int WMain(HMODULE module) { +ProcessExitCode WMain(HMODULE module) { #if defined(COMPONENT_BUILD) if (::GetEnvironmentVariable(L"MINI_INSTALLER_TEST", NULL, 0) == 0) { static const wchar_t kComponentBuildIncompatibleMessage[] = @@ -760,7 +762,7 @@ int WMain(HMODULE module) { L" run setup.exe with the same command line instead. See" L" http://crbug.com/127233#c17 for details."; ::MessageBox(NULL, kComponentBuildIncompatibleMessage, NULL, MB_ICONERROR); - return 1; + return GENERIC_ERROR; } #endif @@ -772,7 +774,7 @@ int WMain(HMODULE module) { // TODO(grt): Make the exit codes more granular so we know where the popular // errors truly are. - int exit_code = 101; + ProcessExitCode exit_code = GENERIC_INITIALIZATION_FAILURE; // Parse the command line. Configuration configuration; @@ -780,13 +782,13 @@ int WMain(HMODULE module) { return exit_code; if (configuration.query_component_build()) { - // Exit immediately with an exit code of 1 to indicate component build and 0 - // to indicate static build. This is used by the tests in - // /src/chrome/test/mini_installer/. + // Exit immediately with a generic success exit code (0) to indicate + // component build and a generic failure exit code (1) to indicate static + // build. This is used by the tests in /src/chrome/test/mini_installer/. #if defined(COMPONENT_BUILD) - return 1; + return SUCCESS_EXIT_CODE; #else - return 0; + return GENERIC_ERROR; #endif } @@ -798,7 +800,7 @@ int WMain(HMODULE module) { // First get a path where we can extract payload PathString base_path; if (!GetWorkDir(module, &base_path)) - return 101; + return GENERIC_INITIALIZATION_FAILURE; #if defined(GOOGLE_CHROME_BUILD) // Set the magic suffix in registry to try full installer next time. We ignore @@ -812,7 +814,7 @@ int WMain(HMODULE module) { PathString setup_path; if (!UnpackBinaryResources(configuration, module, base_path.get(), &archive_path, &setup_path)) { - exit_code = 102; + exit_code = GENERIC_UNPACKING_FAILURE; } else { // While unpacking the binaries, we paged in a whole bunch of memory that // we don't need anymore. Let's give it back to the pool before running @@ -820,7 +822,7 @@ int WMain(HMODULE module) { ::SetProcessWorkingSetSize(::GetCurrentProcess(), -1, -1); if (!RunSetup(configuration, archive_path.get(), setup_path.get(), &exit_code)) { - exit_code = 103; + exit_code = GENERIC_SETUP_FAILURE; } } @@ -833,7 +835,8 @@ int WMain(HMODULE module) { } // namespace mini_installer int MainEntryPoint() { - int result = mini_installer::WMain(::GetModuleHandle(NULL)); + mini_installer::ProcessExitCode result = + mini_installer::WMain(::GetModuleHandle(NULL)); ::ExitProcess(result); } diff --git a/chrome/installer/mini_installer/mini_installer.h b/chrome/installer/mini_installer/mini_installer.h deleted file mode 100644 index 6dc6f62d5d..0000000000 --- a/chrome/installer/mini_installer/mini_installer.h +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_INSTALLER_MINI_INSTALLER_MINI_INSTALLER_H_ -#define CHROME_INSTALLER_MINI_INSTALLER_MINI_INSTALLER_H_ - -namespace mini_installer { - -// Various filenames -const wchar_t kSetupName[] = L"setup.exe"; -const wchar_t kChromePrefix[] = L"chrome"; -const wchar_t kSetupPrefix[] = L"setup"; - -// setup.exe command line arguments -const wchar_t kCmdInstallArchive[] = L" --install-archive"; -const wchar_t kCmdUpdateSetupExe[] = L" --update-setup-exe"; -const wchar_t kCmdNewSetupExe[] = L" --new-setup-exe"; - -// Temp directory prefix that this process creates -const wchar_t kTempPrefix[] = L"CR_"; -// Google Update will use the full installer if this suffix is found in the ap -// value. -const wchar_t kFullInstallerSuffix[] = L"-full"; -// ap value tag for a multi-install product. -const wchar_t kMultiInstallTag[] = L"-multi"; - -// The resource types that would be unpacked from the mini installer. -// 'BN' is uncompressed binary and 'BL' is LZ compressed binary. -const wchar_t kBinResourceType[] = L"BN"; -const wchar_t kLZCResourceType[] = L"BL"; -const wchar_t kLZMAResourceType[] = L"B7"; - -// Registry key to get uninstall command -const wchar_t kApRegistryValueName[] = L"ap"; -// Registry key that tells Chrome installer not to delete extracted files. -const wchar_t kCleanupRegistryValueName[] = L"ChromeInstallerCleanup"; -// Registry key to get uninstall command -const wchar_t kUninstallRegistryValueName[] = L"UninstallString"; - -// Paths for the above registry keys -#if defined(GOOGLE_CHROME_BUILD) -// The concatenation of this plus the Google Update GUID is the app registry -// key. -const wchar_t kApRegistryKeyBase[] = L"Software\\Google\\Update\\ClientState\\"; -const wchar_t kUninstallRegistryKey[] = - L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Google Chrome"; -const wchar_t kCleanupRegistryKey[] = L"Software\\Google"; -#else -const wchar_t kApRegistryKeyBase[] = L"Software\\Chromium"; -const wchar_t kUninstallRegistryKey[] = - L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Chromium"; -const wchar_t kCleanupRegistryKey[] = L"Software\\Chromium"; -#endif - -// One gigabyte is the biggest resource size that it can handle. -const int kMaxResourceSize = 1024*1024*1024; - -// This is the file that contains the list of files to be linked in the -// executable. This file is updated by the installer generator tool chain. -const wchar_t kManifestFilename[] = L"packed_files.txt"; - -} // namespace mini_installer - -#endif // CHROME_INSTALLER_MINI_INSTALLER_MINI_INSTALLER_H_ - diff --git a/chrome/installer/mini_installer/mini_installer_constants.cc b/chrome/installer/mini_installer/mini_installer_constants.cc new file mode 100644 index 0000000000..9a4f0792b0 --- /dev/null +++ b/chrome/installer/mini_installer/mini_installer_constants.cc @@ -0,0 +1,66 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/installer/mini_installer/mini_installer_constants.h" + +namespace mini_installer { + +// Various filenames and prefixes. +// The target name of the installer extracted from resources. +const wchar_t kSetupExe[] = L"setup.exe"; +// The prefix of the chrome archive resource. +const wchar_t kChromeArchivePrefix[] = L"chrome"; +// The prefix of the installer resource. +const wchar_t kSetupPrefix[] = L"setup"; + +// Command line switch names for setup.exe. +const wchar_t kCmdInstallArchive[] = L"install-archive"; +const wchar_t kCmdUpdateSetupExe[] = L"update-setup-exe"; +const wchar_t kCmdNewSetupExe[] = L"new-setup-exe"; + +// Temp directory prefix that this process creates. +const wchar_t kTempPrefix[] = L"CR_"; +// ap value suffix to force subsequent updates to use the full rather than +// differential updater. +const wchar_t kFullInstallerSuffix[] = L"-full"; +// ap value tag for a multi-install product. +const wchar_t kMultiInstallTag[] = L"-multi"; + +// The resource types that would be unpacked from the mini installer. +// Uncompressed binary. +const wchar_t kBinResourceType[] = L"BN"; +// LZ compressed binary. +const wchar_t kLZCResourceType[] = L"BL"; +// 7zip archive. +const wchar_t kLZMAResourceType[] = L"B7"; + +// Registry value names. +// The name of an app's Client State registry value that holds its tag/channel. +const wchar_t kApRegistryValue[] = L"ap"; +// The name of the value in kCleanupRegistryKey that tells the installer not to +// delete extracted files. +const wchar_t kCleanupRegistryValue[] = L"ChromeInstallerCleanup"; +// The name of an app's Client State registry value that holds the path to its +// uninstaller. +const wchar_t kUninstallRegistryValue[] = L"UninstallString"; + +// Registry key paths. +#if defined(GOOGLE_CHROME_BUILD) +// The path to the key containing each app's Client State registry key. +const wchar_t kClientStateKeyBase[] = + L"Software\\Google\\Update\\ClientState\\"; +// The path to the key in which kCleanupRegistryValue is found. +const wchar_t kCleanupRegistryKey[] = + L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Google Chrome"; +#else +// The path to the key containing each app's Client State registry key. +const wchar_t kClientStateKeyBase[] = L"Software\\Chromium"; +// The path to the key in which kCleanupRegistryValue is found. +const wchar_t kCleanupRegistryKey[] = L"Software\\Chromium"; +#endif + +// One gigabyte is the biggest resource size that it can handle. +const size_t kMaxResourceSize = 1024*1024*1024; + +} // namespace mini_installer diff --git a/chrome/installer/mini_installer/mini_installer_constants.h b/chrome/installer/mini_installer/mini_installer_constants.h new file mode 100644 index 0000000000..a146e93685 --- /dev/null +++ b/chrome/installer/mini_installer/mini_installer_constants.h @@ -0,0 +1,42 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_INSTALLER_MINI_INSTALLER_MINI_INSTALLER_CONSTANTS_H_ +#define CHROME_INSTALLER_MINI_INSTALLER_MINI_INSTALLER_CONSTANTS_H_ + +namespace mini_installer { + +// Various filenames and prefixes. +extern const wchar_t kSetupExe[]; +extern const wchar_t kChromeArchivePrefix[]; +extern const wchar_t kSetupPrefix[]; + +// Unprefixed command line switch names for setup.exe. +extern const wchar_t kCmdInstallArchive[]; +extern const wchar_t kCmdUpdateSetupExe[]; +extern const wchar_t kCmdNewSetupExe[]; + +extern const wchar_t kTempPrefix[]; +extern const wchar_t kFullInstallerSuffix[]; +extern const wchar_t kMultiInstallTag[]; + +// The resource types that would be unpacked from the mini installer. +extern const wchar_t kBinResourceType[]; +extern const wchar_t kLZCResourceType[]; +extern const wchar_t kLZMAResourceType[]; + +// Registry value names. +extern const wchar_t kApRegistryValue[]; +extern const wchar_t kCleanupRegistryValue[]; +extern const wchar_t kUninstallRegistryValue[]; + +// Registry key paths. +extern const wchar_t kClientStateKeyBase[]; +extern const wchar_t kCleanupRegistryKey[]; + +extern const size_t kMaxResourceSize; + +} // namespace mini_installer + +#endif // CHROME_INSTALLER_MINI_INSTALLER_MINI_INSTALLER_CONSTANTS_H_ diff --git a/chrome/installer/setup/DEPS b/chrome/installer/setup/DEPS index a96cf4b697..503f7a08e1 100644 --- a/chrome/installer/setup/DEPS +++ b/chrome/installer/setup/DEPS @@ -1,4 +1,5 @@ include_rules = [ "+chrome/app", "+courgette", + "+chrome_elf/chrome_elf_constants.h", ] diff --git a/chrome/installer/setup/install_worker.cc b/chrome/installer/setup/install_worker.cc index 8fab21273e..ca39080071 100644 --- a/chrome/installer/setup/install_worker.cc +++ b/chrome/installer/setup/install_worker.cc @@ -936,8 +936,8 @@ void AddEulaAcceptedWorkItems(const InstallationState& original_state, // Copy the value from the product with the greatest value. bool have_eula_accepted = false; - BrowserDistribution::Type product_type; - DWORD eula_accepted; + BrowserDistribution::Type product_type = BrowserDistribution::NUM_TYPES; + DWORD eula_accepted = 0; const Products& products = installer_state.products(); for (Products::const_iterator it = products.begin(); it < products.end(); ++it) { diff --git a/chrome/installer/setup/setup_util.cc b/chrome/installer/setup/setup_util.cc index c588406ac6..3f9c93703a 100644 --- a/chrome/installer/setup/setup_util.cc +++ b/chrome/installer/setup/setup_util.cc @@ -242,7 +242,7 @@ bool DeleteFileFromTempProcess(const base::FilePath& path, } } else { PLOG(ERROR) << "VirtualAllocEx"; - ::TerminateProcess(pi.hProcess, ~0); + ::TerminateProcess(pi.hProcess, ~static_cast<UINT>(0)); } ::CloseHandle(pi.hThread); ::CloseHandle(pi.hProcess); diff --git a/chrome/installer/setup/uninstall.cc b/chrome/installer/setup/uninstall.cc index 0f04768538..ac9484deff 100644 --- a/chrome/installer/setup/uninstall.cc +++ b/chrome/installer/setup/uninstall.cc @@ -47,6 +47,7 @@ #include "chrome/installer/util/shell_util.h" #include "chrome/installer/util/util_constants.h" #include "chrome/installer/util/work_item.h" +#include "chrome_elf/chrome_elf_constants.h" #include "content/public/common/result_codes.h" #include "rlz/lib/rlz_lib.h" @@ -864,6 +865,20 @@ void UninstallActiveSetupEntries(const InstallerState& installer_state, } } +// Removes the persistent blacklist state for the current user. Note: this will +// not remove the state for users other than the one uninstalling chrome on a +// system-level install (http://crbug.com/388725). Doing so would require +// extracting the per-user registry hive iteration from +// UninstallActiveSetupEntries so that it could service multiple tasks. +void RemoveBlacklistState() { + InstallUtil::DeleteRegistryKey(HKEY_CURRENT_USER, + blacklist::kRegistryBeaconPath, + 0); // wow64_access + InstallUtil::DeleteRegistryKey(HKEY_CURRENT_USER, + blacklist::kRegistryFinchListPath, + 0); // wow64_access +} + } // namespace DeleteResult DeleteChromeDirectoriesIfEmpty( @@ -1258,6 +1273,8 @@ InstallStatus UninstallProduct(const InstallationState& original_state, UninstallFirewallRules(browser_dist, base::FilePath(chrome_exe)); + RemoveBlacklistState(); + // Notify the shell that associations have changed since Chrome was likely // unregistered. SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL); diff --git a/chrome/installer/test/pe_image_resources.cc b/chrome/installer/test/pe_image_resources.cc index 3b39b6923f..365e9669e7 100644 --- a/chrome/installer/test/pe_image_resources.cc +++ b/chrome/installer/test/pe_image_resources.cc @@ -27,7 +27,7 @@ bool StructureAt(const uint8* data, size_t data_size, const T** structure) { // static bool EnumResourcesWorker( const base::win::PEImage& image, const uint8* tree_base, DWORD tree_size, - DWORD directory_offset, upgrade_test::EntryPath &path, + DWORD directory_offset, upgrade_test::EntryPath* path, upgrade_test::EnumResource_Fn callback, uintptr_t context) { bool success = true; const IMAGE_RESOURCE_DIRECTORY* resource_directory; @@ -69,11 +69,11 @@ bool EnumResourcesWorker( success = false; break; } - path.push_back( + path->push_back( upgrade_test::EntryId(std::wstring(&dir_string->NameString[0], dir_string->Length))); } else { - path.push_back(upgrade_test::EntryId(scan->Id)); + path->push_back(upgrade_test::EntryId(scan->Id)); } if (scan->DataIsDirectory) { success = EnumResourcesWorker(image, tree_base, tree_size, @@ -88,7 +88,7 @@ bool EnumResourcesWorker( tree_base + tree_size) { // Despite what winnt.h says, OffsetToData is an RVA. callback( - path, + *path, reinterpret_cast<uint8*>(image.RVAToAddr(data_entry->OffsetToData)), data_entry->Size, data_entry->CodePage, context); } else { @@ -96,7 +96,7 @@ bool EnumResourcesWorker( success = false; } } - path.pop_back(); + path->pop_back(); } return success; @@ -112,11 +112,12 @@ bool EnumResources(const base::win::PEImage& image, EnumResource_Fn callback, DWORD resources_size = image.GetImageDirectoryEntrySize(IMAGE_DIRECTORY_ENTRY_RESOURCE); if (resources_size != 0) { + EntryPath path_storage; return EnumResourcesWorker( image, reinterpret_cast<uint8*>( image.GetImageDirectoryEntryAddr(IMAGE_DIRECTORY_ENTRY_RESOURCE)), - resources_size, 0, EntryPath(), callback, context); + resources_size, 0, &path_storage, callback, context); } return true; } diff --git a/chrome/installer/util/chrome_app_host_distribution.cc b/chrome/installer/util/chrome_app_host_distribution.cc index d69d84dc13..85e50d5a3c 100644 --- a/chrome/installer/util/chrome_app_host_distribution.cc +++ b/chrome/installer/util/chrome_app_host_distribution.cc @@ -28,8 +28,9 @@ const wchar_t kChromeAppHostGuid[] = L"{FDA71E6F-AC4C-4a00-8B70-9958A68906BF}"; } // namespace ChromeAppHostDistribution::ChromeAppHostDistribution() - : BrowserDistribution(CHROME_APP_HOST, - make_scoped_ptr( + : BrowserDistribution( + CHROME_APP_HOST, + scoped_ptr<AppRegistrationData>( new UpdatingAppRegistrationData(kChromeAppHostGuid))) { } diff --git a/chrome/installer/util/chrome_frame_distribution.cc b/chrome/installer/util/chrome_frame_distribution.cc index 385ba2f986..9f57ae61e0 100644 --- a/chrome/installer/util/chrome_frame_distribution.cc +++ b/chrome/installer/util/chrome_frame_distribution.cc @@ -26,8 +26,10 @@ const wchar_t kChromeFrameGuid[] = L"{8BA986DA-5100-405E-AA35-86F34A02ACBF}"; } ChromeFrameDistribution::ChromeFrameDistribution() - : BrowserDistribution(CHROME_FRAME, - make_scoped_ptr(new UpdatingAppRegistrationData(kChromeFrameGuid))) { + : BrowserDistribution( + CHROME_FRAME, + scoped_ptr<AppRegistrationData>( + new UpdatingAppRegistrationData(kChromeFrameGuid))) { } base::string16 ChromeFrameDistribution::GetBaseAppName() { diff --git a/chrome/installer/util/chromium_binaries_distribution.cc b/chrome/installer/util/chromium_binaries_distribution.cc index 2783c51630..30bf44f608 100644 --- a/chrome/installer/util/chromium_binaries_distribution.cc +++ b/chrome/installer/util/chromium_binaries_distribution.cc @@ -17,8 +17,9 @@ const wchar_t kChromiumBinariesName[] = L"Chromium Binaries"; } // namespace ChromiumBinariesDistribution::ChromiumBinariesDistribution() - : BrowserDistribution(CHROME_BINARIES, - make_scoped_ptr(new NonUpdatingAppRegistrationData( + : BrowserDistribution( + CHROME_BINARIES, + scoped_ptr<AppRegistrationData>(new NonUpdatingAppRegistrationData( base::string16(L"Software\\").append(kChromiumBinariesName)))), browser_distribution_( BrowserDistribution::GetSpecificDistribution(CHROME_BROWSER)) { diff --git a/chrome/installer/util/delete_after_reboot_helper_unittest.cc b/chrome/installer/util/delete_after_reboot_helper_unittest.cc index f114b8517d..4c635976cb 100644 --- a/chrome/installer/util/delete_after_reboot_helper_unittest.cc +++ b/chrome/installer/util/delete_after_reboot_helper_unittest.cc @@ -100,8 +100,8 @@ class DeleteAfterRebootHelperTest : public testing::Test { TEST_F(DeleteAfterRebootHelperTest, TestStringListToMultiSZConversions) { struct StringTest { - wchar_t* test_name; - wchar_t* str; + const wchar_t* test_name; + const wchar_t* str; DWORD length; size_t count; } tests[] = { @@ -113,26 +113,29 @@ TEST_F(DeleteAfterRebootHelperTest, TestStringListToMultiSZConversions) { for (int i = 0; i < arraysize(tests); i++) { std::vector<PendingMove> string_list; EXPECT_TRUE(SUCCEEDED( - MultiSZBytesToStringArray(reinterpret_cast<char*>(tests[i].str), - tests[i].length, &string_list))) + MultiSZBytesToStringArray(reinterpret_cast<const char*>(tests[i].str), + tests[i].length, + &string_list))) << tests[i].test_name; EXPECT_EQ(tests[i].count, string_list.size()) << tests[i].test_name; std::vector<char> buffer; buffer.resize(WStringPairListSize(string_list)); StringArrayToMultiSZBytes(string_list, &buffer); - EXPECT_TRUE(CompareBuffers(&buffer[0], - reinterpret_cast<char*>(tests[i].str), - tests[i].length)) << tests[i].test_name; + EXPECT_TRUE(CompareBuffers(const_cast<const char*>(&buffer[0]), + reinterpret_cast<const char*>(tests[i].str), + tests[i].length)) + << tests[i].test_name; } - StringTest failures[] = - { L"malformed", reinterpret_cast<wchar_t*>("oddnumb\0\0"), 9, 1 }; + StringTest failures[] = { + L"malformed", reinterpret_cast<const wchar_t*>("oddnumb\0\0"), 9, 1}; for (int i = 0; i < arraysize(failures); i++) { std::vector<PendingMove> string_list; - EXPECT_FALSE(SUCCEEDED( - MultiSZBytesToStringArray(reinterpret_cast<char*>(failures[i].str), - failures[i].length, &string_list))) + EXPECT_FALSE(SUCCEEDED(MultiSZBytesToStringArray( + reinterpret_cast<const char*>(failures[i].str), + failures[i].length, + &string_list))) << failures[i].test_name; } } diff --git a/chrome/installer/util/google_chrome_binaries_distribution.cc b/chrome/installer/util/google_chrome_binaries_distribution.cc index bdf1bf6f09..c5640f8163 100644 --- a/chrome/installer/util/google_chrome_binaries_distribution.cc +++ b/chrome/installer/util/google_chrome_binaries_distribution.cc @@ -19,9 +19,8 @@ const wchar_t kChromeBinariesName[] = L"Google Chrome binaries"; } // namespace GoogleChromeBinariesDistribution::GoogleChromeBinariesDistribution() - : ChromiumBinariesDistribution( - make_scoped_ptr( - new UpdatingAppRegistrationData(kChromeBinariesGuid))) { + : ChromiumBinariesDistribution(scoped_ptr<AppRegistrationData>( + new UpdatingAppRegistrationData(kChromeBinariesGuid))) { } base::string16 GoogleChromeBinariesDistribution::GetDisplayName() { diff --git a/chrome/installer/util/google_chrome_distribution.cc b/chrome/installer/util/google_chrome_distribution.cc index 3d1522d6a1..e287e87e6d 100644 --- a/chrome/installer/util/google_chrome_distribution.cc +++ b/chrome/installer/util/google_chrome_distribution.cc @@ -63,8 +63,8 @@ base::string16 GetUninstallSurveyUrl() { GoogleChromeDistribution::GoogleChromeDistribution() : BrowserDistribution(CHROME_BROWSER, - make_scoped_ptr( - new UpdatingAppRegistrationData(kChromeGuid))) { + scoped_ptr<AppRegistrationData>( + new UpdatingAppRegistrationData(kChromeGuid))) { } GoogleChromeDistribution::GoogleChromeDistribution( diff --git a/chrome/installer/util/google_chrome_distribution_dummy.cc b/chrome/installer/util/google_chrome_distribution_dummy.cc index 012b72d666..86016bd1e8 100644 --- a/chrome/installer/util/google_chrome_distribution_dummy.cc +++ b/chrome/installer/util/google_chrome_distribution_dummy.cc @@ -19,8 +19,9 @@ #include "chrome/installer/util/non_updating_app_registration_data.h" GoogleChromeDistribution::GoogleChromeDistribution() - : BrowserDistribution(CHROME_BROWSER, - make_scoped_ptr( + : BrowserDistribution( + CHROME_BROWSER, + scoped_ptr<AppRegistrationData>( new NonUpdatingAppRegistrationData(base::string16()))) { } diff --git a/chrome/installer/util/google_chrome_sxs_distribution.cc b/chrome/installer/util/google_chrome_sxs_distribution.cc index 5707660712..cd61cbd1bf 100644 --- a/chrome/installer/util/google_chrome_sxs_distribution.cc +++ b/chrome/installer/util/google_chrome_sxs_distribution.cc @@ -26,9 +26,8 @@ const wchar_t kCommandExecuteImplUuid[] = } // namespace GoogleChromeSxSDistribution::GoogleChromeSxSDistribution() - : GoogleChromeDistribution( - make_scoped_ptr( - new UpdatingAppRegistrationData(kChromeSxSGuid))) { + : GoogleChromeDistribution(scoped_ptr<AppRegistrationData>( + new UpdatingAppRegistrationData(kChromeSxSGuid))) { } base::string16 GoogleChromeSxSDistribution::GetBaseAppName() { diff --git a/chrome/installer/util/google_update_settings.cc b/chrome/installer/util/google_update_settings.cc index 94b7994f8b..4d53ecac94 100644 --- a/chrome/installer/util/google_update_settings.cc +++ b/chrome/installer/util/google_update_settings.cc @@ -5,7 +5,6 @@ #include "chrome/installer/util/google_update_settings.h" #include <algorithm> -#include <string> #include "base/command_line.h" #include "base/files/file_path.h" @@ -53,9 +52,9 @@ GoogleUpdateSettings::kDefaultUpdatePolicy = namespace { -bool ReadGoogleUpdateStrKey(const wchar_t* const name, std::wstring* value) { +bool ReadGoogleUpdateStrKey(const wchar_t* const name, base::string16* value) { BrowserDistribution* dist = BrowserDistribution::GetDistribution(); - std::wstring reg_path = dist->GetStateKey(); + base::string16 reg_path = dist->GetStateKey(); RegKey key(HKEY_CURRENT_USER, reg_path.c_str(), KEY_READ | KEY_WOW64_32KEY); if (key.ReadValue(name, value) != ERROR_SUCCESS) { RegKey hklm_key( @@ -72,8 +71,7 @@ bool ReadGoogleUpdateStrKey(const wchar_t* const name, std::wstring* value) { bool WriteGoogleUpdateStrKeyInternal(const AppRegistrationData& app_reg_data, bool system_install, const wchar_t* const name, - // presubmit: allow wstring - const std::wstring& value, + const base::string16& value, const wchar_t* const aggregate) { const REGSAM kAccess = KEY_SET_VALUE | KEY_WOW64_32KEY; if (system_install) { @@ -81,7 +79,7 @@ bool WriteGoogleUpdateStrKeyInternal(const AppRegistrationData& app_reg_data, // Machine installs require each OS user to write a unique key under a // named key in HKLM as well as an "aggregation" function that describes // how the values of multiple users are to be combined. - std::wstring uniquename; // presubmit: allow wstring + base::string16 uniquename; if (!base::win::GetUserSidString(&uniquename)) { NOTREACHED(); return false; @@ -101,7 +99,7 @@ bool WriteGoogleUpdateStrKeyInternal(const AppRegistrationData& app_reg_data, } bool WriteGoogleUpdateStrKey(const wchar_t* const name, - const std::wstring& value) { + const base::string16& value) { BrowserDistribution* dist = BrowserDistribution::GetDistribution(); return WriteGoogleUpdateStrKeyInternal( dist->GetAppRegistrationData(), false, name, value, NULL); @@ -109,11 +107,11 @@ bool WriteGoogleUpdateStrKey(const wchar_t* const name, bool ClearGoogleUpdateStrKey(const wchar_t* const name) { BrowserDistribution* dist = BrowserDistribution::GetDistribution(); - std::wstring reg_path = dist->GetStateKey(); + base::string16 reg_path = dist->GetStateKey(); RegKey key(HKEY_CURRENT_USER, reg_path.c_str(), KEY_READ | KEY_WRITE | KEY_WOW64_32KEY); - std::wstring value; + base::string16 value; if (key.ReadValue(name, &value) != ERROR_SUCCESS) return false; return (key.WriteValue(name, L"") == ERROR_SUCCESS); @@ -121,7 +119,7 @@ bool ClearGoogleUpdateStrKey(const wchar_t* const name) { bool RemoveGoogleUpdateStrKey(const wchar_t* const name) { BrowserDistribution* dist = BrowserDistribution::GetDistribution(); - std::wstring reg_path = dist->GetStateKey(); + base::string16 reg_path = dist->GetStateKey(); RegKey key(HKEY_CURRENT_USER, reg_path.c_str(), KEY_READ | KEY_WRITE | KEY_WOW64_32KEY); @@ -281,7 +279,7 @@ bool GoogleUpdateSettings::SetCollectStatsConsentAtLevel(bool system_install, // Write to ClientStateMedium for system-level; ClientState otherwise. HKEY root_key = system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; - std::wstring reg_path = + base::string16 reg_path = system_install ? dist->GetStateMediumKey() : dist->GetStateKey(); RegKey key; LONG result = key.Create( @@ -298,16 +296,16 @@ bool GoogleUpdateSettings::SetCollectStatsConsentAtLevel(bool system_install, return (result == ERROR_SUCCESS); } -bool GoogleUpdateSettings::GetMetricsId(std::string* metrics_id) { - std::wstring metrics_id_w; - bool rv = ReadGoogleUpdateStrKey(google_update::kRegMetricsId, &metrics_id_w); - *metrics_id = base::WideToUTF8(metrics_id_w); +bool GoogleUpdateSettings::LoadMetricsClientId(std::string* metrics_id) { + base::string16 metrics_id16; + bool rv = ReadGoogleUpdateStrKey(google_update::kRegMetricsId, &metrics_id16); + *metrics_id = base::UTF16ToUTF8(metrics_id16); return rv; } -bool GoogleUpdateSettings::SetMetricsId(const std::string& metrics_id) { - std::wstring metrics_id_w = base::UTF8ToWide(metrics_id); - return WriteGoogleUpdateStrKey(google_update::kRegMetricsId, metrics_id_w); +bool GoogleUpdateSettings::StoreMetricsClientId(const std::string& metrics_id) { + base::string16 metrics_id16 = base::UTF8ToUTF16(metrics_id); + return WriteGoogleUpdateStrKey(google_update::kRegMetricsId, metrics_id16); } // EULA consent is only relevant for system-level installs. @@ -318,7 +316,7 @@ bool GoogleUpdateSettings::SetEULAConsent( DCHECK(dist); const DWORD eula_accepted = consented ? 1 : 0; const REGSAM kAccess = KEY_SET_VALUE | KEY_WOW64_32KEY; - std::wstring reg_path = dist->GetStateMediumKey(); + base::string16 reg_path = dist->GetStateMediumKey(); bool succeeded = true; RegKey key; @@ -351,7 +349,7 @@ bool GoogleUpdateSettings::SetEULAConsent( } int GoogleUpdateSettings::GetLastRunTime() { - std::wstring time_s; + base::string16 time_s; if (!ReadGoogleUpdateStrKey(google_update::kRegLastRunTimeField, &time_s)) return -1; int64 time_i; @@ -372,32 +370,32 @@ bool GoogleUpdateSettings::RemoveLastRunTime() { return RemoveGoogleUpdateStrKey(google_update::kRegLastRunTimeField); } -bool GoogleUpdateSettings::GetBrowser(std::wstring* browser) { +bool GoogleUpdateSettings::GetBrowser(base::string16* browser) { return ReadGoogleUpdateStrKey(google_update::kRegBrowserField, browser); } -bool GoogleUpdateSettings::GetLanguage(std::wstring* language) { +bool GoogleUpdateSettings::GetLanguage(base::string16* language) { return ReadGoogleUpdateStrKey(google_update::kRegLangField, language); } -bool GoogleUpdateSettings::GetBrand(std::wstring* brand) { +bool GoogleUpdateSettings::GetBrand(base::string16* brand) { return ReadGoogleUpdateStrKey(google_update::kRegRLZBrandField, brand); } -bool GoogleUpdateSettings::GetReactivationBrand(std::wstring* brand) { +bool GoogleUpdateSettings::GetReactivationBrand(base::string16* brand) { return ReadGoogleUpdateStrKey(google_update::kRegRLZReactivationBrandField, brand); } -bool GoogleUpdateSettings::GetClient(std::wstring* client) { +bool GoogleUpdateSettings::GetClient(base::string16* client) { return ReadGoogleUpdateStrKey(google_update::kRegClientField, client); } -bool GoogleUpdateSettings::SetClient(const std::wstring& client) { +bool GoogleUpdateSettings::SetClient(const base::string16& client) { return WriteGoogleUpdateStrKey(google_update::kRegClientField, client); } -bool GoogleUpdateSettings::GetReferral(std::wstring* referral) { +bool GoogleUpdateSettings::GetReferral(base::string16* referral) { return ReadGoogleUpdateStrKey(google_update::kRegReferralField, referral); } @@ -439,14 +437,14 @@ bool GoogleUpdateSettings::GetChromeChannelAndModifiers( void GoogleUpdateSettings::UpdateInstallStatus(bool system_install, installer::ArchiveType archive_type, int install_return_code, - const std::wstring& product_guid) { + const base::string16& product_guid) { DCHECK(archive_type != installer::UNKNOWN_ARCHIVE_TYPE || install_return_code != 0); HKEY reg_root = (system_install) ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; RegKey key; installer::ChannelInfo channel_info; - std::wstring reg_key(google_update::kRegPathClientState); + base::string16 reg_key(google_update::kRegPathClientState); reg_key.append(L"\\"); reg_key.append(product_guid); LONG result = key.Open(reg_root, @@ -537,7 +535,7 @@ void GoogleUpdateSettings::UpdateProfileCounts(int profiles_active, int GoogleUpdateSettings::DuplicateGoogleUpdateSystemClientKey() { BrowserDistribution* dist = BrowserDistribution::GetDistribution(); - std::wstring reg_path = dist->GetStateKey(); + base::string16 reg_path = dist->GetStateKey(); // Minimum access needed is to be able to write to this key. RegKey reg_key( @@ -555,7 +553,7 @@ int GoogleUpdateSettings::DuplicateGoogleUpdateSystemClientKey() { } bool GoogleUpdateSettings::WriteGoogleUpdateSystemClientKey( - int handle, const std::wstring& key, const std::wstring& value) { + int handle, const base::string16& key, const base::string16& value) { HKEY reg_key = reinterpret_cast<HKEY>(reinterpret_cast<void*>(handle)); DWORD size = static_cast<DWORD>(value.size()) * sizeof(wchar_t); LSTATUS status = RegSetValueEx(reg_key, key.c_str(), 0, REG_SZ, @@ -564,7 +562,7 @@ bool GoogleUpdateSettings::WriteGoogleUpdateSystemClientKey( } GoogleUpdateSettings::UpdatePolicy GoogleUpdateSettings::GetAppUpdatePolicy( - const std::wstring& app_guid, + const base::string16& app_guid, bool* is_overridden) { bool found_override = false; UpdatePolicy update_policy = kDefaultUpdatePolicy; diff --git a/chrome/installer/util/google_update_settings.h b/chrome/installer/util/google_update_settings.h index a2ff11db8e..a8e43c426d 100644 --- a/chrome/installer/util/google_update_settings.h +++ b/chrome/installer/util/google_update_settings.h @@ -86,12 +86,12 @@ class GoogleUpdateSettings { bool consented); #endif - // Returns the metrics id set in the registry (that can be used in crash - // reports). If none found, returns empty string. - static bool GetMetricsId(std::string* metrics_id); + // Returns the metrics client id backed up in the registry. If none found, + // returns empty string. + static bool LoadMetricsClientId(std::string* metrics_id); - // Sets the metrics id to be used in crash reports. - static bool SetMetricsId(const std::string& metrics_id); + // Stores a backup of the metrics client id in the registry. + static bool StoreMetricsClientId(const std::string& metrics_id); // Sets the machine-wide EULA consented flag required on OEM installs. // Returns false if the setting could not be recorded. @@ -116,19 +116,19 @@ class GoogleUpdateSettings { // Returns in |browser| the browser used to download chrome as recorded // Google Update. Returns false if the information is not available. - static bool GetBrowser(std::wstring* browser); + static bool GetBrowser(base::string16* browser); // Returns in |language| the language selected by the user when downloading // chrome. This information is collected by the web server used to download // the chrome installer. Returns false if the information is not available. - static bool GetLanguage(std::wstring* language); + static bool GetLanguage(base::string16* language); // Returns in |brand| the RLZ brand code or distribution tag that has been // assigned to a partner. Returns false if the information is not available. // // NOTE: This function is Windows only. If the code you are writing is not // specifically for Windows, prefer calling google_brand::GetBrand(). - static bool GetBrand(std::wstring* brand); + static bool GetBrand(base::string16* brand); // Returns in |brand| the RLZ reactivation brand code or distribution tag // that has been assigned to a partner for reactivating a dormant chrome @@ -137,19 +137,19 @@ class GoogleUpdateSettings { // NOTE: This function is Windows only. If the code you are writing is not // specifically for Windows, prefer calling // google_brand::GetReactivationBrand(). - static bool GetReactivationBrand(std::wstring* brand); + static bool GetReactivationBrand(base::string16* brand); // Returns in |client| the google_update client field, which is currently // used to track experiments. Returns false if the entry does not exist. - static bool GetClient(std::wstring* client); + static bool GetClient(base::string16* client); // Sets the google_update client field. Unlike GetClient() this is set only // for the current user. Returns false if the operation failed. - static bool SetClient(const std::wstring& client); + static bool SetClient(const base::string16& client); // Returns in 'client' the RLZ referral available for some distribution // partners. This value does not exist for most chrome or chromium installs. - static bool GetReferral(std::wstring* referral); + static bool GetReferral(base::string16* referral); // Overwrites the current value of the referral with an empty string. Returns // true if this operation succeeded. @@ -192,7 +192,7 @@ class GoogleUpdateSettings { static void UpdateInstallStatus(bool system_install, installer::ArchiveType archive_type, int install_return_code, - const std::wstring& product_guid); + const base::string16& product_guid); // This method updates the value for Google Update "ap" key for Chrome // based on whether we are doing incremental install (or not) and whether @@ -229,13 +229,13 @@ class GoogleUpdateSettings { // Takes a |handle| to a registry key and writes |value| string into the // specified |key|. See DuplicateGoogleUpdateSystemClientKey for details. static bool WriteGoogleUpdateSystemClientKey(int handle, - const std::wstring& key, - const std::wstring& value); + const base::string16& key, + const base::string16& value); // Returns the effective update policy for |app_guid| as dictated by // Group Policy settings. |is_overridden|, if non-NULL, is populated with // true if an app-specific policy override is in force, or false otherwise. - static UpdatePolicy GetAppUpdatePolicy(const std::wstring& app_guid, + static UpdatePolicy GetAppUpdatePolicy(const base::string16& app_guid, bool* is_overridden); // Returns true if the app indicated by |app_guid| should be updated diff --git a/chrome/installer/util/google_update_settings_unittest.cc b/chrome/installer/util/google_update_settings_unittest.cc index f3ddafc6b5..51e896b372 100644 --- a/chrome/installer/util/google_update_settings_unittest.cc +++ b/chrome/installer/util/google_update_settings_unittest.cc @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "chrome/installer/util/google_update_settings.h" + #include <windows.h> #include <shlwapi.h> // For SHDeleteKey. @@ -15,7 +17,6 @@ #include "chrome/installer/util/fake_installation_state.h" #include "chrome/installer/util/google_update_constants.h" #include "chrome/installer/util/google_update_experiment_util.h" -#include "chrome/installer/util/google_update_settings.h" #include "chrome/installer/util/util_constants.h" #include "chrome/installer/util/work_item_list.h" #include "testing/gtest/include/gtest/gtest.h" @@ -49,7 +50,7 @@ class GoogleUpdateSettingsTest : public testing::Test { RegKey update_key; BrowserDistribution* dist = BrowserDistribution::GetDistribution(); - std::wstring path = dist->GetStateKey(); + base::string16 path = dist->GetStateKey(); ASSERT_EQ(ERROR_SUCCESS, update_key.Create(root, path.c_str(), KEY_WRITE)); ASSERT_EQ(ERROR_SUCCESS, update_key.WriteValue(L"ap", value)); } @@ -58,7 +59,7 @@ class GoogleUpdateSettingsTest : public testing::Test { // the binaries). void SetMultiApField(SystemUserInstall is_system, const wchar_t* value) { // Caller must specify a multi-install ap value. - ASSERT_NE(std::wstring::npos, std::wstring(value).find(L"-multi")); + ASSERT_NE(base::string16::npos, base::string16(value).find(L"-multi")); HKEY root = is_system == SYSTEM_INSTALL ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; RegKey update_key; @@ -70,7 +71,7 @@ class GoogleUpdateSettingsTest : public testing::Test { BrowserDistribution::CHROME_BINARIES) }; for (size_t i = 0; i < arraysize(kDists); ++i) { - std::wstring path = kDists[i]->GetStateKey(); + base::string16 path = kDists[i]->GetStateKey(); ASSERT_EQ(ERROR_SUCCESS, update_key.Create(root, path.c_str(), KEY_WRITE)); ASSERT_EQ(ERROR_SUCCESS, update_key.WriteValue(L"ap", value)); @@ -116,7 +117,7 @@ class GoogleUpdateSettingsTest : public testing::Test { for (size_t i = 0; i < arraysize(prefixes); ++i) { for (size_t j = 0; j < arraysize(expectations); ++j) { for (size_t k = 0; k < arraysize(suffixes); ++k) { - std::wstring ap = prefixes[i]; + base::string16 ap = prefixes[i]; ap += expectations[j].ap_value; ap += suffixes[k]; const wchar_t* channel = expectations[j].channel; @@ -140,7 +141,7 @@ class GoogleUpdateSettingsTest : public testing::Test { BrowserDistribution* chrome = BrowserDistribution::GetSpecificDistribution( BrowserDistribution::CHROME_BROWSER); - std::wstring value; + base::string16 value; #if defined(GOOGLE_CHROME_BUILD) EXPECT_TRUE(chrome->ShouldSetExperimentLabels()); @@ -191,9 +192,9 @@ class GoogleUpdateSettingsTest : public testing::Test { // Creates "ap" key with the value given as parameter. Also adds work // items to work_item_list given so that they can be rolled back later. - bool CreateApKey(WorkItemList* work_item_list, const std::wstring& value) { + bool CreateApKey(WorkItemList* work_item_list, const base::string16& value) { HKEY reg_root = HKEY_CURRENT_USER; - std::wstring reg_key = GetApKeyPath(); + base::string16 reg_key = GetApKeyPath(); work_item_list->AddCreateRegKeyWorkItem( reg_root, reg_key, WorkItem::kWow64Default); work_item_list->AddSetRegValueWorkItem(reg_root, @@ -211,18 +212,18 @@ class GoogleUpdateSettingsTest : public testing::Test { // Returns the key path of "ap" key, e.g.: // Google\Update\ClientState\<kTestProductGuid> - std::wstring GetApKeyPath() { - std::wstring reg_key(google_update::kRegPathClientState); + base::string16 GetApKeyPath() { + base::string16 reg_key(google_update::kRegPathClientState); reg_key.append(L"\\"); reg_key.append(kTestProductGuid); return reg_key; } // Utility method to read "ap" key value - std::wstring ReadApKeyValue() { + base::string16 ReadApKeyValue() { RegKey key; - std::wstring ap_key_value; - std::wstring reg_key = GetApKeyPath(); + base::string16 ap_key_value; + base::string16 reg_key = GetApKeyPath(); if (key.Open(HKEY_CURRENT_USER, reg_key.c_str(), KEY_ALL_ACCESS) == ERROR_SUCCESS) { key.ReadValue(google_update::kRegApField, &ap_key_value); @@ -246,7 +247,8 @@ class GoogleUpdateSettingsTest : public testing::Test { return false; } - DWORD GetUpdatePolicyForAppGuid(const base::string16& app_guid) { + GoogleUpdateSettings::UpdatePolicy GetUpdatePolicyForAppGuid( + const base::string16& app_guid) { RegKey policy_key; if (policy_key.Create(HKEY_LOCAL_MACHINE, GoogleUpdateSettings::kPoliciesKey, @@ -255,13 +257,13 @@ class GoogleUpdateSettingsTest : public testing::Test { GoogleUpdateSettings::kUpdateOverrideValuePrefix); app_update_override.append(app_guid); - DWORD value = -1; + DWORD value; if (policy_key.ReadValueDW(app_update_override.c_str(), &value) == ERROR_SUCCESS) { - return value; + return static_cast<GoogleUpdateSettings::UpdatePolicy>(value); } } - return -1; + return GoogleUpdateSettings::UPDATE_POLICIES_COUNT; } bool SetGlobalUpdatePolicy(GoogleUpdateSettings::UpdatePolicy policy) { @@ -273,14 +275,16 @@ class GoogleUpdateSettingsTest : public testing::Test { static_cast<DWORD>(policy)) == ERROR_SUCCESS; } - DWORD GetGlobalUpdatePolicy() { + GoogleUpdateSettings::UpdatePolicy GetGlobalUpdatePolicy() { RegKey policy_key; - DWORD value = -1; + DWORD value; return (policy_key.Create(HKEY_LOCAL_MACHINE, GoogleUpdateSettings::kPoliciesKey, KEY_QUERY_VALUE) == ERROR_SUCCESS && policy_key.ReadValueDW(GoogleUpdateSettings::kUpdatePolicyValue, - &value) == ERROR_SUCCESS) ? value : -1; + &value) == ERROR_SUCCESS) ? + static_cast<GoogleUpdateSettings::UpdatePolicy>(value) : + GoogleUpdateSettings::UPDATE_POLICIES_COUNT; } bool SetUpdateTimeoutOverride(DWORD time_in_minutes) { @@ -519,8 +523,8 @@ TEST_F(GoogleUpdateSettingsTest, UpdateInstallStatusTest) { work_item_list.reset(WorkItem::CreateWorkItemList()); // Test the case of when "ap" key doesnt exist at all - std::wstring ap_key_value = ReadApKeyValue(); - std::wstring reg_key = GetApKeyPath(); + base::string16 ap_key_value = ReadApKeyValue(); + base::string16 reg_key = GetApKeyPath(); HKEY reg_root = HKEY_CURRENT_USER; bool ap_key_deleted = false; RegKey key; @@ -688,7 +692,7 @@ TEST_F(GoogleUpdateSettingsTest, GetAppUpdatePolicyDefaultOverride) { // Test that an app-specific override is used if present. TEST_F(GoogleUpdateSettingsTest, GetAppUpdatePolicyAppOverride) { - std::wstring app_policy_value( + base::string16 app_policy_value( GoogleUpdateSettings::kUpdateOverrideValuePrefix); app_policy_value.append(kTestProductGuid); @@ -791,10 +795,9 @@ TEST_F(GoogleUpdateSettingsTest, PerAppUpdatesEnabledWithGlobalDisabled) { // Make sure that the reset action returns true and is a no-op. EXPECT_TRUE( GoogleUpdateSettings::ReenableAutoupdatesForApp(kTestProductGuid)); - EXPECT_EQ(static_cast<DWORD>(GoogleUpdateSettings::AUTOMATIC_UPDATES), + EXPECT_EQ(GoogleUpdateSettings::AUTOMATIC_UPDATES, GetUpdatePolicyForAppGuid(kTestProductGuid)); - EXPECT_EQ(static_cast<DWORD>(GoogleUpdateSettings::UPDATES_DISABLED), - GetGlobalUpdatePolicy()); + EXPECT_EQ(GoogleUpdateSettings::UPDATES_DISABLED, GetGlobalUpdatePolicy()); } TEST_F(GoogleUpdateSettingsTest, GlobalUpdatesDisabledByPolicy) { @@ -1023,8 +1026,8 @@ class StatsState { StateSetting state_medium_value_; }; -const StatsState::UserLevelState StatsState::kUserLevel; -const StatsState::SystemLevelState StatsState::kSystemLevel; +const StatsState::UserLevelState StatsState::kUserLevel = {}; +const StatsState::SystemLevelState StatsState::kSystemLevel = {}; // A value parameterized test for testing the stats collection consent setting. class CollectStatsConsent : public ::testing::TestWithParam<StatsState> { @@ -1036,34 +1039,34 @@ class CollectStatsConsent : public ::testing::TestWithParam<StatsState> { static void MakeChromeMultiInstall(HKEY root_key); static void ApplySetting(StatsState::StateSetting setting, HKEY root_key, - const std::wstring& reg_key); + const base::string16& reg_key); - static std::wstring* chrome_version_key_; - static std::wstring* chrome_state_key_; - static std::wstring* chrome_state_medium_key_; - static std::wstring* binaries_state_key_; - static std::wstring* binaries_state_medium_key_; + static base::string16* chrome_version_key_; + static base::string16* chrome_state_key_; + static base::string16* chrome_state_medium_key_; + static base::string16* binaries_state_key_; + static base::string16* binaries_state_medium_key_; registry_util::RegistryOverrideManager override_manager_; }; -std::wstring* CollectStatsConsent::chrome_version_key_; -std::wstring* CollectStatsConsent::chrome_state_key_; -std::wstring* CollectStatsConsent::chrome_state_medium_key_; -std::wstring* CollectStatsConsent::binaries_state_key_; -std::wstring* CollectStatsConsent::binaries_state_medium_key_; +base::string16* CollectStatsConsent::chrome_version_key_; +base::string16* CollectStatsConsent::chrome_state_key_; +base::string16* CollectStatsConsent::chrome_state_medium_key_; +base::string16* CollectStatsConsent::binaries_state_key_; +base::string16* CollectStatsConsent::binaries_state_medium_key_; void CollectStatsConsent::SetUpTestCase() { BrowserDistribution* dist = BrowserDistribution::GetSpecificDistribution( BrowserDistribution::CHROME_BROWSER); - chrome_version_key_ = new std::wstring(dist->GetVersionKey()); - chrome_state_key_ = new std::wstring(dist->GetStateKey()); - chrome_state_medium_key_ = new std::wstring(dist->GetStateMediumKey()); + chrome_version_key_ = new base::string16(dist->GetVersionKey()); + chrome_state_key_ = new base::string16(dist->GetStateKey()); + chrome_state_medium_key_ = new base::string16(dist->GetStateMediumKey()); dist = BrowserDistribution::GetSpecificDistribution( BrowserDistribution::CHROME_BINARIES); - binaries_state_key_ = new std::wstring(dist->GetStateKey()); - binaries_state_medium_key_ = new std::wstring(dist->GetStateMediumKey()); + binaries_state_key_ = new base::string16(dist->GetStateKey()); + binaries_state_medium_key_ = new base::string16(dist->GetStateMediumKey()); } void CollectStatsConsent::TearDownTestCase() { @@ -1078,7 +1081,8 @@ void CollectStatsConsent::TearDownTestCase() { void CollectStatsConsent::SetUp() { const StatsState& stats_state = GetParam(); const HKEY root_key = stats_state.root_key(); - std::wstring reg_temp_name(stats_state.system_level() ? L"HKLM_" : L"HKCU_"); + base::string16 reg_temp_name( + stats_state.system_level() ? L"HKLM_" : L"HKCU_"); reg_temp_name += L"CollectStatsConsent"; override_manager_.OverrideRegistry(root_key, reg_temp_name); @@ -1112,7 +1116,7 @@ void CollectStatsConsent::MakeChromeMultiInstall(HKEY root_key) { // Write the correct value to represent |setting| in the registry. void CollectStatsConsent::ApplySetting(StatsState::StateSetting setting, HKEY root_key, - const std::wstring& reg_key) { + const base::string16& reg_key) { if (setting != StatsState::NO_SETTING) { DWORD value = setting != StatsState::FALSE_SETTING ? 1 : 0; ASSERT_EQ( @@ -1140,7 +1144,7 @@ TEST_P(CollectStatsConsent, SetCollectStatsConsentAtLevel) { EXPECT_TRUE(GoogleUpdateSettings::SetCollectStatsConsentAtLevel( GetParam().system_level(), !GetParam().is_consent_granted())); - const std::wstring* const reg_keys[] = { + const base::string16* const reg_keys[] = { chrome_state_key_, chrome_state_medium_key_, binaries_state_key_, @@ -1148,7 +1152,7 @@ TEST_P(CollectStatsConsent, SetCollectStatsConsentAtLevel) { }; int key_index = ((GetParam().system_level() ? 1 : 0) + (GetParam().multi_install() ? 2 : 0)); - const std::wstring& reg_key = *reg_keys[key_index]; + const base::string16& reg_key = *reg_keys[key_index]; DWORD value = 0; EXPECT_EQ( ERROR_SUCCESS, diff --git a/chrome/installer/util/language_selector.cc b/chrome/installer/util/language_selector.cc index 0dc3f58c5e..a58048d6db 100644 --- a/chrome/installer/util/language_selector.cc +++ b/chrome/installer/util/language_selector.cc @@ -11,6 +11,7 @@ #include <functional> #include "base/logging.h" +#include "base/strings/string16.h" #include "base/strings/string_util.h" #include "base/win/i18n.h" #include "chrome/installer/util/google_update_settings.h" @@ -190,7 +191,7 @@ bool MatchLanguageOffset(const std::wstring& language, int* offset) { // configured languages. void GetCandidatesFromSystem(std::vector<std::wstring>* candidates) { DCHECK(candidates); - std::wstring language; + base::string16 language; // Omaha gets first pick. GoogleUpdateSettings::GetLanguage(&language); diff --git a/chrome/installer/util/shell_util.cc b/chrome/installer/util/shell_util.cc index 222d8b7364..34406a6421 100644 --- a/chrome/installer/util/shell_util.cc +++ b/chrome/installer/util/shell_util.cc @@ -612,13 +612,16 @@ class RegistryEntry { if (is_string_) { base::string16 read_value; found = key.ReadValue(name_.c_str(), &read_value) == ERROR_SUCCESS; - correct_value = read_value.size() == value_.size() && - std::equal(value_.begin(), value_.end(), read_value.begin(), - base::CaseInsensitiveCompare<wchar_t>()); + if (found) { + correct_value = read_value.size() == value_.size() && + std::equal(value_.begin(), value_.end(), read_value.begin(), + base::CaseInsensitiveCompare<wchar_t>()); + } } else { DWORD read_value; found = key.ReadValueDW(name_.c_str(), &read_value) == ERROR_SUCCESS; - correct_value = read_value == int_value_; + if (found) + correct_value = read_value == int_value_; } return found ? (correct_value ? SAME_VALUE : DIFFERENT_VALUE) : DOES_NOT_EXIST; |