Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(170)

Side by Side Diff: content/renderer/renderer_main_platform_delegate_win.cc

Issue 1851213002: Remove sandbox on Windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix nacl compile issues Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/injection_test_win.h" 19 #include "content/public/common/injection_test_win.h"
20 #include "content/public/renderer/render_thread.h" 20 #include "content/public/renderer/render_thread.h"
21 #include "content/renderer/render_thread_impl.h" 21 #include "content/renderer/render_thread_impl.h"
22 #include "sandbox/win/src/sandbox.h"
23 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" 22 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h"
24 #include "third_party/WebKit/public/web/win/WebFontRendering.h" 23 #include "third_party/WebKit/public/web/win/WebFontRendering.h"
25 #include "third_party/icu/source/i18n/unicode/timezone.h" 24 #include "third_party/icu/source/i18n/unicode/timezone.h"
26 #include "third_party/skia/include/ports/SkTypeface_win.h" 25 #include "third_party/skia/include/ports/SkTypeface_win.h"
27 #include "ui/gfx/win/direct_write.h" 26 #include "ui/gfx/win/direct_write.h"
28 #include "ui/gfx/win/dpi.h" 27 #include "ui/gfx/win/dpi.h"
29 28
30 namespace content { 29 namespace content {
31 namespace {
32
33 // Windows-only skia sandbox support
34 // These are used for GDI-path rendering.
35 void SkiaPreCacheFont(const LOGFONT& logfont) {
36 RenderThread* render_thread = RenderThread::Get();
37 if (render_thread) {
38 render_thread->PreCacheFont(logfont);
39 }
40 }
41
42 } // namespace
43 30
44 RendererMainPlatformDelegate::RendererMainPlatformDelegate( 31 RendererMainPlatformDelegate::RendererMainPlatformDelegate(
45 const MainFunctionParams& parameters) 32 const MainFunctionParams& parameters)
46 : parameters_(parameters), 33 : parameters_(parameters),
47 sandbox_test_module_(NULL) { 34 sandbox_test_module_(NULL) {
48 } 35 }
49 36
50 RendererMainPlatformDelegate::~RendererMainPlatformDelegate() { 37 RendererMainPlatformDelegate::~RendererMainPlatformDelegate() {
51 } 38 }
52 39
53 void RendererMainPlatformDelegate::PlatformInitialize() { 40 void RendererMainPlatformDelegate::PlatformInitialize() {
54 const base::CommandLine& command_line = parameters_.command_line;
55
56 // Be mindful of what resources you acquire here. They can be used by 41 // Be mindful of what resources you acquire here. They can be used by
57 // malicious code if the renderer gets compromised. 42 // malicious code if the renderer gets compromised.
58 bool no_sandbox = command_line.HasSwitch(switches::kNoSandbox);
59 43
60 bool use_direct_write = gfx::win::ShouldUseDirectWrite(); 44 bool use_direct_write = gfx::win::ShouldUseDirectWrite();
61 if (!no_sandbox) {
62 // ICU DateFormat class (used in base/time_format.cc) needs to get the
63 // Olson timezone ID by accessing the registry keys under
64 // HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones.
65 // After TimeZone::createDefault is called once here, the timezone ID is
66 // cached and there's no more need to access the registry. If the sandbox
67 // is disabled, we don't have to make this dummy call.
68 scoped_ptr<icu::TimeZone> zone(icu::TimeZone::createDefault());
69
70 if (use_direct_write) {
71 InitializeDWriteFontProxy();
72 } else {
73 SkTypeface_SetEnsureLOGFONTAccessibleProc(SkiaPreCacheFont);
74 }
75 }
76 blink::WebFontRendering::setUseDirectWrite(use_direct_write); 45 blink::WebFontRendering::setUseDirectWrite(use_direct_write);
77 blink::WebFontRendering::setDeviceScaleFactor(gfx::GetDPIScale()); 46 blink::WebFontRendering::setDeviceScaleFactor(gfx::GetDPIScale());
78 } 47 }
79 48
80 void RendererMainPlatformDelegate::PlatformUninitialize() { 49 void RendererMainPlatformDelegate::PlatformUninitialize() {
81 UninitializeDWriteFontProxy(); 50 UninitializeDWriteFontProxy();
82 } 51 }
83 52
84 bool RendererMainPlatformDelegate::EnableSandbox() { 53 bool RendererMainPlatformDelegate::EnableSandbox() {
85 sandbox::TargetServices* target_services = 54 return true;
86 parameters_.sandbox_info->target_services;
87
88 if (target_services) {
89 // Cause advapi32 to load before the sandbox is turned on.
90 unsigned int dummy_rand;
91 rand_s(&dummy_rand);
92
93 target_services->LowerToken();
94 return true;
95 }
96 return false;
97 } 55 }
98 56
99 } // namespace content 57 } // namespace content
OLDNEW
« no previous file with comments | « content/public/test/test_launcher.cc ('k') | content/shell/browser/shell_content_browser_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698