| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_utils.h" | 5 #include "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 <shellapi.h> | 9 #include <shellapi.h> |
| 10 #include <winternl.h> | 10 #include <winternl.h> |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 #include "chrome/common/chrome_switches.h" | 25 #include "chrome/common/chrome_switches.h" |
| 26 #include "chrome_frame/test/chrome_frame_test_utils.h" | 26 #include "chrome_frame/test/chrome_frame_test_utils.h" |
| 27 #include "testing/gtest/include/gtest/gtest.h" | 27 #include "testing/gtest/include/gtest/gtest.h" |
| 28 | 28 |
| 29 const wchar_t kChromeFrameDllName[] = L"npchrome_frame.dll"; | 29 const wchar_t kChromeFrameDllName[] = L"npchrome_frame.dll"; |
| 30 const wchar_t kChromeLauncherExeName[] = L"chrome_launcher.exe"; | 30 const wchar_t kChromeLauncherExeName[] = L"chrome_launcher.exe"; |
| 31 // How long to wait for DLLs to register or unregister themselves before killing | 31 // How long to wait for DLLs to register or unregister themselves before killing |
| 32 // the registrar. | 32 // the registrar. |
| 33 const int64 kDllRegistrationTimeoutMs = 30 * 1000; | 33 const int64 kDllRegistrationTimeoutMs = 30 * 1000; |
| 34 | 34 |
| 35 FilePath GetChromeFrameBuildPath() { | 35 base::FilePath GetChromeFrameBuildPath() { |
| 36 FilePath build_path; | 36 base::FilePath build_path; |
| 37 PathService::Get(chrome::DIR_APP, &build_path); | 37 PathService::Get(chrome::DIR_APP, &build_path); |
| 38 | 38 |
| 39 FilePath dll_path = build_path.Append(kChromeFrameDllName); | 39 base::FilePath dll_path = build_path.Append(kChromeFrameDllName); |
| 40 | 40 |
| 41 if (!file_util::PathExists(dll_path)) { | 41 if (!file_util::PathExists(dll_path)) { |
| 42 // Well, dang.. try looking in the current directory. | 42 // Well, dang.. try looking in the current directory. |
| 43 dll_path = build_path.Append(kChromeFrameDllName); | 43 dll_path = build_path.Append(kChromeFrameDllName); |
| 44 } | 44 } |
| 45 | 45 |
| 46 if (!file_util::PathExists(dll_path)) { | 46 if (!file_util::PathExists(dll_path)) { |
| 47 // No luck, return something empty. | 47 // No luck, return something empty. |
| 48 dll_path = FilePath(); | 48 dll_path = base::FilePath(); |
| 49 } | 49 } |
| 50 | 50 |
| 51 return dll_path; | 51 return dll_path; |
| 52 } | 52 } |
| 53 | 53 |
| 54 const wchar_t ScopedChromeFrameRegistrar::kCallRegistrationEntrypointSwitch[] = | 54 const wchar_t ScopedChromeFrameRegistrar::kCallRegistrationEntrypointSwitch[] = |
| 55 L"--call-registration-entrypoint"; | 55 L"--call-registration-entrypoint"; |
| 56 | 56 |
| 57 bool ScopedChromeFrameRegistrar::register_chrome_path_provider_ = false; | 57 bool ScopedChromeFrameRegistrar::register_chrome_path_provider_ = false; |
| 58 | 58 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 const std::wstring& path, RegistrationType registration_type) { | 142 const std::wstring& path, RegistrationType registration_type) { |
| 143 DoRegistration(path, registration_type, REGISTER); | 143 DoRegistration(path, registration_type, REGISTER); |
| 144 } | 144 } |
| 145 | 145 |
| 146 // static | 146 // static |
| 147 void ScopedChromeFrameRegistrar::UnregisterAtPath( | 147 void ScopedChromeFrameRegistrar::UnregisterAtPath( |
| 148 const std::wstring& path, RegistrationType registration_type) { | 148 const std::wstring& path, RegistrationType registration_type) { |
| 149 DoRegistration(path, registration_type, UNREGISTER); | 149 DoRegistration(path, registration_type, UNREGISTER); |
| 150 } | 150 } |
| 151 | 151 |
| 152 FilePath ScopedChromeFrameRegistrar::GetReferenceChromeFrameDllPath() { | 152 base::FilePath ScopedChromeFrameRegistrar::GetReferenceChromeFrameDllPath() { |
| 153 FilePath reference_build_dir; | 153 base::FilePath reference_build_dir; |
| 154 PathService::Get(chrome::DIR_APP, &reference_build_dir); | 154 PathService::Get(chrome::DIR_APP, &reference_build_dir); |
| 155 | 155 |
| 156 reference_build_dir = reference_build_dir.DirName(); | 156 reference_build_dir = reference_build_dir.DirName(); |
| 157 reference_build_dir = reference_build_dir.DirName(); | 157 reference_build_dir = reference_build_dir.DirName(); |
| 158 | 158 |
| 159 reference_build_dir = reference_build_dir.AppendASCII("chrome_frame"); | 159 reference_build_dir = reference_build_dir.AppendASCII("chrome_frame"); |
| 160 reference_build_dir = reference_build_dir.AppendASCII("tools"); | 160 reference_build_dir = reference_build_dir.AppendASCII("tools"); |
| 161 reference_build_dir = reference_build_dir.AppendASCII("test"); | 161 reference_build_dir = reference_build_dir.AppendASCII("test"); |
| 162 reference_build_dir = reference_build_dir.AppendASCII("reference_build"); | 162 reference_build_dir = reference_build_dir.AppendASCII("reference_build"); |
| 163 reference_build_dir = reference_build_dir.AppendASCII("chrome"); | 163 reference_build_dir = reference_build_dir.AppendASCII("chrome"); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 if (!register_chrome_path_provider_) { | 233 if (!register_chrome_path_provider_) { |
| 234 // Register paths needed by the ScopedChromeFrameRegistrar. | 234 // Register paths needed by the ScopedChromeFrameRegistrar. |
| 235 chrome::RegisterPathProvider(); | 235 chrome::RegisterPathProvider(); |
| 236 register_chrome_path_provider_ = true; | 236 register_chrome_path_provider_ = true; |
| 237 } | 237 } |
| 238 original_dll_path_ = GetChromeFrameBuildPath().value(); | 238 original_dll_path_ = GetChromeFrameBuildPath().value(); |
| 239 RegisterChromeFrameAtPath(original_dll_path_); | 239 RegisterChromeFrameAtPath(original_dll_path_); |
| 240 } | 240 } |
| 241 | 241 |
| 242 ScopedChromeFrameRegistrar::~ScopedChromeFrameRegistrar() { | 242 ScopedChromeFrameRegistrar::~ScopedChromeFrameRegistrar() { |
| 243 if (FilePath(original_dll_path_) != FilePath(new_chrome_frame_dll_path_)) { | 243 if (base::FilePath(original_dll_path_) != |
| 244 base::FilePath(new_chrome_frame_dll_path_)) { |
| 244 RegisterChromeFrameAtPath(original_dll_path_); | 245 RegisterChromeFrameAtPath(original_dll_path_); |
| 245 } else if (registration_type_ == PER_USER) { | 246 } else if (registration_type_ == PER_USER) { |
| 246 UnregisterAtPath(new_chrome_frame_dll_path_, registration_type_); | 247 UnregisterAtPath(new_chrome_frame_dll_path_, registration_type_); |
| 247 HWND chrome_frame_helper_window = | 248 HWND chrome_frame_helper_window = |
| 248 FindWindow(L"ChromeFrameHelperWindowClass", NULL); | 249 FindWindow(L"ChromeFrameHelperWindowClass", NULL); |
| 249 if (IsWindow(chrome_frame_helper_window)) { | 250 if (IsWindow(chrome_frame_helper_window)) { |
| 250 PostMessage(chrome_frame_helper_window, WM_CLOSE, 0, 0); | 251 PostMessage(chrome_frame_helper_window, WM_CLOSE, 0, 0); |
| 251 } else { | 252 } else { |
| 252 base::KillProcesses(L"chrome_frame_helper.exe", 0, NULL); | 253 base::KillProcesses(L"chrome_frame_helper.exe", 0, NULL); |
| 253 } | 254 } |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 UOI_NAME, | 426 UOI_NAME, |
| 426 name, | 427 name, |
| 427 sizeof(name), | 428 sizeof(name), |
| 428 &needed)) { | 429 &needed)) { |
| 429 is_locked = lstrcmpi(name, L"default") != 0; | 430 is_locked = lstrcmpi(name, L"default") != 0; |
| 430 } | 431 } |
| 431 ::CloseDesktop(input_desk); | 432 ::CloseDesktop(input_desk); |
| 432 } | 433 } |
| 433 return is_locked; | 434 return is_locked; |
| 434 } | 435 } |
| OLD | NEW |