| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/child/pdf_child_init.h" | 5 #include "chrome/child/pdf_child_init.h" |
| 6 | 6 |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| 11 #include "chrome/common/chrome_paths.h" | 11 #include "chrome/common/chrome_paths.h" |
| 12 #include "content/public/child/child_thread.h" | 12 #include "content/public/child/child_thread.h" |
| 13 | 13 |
| 14 #if defined(OS_WIN) | 14 #if defined(OS_WIN) |
| 15 #include "base/win/current_module.h" |
| 15 #include "base/win/iat_patch_function.h" | 16 #include "base/win/iat_patch_function.h" |
| 16 #endif | 17 #endif |
| 17 | 18 |
| 18 namespace chrome { | 19 namespace chrome { |
| 19 namespace { | 20 namespace { |
| 20 #if defined(OS_WIN) | 21 #if defined(OS_WIN) |
| 21 static base::win::IATPatchFunction g_iat_patch_createdca; | 22 static base::win::IATPatchFunction g_iat_patch_createdca; |
| 22 HDC WINAPI CreateDCAPatch(LPCSTR driver_name, | 23 HDC WINAPI CreateDCAPatch(LPCSTR driver_name, |
| 23 LPCSTR device_name, | 24 LPCSTR device_name, |
| 24 LPCSTR output, | 25 LPCSTR output, |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 if (content::ChildThread::Get()) | 58 if (content::ChildThread::Get()) |
| 58 content::ChildThread::Get()->ReleaseCachedFonts(); | 59 content::ChildThread::Get()->ReleaseCachedFonts(); |
| 59 } | 60 } |
| 60 } | 61 } |
| 61 return rv; | 62 return rv; |
| 62 } | 63 } |
| 63 #endif // OS_WIN | 64 #endif // OS_WIN |
| 64 | 65 |
| 65 } // namespace | 66 } // namespace |
| 66 | 67 |
| 67 #if defined(OS_WIN) | |
| 68 // http://blogs.msdn.com/oldnewthing/archive/2004/10/25/247180.aspx | |
| 69 extern "C" IMAGE_DOS_HEADER __ImageBase; | |
| 70 #endif // OS_WIN | |
| 71 | |
| 72 void InitializePDF() { | 68 void InitializePDF() { |
| 73 #if defined(OS_WIN) | 69 #if defined(OS_WIN) |
| 74 // Need to patch a few functions for font loading to work correctly. This can | 70 // Need to patch a few functions for font loading to work correctly. This can |
| 75 // be removed once we switch PDF to use Skia. | 71 // be removed once we switch PDF to use Skia. |
| 76 HMODULE current_module = reinterpret_cast<HMODULE>(&__ImageBase); | 72 HMODULE current_module = CURRENT_MODULE(); |
| 77 g_iat_patch_createdca.PatchFromModule(current_module, "gdi32.dll", | 73 g_iat_patch_createdca.PatchFromModule(current_module, "gdi32.dll", |
| 78 "CreateDCA", CreateDCAPatch); | 74 "CreateDCA", CreateDCAPatch); |
| 79 g_iat_patch_get_font_data.PatchFromModule(current_module, "gdi32.dll", | 75 g_iat_patch_get_font_data.PatchFromModule(current_module, "gdi32.dll", |
| 80 "GetFontData", GetFontDataPatch); | 76 "GetFontData", GetFontDataPatch); |
| 81 g_original_get_font_data = reinterpret_cast<GetFontDataPtr>( | 77 g_original_get_font_data = reinterpret_cast<GetFontDataPtr>( |
| 82 g_iat_patch_get_font_data.original_function()); | 78 g_iat_patch_get_font_data.original_function()); |
| 83 #endif // OS_WIN | 79 #endif // OS_WIN |
| 84 } | 80 } |
| 85 | 81 |
| 86 } // namespace chrome | 82 } // namespace chrome |
| OLD | NEW |