Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(105)

Unified Diff: content/ppapi_plugin/ppapi_thread.cc

Issue 897563002: Unify the three places that patch font loading for PDFium on Windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/ppapi_plugin/ppapi_thread.cc
diff --git a/content/ppapi_plugin/ppapi_thread.cc b/content/ppapi_plugin/ppapi_thread.cc
index 6d77afe546f494f9e220b5480421833016773bb3..103a7b8dcd373e3873da822f0d42e01f73cff9a9 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.

Powered by Google App Engine
This is Rietveld 408576698