| 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 "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/strings/string16.h" | 12 #include "base/strings/string16.h" |
| 13 #include "base/win/scoped_comptr.h" | 13 #include "base/win/scoped_comptr.h" |
| 14 #include "base/win/win_util.h" | 14 #include "base/win/win_util.h" |
| 15 #include "base/win/windows_version.h" | 15 #include "base/win/windows_version.h" |
| 16 #include "content/child/dwrite_font_proxy/dwrite_font_proxy_init_win.h" | 16 #include "content/child/dwrite_font_proxy/dwrite_font_proxy_init_win.h" |
| 17 #include "content/child/font_warmup_win.h" | 17 #include "content/child/font_warmup_win.h" |
| 18 #include "content/public/common/content_switches.h" | 18 #include "content/public/common/content_switches.h" |
| 19 #include "content/public/common/dwrite_font_platform_win.h" | |
| 20 #include "content/public/common/injection_test_win.h" | 19 #include "content/public/common/injection_test_win.h" |
| 21 #include "content/public/renderer/render_thread.h" | 20 #include "content/public/renderer/render_thread.h" |
| 22 #include "content/renderer/render_thread_impl.h" | 21 #include "content/renderer/render_thread_impl.h" |
| 23 #include "sandbox/win/src/sandbox.h" | 22 #include "sandbox/win/src/sandbox.h" |
| 24 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" | 23 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" |
| 25 #include "third_party/WebKit/public/web/win/WebFontRendering.h" | 24 #include "third_party/WebKit/public/web/win/WebFontRendering.h" |
| 26 #include "third_party/icu/source/i18n/unicode/timezone.h" | 25 #include "third_party/icu/source/i18n/unicode/timezone.h" |
| 27 #include "third_party/skia/include/ports/SkTypeface_win.h" | 26 #include "third_party/skia/include/ports/SkTypeface_win.h" |
| 28 #include "ui/gfx/win/direct_write.h" | 27 #include "ui/gfx/win/direct_write.h" |
| 29 #include "ui/gfx/win/dpi.h" | 28 #include "ui/gfx/win/dpi.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 if (!no_sandbox) { | 67 if (!no_sandbox) { |
| 69 // ICU DateFormat class (used in base/time_format.cc) needs to get the | 68 // ICU DateFormat class (used in base/time_format.cc) needs to get the |
| 70 // Olson timezone ID by accessing the registry keys under | 69 // Olson timezone ID by accessing the registry keys under |
| 71 // HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones. | 70 // HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones. |
| 72 // After TimeZone::createDefault is called once here, the timezone ID is | 71 // After TimeZone::createDefault is called once here, the timezone ID is |
| 73 // cached and there's no more need to access the registry. If the sandbox | 72 // cached and there's no more need to access the registry. If the sandbox |
| 74 // is disabled, we don't have to make this dummy call. | 73 // is disabled, we don't have to make this dummy call. |
| 75 scoped_ptr<icu::TimeZone> zone(icu::TimeZone::createDefault()); | 74 scoped_ptr<icu::TimeZone> zone(icu::TimeZone::createDefault()); |
| 76 | 75 |
| 77 if (use_direct_write) { | 76 if (use_direct_write) { |
| 78 if (ShouldUseDirectWriteFontProxyFieldTrial()) | 77 InitializeDWriteFontProxy(base::Bind(&GetRenderThreadSender)); |
| 79 InitializeDWriteFontProxy(base::Bind(&GetRenderThreadSender)); | |
| 80 else | |
| 81 WarmupDirectWrite(); | |
| 82 } else { | 78 } else { |
| 83 SkTypeface_SetEnsureLOGFONTAccessibleProc(SkiaPreCacheFont); | 79 SkTypeface_SetEnsureLOGFONTAccessibleProc(SkiaPreCacheFont); |
| 84 } | 80 } |
| 85 } | 81 } |
| 86 blink::WebFontRendering::setUseDirectWrite(use_direct_write); | 82 blink::WebFontRendering::setUseDirectWrite(use_direct_write); |
| 87 blink::WebFontRendering::setDeviceScaleFactor(gfx::GetDPIScale()); | 83 blink::WebFontRendering::setDeviceScaleFactor(gfx::GetDPIScale()); |
| 88 } | 84 } |
| 89 | 85 |
| 90 void RendererMainPlatformDelegate::PlatformUninitialize() { | 86 void RendererMainPlatformDelegate::PlatformUninitialize() { |
| 91 if (ShouldUseDirectWriteFontProxyFieldTrial()) | 87 UninitializeDWriteFontProxy(); |
| 92 UninitializeDWriteFontProxy(); | |
| 93 } | 88 } |
| 94 | 89 |
| 95 bool RendererMainPlatformDelegate::EnableSandbox() { | 90 bool RendererMainPlatformDelegate::EnableSandbox() { |
| 96 sandbox::TargetServices* target_services = | 91 sandbox::TargetServices* target_services = |
| 97 parameters_.sandbox_info->target_services; | 92 parameters_.sandbox_info->target_services; |
| 98 | 93 |
| 99 if (target_services) { | 94 if (target_services) { |
| 100 // Cause advapi32 to load before the sandbox is turned on. | 95 // Cause advapi32 to load before the sandbox is turned on. |
| 101 unsigned int dummy_rand; | 96 unsigned int dummy_rand; |
| 102 rand_s(&dummy_rand); | 97 rand_s(&dummy_rand); |
| 103 | 98 |
| 104 target_services->LowerToken(); | 99 target_services->LowerToken(); |
| 105 return true; | 100 return true; |
| 106 } | 101 } |
| 107 return false; | 102 return false; |
| 108 } | 103 } |
| 109 | 104 |
| 110 } // namespace content | 105 } // namespace content |
| OLD | NEW |