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

Side by Side Diff: content/shell/renderer/shell_content_renderer_client.cc

Issue 231763003: Support sideloaded fonts via command line option for blink layout_tests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: guard for xp Created 6 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 | Annotate | Revision Log
« no previous file with comments | « content/shell/common/webkit_test_helpers.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/shell/renderer/shell_content_renderer_client.h" 5 #include "content/shell/renderer/shell_content_renderer_client.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/debug/debugger.h" 9 #include "base/debug/debugger.h"
10 #include "content/common/sandbox_win.h"
10 #include "content/public/common/content_constants.h" 11 #include "content/public/common/content_constants.h"
11 #include "content/public/common/content_switches.h" 12 #include "content/public/common/content_switches.h"
12 #include "content/public/renderer/render_view.h" 13 #include "content/public/renderer/render_view.h"
13 #include "content/public/test/layouttest_support.h" 14 #include "content/public/test/layouttest_support.h"
14 #include "content/shell/common/shell_switches.h" 15 #include "content/shell/common/shell_switches.h"
16 #include "content/shell/common/webkit_test_helpers.h"
15 #include "content/shell/renderer/shell_render_frame_observer.h" 17 #include "content/shell/renderer/shell_render_frame_observer.h"
16 #include "content/shell/renderer/shell_render_process_observer.h" 18 #include "content/shell/renderer/shell_render_process_observer.h"
17 #include "content/shell/renderer/shell_render_view_observer.h" 19 #include "content/shell/renderer/shell_render_view_observer.h"
18 #include "content/shell/renderer/test_runner/WebTestInterfaces.h" 20 #include "content/shell/renderer/test_runner/WebTestInterfaces.h"
19 #include "content/shell/renderer/test_runner/WebTestProxy.h" 21 #include "content/shell/renderer/test_runner/WebTestProxy.h"
20 #include "content/shell/renderer/test_runner/WebTestRunner.h" 22 #include "content/shell/renderer/test_runner/WebTestRunner.h"
21 #include "content/shell/renderer/webkit_test_runner.h" 23 #include "content/shell/renderer/webkit_test_runner.h"
22 #include "content/test/mock_webclipboard_impl.h" 24 #include "content/test/mock_webclipboard_impl.h"
23 #include "third_party/WebKit/public/platform/WebMediaStreamCenter.h" 25 #include "third_party/WebKit/public/platform/WebMediaStreamCenter.h"
24 #include "third_party/WebKit/public/web/WebPluginParams.h" 26 #include "third_party/WebKit/public/web/WebPluginParams.h"
25 #include "third_party/WebKit/public/web/WebView.h" 27 #include "third_party/WebKit/public/web/WebView.h"
26 #include "v8/include/v8.h" 28 #include "v8/include/v8.h"
27 29
30 #if defined(OS_WIN)
31 #include "content/public/renderer/render_font_warmup_win.h"
32 #include "third_party/WebKit/public/web/win/WebFontRendering.h"
33 #include "third_party/skia/include/ports/SkFontMgr.h"
34 #endif
35
28 using blink::WebAudioDevice; 36 using blink::WebAudioDevice;
29 using blink::WebClipboard; 37 using blink::WebClipboard;
30 using blink::WebLocalFrame; 38 using blink::WebLocalFrame;
31 using blink::WebMIDIAccessor; 39 using blink::WebMIDIAccessor;
32 using blink::WebMIDIAccessorClient; 40 using blink::WebMIDIAccessorClient;
33 using blink::WebMediaStreamCenter; 41 using blink::WebMediaStreamCenter;
34 using blink::WebMediaStreamCenterClient; 42 using blink::WebMediaStreamCenterClient;
35 using blink::WebPlugin; 43 using blink::WebPlugin;
36 using blink::WebPluginParams; 44 using blink::WebPluginParams;
37 using blink::WebRTCPeerConnectionHandler; 45 using blink::WebRTCPeerConnectionHandler;
38 using blink::WebRTCPeerConnectionHandlerClient; 46 using blink::WebRTCPeerConnectionHandlerClient;
39 using blink::WebThemeEngine; 47 using blink::WebThemeEngine;
40 using WebTestRunner::WebTestDelegate; 48 using WebTestRunner::WebTestDelegate;
41 using WebTestRunner::WebTestInterfaces; 49 using WebTestRunner::WebTestInterfaces;
42 using WebTestRunner::WebTestProxyBase; 50 using WebTestRunner::WebTestProxyBase;
43 51
44 namespace content { 52 namespace content {
45 53
54 #if defined(OS_WIN)
55 namespace {
56
57 // DirectWrite only has access to %WINDIR%\Fonts by default. For developer
58 // side-loading, support kRegisterFontFiles to allow access to additional fonts.
59 void RegisterSideloadedTypefaces(SkFontMgr* fontmgr) {
60 std::vector<std::string> files = GetSideloadFontFiles();
61 for (std::vector<std::string>::const_iterator i(files.begin());
62 i != files.end();
63 ++i) {
64 SkTypeface* typeface = fontmgr->createFromFile(i->c_str());
65 DoPreSandboxWarmupForTypeface(typeface);
66 blink::WebFontRendering::addSideloadedFontForTesting(typeface);
67 }
68 }
69
70 } // namespace
71 #endif // OS_WIN
72
46 ShellContentRendererClient::ShellContentRendererClient() { 73 ShellContentRendererClient::ShellContentRendererClient() {
47 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) { 74 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) {
48 EnableWebTestProxyCreation( 75 EnableWebTestProxyCreation(
49 base::Bind(&ShellContentRendererClient::WebTestProxyCreated, 76 base::Bind(&ShellContentRendererClient::WebTestProxyCreated,
50 base::Unretained(this))); 77 base::Unretained(this)));
51 } 78 }
79
80 #if defined(OS_WIN)
81 if (ShouldUseDirectWrite())
82 RegisterSideloadedTypefaces(GetPreSandboxWarmupFontMgr());
83 #endif
52 } 84 }
53 85
54 ShellContentRendererClient::~ShellContentRendererClient() { 86 ShellContentRendererClient::~ShellContentRendererClient() {
55 } 87 }
56 88
57 void ShellContentRendererClient::RenderThreadStarted() { 89 void ShellContentRendererClient::RenderThreadStarted() {
58 shell_observer_.reset(new ShellRenderProcessObserver()); 90 shell_observer_.reset(new ShellRenderProcessObserver());
59 #if defined(OS_MACOSX) 91 #if defined(OS_MACOSX)
60 // We need to call this once before the sandbox was initialized to cache the 92 // We need to call this once before the sandbox was initialized to cache the
61 // value. 93 // value.
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 if (CommandLine::ForCurrentProcess()->HasSwitch( 207 if (CommandLine::ForCurrentProcess()->HasSwitch(
176 switches::kEnableBrowserPluginForAllViewTypes)) { 208 switches::kEnableBrowserPluginForAllViewTypes)) {
177 // Allow BrowserPlugin if forced by command line flag. This is generally 209 // Allow BrowserPlugin if forced by command line flag. This is generally
178 // true for tests. 210 // true for tests.
179 return true; 211 return true;
180 } 212 }
181 return ContentRendererClient::AllowBrowserPlugin(container); 213 return ContentRendererClient::AllowBrowserPlugin(container);
182 } 214 }
183 215
184 } // namespace content 216 } // namespace content
OLDNEW
« no previous file with comments | « content/shell/common/webkit_test_helpers.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698