| 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 "base/at_exit.h" | 10 #include "base/at_exit.h" |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 BrowserDistribution::Type type = | 152 BrowserDistribution::Type type = |
| 153 static_cast<BrowserDistribution::Type>(i); | 153 static_cast<BrowserDistribution::Type>(i); |
| 154 | 154 |
| 155 if (!installer_state->FindProduct(type)) { | 155 if (!installer_state->FindProduct(type)) { |
| 156 const ProductState* state = | 156 const ProductState* state = |
| 157 original_state.GetProductState(installer_state->system_install(), | 157 original_state.GetProductState(installer_state->system_install(), |
| 158 type); | 158 type); |
| 159 if ((state != NULL) && state->is_multi_install()) { | 159 if ((state != NULL) && state->is_multi_install()) { |
| 160 installer_state->AddProductFromState(type, *state); | 160 installer_state->AddProductFromState(type, *state); |
| 161 VLOG(1) << "Product already installed and must be included: " | 161 VLOG(1) << "Product already installed and must be included: " |
| 162 << BrowserDistribution::GetSpecificDistribution( | 162 << BrowserDistribution::GetSpecificDistribution(type)-> |
| 163 type)->GetAppShortCutName(); | 163 GetAppShortCutName(); |
| 164 } | 164 } |
| 165 } | 165 } |
| 166 } | 166 } |
| 167 } | 167 } |
| 168 } | 168 } |
| 169 | 169 |
| 170 // This function is called when --rename-chrome-exe option is specified on | 170 // This function is called when --rename-chrome-exe option is specified on |
| 171 // setup.exe command line. This function assumes an in-use update has happened | 171 // setup.exe command line. This function assumes an in-use update has happened |
| 172 // for Chrome so there should be a file called new_chrome.exe on the file | 172 // for Chrome so there should be a file called new_chrome.exe on the file |
| 173 // system and a key called 'opv' in the registry. This function will move | 173 // system and a key called 'opv' in the registry. This function will move |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 temp_path.path().value(), | 207 temp_path.path().value(), |
| 208 WorkItem::ALWAYS_MOVE); | 208 WorkItem::ALWAYS_MOVE); |
| 209 install_list->AddDeleteTreeWorkItem(chrome_new_exe, temp_path.path()); | 209 install_list->AddDeleteTreeWorkItem(chrome_new_exe, temp_path.path()); |
| 210 // Delete an elevation policy associated with the old version, should one | 210 // Delete an elevation policy associated with the old version, should one |
| 211 // exist. | 211 // exist. |
| 212 if (installer_state->FindProduct(BrowserDistribution::CHROME_FRAME)) { | 212 if (installer_state->FindProduct(BrowserDistribution::CHROME_FRAME)) { |
| 213 installer::AddDeleteOldIELowRightsPolicyWorkItems(*installer_state, | 213 installer::AddDeleteOldIELowRightsPolicyWorkItems(*installer_state, |
| 214 install_list.get()); | 214 install_list.get()); |
| 215 } | 215 } |
| 216 // old_chrome.exe is still in use in most cases, so ignore failures here. | 216 // old_chrome.exe is still in use in most cases, so ignore failures here. |
| 217 install_list->AddDeleteTreeWorkItem(chrome_old_exe, temp_path.path()) | 217 install_list->AddDeleteTreeWorkItem(chrome_old_exe, temp_path.path())-> |
| 218 ->set_ignore_failure(true); | 218 set_ignore_failure(true); |
| 219 | 219 |
| 220 // Add work items to delete the "opv", "cpv", and "cmd" values from all | 220 // Add work items to delete the "opv", "cpv", and "cmd" values from all |
| 221 // products we're operating on (which including the multi-install binaries). | 221 // products we're operating on (which including the multi-install binaries). |
| 222 const Products& products = installer_state->products(); | 222 const Products& products = installer_state->products(); |
| 223 HKEY reg_root = installer_state->root_key(); | 223 HKEY reg_root = installer_state->root_key(); |
| 224 string16 version_key; | 224 string16 version_key; |
| 225 for (size_t i = 0; i < products.size(); ++i) { | 225 for (Products::const_iterator it = products.begin(); it < products.end(); |
| 226 version_key = products[i]->distribution()->GetVersionKey(); | 226 ++it) { |
| 227 version_key = (*it)->distribution()->GetVersionKey(); |
| 227 install_list->AddDeleteRegValueWorkItem( | 228 install_list->AddDeleteRegValueWorkItem( |
| 228 reg_root, version_key, google_update::kRegOldVersionField); | 229 reg_root, version_key, google_update::kRegOldVersionField); |
| 229 install_list->AddDeleteRegValueWorkItem( | 230 install_list->AddDeleteRegValueWorkItem( |
| 230 reg_root, version_key, google_update::kRegCriticalVersionField); | 231 reg_root, version_key, google_update::kRegCriticalVersionField); |
| 231 install_list->AddDeleteRegValueWorkItem( | 232 install_list->AddDeleteRegValueWorkItem( |
| 232 reg_root, version_key, google_update::kRegRenameCmdField); | 233 reg_root, version_key, google_update::kRegRenameCmdField); |
| 233 } | 234 } |
| 234 installer::InstallStatus ret = installer::RENAME_SUCCESSFUL; | 235 installer::InstallStatus ret = installer::RENAME_SUCCESSFUL; |
| 235 if (!install_list->Do()) { | 236 if (!install_list->Do()) { |
| 236 LOG(ERROR) << "Renaming of executables failed. Rolling back any changes."; | 237 LOG(ERROR) << "Renaming of executables failed. Rolling back any changes."; |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 return true; | 396 return true; |
| 396 } | 397 } |
| 397 | 398 |
| 398 if (chrome) { | 399 if (chrome) { |
| 399 if (chrome_frame && | 400 if (chrome_frame && |
| 400 chrome_frame->HasOption(installer::kOptionReadyMode)) { | 401 chrome_frame->HasOption(installer::kOptionReadyMode)) { |
| 401 // We're being asked to install Chrome with Chrome Frame in ready-mode. | 402 // We're being asked to install Chrome with Chrome Frame in ready-mode. |
| 402 // This is an optimistic operation: if a SxS install of Chrome Frame | 403 // This is an optimistic operation: if a SxS install of Chrome Frame |
| 403 // is already present, don't touch it; if a multi-install of Chrome | 404 // is already present, don't touch it; if a multi-install of Chrome |
| 404 // Frame is present, preserve its settings (ready-mode). | 405 // Frame is present, preserve its settings (ready-mode). |
| 405 if (cf_state != NULL) { | 406 if (cf_state) { |
| 406 installer_state->RemoveProduct(chrome_frame); | 407 installer_state->RemoveProduct(chrome_frame); |
| 407 chrome_frame = NULL; | 408 chrome_frame = NULL; |
| 408 if (cf_state->is_multi_install()) { | 409 if (cf_state->is_multi_install()) { |
| 409 chrome_frame = installer_state->AddProductFromState( | 410 chrome_frame = installer_state->AddProductFromState( |
| 410 BrowserDistribution::CHROME_FRAME, *cf_state); | 411 BrowserDistribution::CHROME_FRAME, *cf_state); |
| 411 VLOG(1) << "Upgrading existing multi-install Chrome Frame rather " | 412 VLOG(1) << "Upgrading existing multi-install Chrome Frame rather " |
| 412 "than installing in ready-mode."; | 413 "than installing in ready-mode."; |
| 413 } else { | 414 } else { |
| 414 VLOG(1) << "Skipping upgrade of single-install Chrome Frame rather " | 415 VLOG(1) << "Skipping upgrade of single-install Chrome Frame rather " |
| 415 "than installing in ready-mode."; | 416 "than installing in ready-mode."; |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 535 << "Not given any products to install and no products found to update."; | 536 << "Not given any products to install and no products found to update."; |
| 536 *status = installer::CHROME_NOT_INSTALLED; | 537 *status = installer::CHROME_NOT_INSTALLED; |
| 537 installer_state->WriteInstallerResult(*status, | 538 installer_state->WriteInstallerResult(*status, |
| 538 IDS_INSTALL_NO_PRODUCTS_TO_UPDATE_BASE, NULL); | 539 IDS_INSTALL_NO_PRODUCTS_TO_UPDATE_BASE, NULL); |
| 539 return false; | 540 return false; |
| 540 } | 541 } |
| 541 | 542 |
| 542 if (!installer_state->system_install()) { | 543 if (!installer_state->system_install()) { |
| 543 // This is a user-level installation. Make sure that we are not installing | 544 // This is a user-level installation. Make sure that we are not installing |
| 544 // on top of an existing system-level installation. | 545 // on top of an existing system-level installation. |
| 545 for (size_t i = 0; i < products.size(); ++i) { | 546 for (Products::const_iterator it = products.begin(); it < products.end(); |
| 546 const Product* product = products[i]; | 547 ++it) { |
| 547 BrowserDistribution* browser_dist = product->distribution(); | 548 const Product& product = **it; |
| 549 BrowserDistribution* browser_dist = product.distribution(); |
| 548 | 550 |
| 549 // Skip over the binaries, as it's okay for them to be at both levels | 551 // Skip over the binaries, as it's okay for them to be at both levels |
| 550 // for different products. | 552 // for different products. |
| 551 if (browser_dist->GetType() == BrowserDistribution::CHROME_BINARIES) | 553 if (browser_dist->GetType() == BrowserDistribution::CHROME_BINARIES) |
| 552 continue; | 554 continue; |
| 553 | 555 |
| 554 const ProductState* user_level_product_state = | 556 const ProductState* user_level_product_state = |
| 555 original_state.GetProductState(false, browser_dist->GetType()); | 557 original_state.GetProductState(false, browser_dist->GetType()); |
| 556 const ProductState* system_level_product_state = | 558 const ProductState* system_level_product_state = |
| 557 original_state.GetProductState(true, browser_dist->GetType()); | 559 original_state.GetProductState(true, browser_dist->GetType()); |
| 558 | 560 |
| 559 // Allow upgrades to proceed so that out-of-date versions are not left | 561 // Allow upgrades to proceed so that out-of-date versions are not left |
| 560 // around. | 562 // around. |
| 561 if (user_level_product_state) | 563 if (user_level_product_state) |
| 562 continue; | 564 continue; |
| 563 | 565 |
| 564 // This is a new user-level install... | 566 // This is a new user-level install... |
| 565 | 567 |
| 566 if (system_level_product_state) { | 568 if (system_level_product_state) { |
| 567 // ... and the product already exists at system-level. | 569 // ... and the product already exists at system-level. |
| 568 LOG(ERROR) << "Already installed version " | 570 LOG(ERROR) << "Already installed version " |
| 569 << system_level_product_state->version().GetString() | 571 << system_level_product_state->version().GetString() |
| 570 << " at system-level conflicts with this one at user-level."; | 572 << " at system-level conflicts with this one at user-level."; |
| 571 if (product->is_chrome()) { | 573 if (product.is_chrome()) { |
| 572 // Instruct Google Update to launch the existing system-level Chrome. | 574 // Instruct Google Update to launch the existing system-level Chrome. |
| 573 // There should be no error dialog. | 575 // There should be no error dialog. |
| 574 FilePath install_path(installer::GetChromeInstallPath(true, // system | 576 FilePath install_path(installer::GetChromeInstallPath(true, // system |
| 575 browser_dist)); | 577 browser_dist)); |
| 576 if (install_path.empty()) { | 578 if (install_path.empty()) { |
| 577 // Give up if we failed to construct the install path. | 579 // Give up if we failed to construct the install path. |
| 578 *status = installer::OS_ERROR; | 580 *status = installer::OS_ERROR; |
| 579 installer_state->WriteInstallerResult(*status, | 581 installer_state->WriteInstallerResult(*status, |
| 580 IDS_INSTALL_OS_ERROR_BASE, | 582 IDS_INSTALL_OS_ERROR_BASE, |
| 581 NULL); | 583 NULL); |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 689 install_status = installer::INVALID_ARCHIVE; | 691 install_status = installer::INVALID_ARCHIVE; |
| 690 installer_state.WriteInstallerResult(install_status, | 692 installer_state.WriteInstallerResult(install_status, |
| 691 IDS_INSTALL_INVALID_ARCHIVE_BASE, NULL); | 693 IDS_INSTALL_INVALID_ARCHIVE_BASE, NULL); |
| 692 } else { | 694 } else { |
| 693 VLOG(1) << "version to install: " << installer_version->GetString(); | 695 VLOG(1) << "version to install: " << installer_version->GetString(); |
| 694 bool proceed_with_installation = true; | 696 bool proceed_with_installation = true; |
| 695 uint32 higher_products = 0; | 697 uint32 higher_products = 0; |
| 696 COMPILE_ASSERT( | 698 COMPILE_ASSERT( |
| 697 sizeof(higher_products) * 8 > BrowserDistribution::NUM_TYPES, | 699 sizeof(higher_products) * 8 > BrowserDistribution::NUM_TYPES, |
| 698 too_many_distribution_types_); | 700 too_many_distribution_types_); |
| 699 for (size_t i = 0; i < installer_state.products().size(); ++i) { | 701 const Products& products = installer_state.products(); |
| 700 const Product* product = installer_state.products()[i]; | 702 for (Products::const_iterator it = products.begin(); it < products.end(); |
| 703 ++it) { |
| 704 const Product& product = **it; |
| 701 const ProductState* product_state = | 705 const ProductState* product_state = |
| 702 original_state.GetProductState(system_install, | 706 original_state.GetProductState(system_install, |
| 703 product->distribution()->GetType()); | 707 product.distribution()->GetType()); |
| 704 if (product_state != NULL && | 708 if (product_state != NULL && |
| 705 (product_state->version().CompareTo(*installer_version) > 0)) { | 709 (product_state->version().CompareTo(*installer_version) > 0)) { |
| 706 LOG(ERROR) << "Higher version of " | 710 LOG(ERROR) << "Higher version of " |
| 707 << product->distribution()->GetAppShortCutName() | 711 << product.distribution()->GetAppShortCutName() |
| 708 << " is already installed."; | 712 << " is already installed."; |
| 709 higher_products |= (1 << product->distribution()->GetType()); | 713 higher_products |= (1 << product.distribution()->GetType()); |
| 710 } | 714 } |
| 711 } | 715 } |
| 712 | 716 |
| 713 if (higher_products != 0) { | 717 if (higher_products != 0) { |
| 714 COMPILE_ASSERT(BrowserDistribution::NUM_TYPES == 4, | 718 COMPILE_ASSERT(BrowserDistribution::NUM_TYPES == 4, |
| 715 add_support_for_new_products_here_); | 719 add_support_for_new_products_here_); |
| 716 const uint32 kBrowserBit = 1 << BrowserDistribution::CHROME_BROWSER; | 720 const uint32 kBrowserBit = 1 << BrowserDistribution::CHROME_BROWSER; |
| 717 const uint32 kGCFBit = 1 << BrowserDistribution::CHROME_FRAME; | 721 const uint32 kGCFBit = 1 << BrowserDistribution::CHROME_FRAME; |
| 718 const uint32 kAppHostBit = 1 << BrowserDistribution::CHROME_APP_HOST; | 722 const uint32 kAppHostBit = 1 << BrowserDistribution::CHROME_APP_HOST; |
| 719 int message_id = 0; | 723 int message_id = 0; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 739 } | 743 } |
| 740 | 744 |
| 741 proceed_with_installation = | 745 proceed_with_installation = |
| 742 proceed_with_installation && | 746 proceed_with_installation && |
| 743 CheckGroupPolicySettings(original_state, installer_state, | 747 CheckGroupPolicySettings(original_state, installer_state, |
| 744 *installer_version, &install_status); | 748 *installer_version, &install_status); |
| 745 | 749 |
| 746 if (proceed_with_installation) { | 750 if (proceed_with_installation) { |
| 747 FilePath prefs_source_path(cmd_line.GetSwitchValueNative( | 751 FilePath prefs_source_path(cmd_line.GetSwitchValueNative( |
| 748 installer::switches::kInstallerData)); | 752 installer::switches::kInstallerData)); |
| 749 install_status = installer::InstallOrUpdateProduct(original_state, | 753 install_status = installer::InstallOrUpdateProduct( |
| 750 installer_state, cmd_line.GetProgram(), archive_to_copy, | 754 original_state, installer_state, cmd_line.GetProgram(), |
| 751 temp_path.path(), prefs_source_path, prefs, *installer_version); | 755 archive_to_copy, temp_path.path(), prefs_source_path, prefs, |
| 756 *installer_version); |
| 752 | 757 |
| 753 int install_msg_base = IDS_INSTALL_FAILED_BASE; | 758 int install_msg_base = IDS_INSTALL_FAILED_BASE; |
| 754 string16 chrome_exe; | 759 string16 chrome_exe; |
| 755 string16 quoted_chrome_exe; | 760 string16 quoted_chrome_exe; |
| 756 if (install_status == installer::SAME_VERSION_REPAIR_FAILED) { | 761 if (install_status == installer::SAME_VERSION_REPAIR_FAILED) { |
| 757 if (installer_state.FindProduct(BrowserDistribution::CHROME_FRAME)) { | 762 if (installer_state.FindProduct(BrowserDistribution::CHROME_FRAME)) { |
| 758 install_msg_base = IDS_SAME_VERSION_REPAIR_FAILED_CF_BASE; | 763 install_msg_base = IDS_SAME_VERSION_REPAIR_FAILED_CF_BASE; |
| 759 } else { | 764 } else { |
| 760 install_msg_base = IDS_SAME_VERSION_REPAIR_FAILED_BASE; | 765 install_msg_base = IDS_SAME_VERSION_REPAIR_FAILED_BASE; |
| 761 } | 766 } |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 830 // There is another way to reach this same function if this is a system | 835 // There is another way to reach this same function if this is a system |
| 831 // level install. See HandleNonInstallCmdLineOptions(). | 836 // level install. See HandleNonInstallCmdLineOptions(). |
| 832 { | 837 { |
| 833 // If installation failed, use the path to the currently running setup. | 838 // If installation failed, use the path to the currently running setup. |
| 834 // If installation succeeded, use the path to setup in the installer dir. | 839 // If installation succeeded, use the path to setup in the installer dir. |
| 835 FilePath setup_path(cmd_line.GetProgram()); | 840 FilePath setup_path(cmd_line.GetProgram()); |
| 836 if (InstallUtil::GetInstallReturnCode(install_status) == 0) { | 841 if (InstallUtil::GetInstallReturnCode(install_status) == 0) { |
| 837 setup_path = installer_state.GetInstallerDirectory(*installer_version) | 842 setup_path = installer_state.GetInstallerDirectory(*installer_version) |
| 838 .Append(setup_path.BaseName()); | 843 .Append(setup_path.BaseName()); |
| 839 } | 844 } |
| 840 for (size_t i = 0; i < products.size(); ++i) { | 845 for (Products::const_iterator it = products.begin(); it < products.end(); |
| 841 const Product* product = products[i]; | 846 ++it) { |
| 842 product->distribution()->LaunchUserExperiment(setup_path, | 847 const Product& product = **it; |
| 843 install_status, *installer_version, *product, system_install); | 848 product.distribution()->LaunchUserExperiment(setup_path, |
| 849 install_status, *installer_version, product, system_install); |
| 844 } | 850 } |
| 845 } | 851 } |
| 846 } | 852 } |
| 847 | 853 |
| 848 // Delete the master profile file if present. Note that we do not care about | 854 // Delete the master profile file if present. Note that we do not care about |
| 849 // rollback here and we schedule for deletion on reboot if the delete fails. | 855 // rollback here and we schedule for deletion on reboot if the delete fails. |
| 850 // As such, we do not use DeleteTreeWorkItem. | 856 // As such, we do not use DeleteTreeWorkItem. |
| 851 if (cmd_line.HasSwitch(installer::switches::kInstallerData)) { | 857 if (cmd_line.HasSwitch(installer::switches::kInstallerData)) { |
| 852 FilePath prefs_path(cmd_line.GetSwitchValuePath( | 858 FilePath prefs_path(cmd_line.GetSwitchValuePath( |
| 853 installer::switches::kInstallerData)); | 859 installer::switches::kInstallerData)); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 872 const MasterPreferences& prefs, | 878 const MasterPreferences& prefs, |
| 873 InstallerState* installer_state) { | 879 InstallerState* installer_state) { |
| 874 DCHECK(installer_state); | 880 DCHECK(installer_state); |
| 875 const bool system_install = installer_state->system_install(); | 881 const bool system_install = installer_state->system_install(); |
| 876 installer::InstallStatus install_status = installer::UNKNOWN_STATUS; | 882 installer::InstallStatus install_status = installer::UNKNOWN_STATUS; |
| 877 installer::ArchiveType archive_type = installer::UNKNOWN_ARCHIVE_TYPE; | 883 installer::ArchiveType archive_type = installer::UNKNOWN_ARCHIVE_TYPE; |
| 878 bool incremental_install = false; | 884 bool incremental_install = false; |
| 879 installer_state->UpdateStage(installer::PRECONDITIONS); | 885 installer_state->UpdateStage(installer::PRECONDITIONS); |
| 880 // The stage provides more fine-grained information than -multifail, so remove | 886 // The stage provides more fine-grained information than -multifail, so remove |
| 881 // the -multifail suffix from the Google Update "ap" value. | 887 // the -multifail suffix from the Google Update "ap" value. |
| 882 BrowserDistribution::GetSpecificDistribution(installer_state->state_type()) | 888 BrowserDistribution::GetSpecificDistribution(installer_state->state_type())-> |
| 883 ->UpdateInstallStatus(system_install, archive_type, install_status); | 889 UpdateInstallStatus(system_install, archive_type, install_status); |
| 884 if (CheckPreInstallConditions(original_state, installer_state, | 890 if (CheckPreInstallConditions(original_state, installer_state, |
| 885 &install_status)) { | 891 &install_status)) { |
| 886 VLOG(1) << "Installing to " << installer_state->target_path().value(); | 892 VLOG(1) << "Installing to " << installer_state->target_path().value(); |
| 887 install_status = InstallProductsHelper( | 893 install_status = InstallProductsHelper( |
| 888 original_state, cmd_line, prefs, *installer_state, &archive_type); | 894 original_state, cmd_line, prefs, *installer_state, &archive_type); |
| 889 } else { | 895 } else { |
| 890 // CheckPreInstallConditions must set the status on failure. | 896 // CheckPreInstallConditions must set the status on failure. |
| 891 DCHECK_NE(install_status, installer::UNKNOWN_STATUS); | 897 DCHECK_NE(install_status, installer::UNKNOWN_STATUS); |
| 892 } | 898 } |
| 893 | 899 |
| 894 const Products& products = installer_state->products(); | 900 const Products& products = installer_state->products(); |
| 895 | 901 |
| 896 for (size_t i = 0; i < products.size(); ++i) { | 902 for (Products::const_iterator it = products.begin(); it < products.end(); |
| 897 const Product* product = products[i]; | 903 ++it) { |
| 898 product->distribution()->UpdateInstallStatus( | 904 (*it)->distribution()->UpdateInstallStatus( |
| 899 system_install, archive_type, install_status); | 905 system_install, archive_type, install_status); |
| 900 } | 906 } |
| 901 | 907 |
| 902 installer_state->UpdateStage(installer::NO_STAGE); | 908 installer_state->UpdateStage(installer::NO_STAGE); |
| 903 return install_status; | 909 return install_status; |
| 904 } | 910 } |
| 905 | 911 |
| 906 installer::InstallStatus UninstallProduct( | 912 installer::InstallStatus UninstallProduct( |
| 907 const InstallationState& original_state, | 913 const InstallationState& original_state, |
| 908 const InstallerState& installer_state, | 914 const InstallerState& installer_state, |
| 909 const CommandLine& cmd_line, | 915 const CommandLine& cmd_line, |
| 910 bool remove_all, | 916 bool remove_all, |
| 911 bool force_uninstall, | 917 bool force_uninstall, |
| 912 const Product& product) { | 918 const Product& product) { |
| 913 const ProductState* product_state = | 919 const ProductState* product_state = |
| 914 original_state.GetProductState(installer_state.system_install(), | 920 original_state.GetProductState(installer_state.system_install(), |
| 915 product.distribution()->GetType()); | 921 product.distribution()->GetType()); |
| 916 if (product_state != NULL) { | 922 if (product_state != NULL) { |
| 917 VLOG(1) << "version on the system: " | 923 VLOG(1) << "version on the system: " |
| 918 << product_state->version().GetString(); | 924 << product_state->version().GetString(); |
| 919 } else if (!force_uninstall) { | 925 } else if (!force_uninstall) { |
| 920 LOG(ERROR) << product.distribution()->GetAppShortCutName() | 926 LOG(ERROR) << product.distribution()->GetAppShortCutName() |
| 921 << " not found for uninstall."; | 927 << " not found for uninstall."; |
| 922 return installer::CHROME_NOT_INSTALLED; | 928 return installer::CHROME_NOT_INSTALLED; |
| 923 } | 929 } |
| 924 | 930 |
| 925 return installer::UninstallProduct(original_state, installer_state, | 931 return installer::UninstallProduct( |
| 926 cmd_line.GetProgram(), product, remove_all, force_uninstall, cmd_line); | 932 original_state, installer_state, cmd_line.GetProgram(), product, |
| 933 remove_all, force_uninstall, cmd_line); |
| 927 } | 934 } |
| 928 | 935 |
| 929 // Tell Google Update that an uninstall has taken place. This gives it a chance | 936 // Tell Google Update that an uninstall has taken place. This gives it a chance |
| 930 // to uninstall itself straight away if no more products are installed on the | 937 // to uninstall itself straight away if no more products are installed on the |
| 931 // system rather than waiting for the next time the scheduled task runs. | 938 // system rather than waiting for the next time the scheduled task runs. |
| 932 // Success or failure of Google Update has no bearing on the success or failure | 939 // Success or failure of Google Update has no bearing on the success or failure |
| 933 // of Chrome's uninstallation. | 940 // of Chrome's uninstallation. |
| 934 void UninstallGoogleUpdate(bool system_install) { | 941 void UninstallGoogleUpdate(bool system_install) { |
| 935 string16 uninstall_cmd( | 942 string16 uninstall_cmd( |
| 936 GoogleUpdateSettings::GetUninstallCommandLine(system_install)); | 943 GoogleUpdateSettings::GetUninstallCommandLine(system_install)); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 980 // should stay. | 987 // should stay. |
| 981 DCHECK(products[products.size() - 1]->is_chrome_binaries()); | 988 DCHECK(products[products.size() - 1]->is_chrome_binaries()); |
| 982 } | 989 } |
| 983 | 990 |
| 984 installer::InstallStatus install_status = installer::UNINSTALL_SUCCESSFUL; | 991 installer::InstallStatus install_status = installer::UNINSTALL_SUCCESSFUL; |
| 985 installer::InstallStatus prod_status = installer::UNKNOWN_STATUS; | 992 installer::InstallStatus prod_status = installer::UNKNOWN_STATUS; |
| 986 const bool force = cmd_line.HasSwitch(installer::switches::kForceUninstall); | 993 const bool force = cmd_line.HasSwitch(installer::switches::kForceUninstall); |
| 987 const bool remove_all = !cmd_line.HasSwitch( | 994 const bool remove_all = !cmd_line.HasSwitch( |
| 988 installer::switches::kDoNotRemoveSharedItems); | 995 installer::switches::kDoNotRemoveSharedItems); |
| 989 | 996 |
| 990 for (size_t i = 0; | 997 for (Products::const_iterator it = products.begin(); |
| 991 install_status != installer::UNINSTALL_CANCELLED && | 998 install_status != installer::UNINSTALL_CANCELLED && it < products.end(); |
| 992 i < products.size(); | 999 ++it) { |
| 993 ++i) { | |
| 994 prod_status = UninstallProduct(original_state, installer_state, | 1000 prod_status = UninstallProduct(original_state, installer_state, |
| 995 cmd_line, remove_all, force, *products[i]); | 1001 cmd_line, remove_all, force, **it); |
| 996 if (prod_status != installer::UNINSTALL_SUCCESSFUL) | 1002 if (prod_status != installer::UNINSTALL_SUCCESSFUL) |
| 997 install_status = prod_status; | 1003 install_status = prod_status; |
| 998 } | 1004 } |
| 999 | 1005 |
| 1000 UninstallGoogleUpdate(installer_state.system_install()); | 1006 UninstallGoogleUpdate(installer_state.system_install()); |
| 1001 | 1007 |
| 1002 return install_status; | 1008 return install_status; |
| 1003 } | 1009 } |
| 1004 | 1010 |
| 1005 installer::InstallStatus ShowEULADialog(const string16& inner_frame) { | 1011 installer::InstallStatus ShowEULADialog(const string16& inner_frame) { |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1066 // the Windows last-error code. | 1072 // the Windows last-error code. |
| 1067 LOG(WARNING) << "Scheduling temporary path " << temp_path.path().value() | 1073 LOG(WARNING) << "Scheduling temporary path " << temp_path.path().value() |
| 1068 << " for deletion at reboot."; | 1074 << " for deletion at reboot."; |
| 1069 ScheduleDirectoryForDeletion(temp_path.path().value().c_str()); | 1075 ScheduleDirectoryForDeletion(temp_path.path().value().c_str()); |
| 1070 } | 1076 } |
| 1071 } | 1077 } |
| 1072 | 1078 |
| 1073 *exit_code = InstallUtil::GetInstallReturnCode(status); | 1079 *exit_code = InstallUtil::GetInstallReturnCode(status); |
| 1074 if (*exit_code) { | 1080 if (*exit_code) { |
| 1075 LOG(WARNING) << "setup.exe patching failed."; | 1081 LOG(WARNING) << "setup.exe patching failed."; |
| 1076 installer_state->WriteInstallerResult(status, IDS_SETUP_PATCH_FAILED_BASE, | 1082 installer_state->WriteInstallerResult( |
| 1077 NULL); | 1083 status, IDS_SETUP_PATCH_FAILED_BASE, NULL); |
| 1078 } | 1084 } |
| 1079 // We will be exiting normally, so clear the stage indicator. | 1085 // We will be exiting normally, so clear the stage indicator. |
| 1080 installer_state->UpdateStage(installer::NO_STAGE); | 1086 installer_state->UpdateStage(installer::NO_STAGE); |
| 1081 } else if (cmd_line.HasSwitch(installer::switches::kShowEula)) { | 1087 } else if (cmd_line.HasSwitch(installer::switches::kShowEula)) { |
| 1082 // Check if we need to show the EULA. If it is passed as a command line | 1088 // Check if we need to show the EULA. If it is passed as a command line |
| 1083 // then the dialog is shown and regardless of the outcome setup exits here. | 1089 // then the dialog is shown and regardless of the outcome setup exits here. |
| 1084 string16 inner_frame = | 1090 string16 inner_frame = |
| 1085 cmd_line.GetSwitchValueNative(installer::switches::kShowEula); | 1091 cmd_line.GetSwitchValueNative(installer::switches::kShowEula); |
| 1086 *exit_code = ShowEULADialog(inner_frame); | 1092 *exit_code = ShowEULADialog(inner_frame); |
| 1087 if (installer::EULA_REJECTED != *exit_code) { | 1093 if (installer::EULA_REJECTED != *exit_code) { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1126 suffix = cmd_line.GetSwitchValueNative( | 1132 suffix = cmd_line.GetSwitchValueNative( |
| 1127 installer::switches::kRegisterChromeBrowserSuffix); | 1133 installer::switches::kRegisterChromeBrowserSuffix); |
| 1128 } | 1134 } |
| 1129 if (cmd_line.HasSwitch( | 1135 if (cmd_line.HasSwitch( |
| 1130 installer::switches::kRegisterURLProtocol)) { | 1136 installer::switches::kRegisterURLProtocol)) { |
| 1131 string16 protocol = cmd_line.GetSwitchValueNative( | 1137 string16 protocol = cmd_line.GetSwitchValueNative( |
| 1132 installer::switches::kRegisterURLProtocol); | 1138 installer::switches::kRegisterURLProtocol); |
| 1133 // ShellUtil::RegisterChromeForProtocol performs all registration | 1139 // ShellUtil::RegisterChromeForProtocol performs all registration |
| 1134 // done by ShellUtil::RegisterChromeBrowser, as well as registering | 1140 // done by ShellUtil::RegisterChromeBrowser, as well as registering |
| 1135 // with Windows as capable of handling the supplied protocol. | 1141 // with Windows as capable of handling the supplied protocol. |
| 1136 if (ShellUtil::RegisterChromeForProtocol(chrome_install->distribution(), | 1142 if (ShellUtil::RegisterChromeForProtocol( |
| 1137 chrome_exe, suffix, protocol, false)) | 1143 chrome_install->distribution(), chrome_exe, suffix, protocol, |
| 1144 false)) |
| 1138 status = installer::IN_USE_UPDATED; | 1145 status = installer::IN_USE_UPDATED; |
| 1139 } else { | 1146 } else { |
| 1140 if (ShellUtil::RegisterChromeBrowser(chrome_install->distribution(), | 1147 if (ShellUtil::RegisterChromeBrowser(chrome_install->distribution(), |
| 1141 chrome_exe, suffix, false)) | 1148 chrome_exe, suffix, false)) |
| 1142 status = installer::IN_USE_UPDATED; | 1149 status = installer::IN_USE_UPDATED; |
| 1143 } | 1150 } |
| 1144 } else { | 1151 } else { |
| 1145 LOG(DFATAL) << "Can't register browser - Chrome distribution not found"; | 1152 LOG(DFATAL) << "Can't register browser - Chrome distribution not found"; |
| 1146 } | 1153 } |
| 1147 *exit_code = InstallUtil::GetInstallReturnCode(status); | 1154 *exit_code = InstallUtil::GetInstallReturnCode(status); |
| 1148 } else if (cmd_line.HasSwitch(installer::switches::kRenameChromeExe)) { | 1155 } else if (cmd_line.HasSwitch(installer::switches::kRenameChromeExe)) { |
| 1149 // If --rename-chrome-exe is specified, we want to rename the executables | 1156 // If --rename-chrome-exe is specified, we want to rename the executables |
| 1150 // and exit. | 1157 // and exit. |
| 1151 *exit_code = RenameChromeExecutables(original_state, installer_state); | 1158 *exit_code = RenameChromeExecutables(original_state, installer_state); |
| 1152 } else if (cmd_line.HasSwitch( | 1159 } else if (cmd_line.HasSwitch( |
| 1153 installer::switches::kRemoveChromeRegistration)) { | 1160 installer::switches::kRemoveChromeRegistration)) { |
| 1154 // This is almost reverse of --register-chrome-browser option above. | 1161 // This is almost reverse of --register-chrome-browser option above. |
| 1155 // Here we delete Chrome browser registration. This option should only | 1162 // Here we delete Chrome browser registration. This option should only |
| 1156 // be used when setup.exe is launched with admin rights. We do not | 1163 // be used when setup.exe is launched with admin rights. We do not |
| 1157 // make any user specific changes in this option. | 1164 // make any user specific changes in this option. |
| 1158 string16 suffix; | 1165 string16 suffix; |
| 1159 if (cmd_line.HasSwitch( | 1166 if (cmd_line.HasSwitch( |
| 1160 installer::switches::kRegisterChromeBrowserSuffix)) { | 1167 installer::switches::kRegisterChromeBrowserSuffix)) { |
| 1161 suffix = cmd_line.GetSwitchValueNative( | 1168 suffix = cmd_line.GetSwitchValueNative( |
| 1162 installer::switches::kRegisterChromeBrowserSuffix); | 1169 installer::switches::kRegisterChromeBrowserSuffix); |
| 1163 } | 1170 } |
| 1164 installer::InstallStatus tmp = installer::UNKNOWN_STATUS; | 1171 installer::InstallStatus tmp = installer::UNKNOWN_STATUS; |
| 1165 const Product* chrome_install = | 1172 const Product* chrome_install = |
| 1166 installer_state->FindProduct(BrowserDistribution::CHROME_BROWSER); | 1173 installer_state->FindProduct(BrowserDistribution::CHROME_BROWSER); |
| 1167 DCHECK(chrome_install); | 1174 DCHECK(chrome_install); |
| 1168 if (chrome_install) { | 1175 if (chrome_install) { |
| 1169 installer::DeleteChromeRegistrationKeys(chrome_install->distribution(), | 1176 installer::DeleteChromeRegistrationKeys(chrome_install->distribution(), |
| 1170 HKEY_LOCAL_MACHINE, suffix, installer_state->target_path(), &tmp); | 1177 HKEY_LOCAL_MACHINE, suffix, installer_state->target_path(), &tmp); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1184 int flavor = -1; | 1191 int flavor = -1; |
| 1185 base::StringToInt(cmd_line.GetSwitchValueNative( | 1192 base::StringToInt(cmd_line.GetSwitchValueNative( |
| 1186 installer::switches::kInactiveUserToast), &flavor); | 1193 installer::switches::kInactiveUserToast), &flavor); |
| 1187 std::string experiment_group = | 1194 std::string experiment_group = |
| 1188 cmd_line.GetSwitchValueASCII(installer::switches::kExperimentGroup); | 1195 cmd_line.GetSwitchValueASCII(installer::switches::kExperimentGroup); |
| 1189 DCHECK_NE(-1, flavor); | 1196 DCHECK_NE(-1, flavor); |
| 1190 if (flavor == -1) { | 1197 if (flavor == -1) { |
| 1191 *exit_code = installer::UNKNOWN_STATUS; | 1198 *exit_code = installer::UNKNOWN_STATUS; |
| 1192 } else { | 1199 } else { |
| 1193 const Products& products = installer_state->products(); | 1200 const Products& products = installer_state->products(); |
| 1194 for (size_t i = 0; i < products.size(); ++i) { | 1201 for (Products::const_iterator it = products.begin(); it < products.end(); |
| 1195 const Product* product = products[i]; | 1202 ++it) { |
| 1196 BrowserDistribution* browser_dist = product->distribution(); | 1203 const Product& product = **it; |
| 1197 browser_dist->InactiveUserToastExperiment(flavor, | 1204 BrowserDistribution* browser_dist = product.distribution(); |
| 1198 ASCIIToUTF16(experiment_group), | 1205 browser_dist->InactiveUserToastExperiment( |
| 1199 *product, installer_state->target_path()); | 1206 flavor, ASCIIToUTF16(experiment_group), product, |
| 1207 installer_state->target_path()); |
| 1200 } | 1208 } |
| 1201 } | 1209 } |
| 1202 } else if (cmd_line.HasSwitch(installer::switches::kSystemLevelToast)) { | 1210 } else if (cmd_line.HasSwitch(installer::switches::kSystemLevelToast)) { |
| 1203 const Products& products = installer_state->products(); | 1211 const Products& products = installer_state->products(); |
| 1204 for (size_t i = 0; i < products.size(); ++i) { | 1212 for (Products::const_iterator it = products.begin(); it < products.end(); |
| 1205 const Product* product = products[i]; | 1213 ++it) { |
| 1206 BrowserDistribution* browser_dist = product->distribution(); | 1214 const Product& product = **it; |
| 1215 BrowserDistribution* browser_dist = product.distribution(); |
| 1207 // We started as system-level and have been re-launched as user level | 1216 // We started as system-level and have been re-launched as user level |
| 1208 // to continue with the toast experiment. | 1217 // to continue with the toast experiment. |
| 1209 Version installed_version; | 1218 Version installed_version; |
| 1210 InstallUtil::GetChromeVersion(browser_dist, true, &installed_version); | 1219 InstallUtil::GetChromeVersion(browser_dist, true, &installed_version); |
| 1211 if (!installed_version.IsValid()) { | 1220 if (!installed_version.IsValid()) { |
| 1212 LOG(ERROR) << "No installation of " | 1221 LOG(ERROR) << "No installation of " |
| 1213 << browser_dist->GetAppShortCutName() | 1222 << browser_dist->GetAppShortCutName() |
| 1214 << " found for system-level toast."; | 1223 << " found for system-level toast."; |
| 1215 } else { | 1224 } else { |
| 1216 browser_dist->LaunchUserExperiment(cmd_line.GetProgram(), | 1225 browser_dist->LaunchUserExperiment(cmd_line.GetProgram(), |
| 1217 installer::REENTRY_SYS_UPDATE, | 1226 installer::REENTRY_SYS_UPDATE, |
| 1218 installed_version, *product, true); | 1227 installed_version, product, true); |
| 1219 } | 1228 } |
| 1220 } | 1229 } |
| 1221 } else if (cmd_line.HasSwitch( | 1230 } else if (cmd_line.HasSwitch( |
| 1222 installer::switches::kChromeFrameReadyModeOptIn)) { | 1231 installer::switches::kChromeFrameReadyModeOptIn)) { |
| 1223 *exit_code = InstallUtil::GetInstallReturnCode( | 1232 *exit_code = InstallUtil::GetInstallReturnCode( |
| 1224 installer::ChromeFrameReadyModeOptIn(original_state, *installer_state)); | 1233 installer::ChromeFrameReadyModeOptIn(original_state, *installer_state)); |
| 1225 } else if (cmd_line.HasSwitch( | 1234 } else if (cmd_line.HasSwitch( |
| 1226 installer::switches::kChromeFrameReadyModeTempOptOut)) { | 1235 installer::switches::kChromeFrameReadyModeTempOptOut)) { |
| 1227 *exit_code = InstallUtil::GetInstallReturnCode( | 1236 *exit_code = InstallUtil::GetInstallReturnCode( |
| 1228 installer::ChromeFrameReadyModeTempOptOut(original_state, | 1237 installer::ChromeFrameReadyModeTempOptOut(original_state, |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1294 | 1303 |
| 1295 private: | 1304 private: |
| 1296 bool initialized_; | 1305 bool initialized_; |
| 1297 }; | 1306 }; |
| 1298 | 1307 |
| 1299 // Returns the Custom information for the client identified by the exe path | 1308 // Returns the Custom information for the client identified by the exe path |
| 1300 // passed in. This information is used for crash reporting. | 1309 // passed in. This information is used for crash reporting. |
| 1301 google_breakpad::CustomClientInfo* GetCustomInfo(const wchar_t* exe_path) { | 1310 google_breakpad::CustomClientInfo* GetCustomInfo(const wchar_t* exe_path) { |
| 1302 string16 product; | 1311 string16 product; |
| 1303 string16 version; | 1312 string16 version; |
| 1304 scoped_ptr<FileVersionInfo> | 1313 scoped_ptr<FileVersionInfo> version_info( |
| 1305 version_info(FileVersionInfo::CreateFileVersionInfo(FilePath(exe_path))); | 1314 FileVersionInfo::CreateFileVersionInfo(FilePath(exe_path))); |
| 1306 if (version_info.get()) { | 1315 if (version_info.get()) { |
| 1307 version = version_info->product_version(); | 1316 version = version_info->product_version(); |
| 1308 product = version_info->product_short_name(); | 1317 product = version_info->product_short_name(); |
| 1309 } | 1318 } |
| 1310 | 1319 |
| 1311 if (version.empty()) | 1320 if (version.empty()) |
| 1312 version = L"0.1.0.0"; | 1321 version = L"0.1.0.0"; |
| 1313 | 1322 |
| 1314 if (product.empty()) | 1323 if (product.empty()) |
| 1315 product = L"Chrome Installer"; | 1324 product = L"Chrome Installer"; |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1390 original_state.Initialize(); | 1399 original_state.Initialize(); |
| 1391 | 1400 |
| 1392 InstallerState installer_state; | 1401 InstallerState installer_state; |
| 1393 installer_state.Initialize(cmd_line, prefs, original_state); | 1402 installer_state.Initialize(cmd_line, prefs, original_state); |
| 1394 const bool is_uninstall = cmd_line.HasSwitch(installer::switches::kUninstall); | 1403 const bool is_uninstall = cmd_line.HasSwitch(installer::switches::kUninstall); |
| 1395 | 1404 |
| 1396 // Check to make sure current system is WinXP or later. If not, log | 1405 // Check to make sure current system is WinXP or later. If not, log |
| 1397 // error message and get out. | 1406 // error message and get out. |
| 1398 if (!InstallUtil::IsOSSupported()) { | 1407 if (!InstallUtil::IsOSSupported()) { |
| 1399 LOG(ERROR) << "Chrome only supports Windows XP or later."; | 1408 LOG(ERROR) << "Chrome only supports Windows XP or later."; |
| 1400 installer_state.WriteInstallerResult(installer::OS_NOT_SUPPORTED, | 1409 installer_state.WriteInstallerResult( |
| 1401 IDS_INSTALL_OS_NOT_SUPPORTED_BASE, NULL); | 1410 installer::OS_NOT_SUPPORTED, IDS_INSTALL_OS_NOT_SUPPORTED_BASE, NULL); |
| 1402 return installer::OS_NOT_SUPPORTED; | 1411 return installer::OS_NOT_SUPPORTED; |
| 1403 } | 1412 } |
| 1404 | 1413 |
| 1405 // Initialize COM for use later. | 1414 // Initialize COM for use later. |
| 1406 AutoCom auto_com; | 1415 AutoCom auto_com; |
| 1407 if (!auto_com.Init(system_install)) { | 1416 if (!auto_com.Init(system_install)) { |
| 1408 installer_state.WriteInstallerResult(installer::OS_ERROR, | 1417 installer_state.WriteInstallerResult( |
| 1409 IDS_INSTALL_OS_ERROR_BASE, NULL); | 1418 installer::OS_ERROR, IDS_INSTALL_OS_ERROR_BASE, NULL); |
| 1410 return installer::OS_ERROR; | 1419 return installer::OS_ERROR; |
| 1411 } | 1420 } |
| 1412 | 1421 |
| 1413 // Some command line options don't work with SxS install/uninstall | 1422 // Some command line options don't work with SxS install/uninstall |
| 1414 if (InstallUtil::IsChromeSxSProcess()) { | 1423 if (InstallUtil::IsChromeSxSProcess()) { |
| 1415 if (system_install || | 1424 if (system_install || |
| 1416 prefs.is_multi_install() || | 1425 prefs.is_multi_install() || |
| 1417 cmd_line.HasSwitch(installer::switches::kForceUninstall) || | 1426 cmd_line.HasSwitch(installer::switches::kForceUninstall) || |
| 1418 cmd_line.HasSwitch(installer::switches::kMakeChromeDefault) || | 1427 cmd_line.HasSwitch(installer::switches::kMakeChromeDefault) || |
| 1419 cmd_line.HasSwitch(installer::switches::kRegisterChromeBrowser) || | 1428 cmd_line.HasSwitch(installer::switches::kRegisterChromeBrowser) || |
| 1420 cmd_line.HasSwitch( | 1429 cmd_line.HasSwitch(installer::switches::kRemoveChromeRegistration) || |
| 1421 installer::switches::kRemoveChromeRegistration) || | |
| 1422 cmd_line.HasSwitch(installer::switches::kInactiveUserToast) || | 1430 cmd_line.HasSwitch(installer::switches::kInactiveUserToast) || |
| 1423 cmd_line.HasSwitch(installer::switches::kSystemLevelToast) || | 1431 cmd_line.HasSwitch(installer::switches::kSystemLevelToast) || |
| 1424 cmd_line.HasSwitch(installer::switches::kChromeFrameQuickEnable)) { | 1432 cmd_line.HasSwitch(installer::switches::kChromeFrameQuickEnable)) { |
| 1425 return installer::SXS_OPTION_NOT_SUPPORTED; | 1433 return installer::SXS_OPTION_NOT_SUPPORTED; |
| 1426 } | 1434 } |
| 1427 } | 1435 } |
| 1428 | 1436 |
| 1429 int exit_code = 0; | 1437 int exit_code = 0; |
| 1430 if (HandleNonInstallCmdLineOptions(original_state, cmd_line, &installer_state, | 1438 if (HandleNonInstallCmdLineOptions( |
| 1431 &exit_code)) | 1439 original_state, cmd_line, &installer_state, &exit_code)) { |
| 1432 return exit_code; | 1440 return exit_code; |
| 1441 } |
| 1433 | 1442 |
| 1434 if (system_install && !IsUserAnAdmin()) { | 1443 if (system_install && !IsUserAnAdmin()) { |
| 1435 if (base::win::GetVersion() >= base::win::VERSION_VISTA && | 1444 if (base::win::GetVersion() >= base::win::VERSION_VISTA && |
| 1436 !cmd_line.HasSwitch(installer::switches::kRunAsAdmin)) { | 1445 !cmd_line.HasSwitch(installer::switches::kRunAsAdmin)) { |
| 1437 CommandLine new_cmd(CommandLine::NO_PROGRAM); | 1446 CommandLine new_cmd(CommandLine::NO_PROGRAM); |
| 1438 new_cmd.AppendArguments(cmd_line, true); | 1447 new_cmd.AppendArguments(cmd_line, true); |
| 1439 // Append --run-as-admin flag to let the new instance of setup.exe know | 1448 // Append --run-as-admin flag to let the new instance of setup.exe know |
| 1440 // that we already tried to launch ourselves as admin. | 1449 // that we already tried to launch ourselves as admin. |
| 1441 new_cmd.AppendSwitch(installer::switches::kRunAsAdmin); | 1450 new_cmd.AppendSwitch(installer::switches::kRunAsAdmin); |
| 1442 // If system_install became true due to an environment variable, append | 1451 // If system_install became true due to an environment variable, append |
| 1443 // it to the command line here since env vars may not propagate past the | 1452 // it to the command line here since env vars may not propagate past the |
| 1444 // elevation. | 1453 // elevation. |
| 1445 if (!new_cmd.HasSwitch(installer::switches::kSystemLevel)) | 1454 if (!new_cmd.HasSwitch(installer::switches::kSystemLevel)) |
| 1446 new_cmd.AppendSwitch(installer::switches::kSystemLevel); | 1455 new_cmd.AppendSwitch(installer::switches::kSystemLevel); |
| 1456 |
| 1447 DWORD exit_code = installer::UNKNOWN_STATUS; | 1457 DWORD exit_code = installer::UNKNOWN_STATUS; |
| 1448 InstallUtil::ExecuteExeAsAdmin(new_cmd, &exit_code); | 1458 InstallUtil::ExecuteExeAsAdmin(new_cmd, &exit_code); |
| 1449 return exit_code; | 1459 return exit_code; |
| 1450 } else { | 1460 } else { |
| 1451 LOG(ERROR) << "Non admin user can not install system level Chrome."; | 1461 LOG(ERROR) << "Non admin user can not install system level Chrome."; |
| 1452 installer_state.WriteInstallerResult(installer::INSUFFICIENT_RIGHTS, | 1462 installer_state.WriteInstallerResult(installer::INSUFFICIENT_RIGHTS, |
| 1453 IDS_INSTALL_INSUFFICIENT_RIGHTS_BASE, NULL); | 1463 IDS_INSTALL_INSUFFICIENT_RIGHTS_BASE, NULL); |
| 1454 return installer::INSUFFICIENT_RIGHTS; | 1464 return installer::INSUFFICIENT_RIGHTS; |
| 1455 } | 1465 } |
| 1456 } | 1466 } |
| 1457 | 1467 |
| 1458 installer::InstallStatus install_status = installer::UNKNOWN_STATUS; | 1468 installer::InstallStatus install_status = installer::UNKNOWN_STATUS; |
| 1459 // If --uninstall option is given, uninstall the identified product(s) | 1469 // If --uninstall option is given, uninstall the identified product(s) |
| 1460 if (is_uninstall) { | 1470 if (is_uninstall) { |
| 1461 install_status = UninstallProducts(original_state, installer_state, | 1471 install_status = |
| 1462 cmd_line); | 1472 UninstallProducts(original_state, installer_state, cmd_line); |
| 1463 } else { | 1473 } else { |
| 1464 // If --uninstall option is not specified, we assume it is install case. | 1474 // If --uninstall option is not specified, we assume it is install case. |
| 1465 install_status = InstallProducts(original_state, cmd_line, prefs, | 1475 install_status = |
| 1466 &installer_state); | 1476 InstallProducts(original_state, cmd_line, prefs, &installer_state); |
| 1467 } | 1477 } |
| 1468 | 1478 |
| 1469 // Validate that the machine is now in a good state following the operation. | 1479 // Validate that the machine is now in a good state following the operation. |
| 1470 // TODO(grt): change this to log at DFATAL once we're convinced that the | 1480 // TODO(grt): change this to log at DFATAL once we're convinced that the |
| 1471 // validator handles all cases properly. | 1481 // validator handles all cases properly. |
| 1472 InstallationValidator::InstallationType installation_type = | 1482 InstallationValidator::InstallationType installation_type = |
| 1473 InstallationValidator::NO_PRODUCTS; | 1483 InstallationValidator::NO_PRODUCTS; |
| 1474 LOG_IF(ERROR, | 1484 LOG_IF(ERROR, |
| 1475 !InstallationValidator::ValidateInstallationType(system_install, | 1485 !InstallationValidator::ValidateInstallationType(system_install, |
| 1476 &installation_type)); | 1486 &installation_type)); |
| 1477 | 1487 |
| 1478 const Product* cf_install = | 1488 const Product* cf_install = |
| 1479 installer_state.FindProduct(BrowserDistribution::CHROME_FRAME); | 1489 installer_state.FindProduct(BrowserDistribution::CHROME_FRAME); |
| 1480 | 1490 |
| 1481 if (cf_install && | 1491 if (cf_install && |
| 1482 !cmd_line.HasSwitch(installer::switches::kForceUninstall)) { | 1492 !cmd_line.HasSwitch(installer::switches::kForceUninstall)) { |
| 1483 if (install_status == installer::UNINSTALL_REQUIRES_REBOOT) { | 1493 if (install_status == installer::UNINSTALL_REQUIRES_REBOOT) { |
| 1484 ShowRebootDialog(); | 1494 ShowRebootDialog(); |
| 1485 } else if (is_uninstall) { | 1495 } else if (is_uninstall) { |
| 1486 // Only show the message box if Chrome Frame was the only product being | 1496 // Only show the message box if Chrome Frame was the only product being |
| 1487 // uninstalled. | 1497 // uninstalled. |
| 1488 const Products& products = installer_state.products(); | 1498 const Products& products = installer_state.products(); |
| 1489 int num_products = 0; | 1499 int num_products = 0; |
| 1490 for (size_t i = 0; i < products.size(); ++i) { | 1500 for (Products::const_iterator it = products.begin(); it < products.end(); |
| 1491 if (!products[i]->is_chrome_binaries()) | 1501 ++it) { |
| 1502 if (!(*it)->is_chrome_binaries()) |
| 1492 ++num_products; | 1503 ++num_products; |
| 1493 } | 1504 } |
| 1494 if (num_products == 1U) { | 1505 if (num_products == 1U) { |
| 1495 ::MessageBoxW(NULL, | 1506 ::MessageBoxW(NULL, |
| 1496 installer::GetLocalizedString( | 1507 installer::GetLocalizedString( |
| 1497 IDS_UNINSTALL_COMPLETE_BASE).c_str(), | 1508 IDS_UNINSTALL_COMPLETE_BASE).c_str(), |
| 1498 cf_install->distribution()->GetAppShortCutName().c_str(), | 1509 cf_install->distribution()->GetAppShortCutName().c_str(), |
| 1499 MB_OK); | 1510 MB_OK); |
| 1500 } | 1511 } |
| 1501 } | 1512 } |
| 1502 } | 1513 } |
| 1503 | 1514 |
| 1504 int return_code = 0; | 1515 int return_code = 0; |
| 1505 // MSI demands that custom actions always return 0 (ERROR_SUCCESS) or it will | 1516 // MSI demands that custom actions always return 0 (ERROR_SUCCESS) or it will |
| 1506 // rollback the action. If we're uninstalling we want to avoid this, so always | 1517 // rollback the action. If we're uninstalling we want to avoid this, so always |
| 1507 // report success, squashing any more informative return codes. | 1518 // report success, squashing any more informative return codes. |
| 1508 if (!(installer_state.is_msi() && is_uninstall)) | 1519 if (!(installer_state.is_msi() && is_uninstall)) |
| 1509 // Note that we allow the status installer::UNINSTALL_REQUIRES_REBOOT | 1520 // Note that we allow the status installer::UNINSTALL_REQUIRES_REBOOT |
| 1510 // to pass through, since this is only returned on uninstall which is | 1521 // to pass through, since this is only returned on uninstall which is |
| 1511 // never invoked directly by Google Update. | 1522 // never invoked directly by Google Update. |
| 1512 return_code = InstallUtil::GetInstallReturnCode(install_status); | 1523 return_code = InstallUtil::GetInstallReturnCode(install_status); |
| 1513 | 1524 |
| 1514 VLOG(1) << "Installation complete, returning: " << return_code; | 1525 VLOG(1) << "Installation complete, returning: " << return_code; |
| 1515 | 1526 |
| 1516 return return_code; | 1527 return return_code; |
| 1517 } | 1528 } |
| OLD | NEW |