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

Side by Side Diff: chrome/renderer/chrome_content_renderer_client.cc

Issue 23455047: InstantExtended: Send search URLs to renderers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More browsertest fixes Created 7 years, 2 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 "chrome/renderer/chrome_content_renderer_client.h" 5 #include "chrome/renderer/chrome_content_renderer_client.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/debug/crash_logging.h" 8 #include "base/debug/crash_logging.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 #include "chrome/renderer/playback_extension.h" 52 #include "chrome/renderer/playback_extension.h"
53 #include "chrome/renderer/plugins/plugin_placeholder.h" 53 #include "chrome/renderer/plugins/plugin_placeholder.h"
54 #include "chrome/renderer/plugins/plugin_uma.h" 54 #include "chrome/renderer/plugins/plugin_uma.h"
55 #include "chrome/renderer/prerender/prerender_dispatcher.h" 55 #include "chrome/renderer/prerender/prerender_dispatcher.h"
56 #include "chrome/renderer/prerender/prerender_helper.h" 56 #include "chrome/renderer/prerender/prerender_helper.h"
57 #include "chrome/renderer/prerender/prerender_media_load_deferrer.h" 57 #include "chrome/renderer/prerender/prerender_media_load_deferrer.h"
58 #include "chrome/renderer/prerender/prerenderer_client.h" 58 #include "chrome/renderer/prerender/prerenderer_client.h"
59 #include "chrome/renderer/printing/print_web_view_helper.h" 59 #include "chrome/renderer/printing/print_web_view_helper.h"
60 #include "chrome/renderer/safe_browsing/malware_dom_details.h" 60 #include "chrome/renderer/safe_browsing/malware_dom_details.h"
61 #include "chrome/renderer/safe_browsing/phishing_classifier_delegate.h" 61 #include "chrome/renderer/safe_browsing/phishing_classifier_delegate.h"
62 #include "chrome/renderer/searchbox/search_bouncer.h"
62 #include "chrome/renderer/searchbox/searchbox.h" 63 #include "chrome/renderer/searchbox/searchbox.h"
63 #include "chrome/renderer/searchbox/searchbox_extension.h" 64 #include "chrome/renderer/searchbox/searchbox_extension.h"
64 #include "chrome/renderer/tts_dispatcher.h" 65 #include "chrome/renderer/tts_dispatcher.h"
65 #include "chrome/renderer/validation_message_agent.h" 66 #include "chrome/renderer/validation_message_agent.h"
66 #include "components/autofill/content/renderer/autofill_agent.h" 67 #include "components/autofill/content/renderer/autofill_agent.h"
67 #include "components/autofill/content/renderer/password_autofill_agent.h" 68 #include "components/autofill/content/renderer/password_autofill_agent.h"
68 #include "components/autofill/content/renderer/password_generation_manager.h" 69 #include "components/autofill/content/renderer/password_generation_manager.h"
69 #include "components/visitedlink/renderer/visitedlink_slave.h" 70 #include "components/visitedlink/renderer/visitedlink_slave.h"
70 #include "content/public/common/content_constants.h" 71 #include "content/public/common/content_constants.h"
71 #include "content/public/renderer/render_thread.h" 72 #include "content/public/renderer/render_thread.h"
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 for (size_t i = 0; i < arraysize(kPredefinedAllowedFileHandleOrigins); ++i) 225 for (size_t i = 0; i < arraysize(kPredefinedAllowedFileHandleOrigins); ++i)
225 allowed_file_handle_origins_.insert(kPredefinedAllowedFileHandleOrigins[i]); 226 allowed_file_handle_origins_.insert(kPredefinedAllowedFileHandleOrigins[i]);
226 #endif 227 #endif
227 } 228 }
228 229
229 ChromeContentRendererClient::~ChromeContentRendererClient() { 230 ChromeContentRendererClient::~ChromeContentRendererClient() {
230 g_current_client = NULL; 231 g_current_client = NULL;
231 } 232 }
232 233
233 void ChromeContentRendererClient::RenderThreadStarted() { 234 void ChromeContentRendererClient::RenderThreadStarted() {
235 RenderThread* thread = RenderThread::Get();
236
234 chrome_observer_.reset(new ChromeRenderProcessObserver(this)); 237 chrome_observer_.reset(new ChromeRenderProcessObserver(this));
235 extension_dispatcher_.reset(new extensions::Dispatcher()); 238 // ChromeRenderViewTest::SetUp() creates its own ExtensionDispatcher and
239 // injects it using SetExtensionDispatcher(). Don't overwrite it.
240 if (!extension_dispatcher_)
241 extension_dispatcher_.reset(new extensions::Dispatcher());
236 permissions_policy_delegate_.reset( 242 permissions_policy_delegate_.reset(
237 new extensions::RendererPermissionsPolicyDelegate( 243 new extensions::RendererPermissionsPolicyDelegate(
238 extension_dispatcher_.get())); 244 extension_dispatcher_.get()));
239 prescient_networking_dispatcher_.reset(new PrescientNetworkingDispatcher()); 245 prescient_networking_dispatcher_.reset(new PrescientNetworkingDispatcher());
240 net_predictor_.reset(new RendererNetPredictor()); 246 net_predictor_.reset(new RendererNetPredictor());
241 #if defined(ENABLE_SPELLCHECK) 247 #if defined(ENABLE_SPELLCHECK)
242 spellcheck_.reset(new SpellCheck()); 248 // ChromeRenderViewTest::SetUp() creates a Spellcheck and injects it using
249 // SetSpellcheck(). Don't overwrite it.
250 if (!spellcheck_) {
251 spellcheck_.reset(new SpellCheck());
252 thread->AddObserver(spellcheck_.get());
253 }
243 #endif 254 #endif
244 visited_link_slave_.reset(new visitedlink::VisitedLinkSlave()); 255 visited_link_slave_.reset(new visitedlink::VisitedLinkSlave());
245 #if defined(FULL_SAFE_BROWSING) 256 #if defined(FULL_SAFE_BROWSING)
246 phishing_classifier_.reset(safe_browsing::PhishingClassifierFilter::Create()); 257 phishing_classifier_.reset(safe_browsing::PhishingClassifierFilter::Create());
247 #endif 258 #endif
248 prerender_dispatcher_.reset(new prerender::PrerenderDispatcher()); 259 prerender_dispatcher_.reset(new prerender::PrerenderDispatcher());
249 #if defined(ENABLE_WEBRTC) 260 #if defined(ENABLE_WEBRTC)
250 webrtc_logging_message_filter_ = new WebRtcLoggingMessageFilter( 261 webrtc_logging_message_filter_ = new WebRtcLoggingMessageFilter(
251 content::RenderThread::Get()->GetIOMessageLoopProxy()); 262 content::RenderThread::Get()->GetIOMessageLoopProxy());
252 #endif 263 #endif
253 264 search_bouncer_.reset(new SearchBouncer());
254 RenderThread* thread = RenderThread::Get();
255 265
256 thread->AddObserver(chrome_observer_.get()); 266 thread->AddObserver(chrome_observer_.get());
257 thread->AddObserver(extension_dispatcher_.get()); 267 thread->AddObserver(extension_dispatcher_.get());
258 #if defined(FULL_SAFE_BROWSING) 268 #if defined(FULL_SAFE_BROWSING)
259 thread->AddObserver(phishing_classifier_.get()); 269 thread->AddObserver(phishing_classifier_.get());
260 #endif 270 #endif
261 #if defined(ENABLE_SPELLCHECK)
262 thread->AddObserver(spellcheck_.get());
263 #endif
264 thread->AddObserver(visited_link_slave_.get()); 271 thread->AddObserver(visited_link_slave_.get());
265 thread->AddObserver(prerender_dispatcher_.get()); 272 thread->AddObserver(prerender_dispatcher_.get());
273 thread->AddObserver(search_bouncer_.get());
266 274
267 #if defined(ENABLE_WEBRTC) 275 #if defined(ENABLE_WEBRTC)
268 thread->AddFilter(webrtc_logging_message_filter_.get()); 276 thread->AddFilter(webrtc_logging_message_filter_.get());
269 #endif 277 #endif
270 278
271 thread->RegisterExtension(extensions_v8::ExternalExtension::Get()); 279 thread->RegisterExtension(extensions_v8::ExternalExtension::Get());
272 thread->RegisterExtension(extensions_v8::LoadTimesExtension::Get()); 280 thread->RegisterExtension(extensions_v8::LoadTimesExtension::Get());
273 281
274 CommandLine* command_line = CommandLine::ForCurrentProcess(); 282 CommandLine* command_line = CommandLine::ForCurrentProcess();
275 if (command_line->HasSwitch(switches::kEnableBenchmarking)) 283 if (command_line->HasSwitch(switches::kEnableBenchmarking))
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after
854 // Use an internal error page, if we have one for the status code. 862 // Use an internal error page, if we have one for the status code.
855 if (!LocalizedError::HasStrings(LocalizedError::kHttpErrorDomain, 863 if (!LocalizedError::HasStrings(LocalizedError::kHttpErrorDomain,
856 http_status_code)) { 864 http_status_code)) {
857 return false; 865 return false;
858 } 866 }
859 867
860 *error_domain = LocalizedError::kHttpErrorDomain; 868 *error_domain = LocalizedError::kHttpErrorDomain;
861 return true; 869 return true;
862 } 870 }
863 871
872 bool ChromeContentRendererClient::ShouldSuppressErrorPage(const GURL& url) {
873 // Do not flash an error page if the Instant new tab page fails to load.
874 return search_bouncer_.get() && search_bouncer_->IsNewTabPage(url);
875 }
876
864 void ChromeContentRendererClient::GetNavigationErrorStrings( 877 void ChromeContentRendererClient::GetNavigationErrorStrings(
865 WebKit::WebFrame* frame, 878 WebKit::WebFrame* frame,
866 const WebKit::WebURLRequest& failed_request, 879 const WebKit::WebURLRequest& failed_request,
867 const WebKit::WebURLError& error, 880 const WebKit::WebURLError& error,
868 std::string* error_html, 881 std::string* error_html,
869 string16* error_description) { 882 string16* error_description) {
870 const GURL failed_url = error.unreachableURL; 883 const GURL failed_url = error.unreachableURL;
871 const Extension* extension = NULL; 884 const Extension* extension = NULL;
872 885
873 if (failed_url.is_valid() && 886 if (failed_url.is_valid() &&
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
935 bool ChromeContentRendererClient::ShouldFork(WebFrame* frame, 948 bool ChromeContentRendererClient::ShouldFork(WebFrame* frame,
936 const GURL& url, 949 const GURL& url,
937 const std::string& http_method, 950 const std::string& http_method,
938 bool is_initial_navigation, 951 bool is_initial_navigation,
939 bool is_server_redirect, 952 bool is_server_redirect,
940 bool* send_referrer) { 953 bool* send_referrer) {
941 DCHECK(!frame->parent()); 954 DCHECK(!frame->parent());
942 955
943 // If this is the Instant process, fork all navigations originating from the 956 // If this is the Instant process, fork all navigations originating from the
944 // renderer. The destination page will then be bucketed back to this Instant 957 // renderer. The destination page will then be bucketed back to this Instant
945 // process if it is an Instant url, or to another process if not. 958 // process if it is an Instant url, or to another process if not. Conversely,
946 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kInstantProcess)) { 959 // fork if this is a non-Instant process navigating to an Instant url, so that
960 // such navigations can also be bucketed into an Instant renderer.
961 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kInstantProcess) ||
962 (search_bouncer_.get() && search_bouncer_->ShouldFork(url))) {
947 *send_referrer = true; 963 *send_referrer = true;
948 return true; 964 return true;
949 } 965 }
950 966
951 // For now, we skip the rest for POST submissions. This is because 967 // For now, we skip the rest for POST submissions. This is because
952 // http://crbug.com/101395 is more likely to cause compatibility issues 968 // http://crbug.com/101395 is more likely to cause compatibility issues
953 // with hosted apps and extensions than WebUI pages. We will remove this 969 // with hosted apps and extensions than WebUI pages. We will remove this
954 // check when cross-process POST submissions are supported. 970 // check when cross-process POST submissions are supported.
955 if (http_method != "GET") 971 if (http_method != "GET")
956 return false; 972 return false;
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
1328 // SiteIsolationPolicy is off by default. We would like to activate cross-site 1344 // SiteIsolationPolicy is off by default. We would like to activate cross-site
1329 // document blocking (for UMA data collection) for normal renderer processes 1345 // document blocking (for UMA data collection) for normal renderer processes
1330 // running a normal web page from the Internet. We only turn on 1346 // running a normal web page from the Internet. We only turn on
1331 // SiteIsolationPolicy for a renderer process that does not have the extension 1347 // SiteIsolationPolicy for a renderer process that does not have the extension
1332 // flag on. 1348 // flag on.
1333 CommandLine* command_line = CommandLine::ForCurrentProcess(); 1349 CommandLine* command_line = CommandLine::ForCurrentProcess();
1334 return !command_line->HasSwitch(switches::kExtensionProcess); 1350 return !command_line->HasSwitch(switches::kExtensionProcess);
1335 } 1351 }
1336 1352
1337 } // namespace chrome 1353 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/renderer/chrome_content_renderer_client.h ('k') | chrome/renderer/chrome_content_renderer_client_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698