| 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 <shlobj.h> | 5 #include <shlobj.h> |
| 6 #include <time.h> | 6 #include <time.h> |
| 7 | 7 |
| 8 #include "chrome/installer/setup/install.h" | 8 #include "chrome/installer/setup/install.h" |
| 9 | 9 |
| 10 #include "base/command_line.h" |
| 10 #include "base/file_util.h" | 11 #include "base/file_util.h" |
| 11 #include "base/logging.h" | 12 #include "base/logging.h" |
| 12 #include "base/path_service.h" | 13 #include "base/path_service.h" |
| 13 #include "base/registry.h" | 14 #include "base/registry.h" |
| 14 #include "base/scoped_ptr.h" | 15 #include "base/scoped_ptr.h" |
| 15 #include "chrome/installer/setup/setup_constants.h" | 16 #include "chrome/installer/setup/setup_constants.h" |
| 16 #include "chrome/installer/util/browser_distribution.h" | 17 #include "chrome/installer/util/browser_distribution.h" |
| 17 #include "chrome/installer/util/create_reg_key_work_item.h" | 18 #include "chrome/installer/util/create_reg_key_work_item.h" |
| 18 #include "chrome/installer/util/delete_after_reboot_helper.h" | 19 #include "chrome/installer/util/delete_after_reboot_helper.h" |
| 19 #include "chrome/installer/util/google_update_constants.h" | 20 #include "chrome/installer/util/google_update_constants.h" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 install_list->AddCopyTreeWorkItem(exe_path, exe_dst, temp_path, | 79 install_list->AddCopyTreeWorkItem(exe_path, exe_dst, temp_path, |
| 79 WorkItem::ALWAYS); | 80 WorkItem::ALWAYS); |
| 80 if (system_level) { | 81 if (system_level) { |
| 81 install_list->AddCopyTreeWorkItem(archive_path, archive_dst, temp_path, | 82 install_list->AddCopyTreeWorkItem(archive_path, archive_dst, temp_path, |
| 82 WorkItem::ALWAYS); | 83 WorkItem::ALWAYS); |
| 83 } else { | 84 } else { |
| 84 install_list->AddMoveTreeWorkItem(archive_path, archive_dst, temp_path); | 85 install_list->AddMoveTreeWorkItem(archive_path, archive_dst, temp_path); |
| 85 } | 86 } |
| 86 } | 87 } |
| 87 | 88 |
| 89 void AppendUninstallCommandLineFlags(std::wstring* uninstall_cmd_line, |
| 90 bool is_system) { |
| 91 DCHECK(uninstall_cmd_line); |
| 92 uninstall_cmd_line->append(L" --"); |
| 93 uninstall_cmd_line->append(installer_util::switches::kUninstall); |
| 94 |
| 95 if (InstallUtil::IsChromeFrameProcess()) { |
| 96 uninstall_cmd_line->append(L" --"); |
| 97 uninstall_cmd_line->append(installer_util::switches::kForceUninstall); |
| 98 uninstall_cmd_line->append(L" --"); |
| 99 uninstall_cmd_line->append(installer_util::switches::kDeleteProfile); |
| 100 uninstall_cmd_line->append(L" --"); |
| 101 uninstall_cmd_line->append(installer_util::switches::kChromeFrame); |
| 102 } |
| 103 |
| 104 // Propagate the verbose logging switch to uninstalls too. |
| 105 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 106 if (command_line.HasSwitch(installer_util::switches::kVerboseLogging)) { |
| 107 uninstall_cmd_line->append(L" --"); |
| 108 uninstall_cmd_line->append(installer_util::switches::kVerboseLogging); |
| 109 } |
| 110 |
| 111 if (is_system) { |
| 112 uninstall_cmd_line->append(L" --"); |
| 113 uninstall_cmd_line->append(installer_util::switches::kSystemLevel); |
| 114 } |
| 115 } |
| 116 |
| 88 // This method adds work items to create (or update) Chrome uninstall entry in | 117 // This method adds work items to create (or update) Chrome uninstall entry in |
| 89 // Control Panel->Add/Remove Programs list. | 118 // Control Panel->Add/Remove Programs list. |
| 90 void AddUninstallShortcutWorkItems(HKEY reg_root, | 119 void AddUninstallShortcutWorkItems(HKEY reg_root, |
| 91 const std::wstring& exe_path, | 120 const std::wstring& exe_path, |
| 92 const std::wstring& install_path, | 121 const std::wstring& install_path, |
| 93 const std::wstring& product_name, | 122 const std::wstring& product_name, |
| 94 const std::wstring& new_version, | 123 const std::wstring& new_version, |
| 95 WorkItemList* install_list) { | 124 WorkItemList* install_list) { |
| 96 std::wstring uninstall_cmd(L"\""); | 125 std::wstring uninstall_cmd(L"\""); |
| 97 uninstall_cmd.append(installer::GetInstallerPathUnderChrome(install_path, | 126 uninstall_cmd.append(installer::GetInstallerPathUnderChrome(install_path, |
| 98 new_version)); | 127 new_version)); |
| 99 file_util::AppendToPath(&uninstall_cmd, | 128 file_util::AppendToPath(&uninstall_cmd, |
| 100 file_util::GetFilenameFromPath(exe_path)); | 129 file_util::GetFilenameFromPath(exe_path)); |
| 101 uninstall_cmd.append(L"\" --"); | 130 uninstall_cmd.append(L"\""); |
| 102 uninstall_cmd.append(installer_util::switches::kUninstall); | |
| 103 | 131 |
| 104 #if defined(CHROME_FRAME_BUILD) | 132 AppendUninstallCommandLineFlags(&uninstall_cmd, |
| 105 uninstall_cmd.append(L" --"); | 133 reg_root == HKEY_LOCAL_MACHINE); |
| 106 uninstall_cmd.append(installer_util::switches::kForceUninstall); | |
| 107 uninstall_cmd.append(L" --"); | |
| 108 uninstall_cmd.append(installer_util::switches::kDeleteProfile); | |
| 109 #endif | |
| 110 | |
| 111 if (reg_root == HKEY_LOCAL_MACHINE) { | |
| 112 uninstall_cmd.append(L" --"); | |
| 113 uninstall_cmd.append(installer_util::switches::kSystemLevel); | |
| 114 } | |
| 115 | 134 |
| 116 // Create DisplayName, UninstallString and InstallLocation keys | 135 // Create DisplayName, UninstallString and InstallLocation keys |
| 117 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | 136 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
| 118 std::wstring uninstall_reg = dist->GetUninstallRegPath(); | 137 std::wstring uninstall_reg = dist->GetUninstallRegPath(); |
| 119 install_list->AddCreateRegKeyWorkItem(reg_root, uninstall_reg); | 138 install_list->AddCreateRegKeyWorkItem(reg_root, uninstall_reg); |
| 120 install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg, | 139 install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg, |
| 121 installer_util::kUninstallDisplayNameField, product_name, true); | 140 installer_util::kUninstallDisplayNameField, product_name, true); |
| 122 install_list->AddSetRegValueWorkItem(reg_root, | 141 install_list->AddSetRegValueWorkItem(reg_root, |
| 123 uninstall_reg, | 142 uninstall_reg, |
| 124 installer_util::kUninstallStringField, | 143 installer_util::kUninstallStringField, |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 dist->GetUninstallLinkName() + L".lnk"); | 262 dist->GetUninstallLinkName() + L".lnk"); |
| 244 if ((install_status == installer_util::FIRST_INSTALL_SUCCESS) || | 263 if ((install_status == installer_util::FIRST_INSTALL_SUCCESS) || |
| 245 (install_status == installer_util::INSTALL_REPAIRED) || | 264 (install_status == installer_util::INSTALL_REPAIRED) || |
| 246 (file_util::PathExists(uninstall_link))) { | 265 (file_util::PathExists(uninstall_link))) { |
| 247 if (!file_util::PathExists(shortcut_path)) | 266 if (!file_util::PathExists(shortcut_path)) |
| 248 file_util::CreateDirectoryW(shortcut_path); | 267 file_util::CreateDirectoryW(shortcut_path); |
| 249 std::wstring setup_exe(installer::GetInstallerPathUnderChrome(install_path, | 268 std::wstring setup_exe(installer::GetInstallerPathUnderChrome(install_path, |
| 250 new_version)); | 269 new_version)); |
| 251 file_util::AppendToPath(&setup_exe, | 270 file_util::AppendToPath(&setup_exe, |
| 252 file_util::GetFilenameFromPath(exe_path)); | 271 file_util::GetFilenameFromPath(exe_path)); |
| 253 std::wstring arguments(L" --"); | |
| 254 arguments.append(installer_util::switches::kUninstall); | |
| 255 | 272 |
| 256 #if defined(CHROME_FRAME_BUILD) | 273 std::wstring arguments; |
| 257 arguments.append(L" --"); | 274 AppendUninstallCommandLineFlags(&arguments, system_install); |
| 258 arguments.append(installer_util::switches::kForceUninstall); | |
| 259 arguments.append(L" --"); | |
| 260 arguments.append(installer_util::switches::kDeleteProfile); | |
| 261 #endif | |
| 262 | |
| 263 if (system_install) { | |
| 264 arguments.append(L" --"); | |
| 265 arguments.append(installer_util::switches::kSystemLevel); | |
| 266 } | |
| 267 | 275 |
| 268 LOG(INFO) << "Creating/updating uninstall link at " | 276 LOG(INFO) << "Creating/updating uninstall link at " |
| 269 << uninstall_link.value(); | 277 << uninstall_link.value(); |
| 270 ret = ret && file_util::CreateShortcutLink(setup_exe.c_str(), | 278 ret = ret && file_util::CreateShortcutLink(setup_exe.c_str(), |
| 271 uninstall_link.value().c_str(), | 279 uninstall_link.value().c_str(), |
| 272 NULL, | 280 NULL, |
| 273 arguments.c_str(), | 281 arguments.c_str(), |
| 274 NULL, setup_exe.c_str(), 0); | 282 NULL, setup_exe.c_str(), 0); |
| 275 } | 283 } |
| 276 | 284 |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 const std::wstring& archive_path, | 467 const std::wstring& archive_path, |
| 460 const std::wstring& src_path, | 468 const std::wstring& src_path, |
| 461 const std::wstring& install_path, | 469 const std::wstring& install_path, |
| 462 const std::wstring& temp_dir, | 470 const std::wstring& temp_dir, |
| 463 const HKEY reg_root, | 471 const HKEY reg_root, |
| 464 const installer::Version& new_version, | 472 const installer::Version& new_version, |
| 465 std::wstring* current_version) { | 473 std::wstring* current_version) { |
| 466 if (reg_root != HKEY_LOCAL_MACHINE && reg_root != HKEY_CURRENT_USER) | 474 if (reg_root != HKEY_LOCAL_MACHINE && reg_root != HKEY_CURRENT_USER) |
| 467 return false; | 475 return false; |
| 468 | 476 |
| 469 #if defined(CHROME_FRAME_BUILD) | 477 if (InstallUtil::IsChromeFrameProcess()) { |
| 470 // Make sure that we don't end up deleting installed files on next reboot. | 478 // Make sure that we don't end up deleting installed files on next reboot. |
| 471 if (!RemoveFromMovesPendingReboot(install_path.c_str())) { | 479 if (!RemoveFromMovesPendingReboot(install_path.c_str())) { |
| 472 LOG(ERROR) << "Error accessing pending moves value."; | 480 LOG(ERROR) << "Error accessing pending moves value."; |
| 481 } |
| 473 } | 482 } |
| 474 #endif | |
| 475 | 483 |
| 476 scoped_ptr<WorkItemList> install_list(WorkItem::CreateWorkItemList()); | 484 scoped_ptr<WorkItemList> install_list(WorkItem::CreateWorkItemList()); |
| 477 // A temp directory that work items need and the actual install directory. | 485 // A temp directory that work items need and the actual install directory. |
| 478 install_list->AddCreateDirWorkItem(FilePath::FromWStringHack(temp_dir)); | 486 install_list->AddCreateDirWorkItem(FilePath::FromWStringHack(temp_dir)); |
| 479 install_list->AddCreateDirWorkItem(FilePath::FromWStringHack(install_path)); | 487 install_list->AddCreateDirWorkItem(FilePath::FromWStringHack(install_path)); |
| 480 | 488 |
| 481 // If it is system level install copy the version folder (since we want to | 489 // If it is system level install copy the version folder (since we want to |
| 482 // take the permissions of %ProgramFiles% folder) otherwise just move it. | 490 // take the permissions of %ProgramFiles% folder) otherwise just move it. |
| 483 if (reg_root == HKEY_LOCAL_MACHINE) { | 491 if (reg_root == HKEY_LOCAL_MACHINE) { |
| 484 install_list->AddCopyTreeWorkItem( | 492 install_list->AddCopyTreeWorkItem( |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 649 } | 657 } |
| 650 | 658 |
| 651 std::wstring latest_version_to_keep(new_version.GetString()); | 659 std::wstring latest_version_to_keep(new_version.GetString()); |
| 652 if (!current_version.empty()) | 660 if (!current_version.empty()) |
| 653 latest_version_to_keep.assign(current_version); | 661 latest_version_to_keep.assign(current_version); |
| 654 RemoveOldVersionDirs(install_path, latest_version_to_keep); | 662 RemoveOldVersionDirs(install_path, latest_version_to_keep); |
| 655 } | 663 } |
| 656 | 664 |
| 657 return result; | 665 return result; |
| 658 } | 666 } |
| OLD | NEW |