| 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 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 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/display/win/dpi.h" |
| 29 #include "ui/gfx/win/direct_write.h" | 29 #include "ui/gfx/win/direct_write.h" |
| 30 | 30 |
| 31 namespace content { | 31 namespace content { |
| 32 | 32 |
| 33 namespace { |
| 34 |
| 35 // Helper function to cast RenderThread to IPC::Sender so we can Bind() |
| 36 // it. |
| 37 IPC::Sender* GetRenderThreadSender() { |
| 38 return RenderThread::Get(); |
| 39 } |
| 40 |
| 41 } // namespace |
| 42 |
| 33 RendererMainPlatformDelegate::RendererMainPlatformDelegate( | 43 RendererMainPlatformDelegate::RendererMainPlatformDelegate( |
| 34 const MainFunctionParams& parameters) | 44 const MainFunctionParams& parameters) |
| 35 : parameters_(parameters) {} | 45 : parameters_(parameters) {} |
| 36 | 46 |
| 37 RendererMainPlatformDelegate::~RendererMainPlatformDelegate() { | 47 RendererMainPlatformDelegate::~RendererMainPlatformDelegate() { |
| 38 } | 48 } |
| 39 | 49 |
| 40 void RendererMainPlatformDelegate::PlatformInitialize() { | 50 void RendererMainPlatformDelegate::PlatformInitialize() { |
| 41 const base::CommandLine& command_line = parameters_.command_line; | 51 const base::CommandLine& command_line = parameters_.command_line; |
| 42 | 52 |
| 43 // Be mindful of what resources you acquire here. They can be used by | 53 // Be mindful of what resources you acquire here. They can be used by |
| 44 // malicious code if the renderer gets compromised. | 54 // malicious code if the renderer gets compromised. |
| 45 bool no_sandbox = command_line.HasSwitch(switches::kNoSandbox); | 55 bool no_sandbox = command_line.HasSwitch(switches::kNoSandbox); |
| 46 | 56 |
| 47 if (!no_sandbox) { | 57 if (!no_sandbox) { |
| 48 // ICU DateFormat class (used in base/time_format.cc) needs to get the | 58 // ICU DateFormat class (used in base/time_format.cc) needs to get the |
| 49 // Olson timezone ID by accessing the registry keys under | 59 // Olson timezone ID by accessing the registry keys under |
| 50 // HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones. | 60 // HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones. |
| 51 // After TimeZone::createDefault is called once here, the timezone ID is | 61 // After TimeZone::createDefault is called once here, the timezone ID is |
| 52 // cached and there's no more need to access the registry. If the sandbox | 62 // cached and there's no more need to access the registry. If the sandbox |
| 53 // is disabled, we don't have to make this dummy call. | 63 // is disabled, we don't have to make this dummy call. |
| 54 std::unique_ptr<icu::TimeZone> zone(icu::TimeZone::createDefault()); | 64 std::unique_ptr<icu::TimeZone> zone(icu::TimeZone::createDefault()); |
| 55 | 65 |
| 56 InitializeDWriteFontProxy(); | 66 InitializeDWriteFontProxy(base::Bind(&GetRenderThreadSender)); |
| 57 } | 67 } |
| 58 // TODO(robliao): This should use WebScreenInfo. See http://crbug.com/604555. | 68 // TODO(robliao): This should use WebScreenInfo. See http://crbug.com/604555. |
| 59 blink::WebFontRendering::setDeviceScaleFactor(display::win::GetDPIScale()); | 69 blink::WebFontRendering::setDeviceScaleFactor(display::win::GetDPIScale()); |
| 60 } | 70 } |
| 61 | 71 |
| 62 void RendererMainPlatformDelegate::PlatformUninitialize() { | 72 void RendererMainPlatformDelegate::PlatformUninitialize() { |
| 63 UninitializeDWriteFontProxy(); | 73 UninitializeDWriteFontProxy(); |
| 64 } | 74 } |
| 65 | 75 |
| 66 bool RendererMainPlatformDelegate::EnableSandbox() { | 76 bool RendererMainPlatformDelegate::EnableSandbox() { |
| 67 sandbox::TargetServices* target_services = | 77 sandbox::TargetServices* target_services = |
| 68 parameters_.sandbox_info->target_services; | 78 parameters_.sandbox_info->target_services; |
| 69 | 79 |
| 70 if (target_services) { | 80 if (target_services) { |
| 71 // Cause advapi32 to load before the sandbox is turned on. | 81 // Cause advapi32 to load before the sandbox is turned on. |
| 72 unsigned int dummy_rand; | 82 unsigned int dummy_rand; |
| 73 rand_s(&dummy_rand); | 83 rand_s(&dummy_rand); |
| 74 | 84 |
| 75 target_services->LowerToken(); | 85 target_services->LowerToken(); |
| 76 return true; | 86 return true; |
| 77 } | 87 } |
| 78 return false; | 88 return false; |
| 79 } | 89 } |
| 80 | 90 |
| 81 } // namespace content | 91 } // namespace content |
| OLD | NEW |