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/renderer/shell_render_process_observer.h" | 15 #include "content/shell/renderer/shell_render_process_observer.h" |
16 #include "content/shell/renderer/shell_render_view_observer.h" | 16 #include "content/shell/renderer/shell_render_view_observer.h" |
17 #include "content/shell/renderer/webkit_test_runner.h" | 17 #include "content/shell/renderer/webkit_test_runner.h" |
18 #include "third_party/WebKit/public/platform/WebMediaStreamCenter.h" | 18 #include "third_party/WebKit/public/platform/WebMediaStreamCenter.h" |
19 #include "third_party/WebKit/public/testing/WebTestInterfaces.h" | 19 #include "third_party/WebKit/public/testing/WebTestInterfaces.h" |
20 #include "third_party/WebKit/public/testing/WebTestProxy.h" | 20 #include "third_party/WebKit/public/testing/WebTestProxy.h" |
21 #include "third_party/WebKit/public/testing/WebTestRunner.h" | 21 #include "third_party/WebKit/public/testing/WebTestRunner.h" |
22 #include "third_party/WebKit/public/web/WebPluginParams.h" | 22 #include "third_party/WebKit/public/web/WebPluginParams.h" |
23 #include "third_party/WebKit/public/web/WebView.h" | 23 #include "third_party/WebKit/public/web/WebView.h" |
24 #include "v8/include/v8.h" | 24 #include "v8/include/v8.h" |
25 #include "webkit/mocks/mock_webhyphenator.h" | |
26 #include "webkit/support/mock_webclipboard_impl.h" | 25 #include "webkit/support/mock_webclipboard_impl.h" |
27 | 26 |
28 using WebKit::WebAudioDevice; | 27 using WebKit::WebAudioDevice; |
29 using WebKit::WebClipboard; | 28 using WebKit::WebClipboard; |
30 using WebKit::WebFrame; | 29 using WebKit::WebFrame; |
31 using WebKit::WebHyphenator; | |
32 using WebKit::WebMIDIAccessor; | 30 using WebKit::WebMIDIAccessor; |
33 using WebKit::WebMIDIAccessorClient; | 31 using WebKit::WebMIDIAccessorClient; |
34 using WebKit::WebMediaStreamCenter; | 32 using WebKit::WebMediaStreamCenter; |
35 using WebKit::WebMediaStreamCenterClient; | 33 using WebKit::WebMediaStreamCenterClient; |
36 using WebKit::WebPlugin; | 34 using WebKit::WebPlugin; |
37 using WebKit::WebPluginParams; | 35 using WebKit::WebPluginParams; |
38 using WebKit::WebRTCPeerConnectionHandler; | 36 using WebKit::WebRTCPeerConnectionHandler; |
39 using WebKit::WebRTCPeerConnectionHandlerClient; | 37 using WebKit::WebRTCPeerConnectionHandlerClient; |
40 using WebKit::WebThemeEngine; | 38 using WebKit::WebThemeEngine; |
41 using WebTestRunner::WebTestDelegate; | 39 using WebTestRunner::WebTestDelegate; |
(...skipping 17 matching lines...) Expand all Loading... |
59 EnableWebTestProxyCreation( | 57 EnableWebTestProxyCreation( |
60 base::Bind(&ShellContentRendererClient::WebTestProxyCreated, | 58 base::Bind(&ShellContentRendererClient::WebTestProxyCreated, |
61 base::Unretained(this))); | 59 base::Unretained(this))); |
62 } | 60 } |
63 } | 61 } |
64 | 62 |
65 ShellContentRendererClient::~ShellContentRendererClient() { | 63 ShellContentRendererClient::~ShellContentRendererClient() { |
66 g_renderer_client = NULL; | 64 g_renderer_client = NULL; |
67 } | 65 } |
68 | 66 |
69 void ShellContentRendererClient::LoadHyphenDictionary( | |
70 base::PlatformFile dict_file) { | |
71 if (!hyphenator_) | |
72 hyphenator_.reset(new webkit_glue::MockWebHyphenator); | |
73 base::SeekPlatformFile(dict_file, base::PLATFORM_FILE_FROM_BEGIN, 0); | |
74 hyphenator_->LoadDictionary(dict_file); | |
75 } | |
76 | |
77 void ShellContentRendererClient::RenderThreadStarted() { | 67 void ShellContentRendererClient::RenderThreadStarted() { |
78 shell_observer_.reset(new ShellRenderProcessObserver()); | 68 shell_observer_.reset(new ShellRenderProcessObserver()); |
79 #if defined(OS_MACOSX) | 69 #if defined(OS_MACOSX) |
80 // We need to call this once before the sandbox was initialized to cache the | 70 // We need to call this once before the sandbox was initialized to cache the |
81 // value. | 71 // value. |
82 base::debug::BeingDebugged(); | 72 base::debug::BeingDebugged(); |
83 #endif | 73 #endif |
84 } | 74 } |
85 | 75 |
86 void ShellContentRendererClient::RenderViewCreated(RenderView* render_view) { | 76 void ShellContentRendererClient::RenderViewCreated(RenderView* render_view) { |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 } | 161 } |
172 | 162 |
173 WebKit::WebCrypto* ShellContentRendererClient::OverrideWebCrypto() { | 163 WebKit::WebCrypto* ShellContentRendererClient::OverrideWebCrypto() { |
174 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) | 164 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) |
175 return NULL; | 165 return NULL; |
176 WebTestInterfaces* interfaces = | 166 WebTestInterfaces* interfaces = |
177 ShellRenderProcessObserver::GetInstance()->test_interfaces(); | 167 ShellRenderProcessObserver::GetInstance()->test_interfaces(); |
178 return interfaces->crypto(); | 168 return interfaces->crypto(); |
179 } | 169 } |
180 | 170 |
181 WebHyphenator* ShellContentRendererClient::OverrideWebHyphenator() { | |
182 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) | |
183 return NULL; | |
184 if (!hyphenator_) | |
185 hyphenator_.reset(new webkit_glue::MockWebHyphenator); | |
186 return hyphenator_.get(); | |
187 | |
188 } | |
189 | |
190 WebThemeEngine* ShellContentRendererClient::OverrideThemeEngine() { | 171 WebThemeEngine* ShellContentRendererClient::OverrideThemeEngine() { |
191 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) | 172 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) |
192 return NULL; | 173 return NULL; |
193 return ShellRenderProcessObserver::GetInstance()->test_interfaces() | 174 return ShellRenderProcessObserver::GetInstance()->test_interfaces() |
194 ->themeEngine(); | 175 ->themeEngine(); |
195 } | 176 } |
196 | 177 |
197 void ShellContentRendererClient::WebTestProxyCreated(RenderView* render_view, | 178 void ShellContentRendererClient::WebTestProxyCreated(RenderView* render_view, |
198 WebTestProxyBase* proxy) { | 179 WebTestProxyBase* proxy) { |
199 WebKitTestRunner* test_runner = new WebKitTestRunner(render_view); | 180 WebKitTestRunner* test_runner = new WebKitTestRunner(render_view); |
(...skipping 11 matching lines...) Expand all Loading... |
211 if (CommandLine::ForCurrentProcess()->HasSwitch( | 192 if (CommandLine::ForCurrentProcess()->HasSwitch( |
212 switches::kEnableBrowserPluginForAllViewTypes)) { | 193 switches::kEnableBrowserPluginForAllViewTypes)) { |
213 // Allow BrowserPlugin if forced by command line flag. This is generally | 194 // Allow BrowserPlugin if forced by command line flag. This is generally |
214 // true for tests. | 195 // true for tests. |
215 return true; | 196 return true; |
216 } | 197 } |
217 return ContentRendererClient::AllowBrowserPlugin(container); | 198 return ContentRendererClient::AllowBrowserPlugin(container); |
218 } | 199 } |
219 | 200 |
220 } // namespace content | 201 } // namespace content |
OLD | NEW |