| 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 "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/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 #include "chrome/renderer/playback_extension.h" | 51 #include "chrome/renderer/playback_extension.h" |
| 52 #include "chrome/renderer/plugins/plugin_placeholder.h" | 52 #include "chrome/renderer/plugins/plugin_placeholder.h" |
| 53 #include "chrome/renderer/plugins/plugin_uma.h" | 53 #include "chrome/renderer/plugins/plugin_uma.h" |
| 54 #include "chrome/renderer/prerender/prerender_dispatcher.h" | 54 #include "chrome/renderer/prerender/prerender_dispatcher.h" |
| 55 #include "chrome/renderer/prerender/prerender_helper.h" | 55 #include "chrome/renderer/prerender/prerender_helper.h" |
| 56 #include "chrome/renderer/prerender/prerender_media_load_deferrer.h" | 56 #include "chrome/renderer/prerender/prerender_media_load_deferrer.h" |
| 57 #include "chrome/renderer/prerender/prerenderer_client.h" | 57 #include "chrome/renderer/prerender/prerenderer_client.h" |
| 58 #include "chrome/renderer/printing/print_web_view_helper.h" | 58 #include "chrome/renderer/printing/print_web_view_helper.h" |
| 59 #include "chrome/renderer/safe_browsing/malware_dom_details.h" | 59 #include "chrome/renderer/safe_browsing/malware_dom_details.h" |
| 60 #include "chrome/renderer/safe_browsing/phishing_classifier_delegate.h" | 60 #include "chrome/renderer/safe_browsing/phishing_classifier_delegate.h" |
| 61 #include "chrome/renderer/searchbox/search_bouncer.h" |
| 61 #include "chrome/renderer/searchbox/searchbox.h" | 62 #include "chrome/renderer/searchbox/searchbox.h" |
| 62 #include "chrome/renderer/searchbox/searchbox_extension.h" | 63 #include "chrome/renderer/searchbox/searchbox_extension.h" |
| 63 #include "chrome/renderer/tts_dispatcher.h" | 64 #include "chrome/renderer/tts_dispatcher.h" |
| 64 #include "chrome/renderer/validation_message_agent.h" | 65 #include "chrome/renderer/validation_message_agent.h" |
| 65 #include "components/autofill/content/renderer/autofill_agent.h" | 66 #include "components/autofill/content/renderer/autofill_agent.h" |
| 66 #include "components/autofill/content/renderer/password_autofill_agent.h" | 67 #include "components/autofill/content/renderer/password_autofill_agent.h" |
| 67 #include "components/autofill/content/renderer/password_generation_manager.h" | 68 #include "components/autofill/content/renderer/password_generation_manager.h" |
| 68 #include "components/visitedlink/renderer/visitedlink_slave.h" | 69 #include "components/visitedlink/renderer/visitedlink_slave.h" |
| 69 #include "content/public/common/content_constants.h" | 70 #include "content/public/common/content_constants.h" |
| 70 #include "content/public/renderer/render_thread.h" | 71 #include "content/public/renderer/render_thread.h" |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 #endif | 243 #endif |
| 243 visited_link_slave_.reset(new visitedlink::VisitedLinkSlave()); | 244 visited_link_slave_.reset(new visitedlink::VisitedLinkSlave()); |
| 244 #if defined(FULL_SAFE_BROWSING) | 245 #if defined(FULL_SAFE_BROWSING) |
| 245 phishing_classifier_.reset(safe_browsing::PhishingClassifierFilter::Create()); | 246 phishing_classifier_.reset(safe_browsing::PhishingClassifierFilter::Create()); |
| 246 #endif | 247 #endif |
| 247 prerender_dispatcher_.reset(new prerender::PrerenderDispatcher()); | 248 prerender_dispatcher_.reset(new prerender::PrerenderDispatcher()); |
| 248 #if defined(ENABLE_WEBRTC) | 249 #if defined(ENABLE_WEBRTC) |
| 249 webrtc_logging_message_filter_ = new WebRtcLoggingMessageFilter( | 250 webrtc_logging_message_filter_ = new WebRtcLoggingMessageFilter( |
| 250 content::RenderThread::Get()->GetIOMessageLoopProxy()); | 251 content::RenderThread::Get()->GetIOMessageLoopProxy()); |
| 251 #endif | 252 #endif |
| 253 search_bouncer_.reset(new SearchBouncer()); |
| 252 | 254 |
| 253 RenderThread* thread = RenderThread::Get(); | 255 RenderThread* thread = RenderThread::Get(); |
| 254 | 256 |
| 255 thread->AddObserver(chrome_observer_.get()); | 257 thread->AddObserver(chrome_observer_.get()); |
| 256 thread->AddObserver(extension_dispatcher_.get()); | 258 thread->AddObserver(extension_dispatcher_.get()); |
| 257 #if defined(FULL_SAFE_BROWSING) | 259 #if defined(FULL_SAFE_BROWSING) |
| 258 thread->AddObserver(phishing_classifier_.get()); | 260 thread->AddObserver(phishing_classifier_.get()); |
| 259 #endif | 261 #endif |
| 260 #if defined(ENABLE_SPELLCHECK) | 262 #if defined(ENABLE_SPELLCHECK) |
| 261 thread->AddObserver(spellcheck_.get()); | 263 thread->AddObserver(spellcheck_.get()); |
| 262 #endif | 264 #endif |
| 263 thread->AddObserver(visited_link_slave_.get()); | 265 thread->AddObserver(visited_link_slave_.get()); |
| 264 thread->AddObserver(prerender_dispatcher_.get()); | 266 thread->AddObserver(prerender_dispatcher_.get()); |
| 267 thread->AddObserver(search_bouncer_.get()); |
| 265 | 268 |
| 266 #if defined(ENABLE_WEBRTC) | 269 #if defined(ENABLE_WEBRTC) |
| 267 thread->AddFilter(webrtc_logging_message_filter_.get()); | 270 thread->AddFilter(webrtc_logging_message_filter_.get()); |
| 268 #endif | 271 #endif |
| 269 | 272 |
| 270 thread->RegisterExtension(extensions_v8::ExternalExtension::Get()); | 273 thread->RegisterExtension(extensions_v8::ExternalExtension::Get()); |
| 271 thread->RegisterExtension(extensions_v8::LoadTimesExtension::Get()); | 274 thread->RegisterExtension(extensions_v8::LoadTimesExtension::Get()); |
| 272 | 275 |
| 273 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 276 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 274 if (command_line->HasSwitch(switches::kEnableBenchmarking)) | 277 if (command_line->HasSwitch(switches::kEnableBenchmarking)) |
| (...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 847 // Use an internal error page, if we have one for the status code. | 850 // Use an internal error page, if we have one for the status code. |
| 848 if (!LocalizedError::HasStrings(LocalizedError::kHttpErrorDomain, | 851 if (!LocalizedError::HasStrings(LocalizedError::kHttpErrorDomain, |
| 849 http_status_code)) { | 852 http_status_code)) { |
| 850 return false; | 853 return false; |
| 851 } | 854 } |
| 852 | 855 |
| 853 *error_domain = LocalizedError::kHttpErrorDomain; | 856 *error_domain = LocalizedError::kHttpErrorDomain; |
| 854 return true; | 857 return true; |
| 855 } | 858 } |
| 856 | 859 |
| 860 bool ChromeContentRendererClient::ShouldSuppressErrorPage(const GURL& url) { |
| 861 // Do not flash an error page if the Instant new tab page fails to load. |
| 862 return search_bouncer_.get() && search_bouncer_->IsNewTabPage(url); |
| 863 } |
| 864 |
| 857 void ChromeContentRendererClient::GetNavigationErrorStrings( | 865 void ChromeContentRendererClient::GetNavigationErrorStrings( |
| 858 WebKit::WebFrame* frame, | 866 WebKit::WebFrame* frame, |
| 859 const WebKit::WebURLRequest& failed_request, | 867 const WebKit::WebURLRequest& failed_request, |
| 860 const WebKit::WebURLError& error, | 868 const WebKit::WebURLError& error, |
| 861 std::string* error_html, | 869 std::string* error_html, |
| 862 string16* error_description) { | 870 string16* error_description) { |
| 863 const GURL failed_url = error.unreachableURL; | 871 const GURL failed_url = error.unreachableURL; |
| 864 const Extension* extension = NULL; | 872 const Extension* extension = NULL; |
| 865 | 873 |
| 866 if (failed_url.is_valid() && | 874 if (failed_url.is_valid() && |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 927 bool ChromeContentRendererClient::ShouldFork(WebFrame* frame, | 935 bool ChromeContentRendererClient::ShouldFork(WebFrame* frame, |
| 928 const GURL& url, | 936 const GURL& url, |
| 929 const std::string& http_method, | 937 const std::string& http_method, |
| 930 bool is_initial_navigation, | 938 bool is_initial_navigation, |
| 931 bool is_server_redirect, | 939 bool is_server_redirect, |
| 932 bool* send_referrer) { | 940 bool* send_referrer) { |
| 933 DCHECK(!frame->parent()); | 941 DCHECK(!frame->parent()); |
| 934 | 942 |
| 935 // If this is the Instant process, fork all navigations originating from the | 943 // If this is the Instant process, fork all navigations originating from the |
| 936 // renderer. The destination page will then be bucketed back to this Instant | 944 // renderer. The destination page will then be bucketed back to this Instant |
| 937 // process if it is an Instant url, or to another process if not. | 945 // process if it is an Instant url, or to another process if not. Conversely, |
| 938 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kInstantProcess)) | 946 // fork if this is a non-Instant process navigating to an Instant url, so that |
| 947 // such navigations can also be bucketed into an Instant renderer. |
| 948 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kInstantProcess) || |
| 949 (search_bouncer_.get() && search_bouncer_->ShouldFork(url))) { |
| 939 return true; | 950 return true; |
| 951 } |
| 940 | 952 |
| 941 // For now, we skip the rest for POST submissions. This is because | 953 // For now, we skip the rest for POST submissions. This is because |
| 942 // http://crbug.com/101395 is more likely to cause compatibility issues | 954 // http://crbug.com/101395 is more likely to cause compatibility issues |
| 943 // with hosted apps and extensions than WebUI pages. We will remove this | 955 // with hosted apps and extensions than WebUI pages. We will remove this |
| 944 // check when cross-process POST submissions are supported. | 956 // check when cross-process POST submissions are supported. |
| 945 if (http_method != "GET") | 957 if (http_method != "GET") |
| 946 return false; | 958 return false; |
| 947 | 959 |
| 948 // If this is the Signin process, fork all navigations originating from the | 960 // If this is the Signin process, fork all navigations originating from the |
| 949 // renderer. The destination page will then be bucketed back to this Signin | 961 // renderer. The destination page will then be bucketed back to this Signin |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1309 // SiteIsolationPolicy is off by default. We would like to activate cross-site | 1321 // SiteIsolationPolicy is off by default. We would like to activate cross-site |
| 1310 // document blocking (for UMA data collection) for normal renderer processes | 1322 // document blocking (for UMA data collection) for normal renderer processes |
| 1311 // running a normal web page from the Internet. We only turn on | 1323 // running a normal web page from the Internet. We only turn on |
| 1312 // SiteIsolationPolicy for a renderer process that does not have the extension | 1324 // SiteIsolationPolicy for a renderer process that does not have the extension |
| 1313 // flag on. | 1325 // flag on. |
| 1314 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 1326 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 1315 return !command_line->HasSwitch(switches::kExtensionProcess); | 1327 return !command_line->HasSwitch(switches::kExtensionProcess); |
| 1316 } | 1328 } |
| 1317 | 1329 |
| 1318 } // namespace chrome | 1330 } // namespace chrome |
| OLD | NEW |