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

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

Issue 12090066: [content shell] ShellRenderProcessObserver no longer depends on WebTestInterfaces. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: disable tests which depend on eventsender 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 "content/public/common/content_constants.h" 9 #include "content/public/common/content_constants.h"
10 #include "content/public/common/content_switches.h" 10 #include "content/public/common/content_switches.h"
(...skipping 30 matching lines...) Expand all
41 return !url.host().empty() && 41 return !url.host().empty() &&
42 (url.SchemeIs(chrome::kHttpScheme) || 42 (url.SchemeIs(chrome::kHttpScheme) ||
43 url.SchemeIs(chrome::kHttpsScheme)) && 43 url.SchemeIs(chrome::kHttpsScheme)) &&
44 !IsLocalhost(url.host()) && 44 !IsLocalhost(url.host()) &&
45 !HostIsUsedBySomeTestsToGenerateError(url.host()); 45 !HostIsUsedBySomeTestsToGenerateError(url.host());
46 } 46 }
47 47
48 } // namespace 48 } // namespace
49 49
50 ShellContentRendererClient::ShellContentRendererClient() { 50 ShellContentRendererClient::ShellContentRendererClient() {
51 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) {
52 EnableWebTestProxyCreation(
53 base::Bind(&ShellContentRendererClient::WebTestProxyCreated,
54 base::Unretained(this)));
55 }
56 } 51 }
57 52
58 ShellContentRendererClient::~ShellContentRendererClient() { 53 ShellContentRendererClient::~ShellContentRendererClient() {
59 } 54 }
60 55
61 void ShellContentRendererClient::RenderThreadStarted() { 56 void ShellContentRendererClient::RenderThreadStarted() {
62 shell_observer_.reset(new ShellRenderProcessObserver()); 57 shell_observer_.reset(new ShellRenderProcessObserver());
63 } 58 }
64 59
60 void ShellContentRendererClient::RenderViewCreated(RenderView* render_view) {
61 WebKitTestRunner* test_runner = new WebKitTestRunner(render_view);
62 if (!ShellRenderProcessObserver::GetInstance()->test_delegate()) {
63 ShellRenderProcessObserver::GetInstance()->SetMainWindow(render_view,
64 test_runner,
65 test_runner);
66 }
67 }
68
65 bool ShellContentRendererClient::OverrideCreatePlugin( 69 bool ShellContentRendererClient::OverrideCreatePlugin(
66 RenderView* render_view, 70 RenderView* render_view,
67 WebKit::WebFrame* frame, 71 WebKit::WebFrame* frame,
68 const WebKit::WebPluginParams& params, 72 const WebKit::WebPluginParams& params,
69 WebKit::WebPlugin** plugin) { 73 WebKit::WebPlugin** plugin) {
70 std::string mime_type = params.mimeType.utf8(); 74 std::string mime_type = params.mimeType.utf8();
71 if (mime_type == content::kBrowserPluginMimeType) { 75 if (mime_type == content::kBrowserPluginMimeType) {
72 // Allow browser plugin in content_shell only if it is forced by flag. 76 // Allow browser plugin in content_shell only if it is forced by flag.
73 // Returning true here disables the plugin. 77 // Returning true here disables the plugin.
74 return !CommandLine::ForCurrentProcess()->HasSwitch( 78 return !CommandLine::ForCurrentProcess()->HasSwitch(
(...skipping 15 matching lines...) Expand all
90 const GURL& url, 94 const GURL& url,
91 const GURL& first_party_for_cookies, 95 const GURL& first_party_for_cookies,
92 GURL* new_url) { 96 GURL* new_url) {
93 CommandLine* command_line = CommandLine::ForCurrentProcess(); 97 CommandLine* command_line = CommandLine::ForCurrentProcess();
94 if (!command_line->HasSwitch(switches::kDumpRenderTree)) 98 if (!command_line->HasSwitch(switches::kDumpRenderTree))
95 return false; 99 return false;
96 ShellRenderProcessObserver* render_process_observer = 100 ShellRenderProcessObserver* render_process_observer =
97 ShellRenderProcessObserver::GetInstance(); 101 ShellRenderProcessObserver::GetInstance();
98 if (!command_line->HasSwitch(switches::kAllowExternalPages) && 102 if (!command_line->HasSwitch(switches::kAllowExternalPages) &&
99 IsExternalPage(url) && !IsExternalPage(first_party_for_cookies)) { 103 IsExternalPage(url) && !IsExternalPage(first_party_for_cookies)) {
100 render_process_observer->test_delegate()->printMessage( 104 if (render_process_observer->test_delegate()) {
101 std::string("Blocked access to external URL " + url.spec() + "\n")); 105 render_process_observer->test_delegate()->printMessage(
106 std::string("Blocked access to external URL " + url.spec() + "\n"));
107 }
102 *new_url = GURL(); 108 *new_url = GURL();
103 return true; 109 return true;
104 } 110 }
105 *new_url = render_process_observer->test_delegate()->rewriteLayoutTestsURL( 111 if (render_process_observer->test_delegate()) {
106 url.spec()); 112 *new_url = render_process_observer->test_delegate()->rewriteLayoutTestsURL(
113 url.spec());
114 }
107 return true; 115 return true;
108 } 116 }
109 117
110 void ShellContentRendererClient::WebTestProxyCreated(RenderView* render_view,
111 WebTestProxyBase* proxy) {
112 WebKitTestRunner* test_runner = new WebKitTestRunner(render_view);
113 if (!ShellRenderProcessObserver::GetInstance()->test_delegate()) {
114 ShellRenderProcessObserver::GetInstance()->SetMainWindow(render_view,
115 test_runner,
116 test_runner);
117 }
118 test_runner->set_proxy(proxy);
119 proxy->setDelegate(
120 ShellRenderProcessObserver::GetInstance()->test_delegate());
121 proxy->setInterfaces(
122 ShellRenderProcessObserver::GetInstance()->test_interfaces());
123 render_view->GetWebView()->setSpellCheckClient(proxy->spellCheckClient());
124 }
125
126 } // namespace content 118 } // 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