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

Side by Side Diff: chrome/installer/mini_installer/mini_installer.cc

Issue 10665002: Implement installation of the Chrome App Host. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix unittests. Created 8 years, 5 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) 2011 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 // mini_installer.exe is the first exe that is run when chrome is being 5 // mini_installer.exe is the first exe that is run when chrome is being
6 // installed or upgraded. It is designed to be extremely small (~5KB with no 6 // installed or upgraded. It is designed to be extremely small (~5KB with no
7 // extra resources linked) and it has two main jobs: 7 // extra resources linked) and it has two main jobs:
8 // 1) unpack the resources (possibly decompressing some) 8 // 1) unpack the resources (possibly decompressing some)
9 // 2) run the real installer (setup.exe) with appropriate flags. 9 // 2) run the real installer (setup.exe) with appropriate flags.
10 // 10 //
11 // In order to be really small the app doesn't link against the CRT and 11 // In order to be really small the app doesn't link against the CRT and
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 // should try full installer next time. If the current installer works, this 152 // should try full installer next time. If the current installer works, this
153 // flag is cleared by setup.exe at the end of install. The flag will by default 153 // flag is cleared by setup.exe at the end of install. The flag will by default
154 // be written to HKCU, but if --system-level is included in the command line, 154 // be written to HKCU, but if --system-level is included in the command line,
155 // it will be written to HKLM instead. 155 // it will be written to HKLM instead.
156 // TODO(grt): Write a unit test for this that uses registry virtualization. 156 // TODO(grt): Write a unit test for this that uses registry virtualization.
157 void SetInstallerFlags(const Configuration& configuration) { 157 void SetInstallerFlags(const Configuration& configuration) {
158 RegKey key; 158 RegKey key;
159 const REGSAM key_access = KEY_QUERY_VALUE | KEY_SET_VALUE; 159 const REGSAM key_access = KEY_QUERY_VALUE | KEY_SET_VALUE;
160 const HKEY root_key = 160 const HKEY root_key =
161 configuration.is_system_level() ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; 161 configuration.is_system_level() ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER;
162 // This is ignored if multi-install is true.
162 const wchar_t* app_guid = 163 const wchar_t* app_guid =
163 configuration.has_chrome_frame() ? 164 configuration.has_chrome_frame() ?
164 google_update::kChromeFrameAppGuid : 165 google_update::kChromeFrameAppGuid :
165 configuration.chrome_app_guid(); 166 configuration.chrome_app_guid();
166 StackString<128> value; 167 StackString<128> value;
167 LONG ret; 168 LONG ret;
168 169
169 // When multi_install is true, we are potentially: 170 // When multi_install is true, we are potentially:
170 // 1. Performing a multi-install of some product(s) on a clean machine. 171 // 1. Performing a multi-install of some product(s) on a clean machine.
171 // Neither the product(s) nor the multi-installer will have a ClientState 172 // Neither the product(s) nor the multi-installer will have a ClientState
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 216
216 if (!StrEndsWith(value.get(), kFullInstallerSuffix) && 217 if (!StrEndsWith(value.get(), kFullInstallerSuffix) &&
217 value.append(kFullInstallerSuffix)) { 218 value.append(kFullInstallerSuffix)) {
218 key.WriteValue(kApRegistryValueName, value.get()); 219 key.WriteValue(kApRegistryValueName, value.get());
219 } 220 }
220 } 221 }
221 } 222 }
222 223
223 // Gets the setup.exe path from Registry by looking the value of Uninstall 224 // Gets the setup.exe path from Registry by looking the value of Uninstall
224 // string. |size| is measured in wchar_t units. 225 // string. |size| is measured in wchar_t units.
226 bool GetSetupExePathForGuidFromRegistry(bool system_level,
227 const wchar_t* app_guid,
228 wchar_t* path,
229 size_t size) {
230 const HKEY root_key = system_level ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER;
231 RegKey key;
232 return OpenClientStateKey(root_key, app_guid, KEY_QUERY_VALUE, &key) &&
233 (key.ReadValue(kUninstallRegistryValueName, path, size) == ERROR_SUCCESS);
234 }
235
236 // Gets the setup.exe path from Registry by looking the value of Uninstall
237 // string. |size| is measured in wchar_t units.
225 bool GetSetupExePathFromRegistry(const Configuration& configuration, 238 bool GetSetupExePathFromRegistry(const Configuration& configuration,
226 wchar_t* path, 239 wchar_t* path,
227 size_t size) { 240 size_t size) {
228 const HKEY root_key = 241 bool system_level = configuration.is_system_level();
229 configuration.is_system_level() ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER;
230 RegKey key;
231 bool succeeded = false;
232 242
233 // If this is a multi install, first try looking in the binaries for the path. 243 // If this is a multi install, first try looking in the binaries for the path.
234 if (configuration.is_multi_install() && 244 if (configuration.is_multi_install() && GetSetupExePathForGuidFromRegistry(
235 OpenClientStateKey(root_key, google_update::kMultiInstallAppGuid, 245 system_level, google_update::kMultiInstallAppGuid, path, size)) {
236 KEY_QUERY_VALUE, &key)) { 246 return true;
237 succeeded = (key.ReadValue(kUninstallRegistryValueName, path,
238 size) == ERROR_SUCCESS);
239 } 247 }
240 248
241 // Failing that, look in Chrome Frame's client state key --chrome-frame was 249 // Failing that, look in Chrome Frame's client state key if --chrome-frame was
242 // specified. 250 // specified.
243 if (!succeeded && configuration.has_chrome_frame() && 251 if (configuration.has_chrome_frame() && GetSetupExePathForGuidFromRegistry(
244 OpenClientStateKey(root_key, google_update::kChromeFrameAppGuid, 252 system_level, google_update::kChromeFrameAppGuid, path, size)) {
245 KEY_QUERY_VALUE, &key)) { 253 return true;
246 succeeded = (key.ReadValue(kUninstallRegistryValueName, path,
247 size) == ERROR_SUCCESS);
248 } 254 }
249 255
250 // Make a last-ditch effort to look in Chrome's client state key. 256 // Make a last-ditch effort to look in the Chrome and App Host client state
251 if (!succeeded && 257 // keys.
252 OpenClientStateKey(root_key, configuration.chrome_app_guid(), 258 if (GetSetupExePathForGuidFromRegistry(
253 KEY_QUERY_VALUE, &key)) { 259 system_level, configuration.chrome_app_guid(), path, size)) {
254 succeeded = (key.ReadValue(kUninstallRegistryValueName, path, 260 return true;
255 size) == ERROR_SUCCESS); 261 }
262 if (configuration.has_app_host() && GetSetupExePathForGuidFromRegistry(
263 system_level, google_update::kChromeAppHostAppGuid, path, size)) {
264 return true;
256 } 265 }
257 266
258 return succeeded; 267 return false;
259 } 268 }
260 269
261 // Calls CreateProcess with good default parameters and waits for the process 270 // Calls CreateProcess with good default parameters and waits for the process
262 // to terminate returning the process exit code. 271 // to terminate returning the process exit code.
263 bool RunProcessAndWait(const wchar_t* exe_path, wchar_t* cmdline, 272 bool RunProcessAndWait(const wchar_t* exe_path, wchar_t* cmdline,
264 int* exit_code) { 273 int* exit_code) {
265 STARTUPINFOW si = {sizeof(si)}; 274 STARTUPINFOW si = {sizeof(si)};
266 PROCESS_INFORMATION pi = {0}; 275 PROCESS_INFORMATION pi = {0};
267 if (!::CreateProcess(exe_path, cmdline, NULL, NULL, FALSE, CREATE_NO_WINDOW, 276 if (!::CreateProcess(exe_path, cmdline, NULL, NULL, FALSE, CREATE_NO_WINDOW,
268 NULL, NULL, &si, &pi)) { 277 NULL, NULL, &si, &pi)) {
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after
835 case 1: 844 case 1:
836 dest8[count - 1] = c; 845 dest8[count - 1] = c;
837 } 846 }
838 847
839 while (adjcount-- > 0) // Copy the rest, 4 bytes/32 bits at a time 848 while (adjcount-- > 0) // Copy the rest, 4 bytes/32 bits at a time
840 *(dest32++) = fill; 849 *(dest32++) = fill;
841 850
842 return dest; 851 return dest;
843 } 852 }
844 } // extern "C" 853 } // extern "C"
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698