diff --git a/cef.gyp b/cef.gyp index 99fea4a75..ef4d8e7dc 100644 --- a/cef.gyp +++ b/cef.gyp @@ -1255,6 +1255,9 @@ '<(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.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': [ ['OS=="win"', { @@ -1276,13 +1279,15 @@ '<(DEPTH)/chrome/browser/printing/pdf_to_emf_converter.cc', '<(DEPTH)/chrome/browser/printing/pdf_to_emf_converter.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"', { 'sources': [ '<@(includes_mac)', 'libcef/browser/browser_host_impl_mac.mm', - 'libcef/browser/browser_main_mac.mm', 'libcef/browser/javascript_dialog_mac.mm', 'libcef/browser/menu_creator_runner_mac.h', 'libcef/browser/menu_creator_runner_mac.mm', @@ -1307,7 +1312,6 @@ 'sources': [ '<@(includes_linux)', 'libcef/browser/browser_host_impl_linux.cc', - 'libcef/browser/browser_main_linux.cc', 'libcef/browser/javascript_dialog_linux.cc', 'libcef/browser/menu_creator_runner_linux.cc', 'libcef/browser/menu_creator_runner_linux.h', diff --git a/libcef/browser/browser_main.cc b/libcef/browser/browser_main.cc index 9015c861a..2b4803bf0 100644 --- a/libcef/browser/browser_main.cc +++ b/libcef/browser/browser_main.cc @@ -99,7 +99,10 @@ void CefBrowserMainParts::PostMainMessageLoopStart() { } int CefBrowserMainParts::PreCreateThreads() { +#if defined(OS_WIN) PlatformInitialize(); +#endif + net::NetModule::SetResourceProvider(&NetResourceProvider); // 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; } } + +#if defined(OS_WIN) + PlatformPreMainMessageLoopRun(); +#endif } void CefBrowserMainParts::PostMainMessageLoopRun() { @@ -166,6 +173,4 @@ void CefBrowserMainParts::PostDestroyThreads() { // No CefURLRequestContext instances should exist at this point. DCHECK_EQ(0, CefURLRequestContext::DebugObjCt); #endif - - PlatformCleanup(); } diff --git a/libcef/browser/browser_main.h b/libcef/browser/browser_main.h index 00e05b8aa..56dfd70be 100644 --- a/libcef/browser/browser_main.h +++ b/libcef/browser/browser_main.h @@ -52,8 +52,10 @@ class CefBrowserMainParts : public content::BrowserMainParts { PrefService* pref_service() const { return pref_service_.get(); } private: +#if defined(OS_WIN) void PlatformInitialize(); - void PlatformCleanup(); + void PlatformPreMainMessageLoopRun(); +#endif // defined(OS_WIN) scoped_refptr global_browser_context_; CefDevToolsDelegate* devtools_delegate_; // Deletes itself. diff --git a/libcef/browser/browser_main_linux.cc b/libcef/browser/browser_main_linux.cc deleted file mode 100644 index d9b14a323..000000000 --- a/libcef/browser/browser_main_linux.cc +++ /dev/null @@ -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() { -} diff --git a/libcef/browser/browser_main_mac.mm b/libcef/browser/browser_main_mac.mm deleted file mode 100644 index d9b14a323..000000000 --- a/libcef/browser/browser_main_mac.mm +++ /dev/null @@ -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() { -} diff --git a/libcef/browser/browser_main_win.cc b/libcef/browser/browser_main_win.cc index 094f2202f..056a8afc7 100644 --- a/libcef/browser/browser_main_win.cc +++ b/libcef/browser/browser_main_win.cc @@ -9,6 +9,28 @@ #include "libcef/browser/browser_host_impl.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 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() { HRESULT res; @@ -28,5 +50,38 @@ void CefBrowserMainParts::PlatformInitialize() { 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)); + } + } } diff --git a/libcef/common/cef_message_generator.cc b/libcef/common/cef_message_generator.cc index 6e16dc1d4..dd6ffb9c3 100644 --- a/libcef/common/cef_message_generator.cc +++ b/libcef/common/cef_message_generator.cc @@ -8,26 +8,31 @@ // Generate constructors. #include "ipc/struct_constructor_macros.h" +#include "chrome/common/safe_browsing/ipc_protobuf_message_null_macros.h" #include "libcef/common/cef_message_generator.h" // Generate destructors. #include "ipc/struct_destructor_macros.h" +#include "chrome/common/safe_browsing/ipc_protobuf_message_null_macros.h" #include "libcef/common/cef_message_generator.h" // Generate param traits write methods. #include "ipc/param_traits_write_macros.h" +#include "chrome/common/safe_browsing/protobuf_message_write_macros.h" namespace IPC { #include "libcef/common/cef_message_generator.h" } // namespace IPC // Generate param traits read methods. #include "ipc/param_traits_read_macros.h" +#include "chrome/common/safe_browsing/protobuf_message_read_macros.h" namespace IPC { #include "libcef/common/cef_message_generator.h" } // namespace IPC // Generate param traits log methods. #include "ipc/param_traits_log_macros.h" +#include "chrome/common/safe_browsing/protobuf_message_log_macros.h" namespace IPC { #include "libcef/common/cef_message_generator.h" } // namespace IPC diff --git a/libcef/common/cef_message_generator.h b/libcef/common/cef_message_generator.h index 124361160..446d47444 100644 --- a/libcef/common/cef_message_generator.h +++ b/libcef/common/cef_message_generator.h @@ -5,3 +5,10 @@ // Multiply-included file, hence no include guard. #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 diff --git a/libcef/common/cef_messages.h b/libcef/common/cef_messages.h index b29943399..f5b501b89 100644 --- a/libcef/common/cef_messages.h +++ b/libcef/common/cef_messages.h @@ -218,9 +218,3 @@ struct ParamTraits > { } // namespace IPC #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 diff --git a/libcef/resources/cef_strings.grd b/libcef/resources/cef_strings.grd index b8967af54..98a5a9226 100644 --- a/libcef/resources/cef_strings.grd +++ b/libcef/resources/cef_strings.grd @@ -349,6 +349,13 @@ need to be translated for each locale.--> &No spelling suggestions + + + + + DirectWrite Font Cache Builder + + diff --git a/libcef/utility/content_utility_client.cc b/libcef/utility/content_utility_client.cc index 5b9681eef..918c335bb 100644 --- a/libcef/utility/content_utility_client.cc +++ b/libcef/utility/content_utility_client.cc @@ -13,6 +13,7 @@ #if defined(OS_WIN) #include "libcef/utility/printing_handler.h" +#include "chrome/utility/font_cache_handler_win.h" #endif namespace { @@ -35,6 +36,7 @@ void CreateProxyResolverFactory( CefContentUtilityClient::CefContentUtilityClient() { #if defined(OS_WIN) handlers_.push_back(new PrintingHandler()); + handlers_.push_back(new FontCacheHandler()); #endif }