OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "chrome/installer/util/user_experiment.h" | 5 #include "chrome/installer/util/user_experiment.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 #include <sddl.h> | 8 #include <sddl.h> |
9 #include <stddef.h> | 9 #include <stddef.h> |
10 #include <stdint.h> | 10 #include <stdint.h> |
11 #include <wtsapi32.h> | 11 #include <wtsapi32.h> |
12 #include <vector> | 12 |
| 13 #include <string> |
13 | 14 |
14 #include "base/command_line.h" | 15 #include "base/command_line.h" |
15 #include "base/files/file_path.h" | 16 #include "base/files/file_path.h" |
16 #include "base/macros.h" | 17 #include "base/macros.h" |
17 #include "base/path_service.h" | 18 #include "base/path_service.h" |
18 #include "base/process/launch.h" | 19 #include "base/process/launch.h" |
19 #include "base/rand_util.h" | 20 #include "base/rand_util.h" |
20 #include "base/strings/string_number_conversions.h" | 21 #include "base/strings/string_number_conversions.h" |
21 #include "base/strings/string_split.h" | 22 #include "base/strings/string_split.h" |
22 #include "base/strings/string_util.h" | 23 #include "base/strings/string_util.h" |
23 #include "base/strings/utf_string_conversions.h" | 24 #include "base/strings/utf_string_conversions.h" |
24 #include "base/win/scoped_handle.h" | 25 #include "base/win/scoped_handle.h" |
25 #include "base/win/windows_version.h" | |
26 #include "chrome/common/chrome_paths.h" | 26 #include "chrome/common/chrome_paths.h" |
27 #include "chrome/common/chrome_result_codes.h" | 27 #include "chrome/common/chrome_result_codes.h" |
28 #include "chrome/common/chrome_switches.h" | 28 #include "chrome/common/chrome_switches.h" |
29 #include "chrome/grit/chromium_strings.h" | 29 #include "chrome/grit/chromium_strings.h" |
30 #include "chrome/installer/util/browser_distribution.h" | 30 #include "chrome/installer/util/browser_distribution.h" |
31 #include "chrome/installer/util/google_update_constants.h" | 31 #include "chrome/installer/util/google_update_constants.h" |
32 #include "chrome/installer/util/google_update_settings.h" | 32 #include "chrome/installer/util/google_update_settings.h" |
33 #include "chrome/installer/util/helper.h" | |
34 #include "chrome/installer/util/install_util.h" | 33 #include "chrome/installer/util/install_util.h" |
35 #include "chrome/installer/util/product.h" | 34 #include "chrome/installer/util/product.h" |
36 #include "content/public/common/result_codes.h" | 35 #include "content/public/common/result_codes.h" |
37 | 36 |
38 namespace installer { | 37 namespace installer { |
39 | 38 |
40 namespace { | 39 namespace { |
41 | 40 |
42 // The following strings are the possible outcomes of the toast experiment | 41 // The following strings are the possible outcomes of the toast experiment |
43 // as recorded in the |client| field. | 42 // as recorded in the |client| field. |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 212 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
214 switches::kVerboseLogging)) | 213 switches::kVerboseLogging)) |
215 cmd_line->AppendSwitch(switches::kVerboseLogging); | 214 cmd_line->AppendSwitch(switches::kVerboseLogging); |
216 | 215 |
217 // Get the Google Update results key, and pass it on the command line to | 216 // Get the Google Update results key, and pass it on the command line to |
218 // the child process. | 217 // the child process. |
219 int key = GoogleUpdateSettings::DuplicateGoogleUpdateSystemClientKey(); | 218 int key = GoogleUpdateSettings::DuplicateGoogleUpdateSystemClientKey(); |
220 cmd_line->AppendSwitchASCII(switches::kToastResultsKey, | 219 cmd_line->AppendSwitchASCII(switches::kToastResultsKey, |
221 base::IntToString(key)); | 220 base::IntToString(key)); |
222 | 221 |
223 if (base::win::GetVersion() > base::win::VERSION_XP) { | 222 // Make sure that in Vista and Above we have the proper DACLs so the |
224 // Make sure that in Vista and Above we have the proper DACLs so | 223 // interactive user can launch it. |
225 // the interactive user can launch it. | 224 if (!FixDACLsForExecute(cmd_line->GetProgram())) |
226 if (!FixDACLsForExecute(cmd_line->GetProgram())) | 225 NOTREACHED(); |
227 NOTREACHED(); | |
228 } | |
229 | 226 |
230 DWORD console_id = ::WTSGetActiveConsoleSessionId(); | 227 DWORD console_id = ::WTSGetActiveConsoleSessionId(); |
231 if (console_id == 0xFFFFFFFF) { | 228 if (console_id == 0xFFFFFFFF) { |
232 PLOG(ERROR) << __func__ << " failed to get active session id"; | 229 PLOG(ERROR) << __func__ << " failed to get active session id"; |
233 return false; | 230 return false; |
234 } | 231 } |
235 HANDLE user_token; | 232 HANDLE user_token; |
236 if (!::WTSQueryUserToken(console_id, &user_token)) { | 233 if (!::WTSQueryUserToken(console_id, &user_token)) { |
237 PLOG(ERROR) << __func__ << " failed to get user token for console_id " | 234 PLOG(ERROR) << __func__ << " failed to get user token for console_id " |
238 << console_id; | 235 << console_id; |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
523 SetClient(experiment_group + outcome, true); | 520 SetClient(experiment_group + outcome, true); |
524 | 521 |
525 if (outcome != kToastExpUninstallGroup) | 522 if (outcome != kToastExpUninstallGroup) |
526 return; | 523 return; |
527 // The user wants to uninstall. This is a best effort operation. Note that | 524 // The user wants to uninstall. This is a best effort operation. Note that |
528 // we waited for chrome to exit so the uninstall would not detect chrome | 525 // we waited for chrome to exit so the uninstall would not detect chrome |
529 // running. | 526 // running. |
530 bool system_level_toast = base::CommandLine::ForCurrentProcess()->HasSwitch( | 527 bool system_level_toast = base::CommandLine::ForCurrentProcess()->HasSwitch( |
531 switches::kSystemLevelToast); | 528 switches::kSystemLevelToast); |
532 | 529 |
533 base::CommandLine cmd(InstallUtil::GetChromeUninstallCmd( | 530 base::CommandLine cmd(InstallUtil::GetChromeUninstallCmd(system_level_toast)); |
534 system_level_toast, product.distribution()->GetType())); | |
535 base::LaunchProcess(cmd, base::LaunchOptions()); | 531 base::LaunchProcess(cmd, base::LaunchOptions()); |
536 } | 532 } |
537 | 533 |
538 } // namespace installer | 534 } // namespace installer |
OLD | NEW |