| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 | 9 |
| 10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
| 11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
| 12 #include "base/path_service.h" | 12 #include "base/path_service.h" |
| 13 #include "chrome/common/chrome_paths.h" | 13 #include "chrome/common/chrome_paths.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 15 | 15 |
| 16 // Statics | 16 // Statics |
| 17 | 17 |
| 18 FilePath ScopedChromeFrameRegistrar::GetChromeFrameBuildPath() { | 18 std::wstring ScopedChromeFrameRegistrar::GetChromeFrameBuildPath() { |
| 19 FilePath build_path; | 19 std::wstring build_path; |
| 20 PathService::Get(chrome::DIR_APP, &build_path); | 20 PathService::Get(chrome::DIR_APP, &build_path); |
| 21 build_path = build_path.Append(L"servers"). | 21 file_util::AppendToPath(&build_path, L"servers\\npchrome_tab.dll"); |
| 22 Append(L"npchrome_tab.dll"); | |
| 23 file_util::PathExists(build_path); | 22 file_util::PathExists(build_path); |
| 24 return build_path; | 23 return build_path; |
| 25 } | 24 } |
| 26 | 25 |
| 27 void ScopedChromeFrameRegistrar::RegisterDefaults() { | 26 void ScopedChromeFrameRegistrar::RegisterDefaults() { |
| 28 FilePath dll_path = GetChromeFrameBuildPath(); | 27 std::wstring dll_path_ = GetChromeFrameBuildPath(); |
| 29 RegisterAtPath(dll_path.value()); | 28 RegisterAtPath(dll_path_); |
| 30 } | 29 } |
| 31 | 30 |
| 32 void ScopedChromeFrameRegistrar::RegisterAtPath( | 31 void ScopedChromeFrameRegistrar::RegisterAtPath( |
| 33 const std::wstring& path) { | 32 const std::wstring& path) { |
| 34 | 33 |
| 35 ASSERT_FALSE(path.empty()); | 34 ASSERT_FALSE(path.empty()); |
| 36 HMODULE chrome_frame_dll_handle = LoadLibrary(path.c_str()); | 35 HMODULE chrome_frame_dll_handle = LoadLibrary(path.c_str()); |
| 37 ASSERT_TRUE(chrome_frame_dll_handle != NULL); | 36 ASSERT_TRUE(chrome_frame_dll_handle != NULL); |
| 38 | 37 |
| 39 typedef HRESULT (STDAPICALLTYPE* DllRegisterServerFn)(); | 38 typedef HRESULT (STDAPICALLTYPE* DllRegisterServerFn)(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 50 | 49 |
| 51 if (register_npapi_server != NULL) | 50 if (register_npapi_server != NULL) |
| 52 EXPECT_HRESULT_SUCCEEDED((*register_npapi_server)()); | 51 EXPECT_HRESULT_SUCCEEDED((*register_npapi_server)()); |
| 53 | 52 |
| 54 ASSERT_TRUE(FreeLibrary(chrome_frame_dll_handle)); | 53 ASSERT_TRUE(FreeLibrary(chrome_frame_dll_handle)); |
| 55 } | 54 } |
| 56 | 55 |
| 57 // Non-statics | 56 // Non-statics |
| 58 | 57 |
| 59 ScopedChromeFrameRegistrar::ScopedChromeFrameRegistrar() { | 58 ScopedChromeFrameRegistrar::ScopedChromeFrameRegistrar() { |
| 60 original_dll_path_ = GetChromeFrameBuildPath().ToWStringHack(); | 59 original_dll_path_ = GetChromeFrameBuildPath(); |
| 61 RegisterChromeFrameAtPath(original_dll_path_); | 60 RegisterChromeFrameAtPath(original_dll_path_); |
| 62 } | 61 } |
| 63 | 62 |
| 64 ScopedChromeFrameRegistrar::~ScopedChromeFrameRegistrar() { | 63 ScopedChromeFrameRegistrar::~ScopedChromeFrameRegistrar() { |
| 65 if (FilePath(original_dll_path_) != FilePath(new_chrome_frame_dll_path_)) { | 64 if (FilePath(original_dll_path_) != FilePath(new_chrome_frame_dll_path_)) { |
| 66 RegisterChromeFrameAtPath(original_dll_path_); | 65 RegisterChromeFrameAtPath(original_dll_path_); |
| 67 } | 66 } |
| 68 } | 67 } |
| 69 | 68 |
| 70 void ScopedChromeFrameRegistrar::RegisterChromeFrameAtPath( | 69 void ScopedChromeFrameRegistrar::RegisterChromeFrameAtPath( |
| (...skipping 16 matching lines...) Expand all Loading... |
| 87 file_util::AppendToPath(&reference_build_dir, L"chrome"); | 86 file_util::AppendToPath(&reference_build_dir, L"chrome"); |
| 88 file_util::AppendToPath(&reference_build_dir, L"servers"); | 87 file_util::AppendToPath(&reference_build_dir, L"servers"); |
| 89 file_util::AppendToPath(&reference_build_dir, L"npchrome_tab.dll"); | 88 file_util::AppendToPath(&reference_build_dir, L"npchrome_tab.dll"); |
| 90 | 89 |
| 91 RegisterChromeFrameAtPath(reference_build_dir); | 90 RegisterChromeFrameAtPath(reference_build_dir); |
| 92 } | 91 } |
| 93 | 92 |
| 94 std::wstring ScopedChromeFrameRegistrar::GetChromeFrameDllPath() const { | 93 std::wstring ScopedChromeFrameRegistrar::GetChromeFrameDllPath() const { |
| 95 return new_chrome_frame_dll_path_; | 94 return new_chrome_frame_dll_path_; |
| 96 } | 95 } |
| OLD | NEW |