OLD | NEW |
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 // This file defines specific implementation of BrowserDistribution class for | 5 // This file defines specific implementation of BrowserDistribution class for |
6 // Google Chrome. | 6 // Google Chrome. |
7 | 7 |
8 #include "chrome/installer/util/google_chrome_distribution.h" | 8 #include "chrome/installer/util/google_chrome_distribution.h" |
9 | 9 |
10 #include <windows.h> | 10 #include <windows.h> |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 // If system_level_toast is true, appends --system-level-toast. | 132 // If system_level_toast is true, appends --system-level-toast. |
133 // If handle to experiment result key was given at startup, re-add it. | 133 // If handle to experiment result key was given at startup, re-add it. |
134 // Does not wait for the process to terminate. | 134 // Does not wait for the process to terminate. |
135 bool RelaunchSetup(const std::string& flag, int value, | 135 bool RelaunchSetup(const std::string& flag, int value, |
136 bool system_level_toast) { | 136 bool system_level_toast) { |
137 CommandLine new_cmd_line(CommandLine::ForCurrentProcess()->GetProgram()); | 137 CommandLine new_cmd_line(CommandLine::ForCurrentProcess()->GetProgram()); |
138 new_cmd_line.AppendSwitchASCII(flag, base::IntToString(value)); | 138 new_cmd_line.AppendSwitchASCII(flag, base::IntToString(value)); |
139 | 139 |
140 // Re-add the system level toast flag. | 140 // Re-add the system level toast flag. |
141 if (system_level_toast) { | 141 if (system_level_toast) { |
142 new_cmd_line.AppendSwitch( | 142 new_cmd_line.AppendSwitch(installer_util::switches::kSystemLevelToast); |
143 WideToASCII(installer_util::switches::kSystemLevelToast)); | |
144 | 143 |
145 // Re-add the toast result key. We need to do this because Setup running as | 144 // Re-add the toast result key. We need to do this because Setup running as |
146 // system passes the key to Setup running as user, but that child process | 145 // system passes the key to Setup running as user, but that child process |
147 // does not perform the actual toasting, it launches another Setup (as user) | 146 // does not perform the actual toasting, it launches another Setup (as user) |
148 // to do so. That is the process that needs the key. | 147 // to do so. That is the process that needs the key. |
149 const CommandLine& current_cmd_line = *CommandLine::ForCurrentProcess(); | 148 const CommandLine& current_cmd_line = *CommandLine::ForCurrentProcess(); |
150 std::string key = WideToASCII(installer_util::switches::kToastResultsKey); | 149 std::string key(installer_util::switches::kToastResultsKey); |
151 std::string toast_key = current_cmd_line.GetSwitchValueASCII(key); | 150 std::string toast_key = current_cmd_line.GetSwitchValueASCII(key); |
152 if (!toast_key.empty()) { | 151 if (!toast_key.empty()) { |
153 new_cmd_line.AppendSwitchASCII(key, toast_key); | 152 new_cmd_line.AppendSwitchASCII(key, toast_key); |
154 | 153 |
155 // Use handle inheritance to make sure the duplicated toast results key | 154 // Use handle inheritance to make sure the duplicated toast results key |
156 // gets inherited by the child process. | 155 // gets inherited by the child process. |
157 return base::LaunchAppWithHandleInheritance( | 156 return base::LaunchAppWithHandleInheritance( |
158 new_cmd_line.command_line_string(), false, false, NULL); | 157 new_cmd_line.command_line_string(), false, false, NULL); |
159 } | 158 } |
160 } | 159 } |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 } | 209 } |
211 | 210 |
212 // This function launches setup as the currently logged-in interactive | 211 // This function launches setup as the currently logged-in interactive |
213 // user that is the user whose logon session is attached to winsta0\default. | 212 // user that is the user whose logon session is attached to winsta0\default. |
214 // It assumes that currently we are running as SYSTEM in a non-interactive | 213 // It assumes that currently we are running as SYSTEM in a non-interactive |
215 // windowstation. | 214 // windowstation. |
216 // The function fails if there is no interactive session active, basically | 215 // The function fails if there is no interactive session active, basically |
217 // the computer is on but nobody has logged in locally. | 216 // the computer is on but nobody has logged in locally. |
218 // Remote Desktop sessions do not count as interactive sessions; running this | 217 // Remote Desktop sessions do not count as interactive sessions; running this |
219 // method as a user logged in via remote desktop will do nothing. | 218 // method as a user logged in via remote desktop will do nothing. |
220 bool RelaunchSetupAsConsoleUser(const std::wstring& flag) { | 219 bool RelaunchSetupAsConsoleUser(const std::string& flag) { |
221 FilePath setup_exe = CommandLine::ForCurrentProcess()->GetProgram(); | 220 FilePath setup_exe = CommandLine::ForCurrentProcess()->GetProgram(); |
222 CommandLine cmd_line(setup_exe); | 221 CommandLine cmd_line(setup_exe); |
223 cmd_line.AppendSwitch(WideToASCII(flag)); | 222 cmd_line.AppendSwitch(flag); |
224 | 223 |
225 // Get the Google Update results key, and pass it on the command line to | 224 // Get the Google Update results key, and pass it on the command line to |
226 // the child process. | 225 // the child process. |
227 int key = GoogleUpdateSettings::DuplicateGoogleUpdateSystemClientKey(); | 226 int key = GoogleUpdateSettings::DuplicateGoogleUpdateSystemClientKey(); |
228 cmd_line.AppendSwitchASCII( | 227 cmd_line.AppendSwitchASCII(installer_util::switches::kToastResultsKey, |
229 WideToASCII(installer_util::switches::kToastResultsKey), | 228 base::IntToString(key)); |
230 base::IntToString(key)); | |
231 | 229 |
232 if (base::win::GetVersion() > base::win::VERSION_XP) { | 230 if (base::win::GetVersion() > base::win::VERSION_XP) { |
233 // Make sure that in Vista and Above we have the proper DACLs so | 231 // Make sure that in Vista and Above we have the proper DACLs so |
234 // the interactive user can launch it. | 232 // the interactive user can launch it. |
235 if (!FixDACLsForExecute(setup_exe.ToWStringHack().c_str())) | 233 if (!FixDACLsForExecute(setup_exe.ToWStringHack().c_str())) |
236 NOTREACHED(); | 234 NOTREACHED(); |
237 } | 235 } |
238 | 236 |
239 DWORD console_id = ::WTSGetActiveConsoleSessionId(); | 237 DWORD console_id = ::WTSGetActiveConsoleSessionId(); |
240 if (console_id == 0xFFFFFFFF) | 238 if (console_id == 0xFFFFFFFF) |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
523 void SetClient(std::wstring experiment_group, bool last_write) { | 521 void SetClient(std::wstring experiment_group, bool last_write) { |
524 static int reg_key_handle = -1; | 522 static int reg_key_handle = -1; |
525 if (reg_key_handle == -1) { | 523 if (reg_key_handle == -1) { |
526 // If a specific Toast Results key handle (presumably to our HKLM key) was | 524 // If a specific Toast Results key handle (presumably to our HKLM key) was |
527 // passed in to the command line (such as for system level installs), we use | 525 // passed in to the command line (such as for system level installs), we use |
528 // it. Otherwise, we write to the key under HKCU. | 526 // it. Otherwise, we write to the key under HKCU. |
529 const CommandLine& cmd_line = *CommandLine::ForCurrentProcess(); | 527 const CommandLine& cmd_line = *CommandLine::ForCurrentProcess(); |
530 if (cmd_line.HasSwitch(installer_util::switches::kToastResultsKey)) { | 528 if (cmd_line.HasSwitch(installer_util::switches::kToastResultsKey)) { |
531 // Get the handle to the key under HKLM. | 529 // Get the handle to the key under HKLM. |
532 base::StringToInt(cmd_line.GetSwitchValueASCII( | 530 base::StringToInt(cmd_line.GetSwitchValueASCII( |
533 WideToASCII(installer_util::switches::kToastResultsKey)).c_str(), | 531 installer_util::switches::kToastResultsKey).c_str(), |
534 ®_key_handle); | 532 ®_key_handle); |
535 } else { | 533 } else { |
536 reg_key_handle = 0; | 534 reg_key_handle = 0; |
537 } | 535 } |
538 } | 536 } |
539 | 537 |
540 if (reg_key_handle) { | 538 if (reg_key_handle) { |
541 // Use it to write the experiment results. | 539 // Use it to write the experiment results. |
542 GoogleUpdateSettings::WriteGoogleUpdateSystemClientKey( | 540 GoogleUpdateSettings::WriteGoogleUpdateSystemClientKey( |
543 reg_key_handle, google_update::kRegClientField, experiment_group); | 541 reg_key_handle, google_update::kRegClientField, experiment_group); |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
660 | 658 |
661 if (outcome != kToastExpUninstallGroup) | 659 if (outcome != kToastExpUninstallGroup) |
662 return; | 660 return; |
663 // The user wants to uninstall. This is a best effort operation. Note that | 661 // The user wants to uninstall. This is a best effort operation. Note that |
664 // we waited for chrome to exit so the uninstall would not detect chrome | 662 // we waited for chrome to exit so the uninstall would not detect chrome |
665 // running. | 663 // running. |
666 base::LaunchApp(InstallUtil::GetChromeUninstallCmd(system_install), | 664 base::LaunchApp(InstallUtil::GetChromeUninstallCmd(system_install), |
667 false, false, NULL); | 665 false, false, NULL); |
668 } | 666 } |
669 #endif | 667 #endif |
OLD | NEW |