OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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" | 15 #include "base/command_line.h" |
16 #include "base/file_util.h" | 16 #include "base/file_util.h" |
17 #include "base/logging.h" | 17 #include "base/logging.h" |
18 #include "base/path_service.h" | 18 #include "base/path_service.h" |
19 #include "base/scoped_ptr.h" | 19 #include "base/scoped_ptr.h" |
20 #include "base/string_util.h" | 20 #include "base/string_util.h" |
21 #include "base/values.h" | 21 #include "base/values.h" |
22 #include "base/version.h" | 22 #include "base/version.h" |
23 #include "base/win/registry.h" | 23 #include "base/win/registry.h" |
24 #include "base/win/windows_version.h" | 24 #include "base/win/windows_version.h" |
25 #include "chrome/common/json_value_serializer.h" | 25 #include "chrome/common/json_value_serializer.h" |
26 #include "chrome/installer/util/browser_distribution.h" | 26 #include "chrome/installer/util/browser_distribution.h" |
27 #include "chrome/installer/util/google_update_constants.h" | 27 #include "chrome/installer/util/google_update_constants.h" |
28 #include "chrome/installer/util/l10n_string_util.h" | 28 #include "chrome/installer/util/l10n_string_util.h" |
29 #include "chrome/installer/util/installation_state.h" | |
29 #include "chrome/installer/util/util_constants.h" | 30 #include "chrome/installer/util/util_constants.h" |
30 #include "chrome/installer/util/work_item_list.h" | 31 #include "chrome/installer/util/work_item_list.h" |
31 | 32 |
32 using base::win::RegKey; | 33 using base::win::RegKey; |
34 using installer::ProductState; | |
33 | 35 |
34 bool InstallUtil::ExecuteExeAsAdmin(const CommandLine& cmd, DWORD* exit_code) { | 36 bool InstallUtil::ExecuteExeAsAdmin(const CommandLine& cmd, DWORD* exit_code) { |
35 FilePath::StringType program(cmd.GetProgram().value()); | 37 FilePath::StringType program(cmd.GetProgram().value()); |
36 DCHECK(!program.empty()); | 38 DCHECK(!program.empty()); |
37 DCHECK_NE(program[0], L'\"'); | 39 DCHECK_NE(program[0], L'\"'); |
38 | 40 |
39 CommandLine::StringType params(cmd.command_line_string()); | 41 CommandLine::StringType params(cmd.command_line_string()); |
40 if (params[0] == '"') { | 42 if (params[0] == '"') { |
41 DCHECK_EQ('"', params[program.length() + 1]); | 43 DCHECK_EQ('"', params[program.length() + 1]); |
42 DCHECK_EQ(program, params.substr(1, program.length())); | 44 DCHECK_EQ(program, params.substr(1, program.length())); |
(...skipping 18 matching lines...) Expand all Loading... | |
61 ::WaitForSingleObject(info.hProcess, INFINITE); | 63 ::WaitForSingleObject(info.hProcess, INFINITE); |
62 DWORD ret_val = 0; | 64 DWORD ret_val = 0; |
63 if (!::GetExitCodeProcess(info.hProcess, &ret_val)) | 65 if (!::GetExitCodeProcess(info.hProcess, &ret_val)) |
64 return false; | 66 return false; |
65 | 67 |
66 if (exit_code) | 68 if (exit_code) |
67 *exit_code = ret_val; | 69 *exit_code = ret_val; |
68 return true; | 70 return true; |
69 } | 71 } |
70 | 72 |
71 std::wstring InstallUtil::GetChromeUninstallCmd(bool system_install, | 73 CommandLine InstallUtil::GetChromeUninstallCmd( |
72 BrowserDistribution* dist) { | 74 bool system_install, BrowserDistribution::Type distribution_type) { |
73 DCHECK(dist); | 75 ProductState state; |
tommi (sloooow) - chröme
2011/02/10 20:52:37
With this, now Chrome depends on the ProductState
robertshield
2011/02/10 21:09:39
We could, but I'm not sure that's the best way to
| |
74 HKEY root = system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; | 76 if (state.Initialize(system_install, distribution_type)) { |
75 RegKey key(root, dist->GetUninstallRegPath().c_str(), KEY_READ); | 77 return state.uninstall_command(); |
76 std::wstring uninstall_cmd; | 78 } |
77 key.ReadValue(installer::kUninstallStringField, &uninstall_cmd); | 79 return CommandLine(CommandLine::NO_PROGRAM); |
78 return uninstall_cmd; | |
79 } | 80 } |
80 | 81 |
81 Version* InstallUtil::GetChromeVersion(BrowserDistribution* dist, | 82 Version* InstallUtil::GetChromeVersion(BrowserDistribution* dist, |
82 bool system_install) { | 83 bool system_install) { |
83 DCHECK(dist); | 84 DCHECK(dist); |
84 RegKey key; | 85 RegKey key; |
85 HKEY reg_root = (system_install) ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; | 86 HKEY reg_root = (system_install) ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; |
86 LONG result = key.Open(reg_root, dist->GetVersionKey().c_str(), KEY_READ); | 87 LONG result = key.Open(reg_root, dist->GetVersionKey().c_str(), KEY_READ); |
87 | 88 |
88 std::wstring version_str; | 89 std::wstring version_str; |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
255 std::wstring command; | 256 std::wstring command; |
256 command.append(1, L'"') | 257 command.append(1, L'"') |
257 .append(no_program ? L"" : exe_path) | 258 .append(no_program ? L"" : exe_path) |
258 .append(L"\" ") | 259 .append(L"\" ") |
259 .append(arguments); | 260 .append(arguments); |
260 | 261 |
261 // If we have a program name, return this complete command line. | 262 // If we have a program name, return this complete command line. |
262 *command_line = CommandLine::FromString(command); | 263 *command_line = CommandLine::FromString(command); |
263 } | 264 } |
264 } | 265 } |
OLD | NEW |