Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(496)

Side by Side Diff: chrome/installer/setup/setup_main.cc

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

Powered by Google App Engine
This is Rietveld 408576698