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