diff options
author | rahulk@google.com <rahulk@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-18 21:39:43 +0000 |
---|---|---|
committer | rahulk@google.com <rahulk@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-18 21:39:43 +0000 |
commit | 8bcdcbe8e59f804e03f75e86744211210c64484a (patch) | |
tree | 06a04450b42770a59ecab09998608c005fed391d | |
parent | af784739ebdc4ca47d9d52e366587e4c7ba2313b (diff) | |
download | chromium_src-8bcdcbe8e59f804e03f75e86744211210c64484a.zip chromium_src-8bcdcbe8e59f804e03f75e86744211210c64484a.tar.gz chromium_src-8bcdcbe8e59f804e03f75e86744211210c64484a.tar.bz2 |
First set of changes to start separating Google specific branding from Chromium. This change mostly tries to modify installer to install Chromium or Google Chrome depending on a compile flag. The goal is to try to isolate all the differences in a single class that can be overridden for customization. There is also a lot of refactoring to make this happen.
Some changes are yet to be done but I didn't want to make this change even bigger than it already is. With all these changes the default build should still work as it is (Google Chrome should get installed/uninstalled). The changes yet to be done:
- Separating string resources (this is marked by TODO in one of the files)
- Generate different chrome.7z (Chromium will not include rlz.dll) for mini_installer
BUG=1296800
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@999 0039d316-1c4b-4281-b951-d872f2087c98
25 files changed, 725 insertions, 351 deletions
diff --git a/chrome/app/chrome_exe.vcproj b/chrome/app/chrome_exe.vcproj index a41ff41..2591503 100644 --- a/chrome/app/chrome_exe.vcproj +++ b/chrome/app/chrome_exe.vcproj @@ -21,7 +21,7 @@ <Configuration Name="Debug|Win32" ConfigurationType="1" - InheritedPropertySheets=".\chrome_exe.vsprops;$(SolutionDir)..\build\debug.vsprops;$(SolutionDir)..\chrome\installer\util\using_util.vsprops" + InheritedPropertySheets=".\chrome_exe.vsprops;$(SolutionDir)..\build\debug.vsprops" > <Tool Name="VCPreBuildEventTool" @@ -88,7 +88,7 @@ <Configuration Name="Release|Win32" ConfigurationType="1" - InheritedPropertySheets=".\chrome_exe.vsprops;$(SolutionDir)..\build\release.vsprops;$(SolutionDir)..\chrome\installer\util\using_util.vsprops" + InheritedPropertySheets=".\chrome_exe.vsprops;$(SolutionDir)..\build\release.vsprops" > <Tool Name="VCPreBuildEventTool" diff --git a/chrome/browser/shell_integration.cc b/chrome/browser/shell_integration.cc index bd29986..8df4e9d 100644 --- a/chrome/browser/shell_integration.cc +++ b/chrome/browser/shell_integration.cc @@ -43,6 +43,7 @@ #include "base/win_util.h" #include "chrome/common/chrome_constants.h" #include "chrome/common/win_util.h" +#include "chrome/installer/util/browser_distribution.h" #include "chrome/installer/util/create_reg_key_work_item.h" #include "chrome/installer/util/set_reg_value_work_item.h" #include "chrome/installer/util/shell_util.h" @@ -153,7 +154,8 @@ bool ShellIntegration::SetAsDefaultBrowser() { NULL, CLSCTX_INPROC, __uuidof(IApplicationAssociationRegistration), (void**)&pAAR); if (SUCCEEDED(hr)) { - hr = pAAR->SetAppAsDefaultAll(installer_util::kApplicationName); + BrowserDistribution* dist = BrowserDistribution::GetDistribution(); + hr = pAAR->SetAppAsDefaultAll(dist->GetApplicationName().c_str()); pAAR->Release(); } if (!SUCCEEDED(hr)) @@ -272,8 +274,9 @@ bool ShellIntegration::IsDefaultBrowser() { for (int i = 0; i < _countof(kChromeProtocols); i++) { BOOL result = TRUE; + BrowserDistribution* dist = BrowserDistribution::GetDistribution(); hr = pAAR->QueryAppIsDefault(kChromeProtocols[i].c_str(), AT_URLPROTOCOL, - AL_EFFECTIVE, installer_util::kApplicationName, &result); + AL_EFFECTIVE, dist->GetApplicationName().c_str(), &result); if (!SUCCEEDED(hr) || (result == FALSE)) { pAAR->Release(); return false; diff --git a/chrome/installer/mini_installer/mini_installer.h b/chrome/installer/mini_installer/mini_installer.h index 785749e..f5de5cf 100644 --- a/chrome/installer/mini_installer/mini_installer.h +++ b/chrome/installer/mini_installer/mini_installer.h @@ -47,14 +47,18 @@ const wchar_t kBinResourceType[] = L"BN"; const wchar_t kLZCResourceType[] = L"BL"; const wchar_t kLZMAResourceType[] = L"B7"; -// Uninstall registry location -const wchar_t kUninstallRegistryKey[] = L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Chrome"; +// Registry key to get uninstall command const wchar_t kUninstallRegistryValueName[] = L"UninstallString"; - -// Uninstall registry key that lets user tell Chrome installer not to delete -// extracted files. -const wchar_t kCleanupRegistryKey[] = L"Software\\Google"; +// Registry key that tells Chrome installer not to delete extracted files. const wchar_t kCleanupRegistryValueName[] = L"ChromeInstallerCleanup"; +// Paths for the above two registry keys +#if defined(GOOGLE_CHROME_BUILD) +const wchar_t kUninstallRegistryKey[] = L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Google Chrome"; +const wchar_t kCleanupRegistryKey[] = L"Software\\Google"; +#else +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; diff --git a/chrome/installer/setup/install.cc b/chrome/installer/setup/install.cc index 1231d77..57efed4 100644 --- a/chrome/installer/setup/install.cc +++ b/chrome/installer/setup/install.cc @@ -34,6 +34,7 @@ #include "base/string_util.h" #include "chrome/installer/setup/setup.h" #include "chrome/installer/setup/setup_constants.h" +#include "chrome/installer/util/browser_distribution.h" #include "chrome/installer/util/copy_tree_work_item.h" #include "chrome/installer/util/create_dir_work_item.h" #include "chrome/installer/util/create_reg_key_work_item.h" @@ -64,6 +65,7 @@ std::wstring AppendPath(const std::wstring parent_path, void AddUninstallShortcutWorkItems(HKEY reg_root, const std::wstring& exe_path, const std::wstring& install_path, + const std::wstring& product_name, const std::wstring& new_version, WorkItemList* install_list) { std::wstring uninstall_cmd(L"\""); @@ -75,44 +77,36 @@ void AddUninstallShortcutWorkItems(HKEY reg_root, uninstall_cmd.append(installer_util::switches::kUninstall); // Create DisplayName, UninstallString and InstallLocation keys - install_list->AddCreateRegKeyWorkItem(reg_root, - installer_util::kUninstallRegPath); - const std::wstring& product_name = - installer_util::GetLocalizedString(IDS_PRODUCT_NAME_BASE); - install_list->AddSetRegValueWorkItem( - reg_root, installer_util::kUninstallRegPath, + BrowserDistribution* dist = BrowserDistribution::GetDistribution(); + std::wstring uninstall_reg = dist->GetUninstallRegPath(); + install_list->AddCreateRegKeyWorkItem(reg_root, uninstall_reg); + install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg, installer_util::kUninstallDisplayNameField, product_name, true); install_list->AddSetRegValueWorkItem(reg_root, - installer_util::kUninstallRegPath, + uninstall_reg, installer_util::kUninstallStringField, uninstall_cmd, true); install_list->AddSetRegValueWorkItem(reg_root, - installer_util::kUninstallRegPath, + uninstall_reg, L"InstallLocation", install_path, true); // DisplayIcon, NoModify and NoRepair std::wstring chrome_icon = AppendPath(install_path, installer_util::kChromeExe); ShellUtil::GetChromeIcon(chrome_icon); - install_list->AddSetRegValueWorkItem(reg_root, - installer_util::kUninstallRegPath, + install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg, L"DisplayIcon", chrome_icon, true); - install_list->AddSetRegValueWorkItem(reg_root, - installer_util::kUninstallRegPath, + install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg, L"NoModify", 1, true); - install_list->AddSetRegValueWorkItem(reg_root, - installer_util::kUninstallRegPath, + install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg, L"NoRepair", 1, true); - install_list->AddSetRegValueWorkItem(reg_root, - installer_util::kUninstallRegPath, + install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg, L"Publisher", - installer_util::kPublisherName, true); - install_list->AddSetRegValueWorkItem(reg_root, - installer_util::kUninstallRegPath, + dist->GetPublisherName(), true); + install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg, L"Version", new_version.c_str(), true); - install_list->AddSetRegValueWorkItem(reg_root, - installer_util::kUninstallRegPath, + install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg, L"DisplayVersion", new_version.c_str(), true); time_t rawtime = time(NULL); @@ -120,8 +114,7 @@ void AddUninstallShortcutWorkItems(HKEY reg_root, localtime_s(&timeinfo, &rawtime); wchar_t buffer[9]; if (wcsftime(buffer, 9, L"%Y%m%d", &timeinfo) == 8) { - install_list->AddSetRegValueWorkItem(reg_root, - installer_util::kUninstallRegPath, + install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg, L"InstallDate", buffer, false); } @@ -221,23 +214,25 @@ bool installer::InstallNewVersion(const std::wstring& exe_path, // add shortcut in Control Panel->Add/Remove Programs. AddInstallerCopyTasks(exe_path, archive_path, temp_dir, install_path, new_version.GetString(), install_list.get()); - AddUninstallShortcutWorkItems(reg_root, exe_path, install_path, + const std::wstring& product_name = + installer_util::GetLocalizedString(IDS_PRODUCT_NAME_BASE); + AddUninstallShortcutWorkItems(reg_root, exe_path, install_path, product_name, new_version.GetString(), install_list.get()); // Delete any old_chrome.exe if present. install_list->AddDeleteTreeWorkItem( AppendPath(install_path, installer::kChromeOldExe), std::wstring()); - // Create Google Update key (if not already present) and set the new Chrome + // Create Version key (if not already present) and set the new Chrome // version as last step. - std::wstring chrome_google_update_key = - InstallUtil::GetChromeGoogleUpdateKey(); - install_list->AddCreateRegKeyWorkItem(reg_root, chrome_google_update_key); - install_list->AddSetRegValueWorkItem(reg_root, chrome_google_update_key, + BrowserDistribution* dist = BrowserDistribution::GetDistribution(); + std::wstring version_key = dist->GetVersionKey(); + install_list->AddCreateRegKeyWorkItem(reg_root, version_key); + install_list->AddSetRegValueWorkItem(reg_root, version_key, google_update::kRegNameField, - installer_util::kChrome, - false); // Don't overwrite. - install_list->AddSetRegValueWorkItem(reg_root, chrome_google_update_key, + product_name, + true); // overwrite name also + install_list->AddSetRegValueWorkItem(reg_root, version_key, google_update::kRegVersionField, new_version.GetString(), true); // overwrite version diff --git a/chrome/installer/setup/main.cc b/chrome/installer/setup/main.cc index 67bd872..5c40f5b 100644 --- a/chrome/installer/setup/main.cc +++ b/chrome/installer/setup/main.cc @@ -29,6 +29,7 @@ #include <string> +#include "base/at_exit.h" #include "base/basictypes.h" #include "base/command_line.h" #include "base/file_util.h" @@ -38,6 +39,7 @@ #include "chrome/installer/setup/setup.h" #include "chrome/installer/setup/setup_constants.h" #include "chrome/installer/setup/uninstall.h" +#include "chrome/installer/util/browser_distribution.h" #include "chrome/installer/util/delete_tree_work_item.h" #include "chrome/installer/util/helper.h" #include "chrome/installer/util/install_util.h" @@ -203,46 +205,106 @@ installer::Version* GetVersionFromDir(const std::wstring& chrome_path) { return version; } -// This method checks if we need to change "ap" key in Google Update to try -// full installer as fall back method in case incremental installer fails. -// - If incremental installer fails we append a magic string ("-full"), if -// it is not present already, so that Google Update server next time will send -// full installer to update Chrome on the local machine -// - If we are currently running full installer, we remove this magic -// string (if it is present) regardless of whether installer failed or not. -// There is no fall-back for full installer :) -void ResetGoogleUpdateApKey(bool system_install, bool incremental_install, - installer_util::InstallStatus install_status) { - HKEY reg_root = (system_install) ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; - - RegKey key; - std::wstring ap_key_value; - std::wstring chrome_google_update_state_key( - google_update::kRegPathClientState); - chrome_google_update_state_key.append(L"\\"); - chrome_google_update_state_key.append(google_update::kChromeGuid); - if (!key.Open(reg_root, chrome_google_update_state_key.c_str(), - KEY_ALL_ACCESS) || !key.ReadValue(google_update::kRegApFieldName, - &ap_key_value)) { - LOG(INFO) << "Application key not found. Returning without changing it."; - key.Close(); - return; +installer_util::InstallStatus InstallChrome(const CommandLine& cmd_line, + const installer::Version* installed_version, bool system_install) { + // For install the default location for chrome.packed.7z is in current + // folder, so get that value first. + std::wstring archive = file_util::GetDirectoryFromPath(cmd_line.program()); + file_util::AppendToPath(&archive, + std::wstring(installer::kChromeCompressedArchive)); + // If --install-archive is given, get the user specified value + if (cmd_line.HasSwitch(installer_util::switches::kInstallArchive)) { + archive = cmd_line.GetSwitchValue( + installer_util::switches::kInstallArchive); } + LOG(INFO) << "Archive found to install Chrome " << archive; + + // Create a temp folder where we will unpack Chrome archive. If it fails, + // then we are doomed, so return immediately and no cleanup is required. + std::wstring temp_path; + if (!file_util::CreateNewTempDirectory(std::wstring(L"chrome_"), + &temp_path)) { + LOG(ERROR) << "Could not create temporary path."; + return installer_util::TEMP_DIR_FAILED; + } + LOG(INFO) << "created path " << temp_path; + + std::wstring unpack_path(temp_path); + file_util::AppendToPath(&unpack_path, + std::wstring(installer::kInstallSourceDir)); + bool incremental_install = false; + installer_util::InstallStatus install_status = installer_util::UNKNOWN_STATUS; + if (UnPackArchive(archive, system_install, installed_version, + temp_path, unpack_path, incremental_install)) { + install_status = installer_util::UNCOMPRESSION_FAILED; + } else { + LOG(INFO) << "unpacked to " << unpack_path; + std::wstring src_path(unpack_path); + file_util::AppendToPath(&src_path, + std::wstring(installer::kInstallSourceChromeDir)); + scoped_ptr<installer::Version> + installer_version(GetVersionFromDir(src_path)); + if (!installer_version.get()) { + LOG(ERROR) << "Did not find any valid version in installer."; + install_status = installer_util::INVALID_ARCHIVE; + } else { + LOG(INFO) << "version to install: " << installer_version->GetString(); + if (installed_version && + installed_version->IsHigherThan(installer_version.get())) { + LOG(ERROR) << "Higher version is already installed."; + install_status = installer_util::HIGHER_VERSION_EXISTS; + } else { + // We want to keep uncompressed archive (chrome.7z) that we get after + // uncompressing and binary patching. Get the location for this file. + std::wstring archive_to_copy(temp_path); + file_util::AppendToPath(&archive_to_copy, + std::wstring(installer::kChromeArchive)); + install_status = installer::InstallOrUpdateChrome( + cmd_line.program(), archive_to_copy, temp_path, system_install, + *installer_version, installed_version); + if (install_status == installer_util::FIRST_INSTALL_SUCCESS) { + LOG(INFO) << "First install successful. Launching Chrome."; + installer::LaunchChrome(system_install); + } + } + } + } + + // Delete install temporary directory. + LOG(INFO) << "Deleting temporary directory " << temp_path; + scoped_ptr<DeleteTreeWorkItem> delete_tree( + WorkItem::CreateDeleteTreeWorkItem(temp_path, std::wstring())); + delete_tree->Do(); - std::wstring new_value = InstallUtil::GetNewGoogleUpdateApKey( - incremental_install, install_status, ap_key_value); - if ((new_value.compare(ap_key_value) != 0) && - !key.WriteValue(google_update::kRegApFieldName, new_value.c_str())) { - LOG(ERROR) << "Failed to write value " << new_value - << " to the registry field " << google_update::kRegApFieldName; + BrowserDistribution* dist = BrowserDistribution::GetDistribution(); + dist->UpdateDiffInstallStatus(system_install, incremental_install, + install_status); + return install_status; +} + +installer_util::InstallStatus UninstallChrome(const CommandLine& cmd_line, + const installer::Version* version, + bool system_install) { + bool remove_all = true; + if (cmd_line.HasSwitch(installer_util::switches::kDoNotRemoveSharedItems)) + remove_all = false; + LOG(INFO) << "Uninstalling Chome"; + if (!version) { + LOG(ERROR) << "No Chrome installation found for uninstall."; + return installer_util::CHROME_NOT_INSTALLED; + } else { + return installer_setup::UninstallChrome(cmd_line.program(), system_install, + *version, remove_all); } - key.Close(); } } // namespace int WINAPI wWinMain(HINSTANCE instance, HINSTANCE prev_instance, wchar_t* command_line, int show_command) { + // The exit manager is in charge of calling the dtors of singletons. + base::AtExitManager exit_manager; + CommandLine parsed_command_line; installer::InitInstallerLogging(parsed_command_line); @@ -283,107 +345,19 @@ int WINAPI wWinMain(HINSTANCE instance, HINSTANCE prev_instance, } installer_util::InstallStatus install_status = installer_util::UNKNOWN_STATUS; + // If --uninstall option is given, uninstall chrome if (parsed_command_line.HasSwitch(installer_util::switches::kUninstall)) { - bool remove_all = true; - if (parsed_command_line.HasSwitch( - installer_util::switches::kDoNotRemoveSharedItems)) - remove_all = false; - // If --uninstall option is given, uninstall chrome - LOG(INFO) << "Uninstalling Chome"; - if (!installed_version.get()) { - LOG(ERROR) << "No Chrome installation found for uninstall."; - install_status = installer_util::CHROME_NOT_INSTALLED; - } else { - install_status = installer_setup::UninstallChrome( - parsed_command_line.program(), system_install, - *installed_version, remove_all); - } + install_status = UninstallChrome(parsed_command_line, + installed_version.get(), + system_install); + // If --uninstall option is not specified, we assume it is install case. } else { - // If --uninstall option is not specified, we assume it is install case. - // For install the default location for chrome.packed.7z is in current - // folder, so get that value first. - std::wstring archive_path = - file_util::GetDirectoryFromPath(parsed_command_line.program()); - file_util::AppendToPath(&archive_path, - std::wstring(installer::kChromeCompressedArchive)); - // If --install-archive is given, get the user specified value - if (parsed_command_line.HasSwitch( - installer_util::switches::kInstallArchive)) { - archive_path = parsed_command_line.GetSwitchValue( - installer_util::switches::kInstallArchive); - } - LOG(INFO) << "Archive found to install Chrome " << archive_path; - - // Create a temp folder where we will unpack Chrome archive. If it fails, - // then we are doomed so return immediately and no cleanup is required. - std::wstring install_temp_path; - if (!file_util::CreateNewTempDirectory(std::wstring(L"chrome_"), - &install_temp_path)) { - LOG(ERROR) << "Could not create temporary path."; - return installer_util::TEMP_DIR_FAILED; - } - LOG(INFO) << "created path " << install_temp_path; - std::wstring unpack_path(install_temp_path); - file_util::AppendToPath(&unpack_path, - std::wstring(installer::kInstallSourceDir)); - - bool incremental_install = false; - if (UnPackArchive(archive_path, system_install, installed_version.get(), - install_temp_path, unpack_path, incremental_install)) { - install_status = installer_util::UNCOMPRESSION_FAILED; - } else { - LOG(INFO) << "unpacked to " << unpack_path; - std::wstring src_path(unpack_path); - file_util::AppendToPath(&src_path, - std::wstring(installer::kInstallSourceChromeDir)); - scoped_ptr<installer::Version> - installer_version(GetVersionFromDir(src_path)); - if (!installer_version.get()) { - LOG(ERROR) << "Did not find any valid version in installer."; - install_status = installer_util::INVALID_ARCHIVE; - } else { - LOG(INFO) << "version to be installed: " << - installer_version->GetString(); - if (installed_version.get() && - installed_version->IsHigherThan(installer_version.get())) { - LOG(ERROR) << "Higher version is already installed."; - install_status = installer_util::HIGHER_VERSION_EXISTS; - } else { - // We want to keep uncompressed archive (chrome.7z) that we get after - // uncompressing and binary patching. Get the location for this file. - std::wstring archive_to_copy(install_temp_path); - file_util::AppendToPath(&archive_to_copy, - std::wstring(installer::kChromeArchive)); - install_status = installer::InstallOrUpdateChrome( - parsed_command_line.program(), archive_to_copy, - install_temp_path, system_install, - *installer_version, installed_version.get()); - if (install_status == installer_util::FIRST_INSTALL_SUCCESS) { - LOG(INFO) << "First install successful. Launching Chrome."; - installer::LaunchChrome(system_install); - } - } - } - } - - // Delete install temporary directory. - LOG(INFO) << "Deleting temporary directory " << install_temp_path; - scoped_ptr<DeleteTreeWorkItem> delete_tree( - WorkItem::CreateDeleteTreeWorkItem(install_temp_path, - std::wstring())); - delete_tree->Do(); - - ResetGoogleUpdateApKey(system_install, incremental_install, install_status); - - // TBD: The previous installs/updates may leave some temporary files - // that were not deleted when the installs/updates exited, probably due - // to a crash. Try delete those temporary files again? + install_status = InstallChrome(parsed_command_line, + installed_version.get(), + system_install); } CoUninitialize(); - if (InstallUtil::InstallSuccessful(install_status)) - return 0; // For Google Update's benefit we need to return 0 for success - // cases. - else - return install_status; + BrowserDistribution* dist = BrowserDistribution::GetDistribution(); + return dist->GetInstallReturnCode(install_status); } diff --git a/chrome/installer/setup/setup.vcproj b/chrome/installer/setup/setup.vcproj index e6c6abf..5c468c8 100644 --- a/chrome/installer/setup/setup.vcproj +++ b/chrome/installer/setup/setup.vcproj @@ -21,7 +21,7 @@ <Configuration Name="Debug|Win32" ConfigurationType="1" - InheritedPropertySheets=".\setup_debug.vsprops;..\util\using_util.vsprops;..\util\prebuild\util_prebuild.vsprops" + InheritedPropertySheets=".\setup_debug.vsprops;..\util\prebuild\util_prebuild.vsprops" > <Tool Name="Version" @@ -42,7 +42,7 @@ <Configuration Name="Release|Win32" ConfigurationType="1" - InheritedPropertySheets=".\setup_release.vsprops;..\util\using_util.vsprops;..\util\prebuild\util_prebuild.vsprops" + InheritedPropertySheets=".\setup_release.vsprops;..\util\prebuild\util_prebuild.vsprops" > <Tool Name="Version" @@ -68,10 +68,6 @@ Name="resources" > <File - RelativePath=".\setup_resource.h" - > - </File> - <File RelativePath=".\setup.ico" > </File> @@ -84,6 +80,10 @@ > </File> <File + RelativePath=".\setup_resource.h" + > + </File> + <File RelativePath="$(IntDir)\..\util_prebuild\setup_strings.h" > </File> diff --git a/chrome/installer/setup/uninstall.cc b/chrome/installer/setup/uninstall.cc index c9b80ab..92466b2 100644 --- a/chrome/installer/setup/uninstall.cc +++ b/chrome/installer/setup/uninstall.cc @@ -44,7 +44,9 @@ #include "base/wmi_util.h" #include "chrome/app/result_codes.h" #include "chrome/common/chrome_constants.h" +#include "chrome/installer/setup/setup.h" #include "chrome/installer/setup/setup_constants.h" +#include "chrome/installer/util/browser_distribution.h" #include "chrome/installer/util/helper.h" #include "chrome/installer/util/install_util.h" #include "chrome/installer/util/l10n_string_util.h" @@ -147,6 +149,23 @@ installer_util::InstallStatus IsChromeActiveOrUserCancelled( return installer_util::UNINSTALL_FAILED; } +#if defined(GOOGLE_CHROME_BUILD) +// Uninstall Chrome specific Gears. First we find Gears MSI ProductId (that +// changes with every new version of Gears) using Gears MSI UpgradeCode (that +// does not change) and then uninstall Gears using API. +void UninstallGears() { + wchar_t product[39]; // GUID + '\0' + MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL); // Don't show any UI to user. + for (int i = 0; MsiEnumRelatedProducts(google_update::kGearsUpgradeCode, 0, i, + product) != ERROR_NO_MORE_ITEMS; ++i) { + LOG(INFO) << "Uninstalling Gears - " << product; + unsigned int ret = MsiConfigureProduct(product, INSTALLLEVEL_MAXIMUM, + INSTALLSTATE_ABSENT); + if (ret != ERROR_SUCCESS) + LOG(ERROR) << "Failed to uninstall Gears " << product << ": " << ret; + } +} + // Read the URL from the resource file and substitute the locale parameter // with whatever Google Update tells us is the locale. In case we fail to find // the locale, we use US English. @@ -202,21 +221,7 @@ void LaunchUninstallSurvey(const installer::Version& installed_version) { WMIProcessUtil::Launch(command, &pid); } -// Uninstall Chrome specific Gears. First we find Gears MSI ProductId (that -// changes with every new version of Gears) using Gears MSI UpgradeCode (that -// does not change) and then uninstall Gears using API. -void UninstallGears() { - wchar_t product[39]; // GUID + '\0' - MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL); // Don't show any UI to user. - for (int i = 0; MsiEnumRelatedProducts(google_update::kGearsUpgradeCode, 0, i, - product) != ERROR_NO_MORE_ITEMS; ++i) { - LOG(INFO) << "Uninstalling Gears - " << product; - unsigned int ret = MsiConfigureProduct(product, INSTALLLEVEL_MAXIMUM, - INSTALLSTATE_ABSENT); - if (ret != ERROR_SUCCESS) - LOG(ERROR) << "Failed to uninstall Gears " << product << ": " << ret; - } -} +#endif } // namespace @@ -229,8 +234,11 @@ installer_util::InstallStatus installer_setup::UninstallChrome( if (status != installer_util::UNINSTALL_CONFIRMED) return status; - // Uninstall Gears first. + BrowserDistribution* dist = BrowserDistribution::GetDistribution(); + dist->DoPreUninstallOperations(); +#if defined(GOOGLE_CHROME_BUILD) UninstallGears(); +#endif // Chrome is not in use so lets uninstall Chrome by deleting various files // and registry entries. Here we will just make best effort and keep going @@ -238,11 +246,11 @@ installer_util::InstallStatus installer_setup::UninstallChrome( // First delete shortcut from Start->Programs. DeleteChromeShortcut(system_uninstall); - // Delete the registry keys (Uninstall key and Google Update update key). + // Delete the registry keys (Uninstall key and Version key). HKEY reg_root = system_uninstall ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; RegKey key(reg_root, L"", KEY_ALL_ACCESS); - DeleteRegistryKey(key, installer_util::kUninstallRegPath); - DeleteRegistryKey(key, InstallUtil::GetChromeGoogleUpdateKey()); + DeleteRegistryKey(key, dist->GetUninstallRegPath()); + DeleteRegistryKey(key, dist->GetVersionKey()); // Delete Software\Classes\ChromeHTML, // Software\Clients\StartMenuInternet\chrome.exe and @@ -256,7 +264,7 @@ installer_util::InstallStatus installer_setup::UninstallChrome( DeleteRegistryKey(key, set_access_key); DeleteRegistryValue(reg_root, ShellUtil::kRegRegisteredApplications, - installer_util::kApplicationName); + dist->GetApplicationName()); key.Close(); // Delete shared registry keys as well (these require admin rights) if @@ -267,7 +275,7 @@ installer_util::InstallStatus installer_setup::UninstallChrome( DeleteRegistryKey(hklm_key, html_prog_id); DeleteRegistryValue(HKEY_LOCAL_MACHINE, ShellUtil::kRegRegisteredApplications, - installer_util::kApplicationName); + dist->GetApplicationName()); // Delete media player registry key that exists only in HKLM. std::wstring reg_path(installer::kMediaPlayerRegPath); @@ -287,9 +295,8 @@ installer_util::InstallStatus installer_setup::UninstallChrome( LOG(INFO) << "install destination path: " << install_path; } - std::wstring setup_exe(install_path); - file_util::AppendToPath(&setup_exe, installed_version.GetString()); - file_util::AppendToPath(&setup_exe, installer::kInstallerDir); + std::wstring setup_exe(installer::GetInstallerPathUnderChrome( + install_path, installed_version.GetString())); file_util::AppendToPath(&setup_exe, file_util::GetFilenameFromPath(exe_path)); std::wstring temp_file; @@ -301,6 +308,9 @@ installer_util::InstallStatus installer_setup::UninstallChrome( LOG(ERROR) << "Failed to delete folder: " << install_path; LOG(INFO) << "Uninstallation complete. Launching Uninstall survey."; + dist->DoPostUninstallOperations(installed_version); +#if defined(GOOGLE_CHROME_BUILD) LaunchUninstallSurvey(installed_version); +#endif return installer_util::UNINSTALL_SUCCESSFUL; } diff --git a/chrome/installer/util/browser_distribution.cc b/chrome/installer/util/browser_distribution.cc new file mode 100644 index 0000000..3c02cb0 --- /dev/null +++ b/chrome/installer/util/browser_distribution.cc @@ -0,0 +1,84 @@ +// Copyright 2008, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// This file defines a class that contains various method related to branding. +// It provides only default implementations of these methods. Usually to add +// specific branding, we will need to extend this class with a custom +// implementation. + +#include "chrome/installer/util/browser_distribution.h" +#include "chrome/installer/util/google_chrome_distribution.h" + +BrowserDistribution* BrowserDistribution::GetDistribution() { + static BrowserDistribution* dist = NULL; + if (dist == NULL) { +#if defined(GOOGLE_CHROME_BUILD) + dist = new GoogleChromeDistribution(); +#else + dist = new BrowserDistribution(); +#endif + } + return dist; +} + +void BrowserDistribution::DoPostUninstallOperations( + const installer::Version& version) { +} + +void BrowserDistribution::DoPreUninstallOperations() { +} + +std::wstring BrowserDistribution::GetApplicationName() { + return L"Chromium"; +} + +std::wstring BrowserDistribution::GetInstallSubDir() { + return L"Chromium"; +} + +std::wstring BrowserDistribution::GetPublisherName() { + return L"Chromium"; +} + +int BrowserDistribution::GetInstallReturnCode( + installer_util::InstallStatus install_status) { + return install_status; +} + +std::wstring BrowserDistribution::GetUninstallRegPath() { + return L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Chromium"; +} + +std::wstring BrowserDistribution::GetVersionKey() { + return L"Software\\Chromium"; +} + +void BrowserDistribution::UpdateDiffInstallStatus(bool system_install, + bool incremental_install, installer_util::InstallStatus install_status) { +} diff --git a/chrome/installer/util/browser_distribution.h b/chrome/installer/util/browser_distribution.h new file mode 100644 index 0000000..3ede388 --- /dev/null +++ b/chrome/installer/util/browser_distribution.h @@ -0,0 +1,72 @@ +// Copyright 2008, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// This file declares a class that contains various method related to branding. + +#ifndef CHROME_INSTALLER_UTIL_BROWSER_DISTRIBUTION_H_ +#define CHROME_INSTALLER_UTIL_BROWSER_DISTRIBUTION_H_ + +#include "base/basictypes.h" +#include "chrome/installer/util/util_constants.h" +#include "chrome/installer/util/version.h" + +class BrowserDistribution { + public: + virtual ~BrowserDistribution() {} + + static BrowserDistribution* GetDistribution(); + + virtual void DoPostUninstallOperations(const installer::Version& version); + + virtual void DoPreUninstallOperations(); + + virtual std::wstring GetApplicationName(); + + virtual std::wstring GetInstallSubDir(); + + virtual std::wstring GetPublisherName(); + + virtual int GetInstallReturnCode( + installer_util::InstallStatus install_status); + + virtual std::wstring GetUninstallRegPath(); + + virtual std::wstring GetVersionKey(); + + virtual void UpdateDiffInstallStatus(bool system_install, + bool incremental_install, installer_util::InstallStatus install_status); + + protected: + BrowserDistribution() {} + + private: + DISALLOW_COPY_AND_ASSIGN(BrowserDistribution); +}; + +#endif // CHROME_INSTALLER_UTIL_BROWSER_DISTRIBUTION_H_ diff --git a/chrome/installer/util/google_chrome_distribution.cc b/chrome/installer/util/google_chrome_distribution.cc new file mode 100644 index 0000000..2623b36 --- /dev/null +++ b/chrome/installer/util/google_chrome_distribution.cc @@ -0,0 +1,218 @@ +// Copyright 2008, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// This file defines specific implementation of BrowserDistribution class for +// Google Chrome. + +#include "chrome/installer/util/google_chrome_distribution.h" + +#include <atlbase.h> +#include <windows.h> +#include <msi.h> + +#include "base/file_util.h" +#include "base/path_service.h" +#include "base/registry.h" +#include "base/string_util.h" +#include "base/wmi_util.h" +#include "chrome/installer/util/install_util.h" +#include "chrome/installer/util/google_update_constants.h" +#include "chrome/installer/util/logging_installer.h" + +namespace { +std::wstring GetUninstallSurveyUrl() { + /* TODO(rahulk): Make this work (requires some serious refactoring of + resources and GoogleUpdateSettings class) and get rid of #ifdef from + uninstall.cc. + const ATLSTRINGRESOURCEIMAGE* image = AtlGetStringResourceImage( + _AtlBaseModule.GetModuleInstance(), IDS_UNINSTALL_SURVEY_URL); + DCHECK(image); + std::wstring url = std::wstring(image->achString, image->nLength); + DCHECK(!url.empty()); + + std::wstring language; + if (!GoogleUpdateSettings::GetLanguage(&language)) + language = L"en-US"; // Default to US English. + + return ReplaceStringPlaceholders(url.c_str(), language.c_str(), NULL); + */ + return L""; + +} +} + +void GoogleChromeDistribution::DoPostUninstallOperations( + const installer::Version& version) { + // Send the Chrome version and OS version as params to the form. + // It would be nice to send the locale, too, but I don't see an + // easy way to get that in the existing code. It's something we + // can add later, if needed. + // We depend on installed_version.GetString() not having spaces or other + // characters that need escaping: 0.2.13.4. Should that change, we will + // need to escape the string before using it in a URL. + const std::wstring kVersionParam = L"crversion"; + const std::wstring kVersion = version.GetString(); + const std::wstring kOSParam = L"os"; + std::wstring os_version = L"na"; + OSVERSIONINFO version_info; + version_info.dwOSVersionInfoSize = sizeof(version_info); + if (GetVersionEx(&version_info)) { + os_version = StringPrintf(L"%d.%d.%d", version_info.dwMajorVersion, + version_info.dwMinorVersion, + version_info.dwBuildNumber); + } + + std::wstring iexplore; + if (!PathService::Get(base::DIR_PROGRAM_FILES, &iexplore)) + return; + + file_util::AppendToPath(&iexplore, L"Internet Explorer"); + file_util::AppendToPath(&iexplore, L"iexplore.exe"); + + std::wstring command = iexplore + L" " + GetUninstallSurveyUrl() + L"&" + + kVersionParam + L"=" + kVersion + L"&" + kOSParam + L"=" + os_version; + int pid = 0; + WMIProcessUtil::Launch(command, &pid); +} + +// Uninstall Chrome specific Gears. First we find Gears MSI ProductId (that +// changes with every new version of Gears) using Gears MSI UpgradeCode (that +// does not change) and then uninstall Gears using API. +void GoogleChromeDistribution::DoPreUninstallOperations() { + /* TODO(rahulk) this comment is commented for now because it is causing extra + dependencies for the renderer. Need to remove ifdef from uninstall.cc and + uncomment this function. + wchar_t product[39]; // GUID + '\0' + MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL); // Don't show any UI to user. + for (int i = 0; MsiEnumRelatedProducts(google_update::kGearsUpgradeCode, 0, i, + product) != ERROR_NO_MORE_ITEMS; ++i) { + LOG(INFO) << "Uninstalling Gears - " << product; + unsigned int ret = MsiConfigureProduct(product, INSTALLLEVEL_MAXIMUM, + INSTALLSTATE_ABSENT); + if (ret != ERROR_SUCCESS) + LOG(ERROR) << "Failed to uninstall Gears " << product << ": " << ret; + }*/ +} + +std::wstring GoogleChromeDistribution::GetApplicationName() { + return L"Google Chrome"; +} + +std::wstring GoogleChromeDistribution::GetInstallSubDir() { + return L"Google\\Chrome"; +} + +std::wstring GoogleChromeDistribution::GetNewGoogleUpdateApKey(bool diff_install, + installer_util::InstallStatus status, const std::wstring& value) { + // Magic suffix that we need to add or remove to "ap" key value. + const std::wstring kMagicSuffix = L"-full"; + + bool has_magic_string = false; + if ((value.length() >= kMagicSuffix.length()) && + (value.rfind(kMagicSuffix) == (value.length() - kMagicSuffix.length()))) { + LOG(INFO) << "Incremental installer failure key already set."; + has_magic_string = true; + } + + std::wstring new_value(value); + if ((!diff_install || !GetInstallReturnCode(status)) && has_magic_string) { + LOG(INFO) << "Removing failure key from value " << value; + new_value = value.substr(0, value.length() - kMagicSuffix.length()); + } else if ((diff_install && GetInstallReturnCode(status)) && + !has_magic_string) { + LOG(INFO) << "Incremental installer failed, setting failure key."; + new_value.append(kMagicSuffix); + } + + return new_value; +} + +std::wstring GoogleChromeDistribution::GetPublisherName() { + return L"Google"; +} + +int GoogleChromeDistribution::GetInstallReturnCode( + installer_util::InstallStatus status) { + switch (status) { + case installer_util::FIRST_INSTALL_SUCCESS: + case installer_util::INSTALL_REPAIRED: + case installer_util::NEW_VERSION_UPDATED: + case installer_util::HIGHER_VERSION_EXISTS: + return 0; // For Google Update's benefit we need to return 0 for success + default: + return status; + } +} + +std::wstring GoogleChromeDistribution::GetUninstallRegPath() { + return L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Google Chrome"; +} + +std::wstring GoogleChromeDistribution::GetVersionKey() { + std::wstring key(google_update::kRegPathClients); + key.append(L"\\"); + key.append(google_update::kChromeGuid); + return key; +} + +// This method checks if we need to change "ap" key in Google Update to try +// full installer as fall back method in case incremental installer fails. +// - If incremental installer fails we append a magic string ("-full"), if +// it is not present already, so that Google Update server next time will send +// full installer to update Chrome on the local machine +// - If we are currently running full installer, we remove this magic +// string (if it is present) regardless of whether installer failed or not. +// There is no fall-back for full installer :) +void GoogleChromeDistribution::UpdateDiffInstallStatus(bool system_install, + bool incremental_install, installer_util::InstallStatus install_status) { + HKEY reg_root = (system_install) ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; + + RegKey key; + std::wstring ap_key_value; + std::wstring chrome_google_update_state_key( + google_update::kRegPathClientState); + chrome_google_update_state_key.append(L"\\"); + chrome_google_update_state_key.append(google_update::kChromeGuid); + if (!key.Open(reg_root, chrome_google_update_state_key.c_str(), + KEY_ALL_ACCESS) || !key.ReadValue(google_update::kRegApFieldName, + &ap_key_value)) { + LOG(INFO) << "Application key not found. Returning without changing it."; + key.Close(); + return; + } + + std::wstring new_value = GoogleChromeDistribution::GetNewGoogleUpdateApKey( + incremental_install, install_status, ap_key_value); + if ((new_value.compare(ap_key_value) != 0) && + !key.WriteValue(google_update::kRegApFieldName, new_value.c_str())) { + LOG(ERROR) << "Failed to write value " << new_value + << " to the registry field " << google_update::kRegApFieldName; + } + key.Close(); +} diff --git a/chrome/installer/util/google_chrome_distribution.h b/chrome/installer/util/google_chrome_distribution.h new file mode 100644 index 0000000..f1d6af9 --- /dev/null +++ b/chrome/installer/util/google_chrome_distribution.h @@ -0,0 +1,82 @@ +// Copyright 2008, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// This file extends generic BrowserDistribution class to declare Google Chrome +// specific implementation. + +#ifndef CHROME_INSTALLER_UTIL_GOOGLE_CHROME_DISTRIBUTION_H_ +#define CHROME_INSTALLER_UTIL_GOOGLE_CHROME_DISTRIBUTION_H_ + +#include "chrome/installer/util/browser_distribution.h" +#include "chrome/installer/util/util_constants.h" + +class GoogleChromeDistribution : public BrowserDistribution { + public: + virtual void DoPostUninstallOperations(const installer::Version& version); + + virtual void DoPreUninstallOperations(); + + virtual std::wstring GetApplicationName(); + + virtual std::wstring GetInstallSubDir(); + + // This method generates the new value for Google Update "ap" key for Chrome + // based on whether we are doing incremental install (or not) and whether + // the install succeeded. + // - If install worked, remove the magic string (if present). + // - If incremental installer failed, append a magic string (if + // not present already). + // - If full installer failed, still remove this magic + // string (if it is present already). + // + // diff_install: tells whether this is incremental install or not. + // install_status: if 0, means installation was successful. + // value: current value of Google Update "ap" key. + std::wstring GetNewGoogleUpdateApKey(bool diff_install, + installer_util::InstallStatus status, const std::wstring& value); + + virtual std::wstring GetPublisherName(); + + virtual int GetInstallReturnCode( + installer_util::InstallStatus install_status); + + virtual std::wstring GetUninstallRegPath(); + + virtual std::wstring GetVersionKey(); + + virtual void UpdateDiffInstallStatus(bool system_install, + bool incremental_install, installer_util::InstallStatus install_status); + + private: + friend class BrowserDistribution; + + GoogleChromeDistribution() {} +}; + +#endif // CHROME_INSTALLER_UTIL_GOOGLE_CHROME_DISTRIBUTION_H_ diff --git a/chrome/installer/util/install_util_unittest.cc b/chrome/installer/util/google_chrome_distribution_unittest.cc index b0a816a..30f971a 100644 --- a/chrome/installer/util/install_util_unittest.cc +++ b/chrome/installer/util/google_chrome_distribution_unittest.cc @@ -27,15 +27,16 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // -// Unit tests for InstallUtil class. +// Unit tests for GoogleChromeDistribution class. #include <windows.h> -#include "chrome/installer/util/install_util.h" +#include "chrome/installer/util/browser_distribution.h" +#include "chrome/installer/util/google_chrome_distribution.h" #include "testing/gtest/include/gtest/gtest.h" namespace { -class InstallUtilTest : public testing::Test { +class GoogleChromeDistributionTest : public testing::Test { protected: virtual void SetUp() { // Currently no setup required. @@ -47,51 +48,48 @@ class InstallUtilTest : public testing::Test { }; } // namespace -TEST_F(InstallUtilTest, GetNewGoogleUpdateApKeyTest) { +#if defined(GOOGLE_CHROME_BUILD) +TEST_F(GoogleChromeDistributionTest, GetNewGoogleUpdateApKeyTest) { + GoogleChromeDistribution* dist = static_cast<GoogleChromeDistribution*>( + BrowserDistribution::GetDistribution()); installer_util::InstallStatus s = installer_util::FIRST_INSTALL_SUCCESS; installer_util::InstallStatus f = installer_util::INSTALL_FAILED; // Incremental Installer that worked. - EXPECT_EQ(InstallUtil::GetNewGoogleUpdateApKey(true, s, L""), L""); - EXPECT_EQ(InstallUtil::GetNewGoogleUpdateApKey(true, s, L"1.1"), L"1.1"); - EXPECT_EQ(InstallUtil::GetNewGoogleUpdateApKey(true, s, L"1.1-dev"), - L"1.1-dev"); - EXPECT_EQ(InstallUtil::GetNewGoogleUpdateApKey(true, s, L"-full"), L""); - EXPECT_EQ(InstallUtil::GetNewGoogleUpdateApKey(true, s, L"1.1-full"), - L"1.1"); - EXPECT_EQ(InstallUtil::GetNewGoogleUpdateApKey(true, s, L"1.1-dev-full"), + EXPECT_EQ(dist->GetNewGoogleUpdateApKey(true, s, L""), L""); + EXPECT_EQ(dist->GetNewGoogleUpdateApKey(true, s, L"1.1"), L"1.1"); + EXPECT_EQ(dist->GetNewGoogleUpdateApKey(true, s, L"1.1-dev"), L"1.1-dev"); + EXPECT_EQ(dist->GetNewGoogleUpdateApKey(true, s, L"-full"), L""); + EXPECT_EQ(dist->GetNewGoogleUpdateApKey(true, s, L"1.1-full"), L"1.1"); + EXPECT_EQ(dist->GetNewGoogleUpdateApKey(true, s, L"1.1-dev-full"), L"1.1-dev"); // Incremental Installer that failed. - EXPECT_EQ(InstallUtil::GetNewGoogleUpdateApKey(true, f, L""), L"-full"); - EXPECT_EQ(InstallUtil::GetNewGoogleUpdateApKey(true, f, L"1.1"), L"1.1-full"); - EXPECT_EQ(InstallUtil::GetNewGoogleUpdateApKey(true, f, L"1.1-dev"), + EXPECT_EQ(dist->GetNewGoogleUpdateApKey(true, f, L""), L"-full"); + EXPECT_EQ(dist->GetNewGoogleUpdateApKey(true, f, L"1.1"), L"1.1-full"); + EXPECT_EQ(dist->GetNewGoogleUpdateApKey(true, f, L"1.1-dev"), L"1.1-dev-full"); - EXPECT_EQ(InstallUtil::GetNewGoogleUpdateApKey(true, f, L"-full"), L"-full"); - EXPECT_EQ(InstallUtil::GetNewGoogleUpdateApKey(true, f, L"1.1-full"), - L"1.1-full"); - EXPECT_EQ(InstallUtil::GetNewGoogleUpdateApKey(true, f, L"1.1-dev-full"), + EXPECT_EQ(dist->GetNewGoogleUpdateApKey(true, f, L"-full"), L"-full"); + EXPECT_EQ(dist->GetNewGoogleUpdateApKey(true, f, L"1.1-full"), L"1.1-full"); + EXPECT_EQ(dist->GetNewGoogleUpdateApKey(true, f, L"1.1-dev-full"), L"1.1-dev-full"); // Full Installer that worked. - EXPECT_EQ(InstallUtil::GetNewGoogleUpdateApKey(false, s, L""), L""); - EXPECT_EQ(InstallUtil::GetNewGoogleUpdateApKey(false, s, L"1.1"), L"1.1"); - EXPECT_EQ(InstallUtil::GetNewGoogleUpdateApKey(false, s, L"1.1-dev"), - L"1.1-dev"); - EXPECT_EQ(InstallUtil::GetNewGoogleUpdateApKey(false, s, L"-full"), L""); - EXPECT_EQ(InstallUtil::GetNewGoogleUpdateApKey(false, s, L"1.1-full"), - L"1.1"); - EXPECT_EQ(InstallUtil::GetNewGoogleUpdateApKey(false, s, L"1.1-dev-full"), + EXPECT_EQ(dist->GetNewGoogleUpdateApKey(false, s, L""), L""); + EXPECT_EQ(dist->GetNewGoogleUpdateApKey(false, s, L"1.1"), L"1.1"); + EXPECT_EQ(dist->GetNewGoogleUpdateApKey(false, s, L"1.1-dev"), L"1.1-dev"); + EXPECT_EQ(dist->GetNewGoogleUpdateApKey(false, s, L"-full"), L""); + EXPECT_EQ(dist->GetNewGoogleUpdateApKey(false, s, L"1.1-full"), L"1.1"); + EXPECT_EQ(dist->GetNewGoogleUpdateApKey(false, s, L"1.1-dev-full"), L"1.1-dev"); // Full Installer that failed. - EXPECT_EQ(InstallUtil::GetNewGoogleUpdateApKey(false, f, L""), L""); - EXPECT_EQ(InstallUtil::GetNewGoogleUpdateApKey(false, f, L"1.1"), L"1.1"); - EXPECT_EQ(InstallUtil::GetNewGoogleUpdateApKey(false, f, L"1.1-dev"), - L"1.1-dev"); - EXPECT_EQ(InstallUtil::GetNewGoogleUpdateApKey(false, f, L"-full"), L""); - EXPECT_EQ(InstallUtil::GetNewGoogleUpdateApKey(false, f, L"1.1-full"), - L"1.1"); - EXPECT_EQ(InstallUtil::GetNewGoogleUpdateApKey(false, f, L"1.1-dev-full"), + EXPECT_EQ(dist->GetNewGoogleUpdateApKey(false, f, L""), L""); + EXPECT_EQ(dist->GetNewGoogleUpdateApKey(false, f, L"1.1"), L"1.1"); + EXPECT_EQ(dist->GetNewGoogleUpdateApKey(false, f, L"1.1-dev"), L"1.1-dev"); + EXPECT_EQ(dist->GetNewGoogleUpdateApKey(false, f, L"-full"), L""); + EXPECT_EQ(dist->GetNewGoogleUpdateApKey(false, f, L"1.1-full"), L"1.1"); + EXPECT_EQ(dist->GetNewGoogleUpdateApKey(false, f, L"1.1-dev-full"), L"1.1-dev"); } +#endif diff --git a/chrome/installer/util/helper.cc b/chrome/installer/util/helper.cc index 271fdb2..2546f76 100644 --- a/chrome/installer/util/helper.cc +++ b/chrome/installer/util/helper.cc @@ -33,6 +33,7 @@ #include "base/path_service.h" #include "base/process_util.h" #include "base/scoped_ptr.h" +#include "chrome/installer/util/browser_distribution.h" #include "chrome/installer/util/delete_tree_work_item.h" #include "chrome/installer/util/helper.h" #include "chrome/installer/util/logging_installer.h" @@ -49,10 +50,8 @@ std::wstring installer::GetChromeInstallPath(bool system_install) { } if (!install_path.empty()) { - file_util::AppendToPath(&install_path, - std::wstring(installer_util::kInstallGoogleDir)); - file_util::AppendToPath(&install_path, - std::wstring(installer_util::kChrome)); + BrowserDistribution* dist = BrowserDistribution::GetDistribution(); + file_util::AppendToPath(&install_path, dist->GetInstallSubDir()); file_util::AppendToPath(&install_path, std::wstring(installer_util::kInstallBinaryDir)); } diff --git a/chrome/installer/util/install_util.cc b/chrome/installer/util/install_util.cc index 087589b..8a1dfcc 100644 --- a/chrome/installer/util/install_util.cc +++ b/chrome/installer/util/install_util.cc @@ -37,22 +37,17 @@ #include "base/logging.h" #include "base/registry.h" #include "base/string_util.h" +#include "chrome/installer/util/browser_distribution.h" #include "chrome/installer/util/google_update_constants.h" -std::wstring InstallUtil::GetChromeGoogleUpdateKey() { - std::wstring chrome_google_update_key(google_update::kRegPathClients); - chrome_google_update_key.append(L"\\"); - chrome_google_update_key.append(google_update::kChromeGuid); - return chrome_google_update_key; -} - installer::Version* InstallUtil::GetChromeVersion(bool system_install) { RegKey key; std::wstring version_str; HKEY reg_root = (system_install) ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; - if (!key.Open(reg_root, GetChromeGoogleUpdateKey().c_str(), KEY_READ) || + BrowserDistribution* dist = BrowserDistribution::GetDistribution(); + if (!key.Open(reg_root, dist->GetVersionKey().c_str(), KEY_READ) || !key.ReadValue(google_update::kRegVersionField, &version_str)) { LOG(INFO) << "No existing Chrome install found."; key.Close(); @@ -62,40 +57,3 @@ installer::Version* InstallUtil::GetChromeVersion(bool system_install) { LOG(INFO) << "Existing Chrome version found " << version_str; return installer::Version::GetVersionFromString(version_str); } - -std::wstring InstallUtil::GetNewGoogleUpdateApKey(bool diff_install, - installer_util::InstallStatus status, const std::wstring& value) { - // Magic suffix that we need to add or remove to "ap" key value. - const std::wstring kMagicSuffix = L"-full"; - - bool has_magic_string = false; - if ((value.length() >= kMagicSuffix.length()) && - (value.rfind(kMagicSuffix) == (value.length() - kMagicSuffix.length()))) { - LOG(INFO) << "Incremental installer failure key already set."; - has_magic_string = true; - } - - std::wstring new_value(value); - if ((!diff_install || InstallSuccessful(status)) && has_magic_string) { - LOG(INFO) << "Removing failure key from value " << value; - new_value = value.substr(0, value.length() - kMagicSuffix.length()); - } else if ((diff_install && !InstallSuccessful(status)) && - !has_magic_string) { - LOG(INFO) << "Incremental installer failed, setting failure key."; - new_value.append(kMagicSuffix); - } - - return new_value; -} - -bool InstallUtil::InstallSuccessful(installer_util::InstallStatus status) { - switch (status) { - case installer_util::FIRST_INSTALL_SUCCESS: - case installer_util::INSTALL_REPAIRED: - case installer_util::NEW_VERSION_UPDATED: - case installer_util::HIGHER_VERSION_EXISTS: - return true; - default: - return false; - } -} diff --git a/chrome/installer/util/install_util.h b/chrome/installer/util/install_util.h index 69884e9..3c35a3f 100644 --- a/chrome/installer/util/install_util.h +++ b/chrome/installer/util/install_util.h @@ -45,34 +45,12 @@ // independently. class InstallUtil { public: - // This method gets the Google Update registry key path for Chrome. - // i.e. - Software\Google\Update\Clients\<chrome-guid>"; - static std::wstring GetChromeGoogleUpdateKey(); - // Find the version of Chrome installed on the system by checking the // Google Update registry key. Returns the version or NULL if no version is // found. // system_install: if true, looks for version number under the HKLM root, // otherwise looks under the HKCU. static installer::Version * GetChromeVersion(bool system_install); - - // This method generates the new value for Oamaha "ap" key for Chrome - // based on whether we are doing incremental install (or not) and whether - // the install succeeded. - // - If install worked, remove the magic string (if present). - // - If incremental installer failed, append a magic string (if - // not present already). - // - If full installer failed, still remove this magic - // string (if it is present already). - // - // diff_install: tells whether this is incremental install or not. - // install_status: if 0, means installation was successful. - // value: current value of Google Update "ap" key. - static std::wstring GetNewGoogleUpdateApKey(bool diff_install, - installer_util::InstallStatus status, const std::wstring& value); - - // Given an InstallStatus it tells whether the install was sucessful or not. - static bool InstallSuccessful(installer_util::InstallStatus status); private: DISALLOW_EVIL_CONSTRUCTORS(InstallUtil); }; diff --git a/chrome/installer/util/installer_unittests.vcproj b/chrome/installer/util/installer_unittests.vcproj index b7e3eef..4f710ac 100644 --- a/chrome/installer/util/installer_unittests.vcproj +++ b/chrome/installer/util/installer_unittests.vcproj @@ -17,7 +17,7 @@ <Configuration Name="Debug|Win32" ConfigurationType="1" - InheritedPropertySheets="$(SolutionDir)..\build\common.vsprops;$(SolutionDir)..\build\debug.vsprops;$(SolutionDir)\tools\build\win\unit_test.vsprops;$(SolutionDir)\installer\util\using_util.vsprops;$(SolutionDir)..\testing\using_gtest.vsprops" + InheritedPropertySheets="$(SolutionDir)..\build\common.vsprops;$(SolutionDir)..\build\debug.vsprops;$(SolutionDir)\tools\build\win\unit_test.vsprops;$(SolutionDir)..\testing\using_gtest.vsprops" > <Tool Name="VCPreBuildEventTool" @@ -78,7 +78,7 @@ <Configuration Name="Release|Win32" ConfigurationType="1" - InheritedPropertySheets="$(SolutionDir)..\build\common.vsprops;$(SolutionDir)..\build\release.vsprops;$(SolutionDir)\tools\build\win\unit_test.vsprops;$(SolutionDir)\installer\util\using_util.vsprops;$(SolutionDir)..\testing\using_gtest.vsprops" + InheritedPropertySheets="$(SolutionDir)..\build\common.vsprops;$(SolutionDir)..\build\release.vsprops;$(SolutionDir)\tools\build\win\unit_test.vsprops;$(SolutionDir)..\testing\using_gtest.vsprops" > <Tool Name="VCPreBuildEventTool" @@ -172,7 +172,7 @@ > </File> <File - RelativePath="install_util_unittest.cc" + RelativePath="google_chrome_distribution_unittest.cc" > </File> <File diff --git a/chrome/installer/util/prebuild/create_string_rc.py b/chrome/installer/util/prebuild/create_string_rc.py index a617646..ca4fd09 100644 --- a/chrome/installer/util/prebuild/create_string_rc.py +++ b/chrome/installer/util/prebuild/create_string_rc.py @@ -56,9 +56,9 @@ class TranslationStruct: def CollectTranslatedStrings(): - """Collects all the translations for "Google Chrome" from the XTB files. - Returns a list of tuples of (language, translated string). The list is - sorted by language codes.""" + """Collects all the translations for all the strings specified by kStringIds. + Returns a list of tuples of (string_id, language, translated string). The + list is sorted by language codes.""" kGeneratedResourcesPath = os.path.join(path_utils.ScriptDir(), '..', '..', '..', 'app/generated_resources.grd') kTranslationDirectory = os.path.join(path_utils.ScriptDir(), '..', '..', diff --git a/chrome/installer/util/shell_util.cc b/chrome/installer/util/shell_util.cc index c8ebfc8..bc8b882 100644 --- a/chrome/installer/util/shell_util.cc +++ b/chrome/installer/util/shell_util.cc @@ -47,6 +47,7 @@ #include "base/win_util.h" #include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_switches.h" +#include "chrome/installer/util/browser_distribution.h" #include "chrome/installer/util/create_reg_key_work_item.h" #include "chrome/installer/util/l10n_string_util.h" #include "chrome/installer/util/set_reg_value_work_item.h" @@ -80,9 +81,10 @@ class RegistryEntry { entries.push_front(new RegistryEntry( L"Software\\Classes\\ChromeHTML\\shell\\open\\command", open_cmd)); + BrowserDistribution* dist = BrowserDistribution::GetDistribution(); entries.push_front(new RegistryEntry( L"Software\\Clients\\StartMenuInternet\\chrome.exe", - installer_util::kApplicationName)); + dist->GetApplicationName())); entries.push_front(new RegistryEntry( L"Software\\Clients\\StartMenuInternet\\chrome.exe\\shell\\open\\command", quoted_exe_path)); @@ -107,17 +109,17 @@ class RegistryEntry { entries.push_front(new RegistryEntry( ShellUtil::kRegRegisteredApplications, - installer_util::kApplicationName, + dist->GetApplicationName(), L"Software\\Clients\\StartMenuInternet\\chrome.exe\\Capabilities")); entries.push_front(new RegistryEntry( L"Software\\Clients\\StartMenuInternet\\chrome.exe\\Capabilities", - L"ApplicationDescription", installer_util::kApplicationName)); + L"ApplicationDescription", dist->GetApplicationName())); entries.push_front(new RegistryEntry( L"Software\\Clients\\StartMenuInternet\\chrome.exe\\Capabilities", L"ApplicationIcon", icon_path)); entries.push_front(new RegistryEntry( L"Software\\Clients\\StartMenuInternet\\chrome.exe\\Capabilities", - L"ApplicationName", installer_util::kApplicationName)); + L"ApplicationName", dist->GetApplicationName())); entries.push_front(new RegistryEntry( L"Software\\Clients\\StartMenuInternet\\chrome.exe\\Capabilities\\StartMenu", @@ -251,7 +253,8 @@ ShellUtil::RegisterStatus RegisterOnVista(const std::wstring& chrome_exe, std::wstring exe_path(file_util::GetDirectoryFromPath(chrome_exe)); file_util::AppendToPath(&exe_path, installer_util::kSetupExe); if (!file_util::PathExists(exe_path)) { - RegKey key(HKEY_CURRENT_USER, installer_util::kUninstallRegPath); + BrowserDistribution* dist = BrowserDistribution::GetDistribution(); + RegKey key(HKEY_CURRENT_USER, dist->GetUninstallRegPath().c_str()); key.ReadValue(installer_util::kUninstallStringField, &exe_path); exe_path = exe_path.substr(0, exe_path.find_first_of(L" --")); TrimString(exe_path, L" \"", &exe_path); diff --git a/chrome/installer/util/using_util.vsprops b/chrome/installer/util/using_util.vsprops deleted file mode 100644 index fe84cd9..0000000 --- a/chrome/installer/util/using_util.vsprops +++ /dev/null @@ -1,11 +0,0 @@ -<?xml version="1.0" encoding="Windows-1252"?> -<VisualStudioPropertySheet - ProjectType="Visual C++" - Version="8.00" - Name="using_util" - > - <Tool - Name="VCLinkerTool" - AdditionalDependencies="shlwapi.lib" - /> -</VisualStudioPropertySheet> diff --git a/chrome/installer/util/util.vcproj b/chrome/installer/util/util.vcproj index 0eac40b..8fcb759 100644 --- a/chrome/installer/util/util.vcproj +++ b/chrome/installer/util/util.vcproj @@ -41,6 +41,14 @@ </Configurations> <Files> <File + RelativePath="browser_distribution.cc" + > + </File> + <File + RelativePath="browser_distribution.h" + > + </File> + <File RelativePath="copy_tree_work_item.cc" > </File> @@ -73,6 +81,14 @@ > </File> <File + RelativePath="google_chrome_distribution.cc" + > + </File> + <File + RelativePath="google_chrome_distribution.h" + > + </File> + <File RelativePath="google_update_settings.cc" > </File> diff --git a/chrome/installer/util/util_constants.cc b/chrome/installer/util/util_constants.cc index d008647..32fd6d3 100644 --- a/chrome/installer/util/util_constants.cc +++ b/chrome/installer/util/util_constants.cc @@ -67,16 +67,10 @@ const wchar_t kVerboseLogging[] = L"verbose-logging"; } // namespace switches const wchar_t kInstallBinaryDir[] = L"Application"; -const wchar_t kInstallGoogleDir[] = L"Google"; -const wchar_t kChrome[] = L"Chrome"; const wchar_t kChromeExe[] = L"chrome.exe"; const wchar_t kChromeDll[] = L"chrome.dll"; - -const wchar_t kPublisherName[] = L"Google"; -const wchar_t kApplicationName[] = L"Google Chrome"; const wchar_t kSetupExe[] = L"setup.exe"; -const wchar_t kUninstallRegPath[] = L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Google Chrome"; const wchar_t kUninstallStringField[] = L"UninstallString"; const wchar_t kUninstallDisplayNameField[] = L"DisplayName"; } // namespace installer_util diff --git a/chrome/installer/util/util_constants.h b/chrome/installer/util/util_constants.h index af9596f..449148c 100644 --- a/chrome/installer/util/util_constants.h +++ b/chrome/installer/util/util_constants.h @@ -69,18 +69,10 @@ extern const wchar_t kVerboseLogging[]; } // namespace switches extern const wchar_t kInstallBinaryDir[]; -extern const wchar_t kInstallGoogleDir[]; -extern const wchar_t kChrome[]; extern const wchar_t kChromeExe[]; extern const wchar_t kChromeDll[]; - -// Bug 1214772 - these should be removed for public beta and replaced with -// a localized string. -extern const wchar_t kPublisherName[]; -extern const wchar_t kApplicationName[]; extern const wchar_t kSetupExe[]; -extern const wchar_t kUninstallRegPath[]; extern const wchar_t kUninstallStringField[]; extern const wchar_t kUninstallDisplayNameField[]; } // namespace installer_util diff --git a/chrome/test/mini_installer_test/chrome_mini_installer.cc b/chrome/test/mini_installer_test/chrome_mini_installer.cc index c8d67c3..2376271 100644 --- a/chrome/test/mini_installer_test/chrome_mini_installer.cc +++ b/chrome/test/mini_installer_test/chrome_mini_installer.cc @@ -34,6 +34,7 @@ #include "base/registry.h" #include "base/string_util.h" #include "chrome/installer/setup/setup_constants.h" +#include "chrome/installer/util/browser_distribution.h" #include "chrome/installer/util/install_util.h" #include "chrome/installer/util/google_update_constants.h" #include "chrome/installer/util/util_constants.h" @@ -48,7 +49,8 @@ void ChromeMiniInstaller::InstallMiniInstaller(bool over_install) { } LaunchExe(mini_installer_constants::kChromeMiniInstallerExecutable, mini_installer_constants::kChromeMiniInstallerExecutable); - ASSERT_TRUE(CheckRegistryKey(InstallUtil::GetChromeGoogleUpdateKey())); + BrowserDistribution* dist = BrowserDistribution::GetDistribution(); + ASSERT_TRUE(CheckRegistryKey(dist->GetVersionKey())); FindChromeShortcut(); WaitUntilProcessStartsRunning(installer_util::kChromeExe); if (!over_install) { @@ -77,7 +79,8 @@ void ChromeMiniInstaller::InstallChromeSetupDev() { chrome_google_update_state_key.append(L"\\"); chrome_google_update_state_key.append(google_update::kChromeGuid); ASSERT_TRUE(CheckRegistryKey(chrome_google_update_state_key)); - ASSERT_TRUE(CheckRegistryKey(InstallUtil::GetChromeGoogleUpdateKey())); + BrowserDistribution* dist = BrowserDistribution::GetDistribution(); + ASSERT_TRUE(CheckRegistryKey(dist->GetVersionKey())); FindChromeShortcut(); WaitUntilProcessStartsRunning(installer_util::kChromeExe); ASSERT_TRUE(CloseWindow(mini_installer_constants::kFirstChromeUI, WM_CLOSE)); @@ -110,7 +113,8 @@ void ChromeMiniInstaller::OverInstall() { // Deletes App dir. void ChromeMiniInstaller::UnInstall() { printf("Verifying if Chrome is installed...\n"); - if (!CheckRegistryKey(InstallUtil::GetChromeGoogleUpdateKey())) { + BrowserDistribution* dist = BrowserDistribution::GetDistribution(); + if (!CheckRegistryKey(dist->GetVersionKey())) { printf("Chrome is not installed.\n"); return; } @@ -129,7 +133,7 @@ void ChromeMiniInstaller::UnInstall() { mini_installer_constants::kConfirmDialog, WM_COMMAND)); WaitUntilProcessStopsRunning( mini_installer_constants::kChromeSetupExecutable); - ASSERT_FALSE(CheckRegistryKey(InstallUtil::GetChromeGoogleUpdateKey())); + ASSERT_FALSE(CheckRegistryKey(dist->GetVersionKey())); DeleteAppFolder(); FindChromeShortcut(); if (false == CloseWindow(mini_installer_constants::kChromeUninstallIETitle, @@ -235,7 +239,8 @@ std::wstring ChromeMiniInstaller::GetUninstallPath() { // Reads Chrome registry key. std::wstring ChromeMiniInstaller::GetRegistryKey() { std::wstring build_key_value; - RegKey key(HKEY_CURRENT_USER, InstallUtil::GetChromeGoogleUpdateKey().c_str()); + BrowserDistribution* dist = BrowserDistribution::GetDistribution(); + RegKey key(HKEY_CURRENT_USER, dist->GetVersionKey().c_str()); if (!key.ReadValue(L"pv", &build_key_value)) return false; return build_key_value; diff --git a/chrome/test/mini_installer_test/mini_installer_test.vcproj b/chrome/test/mini_installer_test/mini_installer_test.vcproj index 2a20087..e993140 100644 --- a/chrome/test/mini_installer_test/mini_installer_test.vcproj +++ b/chrome/test/mini_installer_test/mini_installer_test.vcproj @@ -18,7 +18,7 @@ <Configuration Name="Debug|Win32" ConfigurationType="1" - InheritedPropertySheets="$(SolutionDir)..\build\common.vsprops;$(SolutionDir)..\build\debug.vsprops;$(SolutionDir)\tools\build\win\unit_test.vsprops;$(SolutionDir)\installer\util\using_util.vsprops;$(SolutionDir)..\testing\using_gtest.vsprops" + InheritedPropertySheets="$(SolutionDir)..\build\common.vsprops;$(SolutionDir)..\build\debug.vsprops;$(SolutionDir)\tools\build\win\unit_test.vsprops;$(SolutionDir)..\testing\using_gtest.vsprops" > <Tool Name="VCPreBuildEventTool" @@ -80,7 +80,7 @@ <Configuration Name="Release|Win32" ConfigurationType="1" - InheritedPropertySheets="$(SolutionDir)..\build\common.vsprops;$(SolutionDir)..\build\release.vsprops;$(SolutionDir)\tools\build\win\unit_test.vsprops;$(SolutionDir)\installer\util\using_util.vsprops;$(SolutionDir)..\testing\using_gtest.vsprops" + InheritedPropertySheets="$(SolutionDir)..\build\common.vsprops;$(SolutionDir)..\build\release.vsprops;$(SolutionDir)\tools\build\win\unit_test.vsprops;$(SolutionDir)..\testing\using_gtest.vsprops" > <Tool Name="VCPreBuildEventTool" diff --git a/chrome/tools/build/win/release.rules b/chrome/tools/build/win/release.rules index 2b2f683..3d5c94e 100644 --- a/chrome/tools/build/win/release.rules +++ b/chrome/tools/build/win/release.rules @@ -8,7 +8,7 @@ Name="create installer archive" DisplayName="create installer archive" CommandLine="$(SolutionDir)..\third_party\python_24\python.exe $(SolutionDir)tools\build\win\create_installer_archive.py --output_dir="$(OutDir)" --input_file="$(InputPath)" [LastChromeInstaller] [LastChromeVersion] [RebuildArchive]" - Outputs="$(OutDir)/$(InputName).7z;$(OutDir)/packed_files.txt;" + Outputs="$(OutDir)/$(InputName).7z;$(OutDir)/$(InputName).packed.7z;$(OutDir)/setup.ex_;$(OutDir)/packed_files.txt;" AdditionalDependencies="$(SolutionDir)\tools\build\win\create_installer_archive.py;$(OutDir)\chrome.exe;$(OutDir)\crash_reporter.exe;$(OutDir)\chrome.dll;$(OutDir)\locales\en-US.dll;$(OutDir)\icudt38.dll" FileExtensions="*.release" ExecutionDescription="create installer archive" |