Chromium Code Reviews| 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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 162 static_cast<BrowserDistribution::Type>(i); | 162 static_cast<BrowserDistribution::Type>(i); |
| 163 | 163 |
| 164 if (!installer_state->FindProduct(type)) { | 164 if (!installer_state->FindProduct(type)) { |
| 165 const ProductState* state = | 165 const ProductState* state = |
| 166 original_state.GetProductState(installer_state->system_install(), | 166 original_state.GetProductState(installer_state->system_install(), |
| 167 type); | 167 type); |
| 168 if ((state != NULL) && state->is_multi_install()) { | 168 if ((state != NULL) && state->is_multi_install()) { |
| 169 installer_state->AddProductFromState(type, *state); | 169 installer_state->AddProductFromState(type, *state); |
| 170 VLOG(1) << "Product already installed and must be included: " | 170 VLOG(1) << "Product already installed and must be included: " |
| 171 << BrowserDistribution::GetSpecificDistribution(type)-> | 171 << BrowserDistribution::GetSpecificDistribution(type)-> |
| 172 GetAppShortCutName(); | 172 GetDisplayName(); |
|
huangs
2013/05/21 21:35:41
I don't think we should localize our logs. Please
| |
| 173 } | 173 } |
| 174 } | 174 } |
| 175 } | 175 } |
| 176 } | 176 } |
| 177 } | 177 } |
| 178 | 178 |
| 179 // This function is called when --rename-chrome-exe option is specified on | 179 // This function is called when --rename-chrome-exe option is specified on |
| 180 // setup.exe command line. This function assumes an in-use update has happened | 180 // setup.exe command line. This function assumes an in-use update has happened |
| 181 // for Chrome so there should be a file called new_chrome.exe on the file | 181 // for Chrome so there should be a file called new_chrome.exe on the file |
| 182 // system and a key called 'opv' in the registry. This function will move | 182 // 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... | |
| 296 original_state.GetProductState(is_system_install, dist->GetType()); | 296 original_state.GetProductState(is_system_install, dist->GetType()); |
| 297 // Is an earlier version of this product already installed? | 297 // Is an earlier version of this product already installed? |
| 298 if (product_state != NULL && | 298 if (product_state != NULL && |
| 299 product_state->version().CompareTo(new_version) < 0) { | 299 product_state->version().CompareTo(new_version) < 0) { |
| 300 bool is_overridden = false; | 300 bool is_overridden = false; |
| 301 GoogleUpdateSettings::UpdatePolicy app_policy = | 301 GoogleUpdateSettings::UpdatePolicy app_policy = |
| 302 GoogleUpdateSettings::GetAppUpdatePolicy(dist->GetAppGuid(), | 302 GoogleUpdateSettings::GetAppUpdatePolicy(dist->GetAppGuid(), |
| 303 &is_overridden); | 303 &is_overridden); |
| 304 if (is_overridden && app_policy != binaries_policy) { | 304 if (is_overridden && app_policy != binaries_policy) { |
| 305 LOG(ERROR) << "Found legacy Group Policy setting for " | 305 LOG(ERROR) << "Found legacy Group Policy setting for " |
| 306 << dist->GetAppShortCutName() << " (value: " << app_policy | 306 << dist->GetDisplayName() << " (value: " << app_policy |
| 307 << ") that does not match the setting for " | 307 << ") that does not match the setting for " |
| 308 << binaries_dist->GetAppShortCutName() | 308 << binaries_dist->GetDisplayName() |
| 309 << " (value: " << binaries_policy << ")."; | 309 << " (value: " << binaries_policy << ")."; |
| 310 settings_are_valid = false; | 310 settings_are_valid = false; |
| 311 } | 311 } |
| 312 } | 312 } |
| 313 } | 313 } |
| 314 | 314 |
| 315 if (!settings_are_valid) { | 315 if (!settings_are_valid) { |
| 316 // TODO(grt): add " See http://goo.gl/+++ for details." to the end of this | 316 // TODO(grt): add " See http://goo.gl/+++ for details." to the end of this |
| 317 // log message and to the IDS_INSTALL_INCONSISTENT_UPDATE_POLICY string once | 317 // log message and to the IDS_INSTALL_INCONSISTENT_UPDATE_POLICY string once |
| 318 // we have a help center article that explains why this error is being | 318 // we have a help center article that explains why this error is being |
| 319 // reported and how to resolve it. | 319 // reported and how to resolve it. |
| 320 LOG(ERROR) << "Cannot apply update on account of inconsistent " | 320 LOG(ERROR) << "Cannot apply update on account of inconsistent " |
| 321 "Google Update Group Policy settings. Use the Group Policy " | 321 "Google Update Group Policy settings. Use the Group Policy " |
| 322 "Editor to set the update policy override for the " | 322 "Editor to set the update policy override for the " |
| 323 << binaries_dist->GetAppShortCutName() | 323 << binaries_dist->GetDisplayName() |
| 324 << " application and try again."; | 324 << " application and try again."; |
| 325 *status = installer::INCONSISTENT_UPDATE_POLICY; | 325 *status = installer::INCONSISTENT_UPDATE_POLICY; |
| 326 installer_state.WriteInstallerResult( | 326 installer_state.WriteInstallerResult( |
| 327 *status, IDS_INSTALL_INCONSISTENT_UPDATE_POLICY_BASE, NULL); | 327 *status, IDS_INSTALL_INCONSISTENT_UPDATE_POLICY_BASE, NULL); |
| 328 } | 328 } |
| 329 | 329 |
| 330 return settings_are_valid; | 330 return settings_are_valid; |
| 331 #endif // defined(GOOGLE_CHROME_BUILD) | 331 #endif // defined(GOOGLE_CHROME_BUILD) |
| 332 } | 332 } |
| 333 | 333 |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 463 } else { | 463 } else { |
| 464 // This is a non-multi installation. | 464 // This is a non-multi installation. |
| 465 | 465 |
| 466 // Check for an existing installation of the product. | 466 // Check for an existing installation of the product. |
| 467 const ProductState* product_state = original_state.GetProductState( | 467 const ProductState* product_state = original_state.GetProductState( |
| 468 system_level, products[0]->distribution()->GetType()); | 468 system_level, products[0]->distribution()->GetType()); |
| 469 if (product_state != NULL) { | 469 if (product_state != NULL) { |
| 470 // Block downgrades from multi-install to single-install. | 470 // Block downgrades from multi-install to single-install. |
| 471 if (product_state->is_multi_install()) { | 471 if (product_state->is_multi_install()) { |
| 472 LOG(ERROR) << "Multi-install " | 472 LOG(ERROR) << "Multi-install " |
| 473 << products[0]->distribution()->GetAppShortCutName() | 473 << products[0]->distribution()->GetDisplayName() |
| 474 << " exists; aborting single install."; | 474 << " exists; aborting single install."; |
| 475 *status = installer::MULTI_INSTALLATION_EXISTS; | 475 *status = installer::MULTI_INSTALLATION_EXISTS; |
| 476 installer_state->WriteInstallerResult(*status, | 476 installer_state->WriteInstallerResult(*status, |
| 477 IDS_INSTALL_MULTI_INSTALLATION_EXISTS_BASE, NULL); | 477 IDS_INSTALL_MULTI_INSTALLATION_EXISTS_BASE, NULL); |
| 478 return false; | 478 return false; |
| 479 } | 479 } |
| 480 } | 480 } |
| 481 } | 481 } |
| 482 | 482 |
| 483 return true; | 483 return true; |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 755 const Products& products = installer_state.products(); | 755 const Products& products = installer_state.products(); |
| 756 for (Products::const_iterator it = products.begin(); it < products.end(); | 756 for (Products::const_iterator it = products.begin(); it < products.end(); |
| 757 ++it) { | 757 ++it) { |
| 758 const Product& product = **it; | 758 const Product& product = **it; |
| 759 const ProductState* product_state = | 759 const ProductState* product_state = |
| 760 original_state.GetProductState(system_install, | 760 original_state.GetProductState(system_install, |
| 761 product.distribution()->GetType()); | 761 product.distribution()->GetType()); |
| 762 if (product_state != NULL && | 762 if (product_state != NULL && |
| 763 (product_state->version().CompareTo(*installer_version) > 0)) { | 763 (product_state->version().CompareTo(*installer_version) > 0)) { |
| 764 LOG(ERROR) << "Higher version of " | 764 LOG(ERROR) << "Higher version of " |
| 765 << product.distribution()->GetAppShortCutName() | 765 << product.distribution()->GetDisplayName() |
| 766 << " is already installed."; | 766 << " is already installed."; |
| 767 higher_products |= (1 << product.distribution()->GetType()); | 767 higher_products |= (1 << product.distribution()->GetType()); |
| 768 } | 768 } |
| 769 } | 769 } |
| 770 | 770 |
| 771 if (higher_products != 0) { | 771 if (higher_products != 0) { |
| 772 COMPILE_ASSERT(BrowserDistribution::NUM_TYPES == 4, | 772 COMPILE_ASSERT(BrowserDistribution::NUM_TYPES == 4, |
| 773 add_support_for_new_products_here_); | 773 add_support_for_new_products_here_); |
| 774 const uint32 kBrowserBit = 1 << BrowserDistribution::CHROME_BROWSER; | 774 const uint32 kBrowserBit = 1 << BrowserDistribution::CHROME_BROWSER; |
| 775 const uint32 kGCFBit = 1 << BrowserDistribution::CHROME_FRAME; | 775 const uint32 kGCFBit = 1 << BrowserDistribution::CHROME_FRAME; |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1001 bool remove_all, | 1001 bool remove_all, |
| 1002 bool force_uninstall, | 1002 bool force_uninstall, |
| 1003 const Product& product) { | 1003 const Product& product) { |
| 1004 const ProductState* product_state = | 1004 const ProductState* product_state = |
| 1005 original_state.GetProductState(installer_state.system_install(), | 1005 original_state.GetProductState(installer_state.system_install(), |
| 1006 product.distribution()->GetType()); | 1006 product.distribution()->GetType()); |
| 1007 if (product_state != NULL) { | 1007 if (product_state != NULL) { |
| 1008 VLOG(1) << "version on the system: " | 1008 VLOG(1) << "version on the system: " |
| 1009 << product_state->version().GetString(); | 1009 << product_state->version().GetString(); |
| 1010 } else if (!force_uninstall) { | 1010 } else if (!force_uninstall) { |
| 1011 LOG(ERROR) << product.distribution()->GetAppShortCutName() | 1011 LOG(ERROR) << product.distribution()->GetDisplayName() |
| 1012 << " not found for uninstall."; | 1012 << " not found for uninstall."; |
| 1013 return installer::CHROME_NOT_INSTALLED; | 1013 return installer::CHROME_NOT_INSTALLED; |
| 1014 } | 1014 } |
| 1015 | 1015 |
| 1016 return installer::UninstallProduct( | 1016 return installer::UninstallProduct( |
| 1017 original_state, installer_state, cmd_line.GetProgram(), product, | 1017 original_state, installer_state, cmd_line.GetProgram(), product, |
| 1018 remove_all, force_uninstall, cmd_line); | 1018 remove_all, force_uninstall, cmd_line); |
| 1019 } | 1019 } |
| 1020 | 1020 |
| 1021 installer::InstallStatus UninstallProducts( | 1021 installer::InstallStatus UninstallProducts( |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1173 original_state.GetProductState(false, | 1173 original_state.GetProductState(false, |
| 1174 BrowserDistribution::CHROME_BROWSER); | 1174 BrowserDistribution::CHROME_BROWSER); |
| 1175 if (!existing_chrome) { | 1175 if (!existing_chrome) { |
| 1176 existing_chrome = | 1176 existing_chrome = |
| 1177 original_state.GetProductState(true, BrowserDistribution::CHROME_BROWSER); | 1177 original_state.GetProductState(true, BrowserDistribution::CHROME_BROWSER); |
| 1178 } | 1178 } |
| 1179 if (existing_chrome) { | 1179 if (existing_chrome) { |
| 1180 static const wchar_t kPleaseUninstallYourChromeMessage[] = | 1180 static const wchar_t kPleaseUninstallYourChromeMessage[] = |
| 1181 L"You already have a full-installation (non-dev) of %1ls, please " | 1181 L"You already have a full-installation (non-dev) of %1ls, please " |
| 1182 L"uninstall it first using Add/Remove Programs in the control panel."; | 1182 L"uninstall it first using Add/Remove Programs in the control panel."; |
| 1183 string16 name(chrome_dist->GetAppShortCutName()); | 1183 string16 name(chrome_dist->GetDisplayName()); |
| 1184 string16 message(base::StringPrintf(kPleaseUninstallYourChromeMessage, | 1184 string16 message(base::StringPrintf(kPleaseUninstallYourChromeMessage, |
| 1185 name.c_str())); | 1185 name.c_str())); |
| 1186 | 1186 |
| 1187 LOG(ERROR) << "Aborting operation: another installation of " << name | 1187 LOG(ERROR) << "Aborting operation: another installation of " << name |
| 1188 << " was found, as a last resort (if the product is not present " | 1188 << " was found, as a last resort (if the product is not present " |
| 1189 "in Add/Remove Programs), try executing: " | 1189 "in Add/Remove Programs), try executing: " |
| 1190 << existing_chrome->uninstall_command().GetCommandLineString(); | 1190 << existing_chrome->uninstall_command().GetCommandLineString(); |
| 1191 MessageBox(NULL, message.c_str(), NULL, MB_ICONERROR); | 1191 MessageBox(NULL, message.c_str(), NULL, MB_ICONERROR); |
| 1192 return installer::INSTALL_FAILED; | 1192 return installer::INSTALL_FAILED; |
| 1193 } | 1193 } |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1441 for (Products::const_iterator it = products.begin(); it < products.end(); | 1441 for (Products::const_iterator it = products.begin(); it < products.end(); |
| 1442 ++it) { | 1442 ++it) { |
| 1443 const Product& product = **it; | 1443 const Product& product = **it; |
| 1444 BrowserDistribution* browser_dist = product.distribution(); | 1444 BrowserDistribution* browser_dist = product.distribution(); |
| 1445 // We started as system-level and have been re-launched as user level | 1445 // We started as system-level and have been re-launched as user level |
| 1446 // to continue with the toast experiment. | 1446 // to continue with the toast experiment. |
| 1447 Version installed_version; | 1447 Version installed_version; |
| 1448 InstallUtil::GetChromeVersion(browser_dist, true, &installed_version); | 1448 InstallUtil::GetChromeVersion(browser_dist, true, &installed_version); |
| 1449 if (!installed_version.IsValid()) { | 1449 if (!installed_version.IsValid()) { |
| 1450 LOG(ERROR) << "No installation of " | 1450 LOG(ERROR) << "No installation of " |
| 1451 << browser_dist->GetAppShortCutName() | 1451 << browser_dist->GetDisplayName() |
| 1452 << " found for system-level toast."; | 1452 << " found for system-level toast."; |
| 1453 } else { | 1453 } else { |
| 1454 product.LaunchUserExperiment( | 1454 product.LaunchUserExperiment( |
| 1455 cmd_line.GetProgram(), installer::REENTRY_SYS_UPDATE, true); | 1455 cmd_line.GetProgram(), installer::REENTRY_SYS_UPDATE, true); |
| 1456 } | 1456 } |
| 1457 } | 1457 } |
| 1458 } else if (cmd_line.HasSwitch( | 1458 } else if (cmd_line.HasSwitch( |
| 1459 installer::switches::kChromeFrameReadyModeOptIn)) { | 1459 installer::switches::kChromeFrameReadyModeOptIn)) { |
| 1460 *exit_code = InstallUtil::GetInstallReturnCode( | 1460 *exit_code = InstallUtil::GetInstallReturnCode( |
| 1461 installer::ChromeFrameReadyModeOptIn(original_state, *installer_state)); | 1461 installer::ChromeFrameReadyModeOptIn(original_state, *installer_state)); |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1707 int num_products = 0; | 1707 int num_products = 0; |
| 1708 for (Products::const_iterator it = products.begin(); it < products.end(); | 1708 for (Products::const_iterator it = products.begin(); it < products.end(); |
| 1709 ++it) { | 1709 ++it) { |
| 1710 if (!(*it)->is_chrome_binaries()) | 1710 if (!(*it)->is_chrome_binaries()) |
| 1711 ++num_products; | 1711 ++num_products; |
| 1712 } | 1712 } |
| 1713 if (num_products == 1U) { | 1713 if (num_products == 1U) { |
| 1714 ::MessageBoxW(NULL, | 1714 ::MessageBoxW(NULL, |
| 1715 installer::GetLocalizedString( | 1715 installer::GetLocalizedString( |
| 1716 IDS_UNINSTALL_COMPLETE_BASE).c_str(), | 1716 IDS_UNINSTALL_COMPLETE_BASE).c_str(), |
| 1717 cf_install->distribution()->GetAppShortCutName().c_str(), | 1717 cf_install->distribution()->GetDisplayName().c_str(), |
| 1718 MB_OK); | 1718 MB_OK); |
| 1719 } | 1719 } |
| 1720 } | 1720 } |
| 1721 } | 1721 } |
| 1722 | 1722 |
| 1723 int return_code = 0; | 1723 int return_code = 0; |
| 1724 // MSI demands that custom actions always return 0 (ERROR_SUCCESS) or it will | 1724 // MSI demands that custom actions always return 0 (ERROR_SUCCESS) or it will |
| 1725 // rollback the action. If we're uninstalling we want to avoid this, so always | 1725 // rollback the action. If we're uninstalling we want to avoid this, so always |
| 1726 // report success, squashing any more informative return codes. | 1726 // report success, squashing any more informative return codes. |
| 1727 if (!(installer_state.is_msi() && is_uninstall)) | 1727 if (!(installer_state.is_msi() && is_uninstall)) |
| 1728 // Note that we allow the status installer::UNINSTALL_REQUIRES_REBOOT | 1728 // Note that we allow the status installer::UNINSTALL_REQUIRES_REBOOT |
| 1729 // to pass through, since this is only returned on uninstall which is | 1729 // to pass through, since this is only returned on uninstall which is |
| 1730 // never invoked directly by Google Update. | 1730 // never invoked directly by Google Update. |
| 1731 return_code = InstallUtil::GetInstallReturnCode(install_status); | 1731 return_code = InstallUtil::GetInstallReturnCode(install_status); |
| 1732 | 1732 |
| 1733 VLOG(1) << "Installation complete, returning: " << return_code; | 1733 VLOG(1) << "Installation complete, returning: " << return_code; |
| 1734 | 1734 |
| 1735 return return_code; | 1735 return return_code; |
| 1736 } | 1736 } |
| OLD | NEW |