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

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

Issue 2292293002: Add installer::SetupSingleton. (Closed)
Patch Set: Created 4 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
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 #include "chrome/installer/setup/setup_main.h" 5 #include "chrome/installer/setup/setup_main.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <msi.h> 8 #include <msi.h>
9 #include <shellapi.h> 9 #include <shellapi.h>
10 #include <shlobj.h> 10 #include <shlobj.h>
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 #include "base/win/windows_version.h" 44 #include "base/win/windows_version.h"
45 #include "chrome/common/chrome_constants.h" 45 #include "chrome/common/chrome_constants.h"
46 #include "chrome/common/chrome_paths.h" 46 #include "chrome/common/chrome_paths.h"
47 #include "chrome/common/chrome_switches.h" 47 #include "chrome/common/chrome_switches.h"
48 #include "chrome/installer/setup/archive_patch_helper.h" 48 #include "chrome/installer/setup/archive_patch_helper.h"
49 #include "chrome/installer/setup/install.h" 49 #include "chrome/installer/setup/install.h"
50 #include "chrome/installer/setup/install_worker.h" 50 #include "chrome/installer/setup/install_worker.h"
51 #include "chrome/installer/setup/installer_crash_reporting.h" 51 #include "chrome/installer/setup/installer_crash_reporting.h"
52 #include "chrome/installer/setup/installer_metrics.h" 52 #include "chrome/installer/setup/installer_metrics.h"
53 #include "chrome/installer/setup/setup_constants.h" 53 #include "chrome/installer/setup/setup_constants.h"
54 #include "chrome/installer/setup/setup_singleton.h"
54 #include "chrome/installer/setup/setup_util.h" 55 #include "chrome/installer/setup/setup_util.h"
55 #include "chrome/installer/setup/uninstall.h" 56 #include "chrome/installer/setup/uninstall.h"
56 #include "chrome/installer/util/browser_distribution.h" 57 #include "chrome/installer/util/browser_distribution.h"
57 #include "chrome/installer/util/delete_after_reboot_helper.h" 58 #include "chrome/installer/util/delete_after_reboot_helper.h"
58 #include "chrome/installer/util/delete_tree_work_item.h" 59 #include "chrome/installer/util/delete_tree_work_item.h"
59 #include "chrome/installer/util/google_update_constants.h" 60 #include "chrome/installer/util/google_update_constants.h"
60 #include "chrome/installer/util/google_update_settings.h" 61 #include "chrome/installer/util/google_update_settings.h"
61 #include "chrome/installer/util/google_update_util.h" 62 #include "chrome/installer/util/google_update_util.h"
62 #include "chrome/installer/util/helper.h" 63 #include "chrome/installer/util/helper.h"
63 #include "chrome/installer/util/html_dialog.h" 64 #include "chrome/installer/util/html_dialog.h"
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 // This function is called when --rename-chrome-exe option is specified on 389 // This function is called when --rename-chrome-exe option is specified on
389 // setup.exe command line. This function assumes an in-use update has happened 390 // setup.exe command line. This function assumes an in-use update has happened
390 // for Chrome so there should be a file called new_chrome.exe on the file 391 // for Chrome so there should be a file called new_chrome.exe on the file
391 // system and a key called 'opv' in the registry. This function will move 392 // system and a key called 'opv' in the registry. This function will move
392 // new_chrome.exe to chrome.exe and delete 'opv' key in one atomic operation. 393 // new_chrome.exe to chrome.exe and delete 'opv' key in one atomic operation.
393 // This function also deletes elevation policies associated with the old version 394 // This function also deletes elevation policies associated with the old version
394 // if they exist. 395 // if they exist.
395 installer::InstallStatus RenameChromeExecutables( 396 installer::InstallStatus RenameChromeExecutables(
396 const InstallationState& original_state, 397 const InstallationState& original_state,
397 InstallerState* installer_state) { 398 InstallerState* installer_state) {
399 installer::SetupSingleton setup_singleton(*installer_state);
400
398 // See what products are already installed in multi mode. When we do the 401 // See what products are already installed in multi mode. When we do the
399 // rename for multi installs, we must update all installations since they 402 // rename for multi installs, we must update all installations since they
400 // share the binaries. 403 // share the binaries.
401 AddExistingMultiInstalls(original_state, installer_state); 404 AddExistingMultiInstalls(original_state, installer_state);
402 const base::FilePath &target_path = installer_state->target_path(); 405 const base::FilePath &target_path = installer_state->target_path();
403 base::FilePath chrome_exe(target_path.Append(installer::kChromeExe)); 406 base::FilePath chrome_exe(target_path.Append(installer::kChromeExe));
404 base::FilePath chrome_new_exe(target_path.Append(installer::kChromeNewExe)); 407 base::FilePath chrome_new_exe(target_path.Append(installer::kChromeNewExe));
405 base::FilePath chrome_old_exe(target_path.Append(installer::kChromeOldExe)); 408 base::FilePath chrome_old_exe(target_path.Append(installer::kChromeOldExe));
406 409
407 // Create a temporary backup directory on the same volume as chrome.exe so 410 // Create a temporary backup directory on the same volume as chrome.exe so
(...skipping 1333 matching lines...) Expand 10 before | Expand all | Expand 10 after
1741 installer::InitInstallerLogging(prefs); 1744 installer::InitInstallerLogging(prefs);
1742 1745
1743 const base::CommandLine& cmd_line = *base::CommandLine::ForCurrentProcess(); 1746 const base::CommandLine& cmd_line = *base::CommandLine::ForCurrentProcess();
1744 VLOG(1) << "Command Line: " << cmd_line.GetCommandLineString(); 1747 VLOG(1) << "Command Line: " << cmd_line.GetCommandLineString();
1745 1748
1746 VLOG(1) << "multi install is " << prefs.is_multi_install(); 1749 VLOG(1) << "multi install is " << prefs.is_multi_install();
1747 bool system_install = false; 1750 bool system_install = false;
1748 prefs.GetBool(installer::master_preferences::kSystemLevel, &system_install); 1751 prefs.GetBool(installer::master_preferences::kSystemLevel, &system_install);
1749 VLOG(1) << "system install is " << system_install; 1752 VLOG(1) << "system install is " << system_install;
1750 1753
1751 InstallationState original_state; 1754 InstallationState original_state;
grt (UTC plus 2) 2016/08/31 12:03:47 many operations in the installer inspect |original
fdoray 2016/08/31 19:14:21 Done.
1752 original_state.Initialize(); 1755 original_state.Initialize();
1753 1756
1754 InstallerState installer_state; 1757 InstallerState installer_state;
1755 installer_state.Initialize(cmd_line, prefs, original_state); 1758 installer_state.Initialize(cmd_line, prefs, original_state);
1756 1759
1757 installer::ConfigureCrashReporting(installer_state); 1760 installer::ConfigureCrashReporting(installer_state);
1758 installer::SetInitialCrashKeys(installer_state); 1761 installer::SetInitialCrashKeys(installer_state);
1759 installer::SetCrashKeysFromCommandLine(cmd_line); 1762 installer::SetCrashKeysFromCommandLine(cmd_line);
1760 1763
1761 // Make sure the process exits cleanly on unexpected errors. 1764 // Make sure the process exits cleanly on unexpected errors.
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
1836 InstallUtil::ExecuteExeAsAdmin(new_cmd, &exit_code); 1839 InstallUtil::ExecuteExeAsAdmin(new_cmd, &exit_code);
1837 return exit_code; 1840 return exit_code;
1838 } else { 1841 } else {
1839 LOG(ERROR) << "Non admin user can not install system level Chrome."; 1842 LOG(ERROR) << "Non admin user can not install system level Chrome.";
1840 installer_state.WriteInstallerResult(installer::INSUFFICIENT_RIGHTS, 1843 installer_state.WriteInstallerResult(installer::INSUFFICIENT_RIGHTS,
1841 IDS_INSTALL_INSUFFICIENT_RIGHTS_BASE, NULL); 1844 IDS_INSTALL_INSUFFICIENT_RIGHTS_BASE, NULL);
1842 return installer::INSUFFICIENT_RIGHTS; 1845 return installer::INSUFFICIENT_RIGHTS;
1843 } 1846 }
1844 } 1847 }
1845 1848
1849 installer::SetupSingleton setup_singleton(installer_state);
1850
1846 UninstallMultiChromeFrameIfPresent(cmd_line, prefs, 1851 UninstallMultiChromeFrameIfPresent(cmd_line, prefs,
1847 &original_state, &installer_state); 1852 &original_state, &installer_state);
1848 1853
1849 base::FilePath installer_directory; 1854 base::FilePath installer_directory;
1850 installer::InstallStatus install_status = installer::UNKNOWN_STATUS; 1855 installer::InstallStatus install_status = installer::UNKNOWN_STATUS;
1851 // If --uninstall option is given, uninstall the identified product(s) 1856 // If --uninstall option is given, uninstall the identified product(s)
1852 if (is_uninstall) { 1857 if (is_uninstall) {
1853 install_status = 1858 install_status =
1854 UninstallProducts(original_state, installer_state, setup_exe, cmd_line); 1859 UninstallProducts(original_state, installer_state, setup_exe, cmd_line);
1855 } else { 1860 } else {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1892 // never invoked directly by Google Update. 1897 // never invoked directly by Google Update.
1893 return_code = InstallUtil::GetInstallReturnCode(install_status); 1898 return_code = InstallUtil::GetInstallReturnCode(install_status);
1894 } 1899 }
1895 1900
1896 installer::EndPersistentHistogramStorage(installer_state.target_path(), 1901 installer::EndPersistentHistogramStorage(installer_state.target_path(),
1897 system_install); 1902 system_install);
1898 VLOG(1) << "Installation complete, returning: " << return_code; 1903 VLOG(1) << "Installation complete, returning: " << return_code;
1899 1904
1900 return return_code; 1905 return return_code;
1901 } 1906 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698