Commit 98e2c9d0 authored by forshaw's avatar forshaw Committed by Commit bot

Moved render_font to a common location to share with other content.

This patch moves the render_font_warmup_win files into a common
location so that other content processes, especially PPAPI can
share the code. This is needed as a warmup to pushing win32k lockdown
to other content processes.

BUG=523278

Review URL: https://codereview.chromium.org/1326623002

Cr-Commit-Position: refs/heads/master@{#348779}
parent d755e4bf
......@@ -60,6 +60,7 @@ include_rules = [
"+third_party/WebKit/public/web/WebTreeScopeType.h",
"+third_party/WebKit/public/web/WebWindowFeatures.h",
"+third_party/WebKit/public/web/mac/WebScrollbarTheme.h",
"+third_party/WebKit/public/web/win/WebFontRendering.h"
]
specific_include_rules = {
......
......@@ -77,3 +77,4 @@ per-file cc_messages_perftest.cc=danakj@chromium.org
# DirectWrite
per-file dwrite_font_platform_win*=scottmg@chromium.org
per-file font_warmup_win.cc=scottmg@chromium.org
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "content/renderer/render_font_warmup_win.h"
#include "content/common/font_warmup_win.h"
#include <dwrite.h>
......@@ -20,7 +20,7 @@ namespace content {
namespace {
SkFontMgr* g_warmup_fontmgr = NULL;
SkFontMgr* g_warmup_fontmgr = nullptr;
base::win::IATPatchFunction g_iat_patch_open_sc_manager;
base::win::IATPatchFunction g_iat_patch_close_service_handle;
......@@ -30,28 +30,31 @@ base::win::IATPatchFunction g_iat_patch_nt_connect_port;
// These are from ntddk.h
#if !defined(STATUS_ACCESS_DENIED)
#define STATUS_ACCESS_DENIED ((NTSTATUS)0xC0000022L)
#define STATUS_ACCESS_DENIED ((NTSTATUS)0xC0000022L)
#endif
typedef LONG NTSTATUS;
const uintptr_t kFakeSCMHandle = 0xdead0001;
const uintptr_t kFakeServiceHandle = 0xdead0002;
SC_HANDLE WINAPI OpenSCManagerWPatch(const wchar_t* machine_name,
const wchar_t* database_name,
DWORD access_mask) {
::SetLastError(0);
return reinterpret_cast<SC_HANDLE>(0xdeadbeef);
return reinterpret_cast<SC_HANDLE>(kFakeSCMHandle);
}
SC_HANDLE WINAPI OpenServiceWPatch(SC_HANDLE sc_manager,
const wchar_t* service_name,
DWORD access_mask) {
::SetLastError(0);
return reinterpret_cast<SC_HANDLE>(0xdeadbabe);
return reinterpret_cast<SC_HANDLE>(kFakeServiceHandle);
}
BOOL WINAPI CloseServiceHandlePatch(SC_HANDLE service_handle) {
if (service_handle != reinterpret_cast<SC_HANDLE>(0xdeadbabe) &&
service_handle != reinterpret_cast<SC_HANDLE>(0xdeadbeef))
if (service_handle != reinterpret_cast<SC_HANDLE>(kFakeServiceHandle) &&
service_handle != reinterpret_cast<SC_HANDLE>(kFakeSCMHandle))
CHECK(false);
::SetLastError(0);
return TRUE;
......@@ -60,7 +63,7 @@ BOOL WINAPI CloseServiceHandlePatch(SC_HANDLE service_handle) {
BOOL WINAPI StartServiceWPatch(SC_HANDLE service,
DWORD args,
const wchar_t** arg_vectors) {
if (service != reinterpret_cast<SC_HANDLE>(0xdeadbabe))
if (service != reinterpret_cast<SC_HANDLE>(kFakeServiceHandle))
CHECK(false);
::SetLastError(ERROR_ACCESS_DENIED);
return FALSE;
......@@ -101,29 +104,32 @@ void PatchServiceManagerCalls() {
if (is_patched)
return;
const char* service_provider_dll =
(base::win::GetVersion() >= base::win::VERSION_WIN8 ?
"api-ms-win-service-management-l1-1-0.dll" : "advapi32.dll");
(base::win::GetVersion() >= base::win::VERSION_WIN8
? "api-ms-win-service-management-l1-1-0.dll"
: "advapi32.dll");
is_patched = true;
DWORD patched = g_iat_patch_open_sc_manager.Patch(L"dwrite.dll",
service_provider_dll, "OpenSCManagerW", OpenSCManagerWPatch);
DWORD patched =
g_iat_patch_open_sc_manager.Patch(L"dwrite.dll", service_provider_dll,
"OpenSCManagerW", OpenSCManagerWPatch);
DCHECK(patched == 0);
patched = g_iat_patch_close_service_handle.Patch(L"dwrite.dll",
service_provider_dll, "CloseServiceHandle", CloseServiceHandlePatch);
patched = g_iat_patch_close_service_handle.Patch(
L"dwrite.dll", service_provider_dll, "CloseServiceHandle",
CloseServiceHandlePatch);
DCHECK(patched == 0);
patched = g_iat_patch_open_service.Patch(L"dwrite.dll",
service_provider_dll, "OpenServiceW", OpenServiceWPatch);
patched = g_iat_patch_open_service.Patch(L"dwrite.dll", service_provider_dll,
"OpenServiceW", OpenServiceWPatch);
DCHECK(patched == 0);
patched = g_iat_patch_start_service.Patch(L"dwrite.dll",
service_provider_dll, "StartServiceW", StartServiceWPatch);
patched = g_iat_patch_start_service.Patch(
L"dwrite.dll", service_provider_dll, "StartServiceW", StartServiceWPatch);
DCHECK(patched == 0);
patched = g_iat_patch_nt_connect_port.Patch(L"dwrite.dll",
"ntdll.dll", "NtAlpcConnectPort", NtALpcConnectPortPatch);
patched = g_iat_patch_nt_connect_port.Patch(
L"dwrite.dll", "ntdll.dll", "NtAlpcConnectPort", NtALpcConnectPortPatch);
DCHECK(patched == 0);
}
......@@ -152,10 +158,9 @@ void CreateDirectWriteFactory(IDWriteFactory** factory) {
base::debug::Alias(&get_proc_address_get_last_error);
CHECK(false);
}
CHECK(SUCCEEDED(
dwrite_create_factory_proc(DWRITE_FACTORY_TYPE_ISOLATED,
__uuidof(IDWriteFactory),
reinterpret_cast<IUnknown**>(factory))));
CHECK(SUCCEEDED(dwrite_create_factory_proc(
DWRITE_FACTORY_TYPE_ISOLATED, __uuidof(IDWriteFactory),
reinterpret_cast<IUnknown**>(factory))));
}
HRESULT STDMETHODCALLTYPE StubFontCollection(IDWriteFactory* factory,
......@@ -163,7 +168,7 @@ HRESULT STDMETHODCALLTYPE StubFontCollection(IDWriteFactory* factory,
BOOL checkUpdates) {
// We always return pre-created font collection from here.
IDWriteFontCollection* custom_collection = GetCustomFontCollection(factory);
DCHECK(custom_collection != NULL);
DCHECK(custom_collection != nullptr);
*col = custom_collection;
return S_OK;
}
......
......@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_RENDERER_RENDER_FONT_WARMUP_WIN_H_
#define CONTENT_RENDERER_RENDER_FONT_WARMUP_WIN_H_
#ifndef CONTENT_COMMON_FONT_WARMUP_WIN_H_
#define CONTENT_COMMON_FONT_WARMUP_WIN_H_
#include "content/common/content_export.h"
......@@ -22,4 +22,4 @@ CONTENT_EXPORT SkFontMgr* GetPreSandboxWarmupFontMgr();
} // namespace content
#endif // CONTENT_RENDERER_RENDER_FONT_WARMUP_WIN_H_
#endif // CONTENT_COMMON_FONT_WARMUP_WIN_H_
......@@ -259,6 +259,8 @@
'common/font_list_ozone.cc',
'common/font_list_pango.cc',
'common/font_list_win.cc',
'common/font_warmup_win.cc',
'common/font_warmup_win.h',
'common/frame_message_enums.h',
'common/frame_messages.h',
'common/frame_param.cc',
......
......@@ -337,8 +337,6 @@
'renderer/push_messaging/push_messaging_dispatcher.h',
'renderer/raster_worker_pool.cc',
'renderer/raster_worker_pool.h',
'renderer/render_font_warmup_win.cc',
'renderer/render_font_warmup_win.h',
'renderer/render_frame_impl.cc',
'renderer/render_frame_impl.h',
'renderer/render_frame_proxy.cc',
......
......@@ -3,6 +3,5 @@ per-file *.sb=set noparent
per-file *.sb=rsesek@chromium.org
# DirectWrite specific changes
per-file render_font_warmup_win.cc=scottmg@chromium.org
per-file renderer_font_platform_win.*=scottmg@chromium.org
per-file renderer_font_platform_win.*=cpu@chromium.org
......@@ -11,10 +11,10 @@
#include "base/win/scoped_comptr.h"
#include "base/win/win_util.h"
#include "base/win/windows_version.h"
#include "content/common/font_warmup_win.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/injection_test_win.h"
#include "content/public/renderer/render_thread.h"
#include "content/renderer/render_font_warmup_win.h"
#include "content/renderer/render_thread_impl.h"
#include "sandbox/win/src/sandbox.h"
#include "skia/ext/fontmgr_default_win.h"
......
......@@ -35,7 +35,7 @@
#if defined(OS_MACOSX)
#include "content/browser/frame_host/popup_menu_helper_mac.h"
#elif defined(OS_WIN)
#include "content/renderer/render_font_warmup_win.h"
#include "content/common/font_warmup_win.h"
#include "third_party/WebKit/public/web/win/WebFontRendering.h"
#include "third_party/skia/include/ports/SkFontMgr.h"
#include "ui/gfx/win/direct_write.h"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment