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

Unified Diff: chrome/renderer/chrome_render_process_observer.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: chrome/renderer/chrome_render_process_observer.cc
diff --git a/chrome/renderer/chrome_render_process_observer.cc b/chrome/renderer/chrome_render_process_observer.cc
index 9367b98d2318f32f4367e403054aefe549379c54..09873795021c8421cacfc1c453c45bb61c30b484 100644
--- a/chrome/renderer/chrome_render_process_observer.cc
+++ b/chrome/renderer/chrome_render_process_observer.cc
@@ -43,10 +43,6 @@
#include "third_party/WebKit/public/web/WebSecurityPolicy.h"
#include "third_party/WebKit/public/web/WebView.h"
-#if defined(OS_WIN)
-#include "base/win/iat_patch_function.h"
-#endif
-
#if defined(ENABLE_EXTENSIONS)
#include "chrome/renderer/extensions/extension_localization_peer.h"
#endif
@@ -112,43 +108,6 @@ class RendererResourceDelegate : public content::ResourceDispatcherDelegate {
DISALLOW_COPY_AND_ASSIGN(RendererResourceDelegate);
};
-#if defined(OS_WIN)
-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;
- RenderThread::Get()->PreCacheFont(logfont);
- rv = GetFontData(hdc, table, offset, buffer, length);
- RenderThread::Get()->ReleaseCachedFonts();
- }
- }
- return rv;
-}
-#endif // OS_WIN
-
static const int kWaitForWorkersStatsTimeoutMS = 20;
class HeapStatisticsCollector {
@@ -280,22 +239,6 @@ ChromeRenderProcessObserver::ChromeRenderProcessObserver(
// Configure modules that need access to resources.
net::NetModule::SetResourceProvider(chrome_common_net::NetResourceProvider);
-#if defined(OS_WIN)
- // TODO(scottmg): http://crbug.com/448473. This code should be removed once
- // PDF is always OOP and/or PDF is made to use Skia instead of GDI directly.
- if (!command_line.HasSwitch(switches::kEnableOutOfProcessPdf)) {
- // Need to patch a few functions for font loading to work correctly.
- base::FilePath pdf;
- if (PathService::Get(chrome::FILE_PDF_PLUGIN, &pdf) &&
- base::PathExists(pdf)) {
- g_iat_patch_createdca.Patch(pdf.value().c_str(), "gdi32.dll", "CreateDCA",
- CreateDCAPatch);
- g_iat_patch_get_font_data.Patch(pdf.value().c_str(), "gdi32.dll",
- "GetFontData", GetFontDataPatch);
- }
- }
-#endif
-
#if defined(OS_POSIX) && !defined(OS_MACOSX) && defined(USE_NSS)
// On platforms where we use system NSS shared libraries,
// initialize NSS now because it won't be able to load the .so's

Powered by Google App Engine
This is Rietveld 408576698