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

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

Issue 11362161: Use the WebTestProxy for layout tests in content_shell (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: version that doesn't expose RenderViewImpl in public API Created 8 years, 1 month 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
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/shell_content_renderer_client.h" 5 #include "content/shell/shell_content_renderer_client.h"
6 6
7 #include "base/callback.h"
7 #include "base/command_line.h" 8 #include "base/command_line.h"
8 #include "content/public/common/content_constants.h" 9 #include "content/public/common/content_constants.h"
9 #include "content/public/common/content_switches.h" 10 #include "content/public/common/content_switches.h"
11 #include "content/public/test/content_layouttest_support.h"
10 #include "content/shell/shell_render_process_observer.h" 12 #include "content/shell/shell_render_process_observer.h"
11 #include "content/shell/shell_switches.h" 13 #include "content/shell/shell_switches.h"
12 #include "content/shell/webkit_test_runner.h" 14 #include "content/shell/webkit_test_runner.h"
13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginParams.h" 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginParams.h"
17 #include "third_party/WebKit/Tools/DumpRenderTree/chromium/TestRunner/public/Web TestProxy.h"
15 #include "v8/include/v8.h" 18 #include "v8/include/v8.h"
16 19
20 using WebTestRunner::WebTestProxyBase;
21
17 namespace content { 22 namespace content {
18 23
19 ShellContentRendererClient::ShellContentRendererClient() { 24 ShellContentRendererClient::ShellContentRendererClient()
25 : latest_test_runner_(NULL) {
jam 2012/11/08 20:37:06 nit: tabbing
26 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) {
27 EnableWebTestProxyCreation(
28 base::Bind(&ShellContentRendererClient::WebTestProxyCreated,
29 base::Unretained(this)));
30 }
20 } 31 }
21 32
22 ShellContentRendererClient::~ShellContentRendererClient() { 33 ShellContentRendererClient::~ShellContentRendererClient() {
23 } 34 }
24 35
25 void ShellContentRendererClient::RenderThreadStarted() { 36 void ShellContentRendererClient::RenderThreadStarted() {
26 shell_observer_.reset(new ShellRenderProcessObserver()); 37 shell_observer_.reset(new ShellRenderProcessObserver());
27 } 38 }
28 39
29 void ShellContentRendererClient::RenderViewCreated(RenderView* render_view) { 40 void ShellContentRendererClient::RenderViewCreated(RenderView* render_view) {
30 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) 41 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree))
31 return; 42 return;
32 43
33 new WebKitTestRunner(render_view); 44 CHECK(!latest_test_runner_);
45 latest_test_runner_ = new WebKitTestRunner(render_view);
34 } 46 }
35 47
36 bool ShellContentRendererClient::OverrideCreatePlugin( 48 bool ShellContentRendererClient::OverrideCreatePlugin(
37 RenderView* render_view, 49 RenderView* render_view,
38 WebKit::WebFrame* frame, 50 WebKit::WebFrame* frame,
39 const WebKit::WebPluginParams& params, 51 const WebKit::WebPluginParams& params,
40 WebKit::WebPlugin** plugin) { 52 WebKit::WebPlugin** plugin) {
41 std::string mime_type = params.mimeType.utf8(); 53 std::string mime_type = params.mimeType.utf8();
42 if (mime_type == content::kBrowserPluginMimeType) { 54 if (mime_type == content::kBrowserPluginMimeType) {
43 // Allow browser plugin in content_shell only if it is forced by flag. 55 // Allow browser plugin in content_shell only if it is forced by flag.
44 // Returning true here disables the plugin. 56 // Returning true here disables the plugin.
45 return !CommandLine::ForCurrentProcess()->HasSwitch( 57 return !CommandLine::ForCurrentProcess()->HasSwitch(
46 switches::kEnableBrowserPluginForAllViewTypes); 58 switches::kEnableBrowserPluginForAllViewTypes);
47 } 59 }
48 return false; 60 return false;
49 } 61 }
50 62
63 void ShellContentRendererClient::WebTestProxyCreated(WebTestProxyBase* proxy) {
64 CHECK(latest_test_runner_);
65 proxy->setDelegate(latest_test_runner_);
66 latest_test_runner_ = NULL;
67 proxy->setInterfaces(
68 ShellRenderProcessObserver::GetInstance()->test_interfaces());
69 }
70
51 } // namespace content 71 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698