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

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

Issue 1271893003: Add options to write version number to registry. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: extract registry overwrite to its own method Created 5 years, 4 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
« no previous file with comments | « no previous file | chrome/installer/util/util_constants.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 using installer::InstallerState; 73 using installer::InstallerState;
74 using installer::InstallationState; 74 using installer::InstallationState;
75 using installer::InstallationValidator; 75 using installer::InstallationValidator;
76 using installer::MasterPreferences; 76 using installer::MasterPreferences;
77 using installer::Product; 77 using installer::Product;
78 using installer::ProductState; 78 using installer::ProductState;
79 using installer::Products; 79 using installer::Products;
80 80
81 const wchar_t kGoogleUpdatePipeName[] = L"\\\\.\\pipe\\GoogleCrashServices\\"; 81 const wchar_t kGoogleUpdatePipeName[] = L"\\\\.\\pipe\\GoogleCrashServices\\";
82 const wchar_t kSystemPrincipalSid[] = L"S-1-5-18"; 82 const wchar_t kSystemPrincipalSid[] = L"S-1-5-18";
83 const wchar_t kDisplayVersion[] = L"DisplayVersion";
83 84
84 const MINIDUMP_TYPE kLargerDumpType = static_cast<MINIDUMP_TYPE>( 85 const MINIDUMP_TYPE kLargerDumpType = static_cast<MINIDUMP_TYPE>(
85 MiniDumpWithProcessThreadData | // Get PEB and TEB. 86 MiniDumpWithProcessThreadData | // Get PEB and TEB.
86 MiniDumpWithUnloadedModules | // Get unloaded modules when available. 87 MiniDumpWithUnloadedModules | // Get unloaded modules when available.
87 MiniDumpWithIndirectlyReferencedMemory); // Get memory referenced by stack. 88 MiniDumpWithIndirectlyReferencedMemory); // Get memory referenced by stack.
88 89
89 namespace { 90 namespace {
90 91
92 // Overwrite an existing DisplayVersion as written by the MSI installer
93 // with the real version number of Chrome.
94 LONG OverwriteDisplayVersion(base::string16 path, base::string16 value) {
robertshield 2015/08/08 04:32:38 pass by reference, no need to make a copy: const b
bcwhite 2015/08/13 16:25:58 Done.
95 base::win::RegKey key;
96 LONG result;
robertshield 2015/08/08 04:32:39 = 0
bcwhite 2015/08/13 16:25:58 Done.
97 std::wstring existing;
robertshield 2015/08/08 04:32:39 Should be able to use base::string16 here
bcwhite 2015/08/13 16:25:58 Done.
98 if ((result = key.Open(HKEY_LOCAL_MACHINE, path.c_str(),
99 KEY_QUERY_VALUE | KEY_SET_VALUE | KEY_WOW64_64KEY))
100 != ERROR_SUCCESS) {
101 return result;
102 }
103 if ((result = key.ReadValue(kDisplayVersion, &existing)) != ERROR_SUCCESS)
robertshield 2015/08/08 04:33:30 We should log to the installer log when the value
bcwhite 2015/08/13 16:25:58 Done.
104 return result;
robertshield 2015/08/08 04:32:39 It looks like we don't use the value of |existing|
bcwhite 2015/08/13 16:25:58 Done.
105 if ((result = key.WriteValue(kDisplayVersion, value.c_str()))
106 != ERROR_SUCCESS) {
107 return result;
108 }
109 return ERROR_SUCCESS;
110 }
111
91 // Returns NULL if no compressed archive is available for processing, otherwise 112 // Returns NULL if no compressed archive is available for processing, otherwise
92 // returns a patch helper configured to uncompress and patch. 113 // returns a patch helper configured to uncompress and patch.
93 scoped_ptr<installer::ArchivePatchHelper> CreateChromeArchiveHelper( 114 scoped_ptr<installer::ArchivePatchHelper> CreateChromeArchiveHelper(
94 const base::FilePath& setup_exe, 115 const base::FilePath& setup_exe,
95 const base::CommandLine& command_line, 116 const base::CommandLine& command_line,
96 const installer::InstallerState& installer_state, 117 const installer::InstallerState& installer_state,
97 const base::FilePath& working_directory) { 118 const base::FilePath& working_directory) {
98 // A compressed archive is ordinarily given on the command line by the mini 119 // A compressed archive is ordinarily given on the command line by the mini
99 // installer. If one was not given, look for chrome.packed.7z next to the 120 // installer. If one was not given, look for chrome.packed.7z next to the
100 // running program. 121 // running program.
(...skipping 1044 matching lines...) Expand 10 before | Expand all | Expand 10 after
1145 patch_file, 1166 patch_file,
1146 output_file); 1167 output_file);
1147 } else { 1168 } else {
1148 *exit_code = installer::PATCH_INVALID_ARGUMENTS; 1169 *exit_code = installer::PATCH_INVALID_ARGUMENTS;
1149 } 1170 }
1150 } else if (cmd_line.HasSwitch(installer::switches::kReenableAutoupdates)) { 1171 } else if (cmd_line.HasSwitch(installer::switches::kReenableAutoupdates)) {
1151 // setup.exe has been asked to attempt to reenable updates for Chrome. 1172 // setup.exe has been asked to attempt to reenable updates for Chrome.
1152 bool updates_enabled = GoogleUpdateSettings::ReenableAutoupdates(); 1173 bool updates_enabled = GoogleUpdateSettings::ReenableAutoupdates();
1153 *exit_code = updates_enabled ? installer::REENABLE_UPDATES_SUCCEEDED : 1174 *exit_code = updates_enabled ? installer::REENABLE_UPDATES_SUCCEEDED :
1154 installer::REENABLE_UPDATES_FAILED; 1175 installer::REENABLE_UPDATES_FAILED;
1176 } else if (cmd_line.HasSwitch(installer::switches::kSetDisplayVersionPath)) {
1177 const base::string16 registry_path(
1178 cmd_line.GetSwitchValueNative(
1179 installer::switches::kSetDisplayVersionPath));
1180 const base::string16 registry_value(
1181 cmd_line.GetSwitchValueNative(
1182 installer::switches::kSetDisplayVersionValue));
1183 *exit_code = OverwriteDisplayVersion(registry_path, registry_value);
1155 } else { 1184 } else {
1156 handled = false; 1185 handled = false;
1157 } 1186 }
1158 1187
1159 return handled; 1188 return handled;
1160 } 1189 }
1161 1190
1162 bool ShowRebootDialog() { 1191 bool ShowRebootDialog() {
1163 // Get a token for this process. 1192 // Get a token for this process.
1164 HANDLE token; 1193 HANDLE token;
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
1652 cmd_line.HasSwitch(installer::switches::kInactiveUserToast) || 1681 cmd_line.HasSwitch(installer::switches::kInactiveUserToast) ||
1653 cmd_line.HasSwitch(installer::switches::kSystemLevelToast)) { 1682 cmd_line.HasSwitch(installer::switches::kSystemLevelToast)) {
1654 return installer::SXS_OPTION_NOT_SUPPORTED; 1683 return installer::SXS_OPTION_NOT_SUPPORTED;
1655 } 1684 }
1656 } 1685 }
1657 1686
1658 // Some command line options are no longer supported and must error out. 1687 // Some command line options are no longer supported and must error out.
1659 if (installer::ContainsUnsupportedSwitch(cmd_line)) 1688 if (installer::ContainsUnsupportedSwitch(cmd_line))
1660 return installer::UNSUPPORTED_OPTION; 1689 return installer::UNSUPPORTED_OPTION;
1661 1690
1691 if (cmd_line.HasSwitch(installer::switches::kDelay)) {
robertshield 2015/08/08 04:32:39 Could this block be placed at the top of HandleNon
bcwhite 2015/08/13 16:25:58 Done.
1692 std::string delay_seconds_string(
robertshield 2015/08/08 04:32:38 const
bcwhite 2015/08/13 16:25:58 Done.
1693 cmd_line.GetSwitchValueASCII(installer::switches::kDelay));
1694 int delay_seconds = std::stoi(delay_seconds_string);
robertshield 2015/08/08 04:32:38 Most code I see uses base::StringToInt rather than
bcwhite 2015/08/13 16:25:58 Done.
1695 if (delay_seconds > 0) {
1696 ::Sleep(delay_seconds * 1000);
1697 }
1698 }
1699
1662 // A variety of installer operations require the path to the current 1700 // A variety of installer operations require the path to the current
1663 // executable. Get it once here for use throughout these operations. Note that 1701 // executable. Get it once here for use throughout these operations. Note that
1664 // the path service is the authoritative source for this path. One might think 1702 // the path service is the authoritative source for this path. One might think
1665 // that CommandLine::GetProgram would suffice, but it won't since 1703 // that CommandLine::GetProgram would suffice, but it won't since
1666 // CreateProcess may have been called with a command line that is somewhat 1704 // CreateProcess may have been called with a command line that is somewhat
1667 // ambiguous (e.g., an unquoted path with spaces, or a path lacking the file 1705 // ambiguous (e.g., an unquoted path with spaces, or a path lacking the file
1668 // extension), in which case CommandLineToArgv will not yield an argv with the 1706 // extension), in which case CommandLineToArgv will not yield an argv with the
1669 // true path to the program at position 0. 1707 // true path to the program at position 0.
1670 base::FilePath setup_exe; 1708 base::FilePath setup_exe;
1671 PathService::Get(base::FILE_EXE, &setup_exe); 1709 PathService::Get(base::FILE_EXE, &setup_exe);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
1734 // Note that we allow the status installer::UNINSTALL_REQUIRES_REBOOT 1772 // Note that we allow the status installer::UNINSTALL_REQUIRES_REBOOT
1735 // to pass through, since this is only returned on uninstall which is 1773 // to pass through, since this is only returned on uninstall which is
1736 // never invoked directly by Google Update. 1774 // never invoked directly by Google Update.
1737 return_code = InstallUtil::GetInstallReturnCode(install_status); 1775 return_code = InstallUtil::GetInstallReturnCode(install_status);
1738 } 1776 }
1739 1777
1740 VLOG(1) << "Installation complete, returning: " << return_code; 1778 VLOG(1) << "Installation complete, returning: " << return_code;
1741 1779
1742 return return_code; 1780 return return_code;
1743 } 1781 }
OLDNEW
« no previous file with comments | « no previous file | chrome/installer/util/util_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698