| 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 #include "chrome_frame/test/chrome_frame_test_utils.h" | 5 #include "chrome_frame/test/chrome_frame_test_utils.h" |
| 6 | 6 |
| 7 #include <atlbase.h> | 7 #include <atlbase.h> |
| 8 #include <atlwin.h> | 8 #include <atlwin.h> |
| 9 #include <iepmapi.h> | 9 #include <iepmapi.h> |
| 10 #include <sddl.h> | 10 #include <sddl.h> |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 return command; | 132 return command; |
| 133 } | 133 } |
| 134 | 134 |
| 135 base::ProcessHandle LaunchExecutable(const std::wstring& executable, | 135 base::ProcessHandle LaunchExecutable(const std::wstring& executable, |
| 136 const std::wstring& argument) { | 136 const std::wstring& argument) { |
| 137 base::ProcessHandle process = NULL; | 137 base::ProcessHandle process = NULL; |
| 138 std::wstring path = GetExecutableAppPath(executable); | 138 std::wstring path = GetExecutableAppPath(executable); |
| 139 if (path.empty()) { | 139 if (path.empty()) { |
| 140 path = FormatCommandForApp(executable, argument); | 140 path = FormatCommandForApp(executable, argument); |
| 141 if (path.empty()) { | 141 if (path.empty()) { |
| 142 DLOG(ERROR) << "Failed to find executable: " << executable; | 142 LOG(ERROR) << "Failed to find executable: " << executable; |
| 143 } else { | 143 } else { |
| 144 CommandLine cmdline = CommandLine::FromString(path); | 144 CommandLine cmdline = CommandLine::FromString(path); |
| 145 base::LaunchApp(cmdline, false, false, &process); | 145 if (!base::LaunchApp(cmdline, false, false, &process)) { |
| 146 LOG(ERROR) << "LaunchApp failed: " << ::GetLastError(); |
| 147 } |
| 146 } | 148 } |
| 147 } else { | 149 } else { |
| 148 CommandLine cmdline((FilePath(path))); | 150 CommandLine cmdline((FilePath(path))); |
| 149 cmdline.AppendLooseValue(argument); | 151 cmdline.AppendLooseValue(argument); |
| 150 base::LaunchApp(cmdline, false, false, &process); | 152 if (!base::LaunchApp(cmdline, false, false, &process)) { |
| 153 LOG(ERROR) << "LaunchApp failed: " << ::GetLastError(); |
| 154 } |
| 151 } | 155 } |
| 152 return process; | 156 return process; |
| 153 } | 157 } |
| 154 | 158 |
| 155 base::ProcessHandle LaunchFirefox(const std::wstring& url) { | 159 base::ProcessHandle LaunchFirefox(const std::wstring& url) { |
| 156 return LaunchExecutable(kFirefoxImageName, url); | 160 return LaunchExecutable(kFirefoxImageName, url); |
| 157 } | 161 } |
| 158 | 162 |
| 159 base::ProcessHandle LaunchSafari(const std::wstring& url) { | 163 base::ProcessHandle LaunchSafari(const std::wstring& url) { |
| 160 return LaunchExecutable(kSafariImageName, url); | 164 return LaunchExecutable(kSafariImageName, url); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 191 base::ProcessHandle LaunchIEOnVista(const std::wstring& url) { | 195 base::ProcessHandle LaunchIEOnVista(const std::wstring& url) { |
| 192 typedef HRESULT (WINAPI* IELaunchURLPtr)( | 196 typedef HRESULT (WINAPI* IELaunchURLPtr)( |
| 193 const wchar_t* url, | 197 const wchar_t* url, |
| 194 PROCESS_INFORMATION *pi, | 198 PROCESS_INFORMATION *pi, |
| 195 VOID *info); | 199 VOID *info); |
| 196 | 200 |
| 197 IELaunchURLPtr launch; | 201 IELaunchURLPtr launch; |
| 198 PROCESS_INFORMATION pi = {0}; | 202 PROCESS_INFORMATION pi = {0}; |
| 199 IELAUNCHURLINFO info = {sizeof info, 0}; | 203 IELAUNCHURLINFO info = {sizeof info, 0}; |
| 200 HMODULE h = LoadLibrary(L"ieframe.dll"); | 204 HMODULE h = LoadLibrary(L"ieframe.dll"); |
| 201 if (!h) | 205 if (!h) { |
| 206 LOG(ERROR) << "Failed to load ieframe.dll: " << ::GetLastError(); |
| 202 return NULL; | 207 return NULL; |
| 208 } |
| 203 launch = reinterpret_cast<IELaunchURLPtr>(GetProcAddress(h, "IELaunchURL")); | 209 launch = reinterpret_cast<IELaunchURLPtr>(GetProcAddress(h, "IELaunchURL")); |
| 210 CHECK(launch); |
| 204 HRESULT hr = launch(url.c_str(), &pi, &info); | 211 HRESULT hr = launch(url.c_str(), &pi, &info); |
| 205 FreeLibrary(h); | 212 FreeLibrary(h); |
| 206 if (SUCCEEDED(hr)) | 213 if (SUCCEEDED(hr)) { |
| 207 CloseHandle(pi.hThread); | 214 CloseHandle(pi.hThread); |
| 215 } else { |
| 216 LOG(ERROR) << ::StringPrintf("IELaunchURL failed: 0x%08X", hr); |
| 217 } |
| 208 return pi.hProcess; | 218 return pi.hProcess; |
| 209 } | 219 } |
| 210 | 220 |
| 211 base::ProcessHandle LaunchIE(const std::wstring& url) { | 221 base::ProcessHandle LaunchIE(const std::wstring& url) { |
| 212 if (win_util::GetWinVersion() >= win_util::WINVERSION_VISTA) { | 222 if (win_util::GetWinVersion() >= win_util::WINVERSION_VISTA) { |
| 213 return LaunchIEOnVista(url); | 223 return LaunchIEOnVista(url); |
| 214 } else { | 224 } else { |
| 215 return LaunchExecutable(kIEImageName, url); | 225 return LaunchExecutable(kIEImageName, url); |
| 216 } | 226 } |
| 217 } | 227 } |
| (...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 876 if (GetInstalledIEVersion() == IE_8) { | 886 if (GetInstalledIEVersion() == IE_8) { |
| 877 profile_path = GetProfilePath(kIEProfileName); | 887 profile_path = GetProfilePath(kIEProfileName); |
| 878 } else { | 888 } else { |
| 879 profile_path = GetIETemporaryFilesFolder(); | 889 profile_path = GetIETemporaryFilesFolder(); |
| 880 profile_path = profile_path.Append(L"Google Chrome Frame"); | 890 profile_path = profile_path.Append(L"Google Chrome Frame"); |
| 881 } | 891 } |
| 882 return profile_path; | 892 return profile_path; |
| 883 } | 893 } |
| 884 | 894 |
| 885 } // namespace chrome_frame_test | 895 } // namespace chrome_frame_test |
| OLD | NEW |