| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <windows.h> | 5 #include <windows.h> |
| 6 #include <msi.h> | 6 #include <msi.h> |
| 7 #include <shellapi.h> | 7 #include <shellapi.h> |
| 8 #include <shlobj.h> | 8 #include <shlobj.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 static_cast<BrowserDistribution::Type>(i); | 163 static_cast<BrowserDistribution::Type>(i); |
| 164 | 164 |
| 165 if (!installer_state->FindProduct(type)) { | 165 if (!installer_state->FindProduct(type)) { |
| 166 const ProductState* state = | 166 const ProductState* state = |
| 167 original_state.GetProductState(installer_state->system_install(), | 167 original_state.GetProductState(installer_state->system_install(), |
| 168 type); | 168 type); |
| 169 if ((state != NULL) && state->is_multi_install()) { | 169 if ((state != NULL) && state->is_multi_install()) { |
| 170 installer_state->AddProductFromState(type, *state); | 170 installer_state->AddProductFromState(type, *state); |
| 171 VLOG(1) << "Product already installed and must be included: " | 171 VLOG(1) << "Product already installed and must be included: " |
| 172 << BrowserDistribution::GetSpecificDistribution(type)-> | 172 << BrowserDistribution::GetSpecificDistribution(type)-> |
| 173 GetAppShortCutName(); | 173 GetDisplayName(); |
| 174 } | 174 } |
| 175 } | 175 } |
| 176 } | 176 } |
| 177 } | 177 } |
| 178 } | 178 } |
| 179 | 179 |
| 180 // This function is called when --rename-chrome-exe option is specified on | 180 // This function is called when --rename-chrome-exe option is specified on |
| 181 // setup.exe command line. This function assumes an in-use update has happened | 181 // setup.exe command line. This function assumes an in-use update has happened |
| 182 // for Chrome so there should be a file called new_chrome.exe on the file | 182 // for Chrome so there should be a file called new_chrome.exe on the file |
| 183 // system and a key called 'opv' in the registry. This function will move | 183 // system and a key called 'opv' in the registry. This function will move |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 original_state.GetProductState(is_system_install, dist->GetType()); | 297 original_state.GetProductState(is_system_install, dist->GetType()); |
| 298 // Is an earlier version of this product already installed? | 298 // Is an earlier version of this product already installed? |
| 299 if (product_state != NULL && | 299 if (product_state != NULL && |
| 300 product_state->version().CompareTo(new_version) < 0) { | 300 product_state->version().CompareTo(new_version) < 0) { |
| 301 bool is_overridden = false; | 301 bool is_overridden = false; |
| 302 GoogleUpdateSettings::UpdatePolicy app_policy = | 302 GoogleUpdateSettings::UpdatePolicy app_policy = |
| 303 GoogleUpdateSettings::GetAppUpdatePolicy(dist->GetAppGuid(), | 303 GoogleUpdateSettings::GetAppUpdatePolicy(dist->GetAppGuid(), |
| 304 &is_overridden); | 304 &is_overridden); |
| 305 if (is_overridden && app_policy != binaries_policy) { | 305 if (is_overridden && app_policy != binaries_policy) { |
| 306 LOG(ERROR) << "Found legacy Group Policy setting for " | 306 LOG(ERROR) << "Found legacy Group Policy setting for " |
| 307 << dist->GetAppShortCutName() << " (value: " << app_policy | 307 << dist->GetDisplayName() << " (value: " << app_policy |
| 308 << ") that does not match the setting for " | 308 << ") that does not match the setting for " |
| 309 << binaries_dist->GetAppShortCutName() | 309 << binaries_dist->GetDisplayName() |
| 310 << " (value: " << binaries_policy << ")."; | 310 << " (value: " << binaries_policy << ")."; |
| 311 settings_are_valid = false; | 311 settings_are_valid = false; |
| 312 } | 312 } |
| 313 } | 313 } |
| 314 } | 314 } |
| 315 | 315 |
| 316 if (!settings_are_valid) { | 316 if (!settings_are_valid) { |
| 317 // TODO(grt): add " See http://goo.gl/+++ for details." to the end of this | 317 // TODO(grt): add " See http://goo.gl/+++ for details." to the end of this |
| 318 // log message and to the IDS_INSTALL_INCONSISTENT_UPDATE_POLICY string once | 318 // log message and to the IDS_INSTALL_INCONSISTENT_UPDATE_POLICY string once |
| 319 // we have a help center article that explains why this error is being | 319 // we have a help center article that explains why this error is being |
| 320 // reported and how to resolve it. | 320 // reported and how to resolve it. |
| 321 LOG(ERROR) << "Cannot apply update on account of inconsistent " | 321 LOG(ERROR) << "Cannot apply update on account of inconsistent " |
| 322 "Google Update Group Policy settings. Use the Group Policy " | 322 "Google Update Group Policy settings. Use the Group Policy " |
| 323 "Editor to set the update policy override for the " | 323 "Editor to set the update policy override for the " |
| 324 << binaries_dist->GetAppShortCutName() | 324 << binaries_dist->GetDisplayName() |
| 325 << " application and try again."; | 325 << " application and try again."; |
| 326 *status = installer::INCONSISTENT_UPDATE_POLICY; | 326 *status = installer::INCONSISTENT_UPDATE_POLICY; |
| 327 installer_state.WriteInstallerResult( | 327 installer_state.WriteInstallerResult( |
| 328 *status, IDS_INSTALL_INCONSISTENT_UPDATE_POLICY_BASE, NULL); | 328 *status, IDS_INSTALL_INCONSISTENT_UPDATE_POLICY_BASE, NULL); |
| 329 } | 329 } |
| 330 | 330 |
| 331 return settings_are_valid; | 331 return settings_are_valid; |
| 332 #endif // defined(GOOGLE_CHROME_BUILD) | 332 #endif // defined(GOOGLE_CHROME_BUILD) |
| 333 } | 333 } |
| 334 | 334 |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 } else { | 464 } else { |
| 465 // This is a non-multi installation. | 465 // This is a non-multi installation. |
| 466 | 466 |
| 467 // Check for an existing installation of the product. | 467 // Check for an existing installation of the product. |
| 468 const ProductState* product_state = original_state.GetProductState( | 468 const ProductState* product_state = original_state.GetProductState( |
| 469 system_level, products[0]->distribution()->GetType()); | 469 system_level, products[0]->distribution()->GetType()); |
| 470 if (product_state != NULL) { | 470 if (product_state != NULL) { |
| 471 // Block downgrades from multi-install to single-install. | 471 // Block downgrades from multi-install to single-install. |
| 472 if (product_state->is_multi_install()) { | 472 if (product_state->is_multi_install()) { |
| 473 LOG(ERROR) << "Multi-install " | 473 LOG(ERROR) << "Multi-install " |
| 474 << products[0]->distribution()->GetAppShortCutName() | 474 << products[0]->distribution()->GetDisplayName() |
| 475 << " exists; aborting single install."; | 475 << " exists; aborting single install."; |
| 476 *status = installer::MULTI_INSTALLATION_EXISTS; | 476 *status = installer::MULTI_INSTALLATION_EXISTS; |
| 477 installer_state->WriteInstallerResult(*status, | 477 installer_state->WriteInstallerResult(*status, |
| 478 IDS_INSTALL_MULTI_INSTALLATION_EXISTS_BASE, NULL); | 478 IDS_INSTALL_MULTI_INSTALLATION_EXISTS_BASE, NULL); |
| 479 return false; | 479 return false; |
| 480 } | 480 } |
| 481 } | 481 } |
| 482 } | 482 } |
| 483 | 483 |
| 484 return true; | 484 return true; |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 759 const Products& products = installer_state.products(); | 759 const Products& products = installer_state.products(); |
| 760 for (Products::const_iterator it = products.begin(); it < products.end(); | 760 for (Products::const_iterator it = products.begin(); it < products.end(); |
| 761 ++it) { | 761 ++it) { |
| 762 const Product& product = **it; | 762 const Product& product = **it; |
| 763 const ProductState* product_state = | 763 const ProductState* product_state = |
| 764 original_state.GetProductState(system_install, | 764 original_state.GetProductState(system_install, |
| 765 product.distribution()->GetType()); | 765 product.distribution()->GetType()); |
| 766 if (product_state != NULL && | 766 if (product_state != NULL && |
| 767 (product_state->version().CompareTo(*installer_version) > 0)) { | 767 (product_state->version().CompareTo(*installer_version) > 0)) { |
| 768 LOG(ERROR) << "Higher version of " | 768 LOG(ERROR) << "Higher version of " |
| 769 << product.distribution()->GetAppShortCutName() | 769 << product.distribution()->GetDisplayName() |
| 770 << " is already installed."; | 770 << " is already installed."; |
| 771 higher_products |= (1 << product.distribution()->GetType()); | 771 higher_products |= (1 << product.distribution()->GetType()); |
| 772 } | 772 } |
| 773 } | 773 } |
| 774 | 774 |
| 775 if (higher_products != 0) { | 775 if (higher_products != 0) { |
| 776 COMPILE_ASSERT(BrowserDistribution::NUM_TYPES == 4, | 776 COMPILE_ASSERT(BrowserDistribution::NUM_TYPES == 4, |
| 777 add_support_for_new_products_here_); | 777 add_support_for_new_products_here_); |
| 778 const uint32 kBrowserBit = 1 << BrowserDistribution::CHROME_BROWSER; | 778 const uint32 kBrowserBit = 1 << BrowserDistribution::CHROME_BROWSER; |
| 779 const uint32 kGCFBit = 1 << BrowserDistribution::CHROME_FRAME; | 779 const uint32 kGCFBit = 1 << BrowserDistribution::CHROME_FRAME; |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1005 bool remove_all, | 1005 bool remove_all, |
| 1006 bool force_uninstall, | 1006 bool force_uninstall, |
| 1007 const Product& product) { | 1007 const Product& product) { |
| 1008 const ProductState* product_state = | 1008 const ProductState* product_state = |
| 1009 original_state.GetProductState(installer_state.system_install(), | 1009 original_state.GetProductState(installer_state.system_install(), |
| 1010 product.distribution()->GetType()); | 1010 product.distribution()->GetType()); |
| 1011 if (product_state != NULL) { | 1011 if (product_state != NULL) { |
| 1012 VLOG(1) << "version on the system: " | 1012 VLOG(1) << "version on the system: " |
| 1013 << product_state->version().GetString(); | 1013 << product_state->version().GetString(); |
| 1014 } else if (!force_uninstall) { | 1014 } else if (!force_uninstall) { |
| 1015 LOG(ERROR) << product.distribution()->GetAppShortCutName() | 1015 LOG(ERROR) << product.distribution()->GetDisplayName() |
| 1016 << " not found for uninstall."; | 1016 << " not found for uninstall."; |
| 1017 return installer::CHROME_NOT_INSTALLED; | 1017 return installer::CHROME_NOT_INSTALLED; |
| 1018 } | 1018 } |
| 1019 | 1019 |
| 1020 return installer::UninstallProduct( | 1020 return installer::UninstallProduct( |
| 1021 original_state, installer_state, cmd_line.GetProgram(), product, | 1021 original_state, installer_state, cmd_line.GetProgram(), product, |
| 1022 remove_all, force_uninstall, cmd_line); | 1022 remove_all, force_uninstall, cmd_line); |
| 1023 } | 1023 } |
| 1024 | 1024 |
| 1025 installer::InstallStatus UninstallProducts( | 1025 installer::InstallStatus UninstallProducts( |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1177 original_state.GetProductState(false, | 1177 original_state.GetProductState(false, |
| 1178 BrowserDistribution::CHROME_BROWSER); | 1178 BrowserDistribution::CHROME_BROWSER); |
| 1179 if (!existing_chrome) { | 1179 if (!existing_chrome) { |
| 1180 existing_chrome = | 1180 existing_chrome = |
| 1181 original_state.GetProductState(true, BrowserDistribution::CHROME_BROWSER); | 1181 original_state.GetProductState(true, BrowserDistribution::CHROME_BROWSER); |
| 1182 } | 1182 } |
| 1183 if (existing_chrome) { | 1183 if (existing_chrome) { |
| 1184 static const wchar_t kPleaseUninstallYourChromeMessage[] = | 1184 static const wchar_t kPleaseUninstallYourChromeMessage[] = |
| 1185 L"You already have a full-installation (non-dev) of %1ls, please " | 1185 L"You already have a full-installation (non-dev) of %1ls, please " |
| 1186 L"uninstall it first using Add/Remove Programs in the control panel."; | 1186 L"uninstall it first using Add/Remove Programs in the control panel."; |
| 1187 string16 name(chrome_dist->GetAppShortCutName()); | 1187 string16 name(chrome_dist->GetDisplayName()); |
| 1188 string16 message(base::StringPrintf(kPleaseUninstallYourChromeMessage, | 1188 string16 message(base::StringPrintf(kPleaseUninstallYourChromeMessage, |
| 1189 name.c_str())); | 1189 name.c_str())); |
| 1190 | 1190 |
| 1191 LOG(ERROR) << "Aborting operation: another installation of " << name | 1191 LOG(ERROR) << "Aborting operation: another installation of " << name |
| 1192 << " was found, as a last resort (if the product is not present " | 1192 << " was found, as a last resort (if the product is not present " |
| 1193 "in Add/Remove Programs), try executing: " | 1193 "in Add/Remove Programs), try executing: " |
| 1194 << existing_chrome->uninstall_command().GetCommandLineString(); | 1194 << existing_chrome->uninstall_command().GetCommandLineString(); |
| 1195 MessageBox(NULL, message.c_str(), NULL, MB_ICONERROR); | 1195 MessageBox(NULL, message.c_str(), NULL, MB_ICONERROR); |
| 1196 return installer::INSTALL_FAILED; | 1196 return installer::INSTALL_FAILED; |
| 1197 } | 1197 } |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1445 for (Products::const_iterator it = products.begin(); it < products.end(); | 1445 for (Products::const_iterator it = products.begin(); it < products.end(); |
| 1446 ++it) { | 1446 ++it) { |
| 1447 const Product& product = **it; | 1447 const Product& product = **it; |
| 1448 BrowserDistribution* browser_dist = product.distribution(); | 1448 BrowserDistribution* browser_dist = product.distribution(); |
| 1449 // We started as system-level and have been re-launched as user level | 1449 // We started as system-level and have been re-launched as user level |
| 1450 // to continue with the toast experiment. | 1450 // to continue with the toast experiment. |
| 1451 Version installed_version; | 1451 Version installed_version; |
| 1452 InstallUtil::GetChromeVersion(browser_dist, true, &installed_version); | 1452 InstallUtil::GetChromeVersion(browser_dist, true, &installed_version); |
| 1453 if (!installed_version.IsValid()) { | 1453 if (!installed_version.IsValid()) { |
| 1454 LOG(ERROR) << "No installation of " | 1454 LOG(ERROR) << "No installation of " |
| 1455 << browser_dist->GetAppShortCutName() | 1455 << browser_dist->GetDisplayName() |
| 1456 << " found for system-level toast."; | 1456 << " found for system-level toast."; |
| 1457 } else { | 1457 } else { |
| 1458 product.LaunchUserExperiment( | 1458 product.LaunchUserExperiment( |
| 1459 cmd_line.GetProgram(), installer::REENTRY_SYS_UPDATE, true); | 1459 cmd_line.GetProgram(), installer::REENTRY_SYS_UPDATE, true); |
| 1460 } | 1460 } |
| 1461 } | 1461 } |
| 1462 } else if (cmd_line.HasSwitch( | 1462 } else if (cmd_line.HasSwitch( |
| 1463 installer::switches::kChromeFrameReadyModeOptIn)) { | 1463 installer::switches::kChromeFrameReadyModeOptIn)) { |
| 1464 *exit_code = InstallUtil::GetInstallReturnCode( | 1464 *exit_code = InstallUtil::GetInstallReturnCode( |
| 1465 installer::ChromeFrameReadyModeOptIn(original_state, *installer_state)); | 1465 installer::ChromeFrameReadyModeOptIn(original_state, *installer_state)); |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1732 int num_products = 0; | 1732 int num_products = 0; |
| 1733 for (Products::const_iterator it = products.begin(); it < products.end(); | 1733 for (Products::const_iterator it = products.begin(); it < products.end(); |
| 1734 ++it) { | 1734 ++it) { |
| 1735 if (!(*it)->is_chrome_binaries()) | 1735 if (!(*it)->is_chrome_binaries()) |
| 1736 ++num_products; | 1736 ++num_products; |
| 1737 } | 1737 } |
| 1738 if (num_products == 1U) { | 1738 if (num_products == 1U) { |
| 1739 ::MessageBoxW(NULL, | 1739 ::MessageBoxW(NULL, |
| 1740 installer::GetLocalizedString( | 1740 installer::GetLocalizedString( |
| 1741 IDS_UNINSTALL_COMPLETE_BASE).c_str(), | 1741 IDS_UNINSTALL_COMPLETE_BASE).c_str(), |
| 1742 cf_install->distribution()->GetAppShortCutName().c_str(), | 1742 cf_install->distribution()->GetDisplayName().c_str(), |
| 1743 MB_OK); | 1743 MB_OK); |
| 1744 } | 1744 } |
| 1745 } | 1745 } |
| 1746 } | 1746 } |
| 1747 | 1747 |
| 1748 int return_code = 0; | 1748 int return_code = 0; |
| 1749 // MSI demands that custom actions always return 0 (ERROR_SUCCESS) or it will | 1749 // MSI demands that custom actions always return 0 (ERROR_SUCCESS) or it will |
| 1750 // rollback the action. If we're uninstalling we want to avoid this, so always | 1750 // rollback the action. If we're uninstalling we want to avoid this, so always |
| 1751 // report success, squashing any more informative return codes. | 1751 // report success, squashing any more informative return codes. |
| 1752 if (!(installer_state.is_msi() && is_uninstall)) | 1752 if (!(installer_state.is_msi() && is_uninstall)) |
| 1753 // Note that we allow the status installer::UNINSTALL_REQUIRES_REBOOT | 1753 // Note that we allow the status installer::UNINSTALL_REQUIRES_REBOOT |
| 1754 // to pass through, since this is only returned on uninstall which is | 1754 // to pass through, since this is only returned on uninstall which is |
| 1755 // never invoked directly by Google Update. | 1755 // never invoked directly by Google Update. |
| 1756 return_code = InstallUtil::GetInstallReturnCode(install_status); | 1756 return_code = InstallUtil::GetInstallReturnCode(install_status); |
| 1757 | 1757 |
| 1758 VLOG(1) << "Installation complete, returning: " << return_code; | 1758 VLOG(1) << "Installation complete, returning: " << return_code; |
| 1759 | 1759 |
| 1760 return return_code; | 1760 return return_code; |
| 1761 } | 1761 } |
| OLD | NEW |