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