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

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
« no previous file with comments | « chrome/installer/util/install_util.h ('k') | chrome/installer/util/master_preferences.cc » ('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) 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('"', params[program.length() + 1]);
47 DCHECK_EQ(program, params.substr(1, program.length()));
48 params = params.substr(program.length() + 2);
49 } else {
50 DCHECK_EQ(program, params.substr(0, program.length()));
51 params = params.substr(program.length());
52 }
53
54 TrimWhitespace(params, TRIM_ALL, &params);
55
43 SHELLEXECUTEINFO info = {0}; 56 SHELLEXECUTEINFO info = {0};
44 info.cbSize = sizeof(SHELLEXECUTEINFO); 57 info.cbSize = sizeof(SHELLEXECUTEINFO);
45 info.fMask = SEE_MASK_NOCLOSEPROCESS; 58 info.fMask = SEE_MASK_NOCLOSEPROCESS;
46 info.lpVerb = L"runas"; 59 info.lpVerb = L"runas";
47 info.lpFile = exe.c_str(); 60 info.lpFile = program.c_str();
48 info.lpParameters = params.c_str(); 61 info.lpParameters = params.c_str();
49 info.nShow = SW_SHOW; 62 info.nShow = SW_SHOW;
50 if (::ShellExecuteEx(&info) == FALSE) 63 if (::ShellExecuteEx(&info) == FALSE)
51 return false; 64 return false;
52 65
53 ::WaitForSingleObject(info.hProcess, INFINITE); 66 ::WaitForSingleObject(info.hProcess, INFINITE);
54 DWORD ret_val = 0; 67 DWORD ret_val = 0;
55 if (!::GetExitCodeProcess(info.hProcess, &ret_val)) 68 if (!::GetExitCodeProcess(info.hProcess, &ret_val))
56 return false; 69 return false;
57 70
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 const std::wstring& value_name) { 272 const std::wstring& value_name) {
260 RegKey key(reg_root, key_path.c_str(), KEY_ALL_ACCESS); 273 RegKey key(reg_root, key_path.c_str(), KEY_ALL_ACCESS);
261 VLOG(1) << "Deleting registry value " << value_name; 274 VLOG(1) << "Deleting registry value " << value_name;
262 if (key.ValueExists(value_name.c_str()) && 275 if (key.ValueExists(value_name.c_str()) &&
263 !key.DeleteValue(value_name.c_str())) { 276 !key.DeleteValue(value_name.c_str())) {
264 LOG(ERROR) << "Failed to delete registry value: " << value_name; 277 LOG(ERROR) << "Failed to delete registry value: " << value_name;
265 return false; 278 return false;
266 } 279 }
267 return true; 280 return true;
268 } 281 }
OLDNEW
« no previous file with comments | « chrome/installer/util/install_util.h ('k') | chrome/installer/util/master_preferences.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698