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 <dwrite.h> | 7 #include <dwrite.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
14 #include "base/win/scoped_comptr.h" | 14 #include "base/win/scoped_comptr.h" |
15 #include "base/win/win_util.h" | 15 #include "base/win/win_util.h" |
16 #include "base/win/windows_version.h" | 16 #include "base/win/windows_version.h" |
17 #include "content/child/dwrite_font_proxy/dwrite_font_proxy_init_win.h" | 17 #include "content/child/dwrite_font_proxy/dwrite_font_proxy_init_win.h" |
18 #include "content/child/font_warmup_win.h" | 18 #include "content/child/font_warmup_win.h" |
19 #include "content/public/common/content_switches.h" | 19 #include "content/public/common/content_switches.h" |
20 #include "content/public/common/injection_test_win.h" | 20 #include "content/public/common/injection_test_win.h" |
21 #include "content/public/renderer/render_thread.h" | 21 #include "content/public/renderer/render_thread.h" |
22 #include "content/renderer/render_thread_impl.h" | 22 #include "content/renderer/render_thread_impl.h" |
23 #include "sandbox/win/src/sandbox.h" | 23 #include "sandbox/win/src/sandbox.h" |
24 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" | 24 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" |
25 #include "third_party/WebKit/public/web/win/WebFontRendering.h" | 25 #include "third_party/WebKit/public/web/win/WebFontRendering.h" |
26 #include "third_party/icu/source/i18n/unicode/timezone.h" | 26 #include "third_party/icu/source/i18n/unicode/timezone.h" |
27 #include "third_party/skia/include/ports/SkTypeface_win.h" | 27 #include "third_party/skia/include/ports/SkTypeface_win.h" |
| 28 #include "ui/display/win/dpi.h" |
28 #include "ui/gfx/win/direct_write.h" | 29 #include "ui/gfx/win/direct_write.h" |
29 #include "ui/gfx/win/dpi.h" | |
30 | 30 |
31 namespace content { | 31 namespace content { |
32 namespace { | 32 namespace { |
33 | 33 |
34 // Windows-only skia sandbox support | 34 // Windows-only skia sandbox support |
35 // These are used for GDI-path rendering. | 35 // These are used for GDI-path rendering. |
36 void SkiaPreCacheFont(const LOGFONT& logfont) { | 36 void SkiaPreCacheFont(const LOGFONT& logfont) { |
37 RenderThread* render_thread = RenderThread::Get(); | 37 RenderThread* render_thread = RenderThread::Get(); |
38 if (render_thread) { | 38 if (render_thread) { |
39 render_thread->PreCacheFont(logfont); | 39 render_thread->PreCacheFont(logfont); |
(...skipping 28 matching lines...) Expand all Loading... |
68 // is disabled, we don't have to make this dummy call. | 68 // is disabled, we don't have to make this dummy call. |
69 std::unique_ptr<icu::TimeZone> zone(icu::TimeZone::createDefault()); | 69 std::unique_ptr<icu::TimeZone> zone(icu::TimeZone::createDefault()); |
70 | 70 |
71 if (use_direct_write) { | 71 if (use_direct_write) { |
72 InitializeDWriteFontProxy(); | 72 InitializeDWriteFontProxy(); |
73 } else { | 73 } else { |
74 SkTypeface_SetEnsureLOGFONTAccessibleProc(SkiaPreCacheFont); | 74 SkTypeface_SetEnsureLOGFONTAccessibleProc(SkiaPreCacheFont); |
75 } | 75 } |
76 } | 76 } |
77 blink::WebFontRendering::setUseDirectWrite(use_direct_write); | 77 blink::WebFontRendering::setUseDirectWrite(use_direct_write); |
78 blink::WebFontRendering::setDeviceScaleFactor(gfx::GetDPIScale()); | 78 // TODO(robliao): This should use WebScreenInfo. See http://crbug.com/604555. |
| 79 blink::WebFontRendering::setDeviceScaleFactor(display::win::GetDPIScale()); |
79 } | 80 } |
80 | 81 |
81 void RendererMainPlatformDelegate::PlatformUninitialize() { | 82 void RendererMainPlatformDelegate::PlatformUninitialize() { |
82 UninitializeDWriteFontProxy(); | 83 UninitializeDWriteFontProxy(); |
83 } | 84 } |
84 | 85 |
85 bool RendererMainPlatformDelegate::EnableSandbox() { | 86 bool RendererMainPlatformDelegate::EnableSandbox() { |
86 sandbox::TargetServices* target_services = | 87 sandbox::TargetServices* target_services = |
87 parameters_.sandbox_info->target_services; | 88 parameters_.sandbox_info->target_services; |
88 | 89 |
89 if (target_services) { | 90 if (target_services) { |
90 // Cause advapi32 to load before the sandbox is turned on. | 91 // Cause advapi32 to load before the sandbox is turned on. |
91 unsigned int dummy_rand; | 92 unsigned int dummy_rand; |
92 rand_s(&dummy_rand); | 93 rand_s(&dummy_rand); |
93 | 94 |
94 target_services->LowerToken(); | 95 target_services->LowerToken(); |
95 return true; | 96 return true; |
96 } | 97 } |
97 return false; | 98 return false; |
98 } | 99 } |
99 | 100 |
100 } // namespace content | 101 } // namespace content |
OLD | NEW |