Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/renderer/renderer_main_platform_delegate.h" | 5 #include "content/renderer/renderer_main_platform_delegate.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
| 11 #include "base/win/win_util.h" | 11 #include "base/win/win_util.h" |
| 12 #include "content/public/common/content_switches.h" | 12 #include "content/public/common/content_switches.h" |
| 13 #include "content/public/common/injection_test_win.h" | 13 #include "content/public/common/injection_test_win.h" |
| 14 #include "content/public/renderer/render_thread.h" | 14 #include "content/public/renderer/render_thread.h" |
| 15 #include "content/renderer/render_thread_impl.h" | 15 #include "content/renderer/render_thread_impl.h" |
| 16 #include "sandbox/win/src/sandbox.h" | 16 #include "sandbox/win/src/sandbox.h" |
| 17 #include "skia/ext/vector_platform_device_emf_win.h" | 17 #include "skia/ext/vector_platform_device_emf_win.h" |
| 18 #include "third_party/icu/source/i18n/unicode/timezone.h" | 18 #include "third_party/icu/source/i18n/unicode/timezone.h" |
| 19 #include "third_party/skia/include/ports/SkTypeface_win.h" | 19 #include "third_party/skia/include/ports/SkTypeface_win.h" |
| 20 #include "third_party/skia/include/ports/SkFontMgr.h" | |
| 20 | 21 |
| 21 #ifdef ENABLE_VTUNE_JIT_INTERFACE | 22 #ifdef ENABLE_VTUNE_JIT_INTERFACE |
| 22 #include "v8/src/third_party/vtune/v8-vtune.h" | 23 #include "v8/src/third_party/vtune/v8-vtune.h" |
| 23 #endif | 24 #endif |
| 24 | 25 |
| 25 namespace content { | 26 namespace content { |
| 26 namespace { | 27 namespace { |
| 27 | 28 |
| 28 // Windows-only skia sandbox support | 29 // Windows-only skia sandbox support |
| 29 void SkiaPreCacheFont(const LOGFONT& logfont) { | 30 void SkiaPreCacheFont(const LOGFONT& logfont) { |
| 30 RenderThread* render_thread = RenderThread::Get(); | 31 RenderThread* render_thread = RenderThread::Get(); |
| 31 if (render_thread) { | 32 if (render_thread) { |
| 32 render_thread->PreCacheFont(logfont); | 33 render_thread->PreCacheFont(logfont); |
| 33 } | 34 } |
| 34 } | 35 } |
| 35 | 36 |
| 36 void SkiaPreCacheFontCharacters(const LOGFONT& logfont, | 37 void SkiaPreCacheFontCharacters(const LOGFONT& logfont, |
| 37 const wchar_t* text, | 38 const wchar_t* text, |
| 38 unsigned int text_length) { | 39 unsigned int text_length) { |
| 39 RenderThreadImpl* render_thread_impl = RenderThreadImpl::current(); | 40 RenderThreadImpl* render_thread_impl = RenderThreadImpl::current(); |
| 40 if (render_thread_impl) { | 41 if (render_thread_impl) { |
| 41 render_thread_impl->PreCacheFontCharacters( | 42 render_thread_impl->PreCacheFontCharacters( |
| 42 logfont, | 43 logfont, |
| 43 base::string16(text, text_length)); | 44 base::string16(text, text_length)); |
| 44 } | 45 } |
| 45 } | 46 } |
| 46 | 47 |
| 48 SkFontMgr* gBeforeSandboxSkFontMgr; | |
| 49 | |
| 47 } // namespace | 50 } // namespace |
| 48 | 51 |
| 49 RendererMainPlatformDelegate::RendererMainPlatformDelegate( | 52 RendererMainPlatformDelegate::RendererMainPlatformDelegate( |
| 50 const MainFunctionParams& parameters) | 53 const MainFunctionParams& parameters) |
| 51 : parameters_(parameters), | 54 : parameters_(parameters), |
| 52 sandbox_test_module_(NULL) { | 55 sandbox_test_module_(NULL) { |
| 53 } | 56 } |
| 54 | 57 |
| 55 RendererMainPlatformDelegate::~RendererMainPlatformDelegate() { | 58 RendererMainPlatformDelegate::~RendererMainPlatformDelegate() { |
| 56 } | 59 } |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 71 // ICU DateFormat class (used in base/time_format.cc) needs to get the | 74 // ICU DateFormat class (used in base/time_format.cc) needs to get the |
| 72 // Olson timezone ID by accessing the registry keys under | 75 // Olson timezone ID by accessing the registry keys under |
| 73 // HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones. | 76 // HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones. |
| 74 // After TimeZone::createDefault is called once here, the timezone ID is | 77 // After TimeZone::createDefault is called once here, the timezone ID is |
| 75 // cached and there's no more need to access the registry. If the sandbox | 78 // cached and there's no more need to access the registry. If the sandbox |
| 76 // is disabled, we don't have to make this dummy call. | 79 // is disabled, we don't have to make this dummy call. |
| 77 scoped_ptr<icu::TimeZone> zone(icu::TimeZone::createDefault()); | 80 scoped_ptr<icu::TimeZone> zone(icu::TimeZone::createDefault()); |
| 78 SkTypeface_SetEnsureLOGFONTAccessibleProc(SkiaPreCacheFont); | 81 SkTypeface_SetEnsureLOGFONTAccessibleProc(SkiaPreCacheFont); |
| 79 skia::SetSkiaEnsureTypefaceCharactersAccessible( | 82 skia::SetSkiaEnsureTypefaceCharactersAccessible( |
| 80 SkiaPreCacheFontCharacters); | 83 SkiaPreCacheFontCharacters); |
| 84 | |
| 85 // DirectWrite warmup. | |
| 86 gBeforeSandboxSkFontMgr = SkFontMgr_New_DirectWrite(); // Leaked. | |
|
scottmg
2014/03/21 23:04:06
Still working on simplifying this; we can call the
| |
| 87 | |
| 88 SkTypeface* typeface = gBeforeSandboxSkFontMgr->legacyCreateTypeface("Arial" , 0); | |
| 89 | |
| 90 SkPaint paint_warmup; | |
| 91 paint_warmup.setTextSize(12); | |
| 92 paint_warmup.setTypeface(typeface); | |
| 93 paint_warmup.setFakeBoldText(false); | |
| 94 paint_warmup.setTextSkewX(0); | |
| 95 paint_warmup.setSubpixelText(true); | |
| 96 static const uint32_t textFlagsMask = SkPaint::kAntiAlias_Flag | | |
| 97 SkPaint::kLCDRenderText_Flag | | |
| 98 SkPaint::kGenA8FromLCD_Flag; | |
| 99 paint_warmup.setFlags(textFlagsMask); | |
| 100 wchar_t glyph = 91; | |
| 101 paint_warmup.measureText(&glyph, 2); | |
| 81 } | 102 } |
| 82 } | 103 } |
| 83 | 104 |
| 84 void RendererMainPlatformDelegate::PlatformUninitialize() { | 105 void RendererMainPlatformDelegate::PlatformUninitialize() { |
| 85 } | 106 } |
| 86 | 107 |
| 87 bool RendererMainPlatformDelegate::InitSandboxTests(bool no_sandbox) { | 108 bool RendererMainPlatformDelegate::InitSandboxTests(bool no_sandbox) { |
| 88 const CommandLine& command_line = parameters_.command_line; | 109 const CommandLine& command_line = parameters_.command_line; |
| 89 | 110 |
| 90 DVLOG(1) << "Started renderer with " << command_line.GetCommandLineString(); | 111 DVLOG(1) << "Started renderer with " << command_line.GetCommandLineString(); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 133 if (run_security_tests) { | 154 if (run_security_tests) { |
| 134 int test_count = 0; | 155 int test_count = 0; |
| 135 DVLOG(1) << "Running renderer security tests"; | 156 DVLOG(1) << "Running renderer security tests"; |
| 136 BOOL result = run_security_tests(&test_count); | 157 BOOL result = run_security_tests(&test_count); |
| 137 CHECK(result) << "Test number " << test_count << " has failed."; | 158 CHECK(result) << "Test number " << test_count << " has failed."; |
| 138 } | 159 } |
| 139 } | 160 } |
| 140 } | 161 } |
| 141 | 162 |
| 142 } // namespace content | 163 } // namespace content |
| OLD | NEW |