mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Windows: Add DirectWrite font cache support (issue #1652)
This commit is contained in:
8
cef.gyp
8
cef.gyp
@@ -1255,6 +1255,9 @@
|
|||||||
'<(DEPTH)/chrome/renderer/pepper/pepper_flash_menu_host.h',
|
'<(DEPTH)/chrome/renderer/pepper/pepper_flash_menu_host.h',
|
||||||
'<(DEPTH)/chrome/renderer/pepper/pepper_flash_renderer_host.cc',
|
'<(DEPTH)/chrome/renderer/pepper/pepper_flash_renderer_host.cc',
|
||||||
'<(DEPTH)/chrome/renderer/pepper/pepper_flash_renderer_host.h',
|
'<(DEPTH)/chrome/renderer/pepper/pepper_flash_renderer_host.h',
|
||||||
|
# Include sources required by chrome_utility_messages.h.
|
||||||
|
'<(DEPTH)/chrome/common/safe_browsing/zip_analyzer_results.h',
|
||||||
|
'<(DEPTH)/chrome/common/safe_browsing/zip_analyzer_results.cc',
|
||||||
],
|
],
|
||||||
'conditions': [
|
'conditions': [
|
||||||
['OS=="win"', {
|
['OS=="win"', {
|
||||||
@@ -1276,13 +1279,15 @@
|
|||||||
'<(DEPTH)/chrome/browser/printing/pdf_to_emf_converter.cc',
|
'<(DEPTH)/chrome/browser/printing/pdf_to_emf_converter.cc',
|
||||||
'<(DEPTH)/chrome/browser/printing/pdf_to_emf_converter.h',
|
'<(DEPTH)/chrome/browser/printing/pdf_to_emf_converter.h',
|
||||||
'<(DEPTH)/chrome/common/chrome_utility_printing_messages.h',
|
'<(DEPTH)/chrome/common/chrome_utility_printing_messages.h',
|
||||||
|
# Include sources for font cache.
|
||||||
|
'<(DEPTH)/chrome/utility/font_cache_handler_win.cc',
|
||||||
|
'<(DEPTH)/chrome/utility/font_cache_handler_win.h',
|
||||||
],
|
],
|
||||||
}],
|
}],
|
||||||
[ 'OS=="mac"', {
|
[ 'OS=="mac"', {
|
||||||
'sources': [
|
'sources': [
|
||||||
'<@(includes_mac)',
|
'<@(includes_mac)',
|
||||||
'libcef/browser/browser_host_impl_mac.mm',
|
'libcef/browser/browser_host_impl_mac.mm',
|
||||||
'libcef/browser/browser_main_mac.mm',
|
|
||||||
'libcef/browser/javascript_dialog_mac.mm',
|
'libcef/browser/javascript_dialog_mac.mm',
|
||||||
'libcef/browser/menu_creator_runner_mac.h',
|
'libcef/browser/menu_creator_runner_mac.h',
|
||||||
'libcef/browser/menu_creator_runner_mac.mm',
|
'libcef/browser/menu_creator_runner_mac.mm',
|
||||||
@@ -1307,7 +1312,6 @@
|
|||||||
'sources': [
|
'sources': [
|
||||||
'<@(includes_linux)',
|
'<@(includes_linux)',
|
||||||
'libcef/browser/browser_host_impl_linux.cc',
|
'libcef/browser/browser_host_impl_linux.cc',
|
||||||
'libcef/browser/browser_main_linux.cc',
|
|
||||||
'libcef/browser/javascript_dialog_linux.cc',
|
'libcef/browser/javascript_dialog_linux.cc',
|
||||||
'libcef/browser/menu_creator_runner_linux.cc',
|
'libcef/browser/menu_creator_runner_linux.cc',
|
||||||
'libcef/browser/menu_creator_runner_linux.h',
|
'libcef/browser/menu_creator_runner_linux.h',
|
||||||
|
@@ -99,7 +99,10 @@ void CefBrowserMainParts::PostMainMessageLoopStart() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int CefBrowserMainParts::PreCreateThreads() {
|
int CefBrowserMainParts::PreCreateThreads() {
|
||||||
|
#if defined(OS_WIN)
|
||||||
PlatformInitialize();
|
PlatformInitialize();
|
||||||
|
#endif
|
||||||
|
|
||||||
net::NetModule::SetResourceProvider(&NetResourceProvider);
|
net::NetModule::SetResourceProvider(&NetResourceProvider);
|
||||||
|
|
||||||
// Initialize the GpuDataManager before IO access restrictions are applied and
|
// Initialize the GpuDataManager before IO access restrictions are applied and
|
||||||
@@ -140,6 +143,10 @@ void CefBrowserMainParts::PreMainMessageLoopRun() {
|
|||||||
LOG(WARNING) << "Invalid http debugger port number " << port;
|
LOG(WARNING) << "Invalid http debugger port number " << port;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(OS_WIN)
|
||||||
|
PlatformPreMainMessageLoopRun();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void CefBrowserMainParts::PostMainMessageLoopRun() {
|
void CefBrowserMainParts::PostMainMessageLoopRun() {
|
||||||
@@ -166,6 +173,4 @@ void CefBrowserMainParts::PostDestroyThreads() {
|
|||||||
// No CefURLRequestContext instances should exist at this point.
|
// No CefURLRequestContext instances should exist at this point.
|
||||||
DCHECK_EQ(0, CefURLRequestContext::DebugObjCt);
|
DCHECK_EQ(0, CefURLRequestContext::DebugObjCt);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
PlatformCleanup();
|
|
||||||
}
|
}
|
||||||
|
@@ -52,8 +52,10 @@ class CefBrowserMainParts : public content::BrowserMainParts {
|
|||||||
PrefService* pref_service() const { return pref_service_.get(); }
|
PrefService* pref_service() const { return pref_service_.get(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
#if defined(OS_WIN)
|
||||||
void PlatformInitialize();
|
void PlatformInitialize();
|
||||||
void PlatformCleanup();
|
void PlatformPreMainMessageLoopRun();
|
||||||
|
#endif // defined(OS_WIN)
|
||||||
|
|
||||||
scoped_refptr<CefBrowserContextImpl> global_browser_context_;
|
scoped_refptr<CefBrowserContextImpl> global_browser_context_;
|
||||||
CefDevToolsDelegate* devtools_delegate_; // Deletes itself.
|
CefDevToolsDelegate* devtools_delegate_; // Deletes itself.
|
||||||
|
@@ -1,11 +0,0 @@
|
|||||||
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
|
||||||
// found in the LICENSE file.
|
|
||||||
|
|
||||||
#include "libcef/browser/browser_main.h"
|
|
||||||
|
|
||||||
void CefBrowserMainParts::PlatformInitialize() {
|
|
||||||
}
|
|
||||||
|
|
||||||
void CefBrowserMainParts::PlatformCleanup() {
|
|
||||||
}
|
|
@@ -1,11 +0,0 @@
|
|||||||
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
|
||||||
// found in the LICENSE file.
|
|
||||||
|
|
||||||
#include "libcef/browser/browser_main.h"
|
|
||||||
|
|
||||||
void CefBrowserMainParts::PlatformInitialize() {
|
|
||||||
}
|
|
||||||
|
|
||||||
void CefBrowserMainParts::PlatformCleanup() {
|
|
||||||
}
|
|
@@ -9,6 +9,28 @@
|
|||||||
#include "libcef/browser/browser_host_impl.h"
|
#include "libcef/browser/browser_host_impl.h"
|
||||||
#include "libcef/browser/browser_main.h"
|
#include "libcef/browser/browser_main.h"
|
||||||
|
|
||||||
|
#include "chrome/common/chrome_utility_messages.h"
|
||||||
|
#include "content/public/browser/utility_process_host.h"
|
||||||
|
#include "content/public/browser/utility_process_host_client.h"
|
||||||
|
#include "content/public/common/dwrite_font_platform_win.h"
|
||||||
|
#include "grit/cef_strings.h"
|
||||||
|
#include "ui/base/l10n/l10n_util.h"
|
||||||
|
#include "ui/gfx/win/direct_write.h"
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
void ExecuteFontCacheBuildTask(const base::FilePath& path) {
|
||||||
|
base::WeakPtr<content::UtilityProcessHost> utility_process_host(
|
||||||
|
content::UtilityProcessHost::Create(NULL, NULL)->AsWeakPtr());
|
||||||
|
utility_process_host->SetName(l10n_util::GetStringUTF16(
|
||||||
|
IDS_UTILITY_PROCESS_FONT_CACHE_BUILDER_NAME));
|
||||||
|
utility_process_host->DisableSandbox();
|
||||||
|
utility_process_host->Send(
|
||||||
|
new ChromeUtilityHostMsg_BuildDirectWriteFontCache(path));
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
void CefBrowserMainParts::PlatformInitialize() {
|
void CefBrowserMainParts::PlatformInitialize() {
|
||||||
HRESULT res;
|
HRESULT res;
|
||||||
|
|
||||||
@@ -28,5 +50,38 @@ void CefBrowserMainParts::PlatformInitialize() {
|
|||||||
CefBrowserHostImpl::RegisterWindowClass();
|
CefBrowserHostImpl::RegisterWindowClass();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CefBrowserMainParts::PlatformCleanup() {
|
void CefBrowserMainParts::PlatformPreMainMessageLoopRun() {
|
||||||
|
// From ChromeBrowserMainPartsWin::PostProfileInit().
|
||||||
|
// DirectWrite support is mainly available on Windows 7 and up.
|
||||||
|
if (gfx::win::ShouldUseDirectWrite()) {
|
||||||
|
const base::FilePath& cache_path = global_browser_context_->GetPath();
|
||||||
|
if (cache_path.empty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
const base::FilePath& font_cache_path =
|
||||||
|
cache_path.AppendASCII(content::kFontCacheSharedSectionName);
|
||||||
|
// This function will create a read only section if cache file exists
|
||||||
|
// otherwise it will spawn utility process to build cache file, which will
|
||||||
|
// be used during next browser start/postprofileinit.
|
||||||
|
if (!content::LoadFontCache(font_cache_path)) {
|
||||||
|
// We delay building of font cache until first startup page loads.
|
||||||
|
// During first renderer start there are lot of things happening
|
||||||
|
// simultaneously some of them are:
|
||||||
|
// - Renderer is going through all font files on the system to create
|
||||||
|
// a font collection.
|
||||||
|
// - Renderer loading up startup URL, accessing HTML/JS File cache,
|
||||||
|
// net activity etc.
|
||||||
|
// - Extension initialization.
|
||||||
|
// We delay building of cache mainly to avoid parallel font file
|
||||||
|
// loading along with Renderer. Some systems have significant number of
|
||||||
|
// font files which takes long time to process.
|
||||||
|
// Related information is at http://crbug.com/436195.
|
||||||
|
const int kBuildFontCacheDelaySec = 30;
|
||||||
|
content::BrowserThread::PostDelayedTask(
|
||||||
|
content::BrowserThread::IO,
|
||||||
|
FROM_HERE,
|
||||||
|
base::Bind(ExecuteFontCacheBuildTask, font_cache_path),
|
||||||
|
base::TimeDelta::FromSeconds(kBuildFontCacheDelaySec));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -8,26 +8,31 @@
|
|||||||
|
|
||||||
// Generate constructors.
|
// Generate constructors.
|
||||||
#include "ipc/struct_constructor_macros.h"
|
#include "ipc/struct_constructor_macros.h"
|
||||||
|
#include "chrome/common/safe_browsing/ipc_protobuf_message_null_macros.h"
|
||||||
#include "libcef/common/cef_message_generator.h"
|
#include "libcef/common/cef_message_generator.h"
|
||||||
|
|
||||||
// Generate destructors.
|
// Generate destructors.
|
||||||
#include "ipc/struct_destructor_macros.h"
|
#include "ipc/struct_destructor_macros.h"
|
||||||
|
#include "chrome/common/safe_browsing/ipc_protobuf_message_null_macros.h"
|
||||||
#include "libcef/common/cef_message_generator.h"
|
#include "libcef/common/cef_message_generator.h"
|
||||||
|
|
||||||
// Generate param traits write methods.
|
// Generate param traits write methods.
|
||||||
#include "ipc/param_traits_write_macros.h"
|
#include "ipc/param_traits_write_macros.h"
|
||||||
|
#include "chrome/common/safe_browsing/protobuf_message_write_macros.h"
|
||||||
namespace IPC {
|
namespace IPC {
|
||||||
#include "libcef/common/cef_message_generator.h"
|
#include "libcef/common/cef_message_generator.h"
|
||||||
} // namespace IPC
|
} // namespace IPC
|
||||||
|
|
||||||
// Generate param traits read methods.
|
// Generate param traits read methods.
|
||||||
#include "ipc/param_traits_read_macros.h"
|
#include "ipc/param_traits_read_macros.h"
|
||||||
|
#include "chrome/common/safe_browsing/protobuf_message_read_macros.h"
|
||||||
namespace IPC {
|
namespace IPC {
|
||||||
#include "libcef/common/cef_message_generator.h"
|
#include "libcef/common/cef_message_generator.h"
|
||||||
} // namespace IPC
|
} // namespace IPC
|
||||||
|
|
||||||
// Generate param traits log methods.
|
// Generate param traits log methods.
|
||||||
#include "ipc/param_traits_log_macros.h"
|
#include "ipc/param_traits_log_macros.h"
|
||||||
|
#include "chrome/common/safe_browsing/protobuf_message_log_macros.h"
|
||||||
namespace IPC {
|
namespace IPC {
|
||||||
#include "libcef/common/cef_message_generator.h"
|
#include "libcef/common/cef_message_generator.h"
|
||||||
} // namespace IPC
|
} // namespace IPC
|
||||||
|
@@ -5,3 +5,10 @@
|
|||||||
// Multiply-included file, hence no include guard.
|
// Multiply-included file, hence no include guard.
|
||||||
|
|
||||||
#include "libcef/common/cef_messages.h"
|
#include "libcef/common/cef_messages.h"
|
||||||
|
|
||||||
|
#include "chrome/common/chrome_utility_messages.h"
|
||||||
|
#include "chrome/common/spellcheck_messages.h"
|
||||||
|
|
||||||
|
#if defined(OS_WIN)
|
||||||
|
#include "chrome/common/chrome_utility_printing_messages.h"
|
||||||
|
#endif
|
||||||
|
@@ -218,9 +218,3 @@ struct ParamTraits<scoped_refptr<net::UploadData> > {
|
|||||||
} // namespace IPC
|
} // namespace IPC
|
||||||
|
|
||||||
#endif // CEF_LIBCEF_COMMON_CEF_MESSAGES_H_
|
#endif // CEF_LIBCEF_COMMON_CEF_MESSAGES_H_
|
||||||
|
|
||||||
#include "chrome/common/spellcheck_messages.h"
|
|
||||||
|
|
||||||
#if defined(OS_WIN)
|
|
||||||
#include "chrome/common/chrome_utility_printing_messages.h"
|
|
||||||
#endif
|
|
||||||
|
@@ -349,6 +349,13 @@ need to be translated for each locale.-->
|
|||||||
<message name="IDS_CONTENT_CONTEXT_NO_SPELLING_SUGGESTIONS" desc="The name of the No Spelling Suggestions display in the content area context menu">
|
<message name="IDS_CONTENT_CONTEXT_NO_SPELLING_SUGGESTIONS" desc="The name of the No Spelling Suggestions display in the content area context menu">
|
||||||
&No spelling suggestions
|
&No spelling suggestions
|
||||||
</message>
|
</message>
|
||||||
|
|
||||||
|
<!-- Font cache -->
|
||||||
|
<if expr="is_win">
|
||||||
|
<message name="IDS_UTILITY_PROCESS_FONT_CACHE_BUILDER_NAME" desc="The name of the utility process used for building the DirectWrite font cache.">
|
||||||
|
DirectWrite Font Cache Builder
|
||||||
|
</message>
|
||||||
|
</if>
|
||||||
</messages>
|
</messages>
|
||||||
</release>
|
</release>
|
||||||
</grit>
|
</grit>
|
||||||
|
@@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
#if defined(OS_WIN)
|
#if defined(OS_WIN)
|
||||||
#include "libcef/utility/printing_handler.h"
|
#include "libcef/utility/printing_handler.h"
|
||||||
|
#include "chrome/utility/font_cache_handler_win.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
@@ -35,6 +36,7 @@ void CreateProxyResolverFactory(
|
|||||||
CefContentUtilityClient::CefContentUtilityClient() {
|
CefContentUtilityClient::CefContentUtilityClient() {
|
||||||
#if defined(OS_WIN)
|
#if defined(OS_WIN)
|
||||||
handlers_.push_back(new PrintingHandler());
|
handlers_.push_back(new PrintingHandler());
|
||||||
|
handlers_.push_back(new FontCacheHandler());
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user