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/file_util.h" | 16 #include "base/file_util.h" |
16 #include "base/logging.h" | 17 #include "base/logging.h" |
17 #include "base/path_service.h" | 18 #include "base/path_service.h" |
18 #include "base/scoped_ptr.h" | 19 #include "base/scoped_ptr.h" |
19 #include "base/string_util.h" | 20 #include "base/string_util.h" |
20 #include "base/values.h" | 21 #include "base/values.h" |
| 22 #include "base/version.h" |
21 #include "base/win/registry.h" | 23 #include "base/win/registry.h" |
22 #include "base/win/windows_version.h" | 24 #include "base/win/windows_version.h" |
23 #include "chrome/common/json_value_serializer.h" | 25 #include "chrome/common/json_value_serializer.h" |
24 #include "chrome/installer/util/browser_distribution.h" | 26 #include "chrome/installer/util/browser_distribution.h" |
25 #include "chrome/installer/util/google_update_constants.h" | 27 #include "chrome/installer/util/google_update_constants.h" |
26 #include "chrome/installer/util/l10n_string_util.h" | 28 #include "chrome/installer/util/l10n_string_util.h" |
27 #include "chrome/installer/util/master_preferences_constants.h" | |
28 #include "chrome/installer/util/util_constants.h" | 29 #include "chrome/installer/util/util_constants.h" |
29 #include "chrome/installer/util/work_item_list.h" | 30 #include "chrome/installer/util/work_item_list.h" |
30 | 31 |
31 using base::win::RegKey; | 32 using base::win::RegKey; |
32 using installer::MasterPreferences; | |
33 | 33 |
34 bool InstallUtil::ExecuteExeAsAdmin(const CommandLine& cmd, DWORD* exit_code) { | 34 bool InstallUtil::ExecuteExeAsAdmin(const CommandLine& cmd, DWORD* exit_code) { |
35 FilePath::StringType program(cmd.GetProgram().value()); | 35 FilePath::StringType program(cmd.GetProgram().value()); |
36 DCHECK(!program.empty()); | 36 DCHECK(!program.empty()); |
37 DCHECK_NE(program[0], L'\"'); | 37 DCHECK_NE(program[0], L'\"'); |
38 | 38 |
39 CommandLine::StringType params(cmd.command_line_string()); | 39 CommandLine::StringType params(cmd.command_line_string()); |
40 if (params[0] == '"') { | 40 if (params[0] == '"') { |
41 DCHECK_EQ('"', params[program.length() + 1]); | 41 DCHECK_EQ('"', params[program.length() + 1]); |
42 DCHECK_EQ(program, params.substr(1, program.length())); | 42 DCHECK_EQ(program, params.substr(1, program.length())); |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 switch (status) { | 233 switch (status) { |
234 case installer::FIRST_INSTALL_SUCCESS: | 234 case installer::FIRST_INSTALL_SUCCESS: |
235 case installer::INSTALL_REPAIRED: | 235 case installer::INSTALL_REPAIRED: |
236 case installer::NEW_VERSION_UPDATED: | 236 case installer::NEW_VERSION_UPDATED: |
237 case installer::IN_USE_UPDATED: | 237 case installer::IN_USE_UPDATED: |
238 return 0; | 238 return 0; |
239 default: | 239 default: |
240 return status; | 240 return status; |
241 } | 241 } |
242 } | 242 } |
| 243 |
| 244 // static |
| 245 void InstallUtil::MakeUninstallCommand(const std::wstring& exe_path, |
| 246 const std::wstring& arguments, |
| 247 CommandLine* command_line) { |
| 248 const bool no_program = exe_path.empty(); |
| 249 |
| 250 // Return a bunch of nothingness. |
| 251 if (no_program && arguments.empty()) { |
| 252 *command_line = CommandLine(CommandLine::NO_PROGRAM); |
| 253 } else { |
| 254 // Form a full command line string. |
| 255 std::wstring command; |
| 256 command.append(1, L'"') |
| 257 .append(no_program ? L"" : exe_path) |
| 258 .append(L"\" ") |
| 259 .append(arguments); |
| 260 |
| 261 // If we have a program name, return this complete command line. |
| 262 *command_line = CommandLine::FromString(command); |
| 263 } |
| 264 } |
OLD | NEW |