| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/installer/setup/install.h" |
| 6 |
| 5 #include <shlobj.h> | 7 #include <shlobj.h> |
| 6 #include <time.h> | 8 #include <time.h> |
| 7 | 9 |
| 8 #include "chrome/installer/setup/install.h" | |
| 9 | |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/path_service.h" | 13 #include "base/path_service.h" |
| 14 #include "base/registry.h" | |
| 15 #include "base/scoped_ptr.h" | 14 #include "base/scoped_ptr.h" |
| 15 #include "base/win/registry.h" |
| 16 #include "chrome/installer/setup/setup_constants.h" | 16 #include "chrome/installer/setup/setup_constants.h" |
| 17 #include "chrome/installer/util/browser_distribution.h" | 17 #include "chrome/installer/util/browser_distribution.h" |
| 18 #include "chrome/installer/util/create_reg_key_work_item.h" | 18 #include "chrome/installer/util/create_reg_key_work_item.h" |
| 19 #include "chrome/installer/util/delete_after_reboot_helper.h" | 19 #include "chrome/installer/util/delete_after_reboot_helper.h" |
| 20 #include "chrome/installer/util/google_update_constants.h" | 20 #include "chrome/installer/util/google_update_constants.h" |
| 21 #include "chrome/installer/util/helper.h" | 21 #include "chrome/installer/util/helper.h" |
| 22 #include "chrome/installer/util/install_util.h" | 22 #include "chrome/installer/util/install_util.h" |
| 23 #include "chrome/installer/util/master_preferences.h" | 23 #include "chrome/installer/util/master_preferences.h" |
| 24 #include "chrome/installer/util/set_reg_value_work_item.h" | 24 #include "chrome/installer/util/set_reg_value_work_item.h" |
| 25 #include "chrome/installer/util/shell_util.h" | 25 #include "chrome/installer/util/shell_util.h" |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 // attempting to install the MSI on top of a non-MSI managed installation. | 209 // attempting to install the MSI on top of a non-MSI managed installation. |
| 210 // If so, try and remove any existing uninstallation shortcuts, as we want the | 210 // If so, try and remove any existing uninstallation shortcuts, as we want the |
| 211 // uninstall to be managed entirely by the MSI machinery (accessible via the | 211 // uninstall to be managed entirely by the MSI machinery (accessible via the |
| 212 // Add/Remove programs dialog). | 212 // Add/Remove programs dialog). |
| 213 void DeleteUninstallShortcutsForMSI(bool is_system_install) { | 213 void DeleteUninstallShortcutsForMSI(bool is_system_install) { |
| 214 DCHECK(InstallUtil::IsMSIProcess(is_system_install)) | 214 DCHECK(InstallUtil::IsMSIProcess(is_system_install)) |
| 215 << "This must only be called for MSI installations!"; | 215 << "This must only be called for MSI installations!"; |
| 216 | 216 |
| 217 // First attempt to delete the old installation's ARP dialog entry. | 217 // First attempt to delete the old installation's ARP dialog entry. |
| 218 HKEY reg_root = is_system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; | 218 HKEY reg_root = is_system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; |
| 219 RegKey root_key(reg_root, L"", KEY_ALL_ACCESS); | 219 base::win::RegKey root_key(reg_root, L"", KEY_ALL_ACCESS); |
| 220 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | 220 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
| 221 std::wstring uninstall_reg = dist->GetUninstallRegPath(); | 221 std::wstring uninstall_reg = dist->GetUninstallRegPath(); |
| 222 InstallUtil::DeleteRegistryKey(root_key, uninstall_reg); | 222 InstallUtil::DeleteRegistryKey(root_key, uninstall_reg); |
| 223 | 223 |
| 224 // Then attempt to delete the old installation's start menu shortcut. | 224 // Then attempt to delete the old installation's start menu shortcut. |
| 225 FilePath uninstall_link; | 225 FilePath uninstall_link; |
| 226 if (is_system_install) { | 226 if (is_system_install) { |
| 227 PathService::Get(base::DIR_COMMON_START_MENU, &uninstall_link); | 227 PathService::Get(base::DIR_COMMON_START_MENU, &uninstall_link); |
| 228 } else { | 228 } else { |
| 229 PathService::Get(base::DIR_START_MENU, &uninstall_link); | 229 PathService::Get(base::DIR_START_MENU, &uninstall_link); |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 scoped_ptr<WorkItemList> install_list(WorkItem::CreateWorkItemList()); | 597 scoped_ptr<WorkItemList> install_list(WorkItem::CreateWorkItemList()); |
| 598 // A temp directory that work items need and the actual install directory. | 598 // A temp directory that work items need and the actual install directory. |
| 599 install_list->AddCreateDirWorkItem(FilePath::FromWStringHack(temp_dir)); | 599 install_list->AddCreateDirWorkItem(FilePath::FromWStringHack(temp_dir)); |
| 600 install_list->AddCreateDirWorkItem(FilePath::FromWStringHack(install_path)); | 600 install_list->AddCreateDirWorkItem(FilePath::FromWStringHack(install_path)); |
| 601 | 601 |
| 602 // Delete any new_chrome.exe if present (we will end up creating a new one | 602 // Delete any new_chrome.exe if present (we will end up creating a new one |
| 603 // if required) and then copy chrome.exe | 603 // if required) and then copy chrome.exe |
| 604 std::wstring new_chrome_exe = AppendPath(install_path, | 604 std::wstring new_chrome_exe = AppendPath(install_path, |
| 605 installer_util::kChromeNewExe); | 605 installer_util::kChromeNewExe); |
| 606 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | 606 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
| 607 RegKey chrome_key(reg_root, dist->GetVersionKey().c_str(), KEY_READ); | 607 base::win::RegKey chrome_key(reg_root, dist->GetVersionKey().c_str(), |
| 608 KEY_READ); |
| 608 if (file_util::PathExists(FilePath::FromWStringHack(new_chrome_exe))) | 609 if (file_util::PathExists(FilePath::FromWStringHack(new_chrome_exe))) |
| 609 chrome_key.ReadValue(google_update::kRegOldVersionField, current_version); | 610 chrome_key.ReadValue(google_update::kRegOldVersionField, current_version); |
| 610 if (current_version->empty()) | 611 if (current_version->empty()) |
| 611 chrome_key.ReadValue(google_update::kRegVersionField, current_version); | 612 chrome_key.ReadValue(google_update::kRegVersionField, current_version); |
| 612 chrome_key.Close(); | 613 chrome_key.Close(); |
| 613 | 614 |
| 614 install_list->AddDeleteTreeWorkItem(new_chrome_exe, std::wstring()); | 615 install_list->AddDeleteTreeWorkItem(new_chrome_exe, std::wstring()); |
| 615 install_list->AddCopyTreeWorkItem( | 616 install_list->AddCopyTreeWorkItem( |
| 616 AppendPath(src_path, installer_util::kChromeExe), | 617 AppendPath(src_path, installer_util::kChromeExe), |
| 617 AppendPath(install_path, installer_util::kChromeExe), | 618 AppendPath(install_path, installer_util::kChromeExe), |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 797 } | 798 } |
| 798 | 799 |
| 799 std::wstring latest_version_to_keep(new_version.GetString()); | 800 std::wstring latest_version_to_keep(new_version.GetString()); |
| 800 if (!current_version.empty()) | 801 if (!current_version.empty()) |
| 801 latest_version_to_keep.assign(current_version); | 802 latest_version_to_keep.assign(current_version); |
| 802 RemoveOldVersionDirs(install_path, latest_version_to_keep); | 803 RemoveOldVersionDirs(install_path, latest_version_to_keep); |
| 803 } | 804 } |
| 804 | 805 |
| 805 return result; | 806 return result; |
| 806 } | 807 } |
| OLD | NEW |