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

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

Issue 12258047: [content shell] Use the TestRunner library again and remove the mock testRunner (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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
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/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/common/url_constants.h"
13 #include "content/public/renderer/render_view.h" 12 #include "content/public/renderer/render_view.h"
14 #include "content/public/test/layouttest_support.h" 13 #include "content/public/test/layouttest_support.h"
15 #include "content/shell/shell_render_process_observer.h" 14 #include "content/shell/shell_render_process_observer.h"
16 #include "content/shell/shell_switches.h" 15 #include "content/shell/shell_switches.h"
17 #include "content/shell/webkit_test_runner.h" 16 #include "content/shell/webkit_test_runner.h"
18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginParams.h" 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginParams.h"
20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
21 #include "third_party/WebKit/Tools/DumpRenderTree/chromium/TestRunner/public/Web TestProxy.h" 19 #include "third_party/WebKit/Tools/DumpRenderTree/chromium/TestRunner/public/Web TestProxy.h"
22 #include "v8/include/v8.h" 20 #include "v8/include/v8.h"
23 21
24 using WebKit::WebFrame; 22 using WebKit::WebFrame;
23 using WebKit::WebPlugin;
24 using WebKit::WebPluginParams;
25 using WebTestRunner::WebTestProxyBase; 25 using WebTestRunner::WebTestProxyBase;
26 26
27 namespace content { 27 namespace content {
28 28
29 namespace {
30
31 bool IsLocalhost(const std::string& host) {
32 return host == "127.0.0.1" || host == "localhost";
33 }
34
35 bool HostIsUsedBySomeTestsToGenerateError(const std::string& host) {
36 return host == "255.255.255.255";
37 }
38
39 bool IsExternalPage(const GURL& url) {
40 return !url.host().empty() &&
41 (url.SchemeIs(chrome::kHttpScheme) ||
42 url.SchemeIs(chrome::kHttpsScheme)) &&
43 !IsLocalhost(url.host()) &&
44 !HostIsUsedBySomeTestsToGenerateError(url.host());
45 }
46
47 } // namespace
48
49 ShellContentRendererClient::ShellContentRendererClient() { 29 ShellContentRendererClient::ShellContentRendererClient() {
30 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) {
31 EnableWebTestProxyCreation(
32 base::Bind(&ShellContentRendererClient::WebTestProxyCreated,
33 base::Unretained(this)));
34 }
50 } 35 }
51 36
52 ShellContentRendererClient::~ShellContentRendererClient() { 37 ShellContentRendererClient::~ShellContentRendererClient() {
53 } 38 }
54 39
55 void ShellContentRendererClient::RenderThreadStarted() { 40 void ShellContentRendererClient::RenderThreadStarted() {
56 shell_observer_.reset(new ShellRenderProcessObserver()); 41 shell_observer_.reset(new ShellRenderProcessObserver());
57 #if defined(OS_MACOSX) 42 #if defined(OS_MACOSX)
58 // We need to call this once before the sandbox was initialized to cache the 43 // We need to call this once before the sandbox was initialized to cache the
59 // value. 44 // value.
60 base::debug::BeingDebugged(); 45 base::debug::BeingDebugged();
61 #endif 46 #endif
62 } 47 }
63 48
64 void ShellContentRendererClient::RenderViewCreated(RenderView* render_view) {
65 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree))
66 return;
67 WebKitTestRunner* test_runner = new WebKitTestRunner(render_view);
68 if (!ShellRenderProcessObserver::GetInstance()->test_delegate()) {
69 ShellRenderProcessObserver::GetInstance()->SetMainWindow(render_view,
70 test_runner,
71 test_runner);
72 }
73 }
74
75 bool ShellContentRendererClient::OverrideCreatePlugin( 49 bool ShellContentRendererClient::OverrideCreatePlugin(
76 RenderView* render_view, 50 RenderView* render_view,
77 WebKit::WebFrame* frame, 51 WebFrame* frame,
78 const WebKit::WebPluginParams& params, 52 const WebPluginParams& params,
79 WebKit::WebPlugin** plugin) { 53 WebPlugin** plugin) {
80 std::string mime_type = params.mimeType.utf8(); 54 std::string mime_type = params.mimeType.utf8();
81 if (mime_type == content::kBrowserPluginMimeType) { 55 if (mime_type == content::kBrowserPluginMimeType) {
82 // Allow browser plugin in content_shell only if it is forced by flag. 56 // Allow browser plugin in content_shell only if it is forced by flag.
83 // Returning true here disables the plugin. 57 // Returning true here disables the plugin.
84 return !CommandLine::ForCurrentProcess()->HasSwitch( 58 return !CommandLine::ForCurrentProcess()->HasSwitch(
85 switches::kEnableBrowserPluginForAllViewTypes); 59 switches::kEnableBrowserPluginForAllViewTypes);
86 } 60 }
87 return false; 61 return false;
88 } 62 }
89 63
64 void ShellContentRendererClient::WebTestProxyCreated(RenderView* render_view,
65 WebTestProxyBase* proxy) {
66 WebKitTestRunner* test_runner = new WebKitTestRunner(render_view);
67 test_runner->set_proxy(proxy);
68 render_view->GetWebView()->setSpellCheckClient(proxy->spellCheckClient());
69 if (!ShellRenderProcessObserver::GetInstance()->test_delegate()) {
70 ShellRenderProcessObserver::GetInstance()->SetMainWindow(render_view,
71 test_runner,
72 test_runner);
73 }
74 proxy->setDelegate(
75 ShellRenderProcessObserver::GetInstance()->test_delegate());
76 proxy->setInterfaces(
77 ShellRenderProcessObserver::GetInstance()->test_interfaces());
78 }
79
90 } // namespace content 80 } // namespace content
OLDNEW
« no previous file with comments | « content/shell/shell_content_renderer_client.h ('k') | content/shell/shell_render_process_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698