OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <windows.h> | 5 #include <windows.h> |
6 #include <msi.h> | 6 #include <msi.h> |
7 #include <shellapi.h> | 7 #include <shellapi.h> |
8 #include <shlobj.h> | 8 #include <shlobj.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 ScheduleDirectoryForDeletion(prefs_path.c_str()); | 394 ScheduleDirectoryForDeletion(prefs_path.c_str()); |
395 } | 395 } |
396 } | 396 } |
397 | 397 |
398 dist->UpdateDiffInstallStatus(system_level, incremental_install, | 398 dist->UpdateDiffInstallStatus(system_level, incremental_install, |
399 install_status); | 399 install_status); |
400 return install_status; | 400 return install_status; |
401 } | 401 } |
402 | 402 |
403 installer_util::InstallStatus UninstallChrome(const CommandLine& cmd_line, | 403 installer_util::InstallStatus UninstallChrome(const CommandLine& cmd_line, |
404 const wchar_t* cmd_params, | |
405 const installer::Version* version, | 404 const installer::Version* version, |
406 bool system_install) { | 405 bool system_install) { |
407 VLOG(1) << "Uninstalling Chome"; | 406 VLOG(1) << "Uninstalling Chome"; |
408 bool force = cmd_line.HasSwitch(installer_util::switches::kForceUninstall); | 407 bool force = cmd_line.HasSwitch(installer_util::switches::kForceUninstall); |
409 if (!version && !force) { | 408 if (!version && !force) { |
410 LOG(ERROR) << "No Chrome installation found for uninstall."; | 409 LOG(ERROR) << "No Chrome installation found for uninstall."; |
411 InstallUtil::WriteInstallerResult(system_install, | 410 InstallUtil::WriteInstallerResult(system_install, |
412 installer_util::CHROME_NOT_INSTALLED, | 411 installer_util::CHROME_NOT_INSTALLED, |
413 IDS_UNINSTALL_FAILED_BASE, NULL); | 412 IDS_UNINSTALL_FAILED_BASE, NULL); |
414 return installer_util::CHROME_NOT_INSTALLED; | 413 return installer_util::CHROME_NOT_INSTALLED; |
415 } | 414 } |
416 | 415 |
417 bool remove_all = !cmd_line.HasSwitch( | 416 bool remove_all = !cmd_line.HasSwitch( |
418 installer_util::switches::kDoNotRemoveSharedItems); | 417 installer_util::switches::kDoNotRemoveSharedItems); |
419 | 418 |
420 return installer_setup::UninstallChrome(cmd_line.GetProgram().value(), | 419 return installer_setup::UninstallChrome(cmd_line.GetProgram().value(), |
421 system_install, | 420 system_install, |
422 remove_all, force, | 421 remove_all, force, |
423 cmd_line, cmd_params); | 422 cmd_line); |
424 } | 423 } |
425 | 424 |
426 installer_util::InstallStatus ShowEULADialog(const std::wstring& inner_frame) { | 425 installer_util::InstallStatus ShowEULADialog(const std::wstring& inner_frame) { |
427 VLOG(1) << "About to show EULA"; | 426 VLOG(1) << "About to show EULA"; |
428 std::wstring eula_path = installer_util::GetLocalizedEulaResource(); | 427 std::wstring eula_path = installer_util::GetLocalizedEulaResource(); |
429 if (eula_path.empty()) { | 428 if (eula_path.empty()) { |
430 LOG(ERROR) << "No EULA path available"; | 429 LOG(ERROR) << "No EULA path available"; |
431 return installer_util::EULA_REJECTED; | 430 return installer_util::EULA_REJECTED; |
432 } | 431 } |
433 // Newer versions of the caller pass an inner frame parameter that must | 432 // Newer versions of the caller pass an inner frame parameter that must |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
674 } | 673 } |
675 | 674 |
676 int exit_code = 0; | 675 int exit_code = 0; |
677 if (HandleNonInstallCmdLineOptions(parsed_command_line, system_install, | 676 if (HandleNonInstallCmdLineOptions(parsed_command_line, system_install, |
678 exit_code)) | 677 exit_code)) |
679 return exit_code; | 678 return exit_code; |
680 | 679 |
681 if (system_install && !IsUserAnAdmin()) { | 680 if (system_install && !IsUserAnAdmin()) { |
682 if (base::win::GetVersion() >= base::win::VERSION_VISTA && | 681 if (base::win::GetVersion() >= base::win::VERSION_VISTA && |
683 !parsed_command_line.HasSwitch(installer_util::switches::kRunAsAdmin)) { | 682 !parsed_command_line.HasSwitch(installer_util::switches::kRunAsAdmin)) { |
684 std::wstring exe = parsed_command_line.GetProgram().value(); | 683 CommandLine new_cmd(CommandLine::NO_PROGRAM); |
685 std::wstring params(command_line); | 684 new_cmd.AppendArguments(parsed_command_line, true); |
686 // Append --run-as-admin flag to let the new instance of setup.exe know | 685 // Append --run-as-admin flag to let the new instance of setup.exe know |
687 // that we already tried to launch ourselves as admin. | 686 // that we already tried to launch ourselves as admin. |
688 params.append(L" --"); | 687 new_cmd.AppendSwitch(installer_util::switches::kRunAsAdmin); |
689 params.append(installer_util::switches::kRunAsAdmin); | |
690 DWORD exit_code = installer_util::UNKNOWN_STATUS; | 688 DWORD exit_code = installer_util::UNKNOWN_STATUS; |
691 InstallUtil::ExecuteExeAsAdmin(exe, params, &exit_code); | 689 InstallUtil::ExecuteExeAsAdmin(new_cmd, &exit_code); |
692 return exit_code; | 690 return exit_code; |
693 } else { | 691 } else { |
694 LOG(ERROR) << "Non admin user can not install system level Chrome."; | 692 LOG(ERROR) << "Non admin user can not install system level Chrome."; |
695 InstallUtil::WriteInstallerResult(system_install, | 693 InstallUtil::WriteInstallerResult(system_install, |
696 installer_util::INSUFFICIENT_RIGHTS, | 694 installer_util::INSUFFICIENT_RIGHTS, |
697 IDS_INSTALL_INSUFFICIENT_RIGHTS_BASE, | 695 IDS_INSTALL_INSUFFICIENT_RIGHTS_BASE, |
698 NULL); | 696 NULL); |
699 return installer_util::INSUFFICIENT_RIGHTS; | 697 return installer_util::INSUFFICIENT_RIGHTS; |
700 } | 698 } |
701 } | 699 } |
702 | 700 |
703 // Check the existing version installed. | 701 // Check the existing version installed. |
704 scoped_ptr<installer::Version> | 702 scoped_ptr<installer::Version> |
705 installed_version(InstallUtil::GetChromeVersion(system_install)); | 703 installed_version(InstallUtil::GetChromeVersion(system_install)); |
706 if (installed_version.get()) | 704 if (installed_version.get()) |
707 VLOG(1) << "version on the system: " << installed_version->GetString(); | 705 VLOG(1) << "version on the system: " << installed_version->GetString(); |
708 | 706 |
709 installer_util::InstallStatus install_status = installer_util::UNKNOWN_STATUS; | 707 installer_util::InstallStatus install_status = installer_util::UNKNOWN_STATUS; |
710 // If --uninstall option is given, uninstall chrome | 708 // If --uninstall option is given, uninstall chrome |
711 if (parsed_command_line.HasSwitch(installer_util::switches::kUninstall)) { | 709 if (parsed_command_line.HasSwitch(installer_util::switches::kUninstall)) { |
712 install_status = UninstallChrome(parsed_command_line, | 710 install_status = UninstallChrome(parsed_command_line, |
713 command_line, | |
714 installed_version.get(), | 711 installed_version.get(), |
715 system_install); | 712 system_install); |
716 // If --uninstall option is not specified, we assume it is install case. | 713 // If --uninstall option is not specified, we assume it is install case. |
717 } else { | 714 } else { |
718 install_status = InstallChrome(parsed_command_line, installed_version.get(), | 715 install_status = InstallChrome(parsed_command_line, installed_version.get(), |
719 prefs); | 716 prefs); |
720 } | 717 } |
721 | 718 |
722 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | 719 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
723 | 720 |
(...skipping 20 matching lines...) Expand all Loading... |
744 parsed_command_line.HasSwitch(installer_util::switches::kUninstall))) { | 741 parsed_command_line.HasSwitch(installer_util::switches::kUninstall))) { |
745 // Note that we allow the status installer_util::UNINSTALL_REQUIRES_REBOOT | 742 // Note that we allow the status installer_util::UNINSTALL_REQUIRES_REBOOT |
746 // to pass through, since this is only returned on uninstall which is never | 743 // to pass through, since this is only returned on uninstall which is never |
747 // invoked directly by Google Update. | 744 // invoked directly by Google Update. |
748 return_code = dist->GetInstallReturnCode(install_status); | 745 return_code = dist->GetInstallReturnCode(install_status); |
749 } | 746 } |
750 | 747 |
751 VLOG(1) << "Installation complete, returning: " << return_code; | 748 VLOG(1) << "Installation complete, returning: " << return_code; |
752 return return_code; | 749 return return_code; |
753 } | 750 } |
OLD | NEW |