diff options
author | jam <jam@chromium.org> | 2015-02-03 10:16:08 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-02-03 18:16:56 +0000 |
commit | 8a021512a24f87d3b1723f260e0380b874f3b9eb (patch) | |
tree | fe0fd8bea7c18d5b6d6f28338d150db187512866 /content/ppapi_plugin | |
parent | 4adea21c6771ac1aaa6260524c3c283e85415672 (diff) | |
download | chromium_src-8a021512a24f87d3b1723f260e0380b874f3b9eb.zip chromium_src-8a021512a24f87d3b1723f260e0380b874f3b9eb.tar.gz chromium_src-8a021512a24f87d3b1723f260e0380b874f3b9eb.tar.bz2 |
Unify the three places that patch font loading for PDFium on Windows.
This also removed the code from content, which doesn't belong there because it's for a feature in Chrome.
In order to implement this in a unified way, I needed to create a public interface around ChildThread. A lot of the change is updating callers of ChildThread to use ChildThreadImpl instead.
BUG=448473
Review URL: https://codereview.chromium.org/897563002
Cr-Commit-Position: refs/heads/master@{#314367}
Diffstat (limited to 'content/ppapi_plugin')
-rw-r--r-- | content/ppapi_plugin/ppapi_blink_platform_impl.cc | 2 | ||||
-rw-r--r-- | content/ppapi_plugin/ppapi_thread.cc | 68 | ||||
-rw-r--r-- | content/ppapi_plugin/ppapi_thread.h | 14 |
3 files changed, 17 insertions, 67 deletions
diff --git a/content/ppapi_plugin/ppapi_blink_platform_impl.cc b/content/ppapi_plugin/ppapi_blink_platform_impl.cc index ad84196..793f6d6 100644 --- a/content/ppapi_plugin/ppapi_blink_platform_impl.cc +++ b/content/ppapi_plugin/ppapi_blink_platform_impl.cc @@ -10,7 +10,7 @@ #include "base/strings/string16.h" #include "base/threading/platform_thread.h" #include "build/build_config.h" -#include "content/child/child_thread.h" +#include "content/child/child_thread_impl.h" #include "content/common/child_process_messages.h" #include "ppapi/proxy/plugin_globals.h" #include "ppapi/shared_impl/proxy_lock.h" diff --git a/content/ppapi_plugin/ppapi_thread.cc b/content/ppapi_plugin/ppapi_thread.cc index 6d77afe..103a7b8 100644 --- a/content/ppapi_plugin/ppapi_thread.cc +++ b/content/ppapi_plugin/ppapi_thread.cc @@ -42,12 +42,10 @@ #include "ppapi/proxy/plugin_message_filter.h" #include "ppapi/proxy/ppapi_messages.h" #include "ppapi/proxy/resource_reply_thread_registrar.h" -#include "ppapi/shared_impl/proxy_lock.h" #include "third_party/WebKit/public/web/WebKit.h" #include "ui/base/ui_base_switches.h" #if defined(OS_WIN) -#include "base/win/iat_patch_function.h" #include "base/win/win_util.h" #include "base/win/windows_version.h" #include "sandbox/win/src/sandbox.h" @@ -94,54 +92,6 @@ static void WarmupWindowsLocales(const ppapi::PpapiPermissions& permissions) { } } -// TODO(scottmg): http://crbug.com/448473. This code should be removed from the -// renderer once PDF is always OOP and/or PDF is made to use Skia instead of GDI -// directly. -const wchar_t kPdfFileName[] = L"pdf.dll"; - -static base::win::IATPatchFunction g_iat_patch_createdca; -HDC WINAPI CreateDCAPatch(LPCSTR driver_name, - LPCSTR device_name, - LPCSTR output, - const void* init_data) { - DCHECK(std::string("DISPLAY") == std::string(driver_name)); - DCHECK(!device_name); - DCHECK(!output); - DCHECK(!init_data); - - // CreateDC fails behind the sandbox, but not CreateCompatibleDC. - return CreateCompatibleDC(NULL); -} - -static base::win::IATPatchFunction g_iat_patch_get_font_data; -DWORD WINAPI GetFontDataPatch(HDC hdc, - DWORD table, - DWORD offset, - LPVOID buffer, - DWORD length) { - int rv = GetFontData(hdc, table, offset, buffer, length); - if (rv == GDI_ERROR && hdc) { - HFONT font = static_cast<HFONT>(GetCurrentObject(hdc, OBJ_FONT)); - - LOGFONT logfont; - if (GetObject(font, sizeof(LOGFONT), &logfont)) { - std::vector<char> font_data; - { - ppapi::ProxyAutoLock lock; - // In the sandbox, font loading will fail. We ask the browser to load it - // which causes it to be loaded by the kernel, which then makes the - // subsequent call succeed. - ppapi::proxy::PluginGlobals::Get()->PreCacheFontForFlash( - reinterpret_cast<const void*>(&logfont)); - } - rv = GetFontData(hdc, table, offset, buffer, length); - } - } - return rv; -} - -#else -extern void* g_target_services; #endif namespace content { @@ -173,7 +123,7 @@ PpapiThread::~PpapiThread() { } void PpapiThread::Shutdown() { - ChildThread::Shutdown(); + ChildThreadImpl::Shutdown(); ppapi::proxy::PluginGlobals::Get()->ResetPluginProxyDelegate(); if (plugin_entry_points_.shutdown_module) @@ -185,7 +135,7 @@ void PpapiThread::Shutdown() { bool PpapiThread::Send(IPC::Message* msg) { // Allow access from multiple threads. if (base::MessageLoop::current() == message_loop()) - return ChildThread::Send(msg); + return ChildThreadImpl::Send(msg); return sync_message_filter()->Send(msg); } @@ -207,7 +157,7 @@ bool PpapiThread::OnControlMessageReceived(const IPC::Message& msg) { } void PpapiThread::OnChannelConnected(int32 peer_pid) { - ChildThread::OnChannelConnected(peer_pid); + ChildThreadImpl::OnChannelConnected(peer_pid); #if defined(OS_WIN) if (is_broker_) peer_handle_.Set(::OpenProcess(PROCESS_DUP_HANDLE, FALSE, peer_pid)); @@ -253,8 +203,7 @@ std::string PpapiThread::GetUILanguage() { void PpapiThread::PreCacheFont(const void* logfontw) { #if defined(OS_WIN) - Send(new ChildProcessHostMsg_PreCacheFont( - *static_cast<const LOGFONTW*>(logfontw))); + ChildThreadImpl::PreCacheFont(*static_cast<const LOGFONTW*>(logfontw)); #endif } @@ -374,15 +323,6 @@ void PpapiThread::OnLoadPlugin(const base::FilePath& path, // otherwise these would be silent terminations and fly under the radar). base::win::SetAbortBehaviorForCrashReporting(); - // Need to patch a few functions for font loading to work correctly. This can - // be removed once we switch PDF to use Skia. - if (GetModuleHandle(kPdfFileName)) { - g_iat_patch_createdca.Patch(kPdfFileName, "gdi32.dll", "CreateDCA", - CreateDCAPatch); - g_iat_patch_get_font_data.Patch(kPdfFileName, "gdi32.dll", "GetFontData", - GetFontDataPatch); - } - // Once we lower the token the sandbox is locked down and no new modules // can be loaded. TODO(cpu): consider changing to the loading style of // regular plugins. diff --git a/content/ppapi_plugin/ppapi_thread.h b/content/ppapi_plugin/ppapi_thread.h index 3d80e49..8b4f522 100644 --- a/content/ppapi_plugin/ppapi_thread.h +++ b/content/ppapi_plugin/ppapi_thread.h @@ -14,7 +14,7 @@ #include "base/process/process.h" #include "base/scoped_native_library.h" #include "build/build_config.h" -#include "content/child/child_thread.h" +#include "content/child/child_thread_impl.h" #include "content/public/common/pepper_plugin_info.h" #include "ppapi/c/pp_module.h" #include "ppapi/c/trusted/ppp_broker.h" @@ -40,7 +40,13 @@ namespace content { class PpapiBlinkPlatformImpl; -class PpapiThread : public ChildThread, +#if defined(COMPILER_MSVC) +// See explanation for other RenderViewHostImpl which is the same issue. +#pragma warning(push) +#pragma warning(disable: 4250) +#endif + +class PpapiThread : public ChildThreadImpl, public ppapi::proxy::PluginDispatcher::PluginDelegate, public ppapi::proxy::PluginProxyDelegate { public: @@ -158,6 +164,10 @@ class PpapiThread : public ChildThread, DISALLOW_IMPLICIT_CONSTRUCTORS(PpapiThread); }; +#if defined(COMPILER_MSVC) +#pragma warning(pop) +#endif + } // namespace content #endif // CONTENT_PPAPI_PLUGIN_PPAPI_THREAD_H_ |