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/shell_content_renderer_client.h" | 5 #include "content/shell/shell_content_renderer_client.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "content/public/common/content_constants.h" | 8 #include "content/public/common/content_constants.h" |
9 #include "content/public/common/content_switches.h" | 9 #include "content/public/common/content_switches.h" |
| 10 #include "content/public/layouttest_support/content_layouttest_support.h" |
10 #include "content/shell/shell_render_process_observer.h" | 11 #include "content/shell/shell_render_process_observer.h" |
11 #include "content/shell/shell_switches.h" | 12 #include "content/shell/shell_switches.h" |
12 #include "content/shell/webkit_test_runner.h" | 13 #include "content/shell/webkit_test_runner.h" |
13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginParams.h" | 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginParams.h" |
| 16 #include "third_party/WebKit/Tools/DumpRenderTree/chromium/TestRunner/public/Web
TestProxy.h" |
15 #include "v8/include/v8.h" | 17 #include "v8/include/v8.h" |
16 | 18 |
| 19 using WebTestRunner::WebTestProxyBase; |
| 20 |
17 namespace content { | 21 namespace content { |
18 | 22 |
19 ShellContentRendererClient::ShellContentRendererClient() { | 23 ShellContentRendererClient::ShellContentRendererClient() |
| 24 : latest_test_runner_(NULL) { |
20 } | 25 } |
21 | 26 |
22 ShellContentRendererClient::~ShellContentRendererClient() { | 27 ShellContentRendererClient::~ShellContentRendererClient() { |
23 } | 28 } |
24 | 29 |
25 void ShellContentRendererClient::RenderThreadStarted() { | 30 void ShellContentRendererClient::RenderThreadStarted() { |
26 shell_observer_.reset(new ShellRenderProcessObserver()); | 31 shell_observer_.reset(new ShellRenderProcessObserver()); |
27 } | 32 } |
28 | 33 |
29 void ShellContentRendererClient::RenderViewCreated(RenderView* render_view) { | 34 void ShellContentRendererClient::RenderViewCreated(RenderView* render_view) { |
30 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) | 35 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) |
31 return; | 36 return; |
32 | 37 |
33 new WebKitTestRunner(render_view); | 38 CHECK(!latest_test_runner_); |
| 39 latest_test_runner_ = new WebKitTestRunner(render_view); |
| 40 } |
| 41 |
| 42 bool ShellContentRendererClient::OverrideCreateRenderViewImpl( |
| 43 RenderViewImplParams* params, |
| 44 RenderViewImpl** render_view) { |
| 45 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) |
| 46 return false; |
| 47 |
| 48 WebTestProxyBase* proxy = NULL; |
| 49 *render_view = CreateWebTestProxy(params, &proxy); |
| 50 |
| 51 CHECK(latest_test_runner_); |
| 52 proxy->setDelegate(latest_test_runner_); |
| 53 latest_test_runner_ = NULL; |
| 54 proxy->setInterfaces( |
| 55 ShellRenderProcessObserver::GetInstance()->test_interfaces()); |
| 56 return true; |
34 } | 57 } |
35 | 58 |
36 bool ShellContentRendererClient::OverrideCreatePlugin( | 59 bool ShellContentRendererClient::OverrideCreatePlugin( |
37 RenderView* render_view, | 60 RenderView* render_view, |
38 WebKit::WebFrame* frame, | 61 WebKit::WebFrame* frame, |
39 const WebKit::WebPluginParams& params, | 62 const WebKit::WebPluginParams& params, |
40 WebKit::WebPlugin** plugin) { | 63 WebKit::WebPlugin** plugin) { |
41 std::string mime_type = params.mimeType.utf8(); | 64 std::string mime_type = params.mimeType.utf8(); |
42 if (mime_type == content::kBrowserPluginMimeType) { | 65 if (mime_type == content::kBrowserPluginMimeType) { |
43 // Allow browser plugin in content_shell only if it is forced by flag. | 66 // Allow browser plugin in content_shell only if it is forced by flag. |
44 // Returning true here disables the plugin. | 67 // Returning true here disables the plugin. |
45 return !CommandLine::ForCurrentProcess()->HasSwitch( | 68 return !CommandLine::ForCurrentProcess()->HasSwitch( |
46 switches::kEnableBrowserPluginForAllViewTypes); | 69 switches::kEnableBrowserPluginForAllViewTypes); |
47 } | 70 } |
48 return false; | 71 return false; |
49 } | 72 } |
50 | 73 |
51 } // namespace content | 74 } // namespace content |
OLD | NEW |