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> |
11 | 11 |
12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
13 #include "base/file_path.h" | 13 #include "base/file_path.h" |
14 #include "base/file_version_info.h" | 14 #include "base/file_version_info.h" |
15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
16 #include "base/path_service.h" | 16 #include "base/path_service.h" |
17 #include "base/process_util.h" | 17 #include "base/process_util.h" |
18 #include "base/string_util.h" | 18 #include "base/string_util.h" |
19 #include "base/stringprintf.h" | 19 #include "base/stringprintf.h" |
20 #include "base/utf_string_conversions.h" | 20 #include "base/utf_string_conversions.h" |
21 #include "base/win/registry.h" | 21 #include "base/win/registry.h" |
22 #include "base/win/scoped_handle.h" | 22 #include "base/win/scoped_handle.h" |
23 #include "base/win/windows_version.h" | 23 #include "base/win/windows_version.h" |
24 #include "chrome/common/chrome_switches.h" | |
25 #include "chrome/common/chrome_paths.h" | 24 #include "chrome/common/chrome_paths.h" |
26 #include "chrome/common/chrome_paths_internal.h" | 25 #include "chrome/common/chrome_paths_internal.h" |
| 26 #include "chrome/common/chrome_switches.h" |
27 #include "chrome_frame/utils.h" | 27 #include "chrome_frame/utils.h" |
28 #include "testing/gtest/include/gtest/gtest.h" | 28 #include "testing/gtest/include/gtest/gtest.h" |
29 #include "ui/base/clipboard/clipboard.h" | 29 #include "ui/base/clipboard/clipboard.h" |
30 #include "ui/base/clipboard/scoped_clipboard_writer.h" | 30 #include "ui/base/clipboard/scoped_clipboard_writer.h" |
31 | 31 |
32 namespace chrome_frame_test { | 32 namespace chrome_frame_test { |
33 | 33 |
34 const wchar_t kCrashServicePipeName[] = L"\\\\.\\pipe\\ChromeCrashServices"; | 34 const wchar_t kCrashServicePipeName[] = L"\\\\.\\pipe\\ChromeCrashServices"; |
35 | 35 |
36 const DWORD kCrashServicePipeDesiredAccess = FILE_READ_DATA | | 36 const DWORD kCrashServicePipeDesiredAccess = FILE_READ_DATA | |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 base::ProcessHandle LaunchIE(const std::wstring& url) { | 235 base::ProcessHandle LaunchIE(const std::wstring& url) { |
236 if (base::win::GetVersion() >= base::win::VERSION_VISTA) { | 236 if (base::win::GetVersion() >= base::win::VERSION_VISTA) { |
237 return LaunchIEOnVista(url); | 237 return LaunchIEOnVista(url); |
238 } | 238 } |
239 return LaunchExecutable(kIEImageName, url); | 239 return LaunchExecutable(kIEImageName, url); |
240 } | 240 } |
241 | 241 |
242 int CloseAllIEWindows() { | 242 int CloseAllIEWindows() { |
243 int ret = 0; | 243 int ret = 0; |
244 | 244 |
245 ScopedComPtr<IShellWindows> windows; | 245 base::win::ScopedComPtr<IShellWindows> windows; |
246 HRESULT hr = ::CoCreateInstance(__uuidof(ShellWindows), NULL, CLSCTX_ALL, | 246 HRESULT hr = ::CoCreateInstance(__uuidof(ShellWindows), NULL, CLSCTX_ALL, |
247 IID_IShellWindows, reinterpret_cast<void**>(windows.Receive())); | 247 IID_IShellWindows, reinterpret_cast<void**>(windows.Receive())); |
248 DCHECK(SUCCEEDED(hr)); | 248 DCHECK(SUCCEEDED(hr)); |
249 | 249 |
250 if (SUCCEEDED(hr)) { | 250 if (SUCCEEDED(hr)) { |
251 long count = 0; // NOLINT | 251 long count = 0; // NOLINT |
252 windows->get_Count(&count); | 252 windows->get_Count(&count); |
253 VARIANT i = { VT_I4 }; | 253 VARIANT i = { VT_I4 }; |
254 for (i.lVal = 0; i.lVal < count; ++i.lVal) { | 254 for (i.lVal = 0; i.lVal < count; ++i.lVal) { |
255 ScopedComPtr<IDispatch> folder; | 255 base::win::ScopedComPtr<IDispatch> folder; |
256 windows->Item(i, folder.Receive()); | 256 windows->Item(i, folder.Receive()); |
257 if (folder != NULL) { | 257 if (folder != NULL) { |
258 ScopedComPtr<IWebBrowser2> browser; | 258 base::win::ScopedComPtr<IWebBrowser2> browser; |
259 if (SUCCEEDED(browser.QueryFrom(folder))) { | 259 if (SUCCEEDED(browser.QueryFrom(folder))) { |
260 bool is_ie = true; | 260 bool is_ie = true; |
261 HWND window = NULL; | 261 HWND window = NULL; |
262 // Check the class of the browser window to make sure we only close | 262 // Check the class of the browser window to make sure we only close |
263 // IE windows. | 263 // IE windows. |
264 if (browser->get_HWND(reinterpret_cast<SHANDLE_PTR*>(window))) { | 264 if (browser->get_HWND(reinterpret_cast<SHANDLE_PTR*>(window))) { |
265 wchar_t class_name[MAX_PATH]; | 265 wchar_t class_name[MAX_PATH]; |
266 if (::GetClassName(window, class_name, arraysize(class_name))) { | 266 if (::GetClassName(window, class_name, arraysize(class_name))) { |
267 is_ie = _wcsicmp(class_name, L"IEFrame") == 0; | 267 is_ie = _wcsicmp(class_name, L"IEFrame") == 0; |
268 } | 268 } |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 DWORD cocreate_flags = CLSCTX_LOCAL_SERVER; | 376 DWORD cocreate_flags = CLSCTX_LOCAL_SERVER; |
377 chrome_frame_test::LowIntegrityToken token; | 377 chrome_frame_test::LowIntegrityToken token; |
378 // Vista has a bug which manifests itself when a medium integrity process | 378 // Vista has a bug which manifests itself when a medium integrity process |
379 // launches a COM server like IE which runs in protected mode due to UAC. | 379 // launches a COM server like IE which runs in protected mode due to UAC. |
380 // This causes the IWebBrowser2 interface which is returned to be useless, | 380 // This causes the IWebBrowser2 interface which is returned to be useless, |
381 // i.e it does not receive any events, etc. Our workaround for this is | 381 // i.e it does not receive any events, etc. Our workaround for this is |
382 // to impersonate a low integrity token and then launch IE. | 382 // to impersonate a low integrity token and then launch IE. |
383 if (base::win::GetVersion() == base::win::VERSION_VISTA && | 383 if (base::win::GetVersion() == base::win::VERSION_VISTA && |
384 GetInstalledIEVersion() == IE_7) { | 384 GetInstalledIEVersion() == IE_7) { |
385 // Create medium integrity browser that will launch IE broker. | 385 // Create medium integrity browser that will launch IE broker. |
386 ScopedComPtr<IWebBrowser2> medium_integrity_browser; | 386 base::win::ScopedComPtr<IWebBrowser2> medium_integrity_browser; |
387 hr = medium_integrity_browser.CreateInstance(CLSID_InternetExplorer, NULL, | 387 hr = medium_integrity_browser.CreateInstance(CLSID_InternetExplorer, NULL, |
388 CLSCTX_LOCAL_SERVER); | 388 CLSCTX_LOCAL_SERVER); |
389 if (FAILED(hr)) | 389 if (FAILED(hr)) |
390 return hr; | 390 return hr; |
391 medium_integrity_browser->Quit(); | 391 medium_integrity_browser->Quit(); |
392 // Broker remains alive. | 392 // Broker remains alive. |
393 if (!token.Impersonate()) { | 393 if (!token.Impersonate()) { |
394 hr = HRESULT_FROM_WIN32(GetLastError()); | 394 hr = HRESULT_FROM_WIN32(GetLastError()); |
395 return hr; | 395 return hr; |
396 } | 396 } |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
675 | 675 |
676 ScopedChromeFrameRegistrar::RegistrationType GetTestBedType() { | 676 ScopedChromeFrameRegistrar::RegistrationType GetTestBedType() { |
677 if (GetConfigBool(false, L"PerUserTestBed")) { | 677 if (GetConfigBool(false, L"PerUserTestBed")) { |
678 return ScopedChromeFrameRegistrar::PER_USER; | 678 return ScopedChromeFrameRegistrar::PER_USER; |
679 } else { | 679 } else { |
680 return ScopedChromeFrameRegistrar::SYSTEM_LEVEL; | 680 return ScopedChromeFrameRegistrar::SYSTEM_LEVEL; |
681 } | 681 } |
682 } | 682 } |
683 | 683 |
684 } // namespace chrome_frame_test | 684 } // namespace chrome_frame_test |
OLD | NEW |