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

Side by Side Diff: chrome/installer/util/install_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 // See the corresponding header file for description of the functions in this 5 // See the corresponding header file for description of the functions in this
6 // file. 6 // file.
7 7
8 #include "chrome/installer/util/install_util.h" 8 #include "chrome/installer/util/install_util.h"
9 9
10 #include <shellapi.h> 10 #include <shellapi.h>
11 #include <shlobj.h> 11 #include <shlobj.h>
12 12
13 #include <algorithm> 13 #include <algorithm>
14 14
15 #include "base/command_line.h"
16 #include "base/file_util.h" 15 #include "base/file_util.h"
17 #include "base/logging.h" 16 #include "base/logging.h"
18 #include "base/path_service.h" 17 #include "base/path_service.h"
19 #include "base/scoped_ptr.h" 18 #include "base/scoped_ptr.h"
20 #include "base/string_util.h" 19 #include "base/string_util.h"
21 #include "base/values.h" 20 #include "base/values.h"
22 #include "base/win/registry.h" 21 #include "base/win/registry.h"
23 #include "base/win/windows_version.h" 22 #include "base/win/windows_version.h"
24 #include "chrome/common/json_value_serializer.h" 23 #include "chrome/common/json_value_serializer.h"
25 #include "chrome/installer/util/browser_distribution.h" 24 #include "chrome/installer/util/browser_distribution.h"
26 #include "chrome/installer/util/google_update_constants.h" 25 #include "chrome/installer/util/google_update_constants.h"
27 #include "chrome/installer/util/l10n_string_util.h" 26 #include "chrome/installer/util/l10n_string_util.h"
28 #include "chrome/installer/util/master_preferences_constants.h" 27 #include "chrome/installer/util/master_preferences_constants.h"
29 #include "chrome/installer/util/util_constants.h" 28 #include "chrome/installer/util/util_constants.h"
30 #include "chrome/installer/util/work_item_list.h" 29 #include "chrome/installer/util/work_item_list.h"
31 30
32 using base::win::RegKey; 31 using base::win::RegKey;
33 using installer_util::MasterPreferences; 32 using installer_util::MasterPreferences;
34 33
35 const MasterPreferences& InstallUtil::GetMasterPreferencesForCurrentProcess() { 34 const MasterPreferences& InstallUtil::GetMasterPreferencesForCurrentProcess() {
36 static MasterPreferences prefs(*CommandLine::ForCurrentProcess()); 35 static MasterPreferences prefs(*CommandLine::ForCurrentProcess());
37 return prefs; 36 return prefs;
38 } 37 }
39 38
40 bool InstallUtil::ExecuteExeAsAdmin(const std::wstring& exe, 39 bool InstallUtil::ExecuteExeAsAdmin(const CommandLine& cmd, DWORD* exit_code) {
41 const std::wstring& params, 40 FilePath::StringType program(cmd.GetProgram().value());
42 DWORD* exit_code) { 41 DCHECK(!program.empty());
42 DCHECK(program[0] != '\"');
43
44 CommandLine::StringType params(cmd.command_line_string());
45 if (params[0] == '"') {
46 DCHECK_EQ(program, params.substr(1, program.length()));
47 params = params.substr(program.length() + 2);
48 } else {
49 DCHECK_EQ(program, params.substr(0, program.length()));
50 params = params.substr(program.length());
51 }
52
53 TrimWhitespace(params, TRIM_ALL, &params);
54
43 SHELLEXECUTEINFO info = {0}; 55 SHELLEXECUTEINFO info = {0};
44 info.cbSize = sizeof(SHELLEXECUTEINFO); 56 info.cbSize = sizeof(SHELLEXECUTEINFO);
45 info.fMask = SEE_MASK_NOCLOSEPROCESS; 57 info.fMask = SEE_MASK_NOCLOSEPROCESS;
46 info.lpVerb = L"runas"; 58 info.lpVerb = L"runas";
47 info.lpFile = exe.c_str(); 59 info.lpFile = program.c_str();
48 info.lpParameters = params.c_str(); 60 info.lpParameters = params.c_str();
49 info.nShow = SW_SHOW; 61 info.nShow = SW_SHOW;
50 if (::ShellExecuteEx(&info) == FALSE) 62 if (::ShellExecuteEx(&info) == FALSE)
51 return false; 63 return false;
52 64
53 ::WaitForSingleObject(info.hProcess, INFINITE); 65 ::WaitForSingleObject(info.hProcess, INFINITE);
54 DWORD ret_val = 0; 66 DWORD ret_val = 0;
55 if (!::GetExitCodeProcess(info.hProcess, &ret_val)) 67 if (!::GetExitCodeProcess(info.hProcess, &ret_val))
56 return false; 68 return false;
57 69
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 const std::wstring& value_name) { 271 const std::wstring& value_name) {
260 RegKey key(reg_root, key_path.c_str(), KEY_ALL_ACCESS); 272 RegKey key(reg_root, key_path.c_str(), KEY_ALL_ACCESS);
261 VLOG(1) << "Deleting registry value " << value_name; 273 VLOG(1) << "Deleting registry value " << value_name;
262 if (key.ValueExists(value_name.c_str()) && 274 if (key.ValueExists(value_name.c_str()) &&
263 !key.DeleteValue(value_name.c_str())) { 275 !key.DeleteValue(value_name.c_str())) {
264 LOG(ERROR) << "Failed to delete registry value: " << value_name; 276 LOG(ERROR) << "Failed to delete registry value: " << value_name;
265 return false; 277 return false;
266 } 278 }
267 return true; 279 return true;
268 } 280 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698