Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(171)

Side by Side Diff: chrome_frame/test/chrome_frame_test_utils.cc

Issue 7669061: Tommi: I need an owner review for the chrome frame changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Fixing license issue from presubmit check Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 const int kCrashServiceStartupTimeoutMs = 500; 44 const int kCrashServiceStartupTimeoutMs = 500;
45 45
46 const wchar_t kIEImageName[] = L"iexplore.exe"; 46 const wchar_t kIEImageName[] = L"iexplore.exe";
47 const wchar_t kIEBrokerImageName[] = L"ieuser.exe"; 47 const wchar_t kIEBrokerImageName[] = L"ieuser.exe";
48 const char kChromeImageName[] = "chrome.exe"; 48 const char kChromeImageName[] = "chrome.exe";
49 const wchar_t kIEProfileName[] = L"iexplore"; 49 const wchar_t kIEProfileName[] = L"iexplore";
50 const wchar_t kChromeLauncher[] = L"chrome_launcher.exe"; 50 const wchar_t kChromeLauncher[] = L"chrome_launcher.exe";
51 const int kChromeFrameLongNavigationTimeoutInSeconds = 10; 51 const int kChromeFrameLongNavigationTimeoutInSeconds = 10;
52 const int kChromeFrameVeryLongNavigationTimeoutInSeconds = 30; 52 const int kChromeFrameVeryLongNavigationTimeoutInSeconds = 30;
53 53
54 const wchar_t TempRegKeyOverride::kTempTestKeyPath[] =
55 L"Software\\Chromium\\TempTestKeys";
56
57 // Callback function for EnumThreadWindows. 54 // Callback function for EnumThreadWindows.
58 BOOL CALLBACK CloseWindowsThreadCallback(HWND hwnd, LPARAM param) { 55 BOOL CALLBACK CloseWindowsThreadCallback(HWND hwnd, LPARAM param) {
59 int& count = *reinterpret_cast<int*>(param); 56 int& count = *reinterpret_cast<int*>(param);
60 if (IsWindowVisible(hwnd)) { 57 if (IsWindowVisible(hwnd)) {
61 if (IsWindowEnabled(hwnd)) { 58 if (IsWindowEnabled(hwnd)) {
62 DWORD results = 0; 59 DWORD results = 0;
63 if (!::SendMessageTimeout(hwnd, WM_SYSCOMMAND, SC_CLOSE, 0, SMTO_BLOCK, 60 if (!::SendMessageTimeout(hwnd, WM_SYSCOMMAND, SC_CLOSE, 0, SMTO_BLOCK,
64 10000, &results)) { 61 10000, &results)) {
65 LOG(WARNING) << "Window hung: " << base::StringPrintf(L"%08X", hwnd); 62 LOG(WARNING) << "Window hung: " << base::StringPrintf(L"%08X", hwnd);
66 } 63 }
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 606
610 // First check to see if it's even still running just to minimize the 607 // First check to see if it's even still running just to minimize the
611 // likelihood of spurious error messages from KillProcess. 608 // likelihood of spurious error messages from KillProcess.
612 if (WAIT_OBJECT_0 != ::WaitForSingleObject(crash_service, 0)) { 609 if (WAIT_OBJECT_0 != ::WaitForSingleObject(crash_service, 0)) {
613 base::KillProcess(crash_service, 0, false); 610 base::KillProcess(crash_service, 0, false);
614 } 611 }
615 return NULL; 612 return NULL;
616 } 613 }
617 } 614 }
618 615
619 TempRegKeyOverride::TempRegKeyOverride(HKEY override, const wchar_t* temp_name)
620 : override_(override), temp_name_(temp_name) {
621 DCHECK(temp_name && lstrlenW(temp_name));
622 std::wstring key_path(kTempTestKeyPath);
623 key_path += L"\\" + temp_name_;
624 EXPECT_EQ(ERROR_SUCCESS, temp_key_.Create(HKEY_CURRENT_USER, key_path.c_str(),
625 KEY_ALL_ACCESS));
626 EXPECT_EQ(ERROR_SUCCESS,
627 ::RegOverridePredefKey(override_, temp_key_.Handle()));
628 }
629
630 TempRegKeyOverride::~TempRegKeyOverride() {
631 ::RegOverridePredefKey(override_, NULL);
632 // The temp key will be deleted via a call to DeleteAllTempKeys().
633 }
634
635 // static
636 void TempRegKeyOverride::DeleteAllTempKeys() {
637 base::win::RegKey key;
638 if (key.Open(HKEY_CURRENT_USER, L"", KEY_ALL_ACCESS) == ERROR_SUCCESS) {
639 key.DeleteKey(kTempTestKeyPath);
640 }
641 }
642
643 ScopedVirtualizeHklmAndHkcu::ScopedVirtualizeHklmAndHkcu() { 616 ScopedVirtualizeHklmAndHkcu::ScopedVirtualizeHklmAndHkcu() {
644 TempRegKeyOverride::DeleteAllTempKeys(); 617 override_manager_.OverrideRegistry(HKEY_LOCAL_MACHINE, L"hklm_fake");
645 hklm_.reset(new TempRegKeyOverride(HKEY_LOCAL_MACHINE, L"hklm_fake")); 618 override_manager_.OverrideRegistry(HKEY_CURRENT_USER, L"hkcu_fake");
646 hkcu_.reset(new TempRegKeyOverride(HKEY_CURRENT_USER, L"hkcu_fake"));
647 } 619 }
648 620
649 ScopedVirtualizeHklmAndHkcu::~ScopedVirtualizeHklmAndHkcu() { 621 ScopedVirtualizeHklmAndHkcu::~ScopedVirtualizeHklmAndHkcu() {
650 hkcu_.reset(NULL); 622 }
651 hklm_.reset(NULL); 623
652 TempRegKeyOverride::DeleteAllTempKeys(); 624 void ScopedVirtualizeHklmAndHkcu::RemoveAllOverrides() {
625 override_manager_.RemoveAllOverrides();
653 } 626 }
654 627
655 bool KillProcesses(const std::wstring& executable_name, int exit_code, 628 bool KillProcesses(const std::wstring& executable_name, int exit_code,
656 bool wait) { 629 bool wait) {
657 bool result = true; 630 bool result = true;
658 base::NamedProcessIterator iter(executable_name, NULL); 631 base::NamedProcessIterator iter(executable_name, NULL);
659 while (const base::ProcessEntry* entry = iter.NextProcessEntry()) { 632 while (const base::ProcessEntry* entry = iter.NextProcessEntry()) {
660 result &= base::KillProcessById(entry->pid(), exit_code, wait); 633 result &= base::KillProcessById(entry->pid(), exit_code, wait);
661 } 634 }
662 return result; 635 return result;
(...skipping 11 matching lines...) Expand all
674 wchar_t local_app_data_path[MAX_PATH + 1] = {0}; 647 wchar_t local_app_data_path[MAX_PATH + 1] = {0};
675 SHGetFolderPath(NULL, CSIDL_LOCAL_APPDATA, NULL, SHGFP_TYPE_CURRENT, 648 SHGetFolderPath(NULL, CSIDL_LOCAL_APPDATA, NULL, SHGFP_TYPE_CURRENT,
676 local_app_data_path); 649 local_app_data_path);
677 650
678 std::wstring session_history_path = local_app_data_path; 651 std::wstring session_history_path = local_app_data_path;
679 session_history_path += L"\\Microsoft\\Internet Explorer\\Recovery"; 652 session_history_path += L"\\Microsoft\\Internet Explorer\\Recovery";
680 file_util::Delete(session_history_path, true); 653 file_util::Delete(session_history_path, true);
681 } 654 }
682 655
683 } // namespace chrome_frame_test 656 } // namespace chrome_frame_test
OLDNEW
« no previous file with comments | « chrome_frame/test/chrome_frame_test_utils.h ('k') | chrome_frame/test/policy_settings_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698