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/util/shell_util.cc

Issue 4928002: Changing the installer switches from wchar_t[] to char[].... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 1 month 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) 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 // This file defines functions that integrate Chrome in Windows shell. These 5 // This file defines functions that integrate Chrome in Windows shell. These
6 // functions can be used by Chrome as well as Chrome installer. All of the 6 // functions can be used by Chrome as well as Chrome installer. All of the
7 // work is done by the local functions defined in anonymous namespace in 7 // work is done by the local functions defined in anonymous namespace in
8 // this class. 8 // this class.
9 9
10 #include "chrome/installer/util/shell_util.h" 10 #include "chrome/installer/util/shell_util.h"
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 RegistryEntry::GetSystemEntries(chrome_exe, suffix, &entries); 288 RegistryEntry::GetSystemEntries(chrome_exe, suffix, &entries);
289 for (std::list<RegistryEntry*>::const_iterator itr = entries.begin(); 289 for (std::list<RegistryEntry*>::const_iterator itr = entries.begin();
290 itr != entries.end() && registered; ++itr) { 290 itr != entries.end() && registered; ++itr) {
291 // We do not need registered = registered && ... since the loop condition 291 // We do not need registered = registered && ... since the loop condition
292 // is set to exit early. 292 // is set to exit early.
293 registered = (*itr)->ExistsInHKLM(); 293 registered = (*itr)->ExistsInHKLM();
294 } 294 }
295 return registered; 295 return registered;
296 } 296 }
297 297
298 // This method registers Chrome on Vista by launching eleavated setup.exe. 298 // This method registers Chrome on Vista by launching an elevated setup.exe.
299 // That will show user standard Vista elevation prompt. If user accepts it 299 // That will show the user the standard Vista elevation prompt. If the user
300 // the new process will make the necessary changes and return SUCCESS that 300 // accepts it the new process will make the necessary changes and return SUCCESS
301 // we capture and return. 301 // that we capture and return.
302 bool ElevateAndRegisterChrome(const std::wstring& chrome_exe, 302 bool ElevateAndRegisterChrome(const std::wstring& chrome_exe,
303 const std::wstring& suffix) { 303 const std::wstring& suffix) {
304 FilePath exe_path = 304 FilePath exe_path =
305 FilePath::FromWStringHack(chrome_exe).DirName() 305 FilePath::FromWStringHack(chrome_exe).DirName()
306 .Append(installer_util::kSetupExe); 306 .Append(installer_util::kSetupExe);
307 if (!file_util::PathExists(exe_path)) { 307 if (!file_util::PathExists(exe_path)) {
308 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); 308 BrowserDistribution* dist = BrowserDistribution::GetDistribution();
309 HKEY reg_root = InstallUtil::IsPerUserInstall(chrome_exe.c_str()) ? 309 HKEY reg_root = InstallUtil::IsPerUserInstall(chrome_exe.c_str()) ?
310 HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE; 310 HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE;
311 RegKey key(reg_root, dist->GetUninstallRegPath().c_str(), KEY_READ); 311 RegKey key(reg_root, dist->GetUninstallRegPath().c_str(), KEY_READ);
312 std::wstring uninstall_string; 312 std::wstring uninstall_string;
313 key.ReadValue(installer_util::kUninstallStringField, &uninstall_string); 313 key.ReadValue(installer_util::kUninstallStringField, &uninstall_string);
314 CommandLine command_line = CommandLine::FromString(uninstall_string); 314 CommandLine command_line = CommandLine::FromString(uninstall_string);
315 exe_path = command_line.GetProgram(); 315 exe_path = command_line.GetProgram();
316 } 316 }
317
317 if (file_util::PathExists(exe_path)) { 318 if (file_util::PathExists(exe_path)) {
318 std::wstring params(L"--"); 319 CommandLine cmd(exe_path);
319 params.append( 320 cmd.AppendSwitchNative(installer_util::switches::kRegisterChromeBrowser,
320 ASCIIToWide(installer_util::switches::kRegisterChromeBrowser)); 321 chrome_exe);
321 params.append(L"=\"" + chrome_exe + L"\"");
322 if (!suffix.empty()) { 322 if (!suffix.empty()) {
323 params.append(L" --"); 323 cmd.AppendSwitchNative(
324 params.append(ASCIIToWide( 324 installer_util::switches::kRegisterChromeBrowserSuffix, suffix);
325 installer_util::switches::kRegisterChromeBrowserSuffix));
326 params.append(L"=\"" + suffix + L"\"");
327 } 325 }
328 326
329 CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); 327 CommandLine& browser_command_line = *CommandLine::ForCurrentProcess();
330 if (browser_command_line.HasSwitch(switches::kChromeFrame)) { 328 if (browser_command_line.HasSwitch(switches::kChromeFrame)) {
331 params.append(L" --"); 329 cmd.AppendSwitch(installer_util::switches::kChromeFrame);
332 params.append(installer_util::switches::kChromeFrame);
333 } 330 }
334 331
335 DWORD ret_val = 0; 332 DWORD ret_val = 0;
336 InstallUtil::ExecuteExeAsAdmin(exe_path.value(), params, &ret_val); 333 InstallUtil::ExecuteExeAsAdmin(cmd, &ret_val);
337 if (ret_val == 0) 334 if (ret_val == 0)
338 return true; 335 return true;
339 } 336 }
340 return false; 337 return false;
341 } 338 }
342 339
343 // This method tries to figure out if another user has already registered her 340 // This method tries to figure out if another user has already registered her
344 // own copy of Chrome so that we can avoid overwriting it and append current 341 // own copy of Chrome so that we can avoid overwriting it and append current
345 // user's login name to default browser registry entries. This function is 342 // user's login name to default browser registry entries. This function is
346 // not meant to detect all cases. It just tries to handle the most common case. 343 // not meant to detect all cases. It just tries to handle the most common case.
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
803 chrome_exe.c_str(), // target 800 chrome_exe.c_str(), // target
804 shortcut.c_str(), // shortcut 801 shortcut.c_str(), // shortcut
805 chrome_path.c_str(), // working dir 802 chrome_path.c_str(), // working dir
806 NULL, // arguments 803 NULL, // arguments
807 description.c_str(), // description 804 description.c_str(), // description
808 chrome_exe.c_str(), // icon file 805 chrome_exe.c_str(), // icon file
809 icon_index, // icon index 806 icon_index, // icon index
810 dist->GetBrowserAppId().c_str()); // app id 807 dist->GetBrowserAppId().c_str()); // app id
811 } 808 }
812 } 809 }
OLDNEW
« no previous file with comments | « chrome/installer/util/master_preferences_unittest.cc ('k') | chrome/installer/util/util_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698