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 #include "chrome_frame/test/chrome_frame_test_utils.h" | 5 #include "chrome_frame/test/chrome_frame_test_utils.h" |
6 | 6 |
7 #include <atlapp.h> | 7 #include <atlapp.h> |
8 #include <atlmisc.h> | 8 #include <atlmisc.h> |
9 #include <iepmapi.h> | 9 #include <iepmapi.h> |
10 #include <sddl.h> | 10 #include <sddl.h> |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 base::ProcessHandle LaunchExecutable(const std::wstring& executable, | 152 base::ProcessHandle LaunchExecutable(const std::wstring& executable, |
153 const std::wstring& argument) { | 153 const std::wstring& argument) { |
154 base::ProcessHandle process = NULL; | 154 base::ProcessHandle process = NULL; |
155 std::wstring path = GetExecutableAppPath(executable); | 155 std::wstring path = GetExecutableAppPath(executable); |
156 if (path.empty()) { | 156 if (path.empty()) { |
157 path = FormatCommandForApp(executable, argument); | 157 path = FormatCommandForApp(executable, argument); |
158 if (path.empty()) { | 158 if (path.empty()) { |
159 LOG(ERROR) << "Failed to find executable: " << executable; | 159 LOG(ERROR) << "Failed to find executable: " << executable; |
160 } else { | 160 } else { |
161 CommandLine cmdline = CommandLine::FromString(path); | 161 CommandLine cmdline = CommandLine::FromString(path); |
162 base::LaunchOptions options; | 162 if (!base::LaunchProcess(cmdline, base::LaunchOptions(), &process)) { |
163 options.process_handle = &process; | |
164 if (!base::LaunchProcess(cmdline, options)) { | |
165 LOG(ERROR) << "LaunchProcess failed: " << ::GetLastError(); | 163 LOG(ERROR) << "LaunchProcess failed: " << ::GetLastError(); |
166 } | 164 } |
167 } | 165 } |
168 } else { | 166 } else { |
169 CommandLine cmdline((FilePath(path))); | 167 CommandLine cmdline((FilePath(path))); |
170 cmdline.AppendArgNative(argument); | 168 cmdline.AppendArgNative(argument); |
171 base::LaunchOptions options; | 169 if (!base::LaunchProcess(cmdline, base::LaunchOptions(), &process)) { |
172 options.process_handle = &process; | |
173 if (!base::LaunchProcess(cmdline, options)) { | |
174 LOG(ERROR) << "LaunchProcess failed: " << ::GetLastError(); | 170 LOG(ERROR) << "LaunchProcess failed: " << ::GetLastError(); |
175 } | 171 } |
176 } | 172 } |
177 return process; | 173 return process; |
178 } | 174 } |
179 | 175 |
180 base::ProcessHandle LaunchChrome(const std::wstring& url) { | 176 base::ProcessHandle LaunchChrome(const std::wstring& url) { |
181 FilePath path; | 177 FilePath path; |
182 PathService::Get(base::DIR_MODULE, &path); | 178 PathService::Get(base::DIR_MODULE, &path); |
183 path = path.AppendASCII(kChromeImageName); | 179 path = path.AppendASCII(kChromeImageName); |
184 | 180 |
185 CommandLine cmd(path); | 181 CommandLine cmd(path); |
186 cmd.AppendSwitch(switches::kNoFirstRun); | 182 cmd.AppendSwitch(switches::kNoFirstRun); |
187 cmd.AppendArgNative(url); | 183 cmd.AppendArgNative(url); |
188 | 184 |
189 base::ProcessHandle process = NULL; | 185 base::ProcessHandle process = NULL; |
190 base::LaunchOptions options; | 186 base::LaunchProcess(cmd, base::LaunchOptions(), &process); |
191 options.process_handle = &process; | |
192 base::LaunchProcess(cmd, options); | |
193 return process; | 187 return process; |
194 } | 188 } |
195 | 189 |
196 base::ProcessHandle LaunchIEOnVista(const std::wstring& url) { | 190 base::ProcessHandle LaunchIEOnVista(const std::wstring& url) { |
197 typedef HRESULT (WINAPI* IELaunchURLPtr)( | 191 typedef HRESULT (WINAPI* IELaunchURLPtr)( |
198 const wchar_t* url, | 192 const wchar_t* url, |
199 PROCESS_INFORMATION *pi, | 193 PROCESS_INFORMATION *pi, |
200 VOID *info); | 194 VOID *info); |
201 | 195 |
202 IELaunchURLPtr launch; | 196 IELaunchURLPtr launch; |
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
589 if (!PathService::Get(base::DIR_EXE, &exe_dir)) { | 583 if (!PathService::Get(base::DIR_EXE, &exe_dir)) { |
590 DCHECK(false); | 584 DCHECK(false); |
591 return NULL; | 585 return NULL; |
592 } | 586 } |
593 | 587 |
594 base::ProcessHandle crash_service = NULL; | 588 base::ProcessHandle crash_service = NULL; |
595 | 589 |
596 DVLOG(1) << "Starting crash_service.exe so you know if a test crashes!"; | 590 DVLOG(1) << "Starting crash_service.exe so you know if a test crashes!"; |
597 | 591 |
598 FilePath crash_service_path = exe_dir.AppendASCII("crash_service.exe"); | 592 FilePath crash_service_path = exe_dir.AppendASCII("crash_service.exe"); |
599 base::LaunchOptions options; | 593 if (!base::LaunchProcess(crash_service_path.value(), base::LaunchOptions(), |
600 options.process_handle = &crash_service; | 594 &crash_service)) { |
601 if (!base::LaunchProcess(crash_service_path.value(), options)) { | |
602 DLOG(ERROR) << "Couldn't start crash_service.exe"; | 595 DLOG(ERROR) << "Couldn't start crash_service.exe"; |
603 return NULL; | 596 return NULL; |
604 } | 597 } |
605 | 598 |
606 base::Time start = base::Time::Now(); | 599 base::Time start = base::Time::Now(); |
607 | 600 |
608 if (DetectRunningCrashService(kCrashServiceStartupTimeoutMs)) { | 601 if (DetectRunningCrashService(kCrashServiceStartupTimeoutMs)) { |
609 DVLOG(1) << "crash_service.exe is ready for clients in " | 602 DVLOG(1) << "crash_service.exe is ready for clients in " |
610 << (base::Time::Now() - start).InMilliseconds() << " ms."; | 603 << (base::Time::Now() - start).InMilliseconds() << " ms."; |
611 return crash_service; | 604 return crash_service; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
681 wchar_t local_app_data_path[MAX_PATH + 1] = {0}; | 674 wchar_t local_app_data_path[MAX_PATH + 1] = {0}; |
682 SHGetFolderPath(NULL, CSIDL_LOCAL_APPDATA, NULL, SHGFP_TYPE_CURRENT, | 675 SHGetFolderPath(NULL, CSIDL_LOCAL_APPDATA, NULL, SHGFP_TYPE_CURRENT, |
683 local_app_data_path); | 676 local_app_data_path); |
684 | 677 |
685 std::wstring session_history_path = local_app_data_path; | 678 std::wstring session_history_path = local_app_data_path; |
686 session_history_path += L"\\Microsoft\\Internet Explorer\\Recovery"; | 679 session_history_path += L"\\Microsoft\\Internet Explorer\\Recovery"; |
687 file_util::Delete(session_history_path, true); | 680 file_util::Delete(session_history_path, true); |
688 } | 681 } |
689 | 682 |
690 } // namespace chrome_frame_test | 683 } // namespace chrome_frame_test |
OLD | NEW |