Chromium Code Reviews| 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/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 Loading... | |
| 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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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() { |
| 234 chrome_observer_.reset(new ChromeRenderProcessObserver(this)); | 235 chrome_observer_.reset(new ChromeRenderProcessObserver(this)); |
| 235 extension_dispatcher_.reset(new extensions::Dispatcher()); | 236 if (!extension_dispatcher_) |
|
sky
2013/09/25 20:43:17
Why the ifs here and 244?
Jered
2013/09/25 22:23:38
Added comments.
| |
| 237 extension_dispatcher_.reset(new extensions::Dispatcher()); | |
| 236 permissions_policy_delegate_.reset( | 238 permissions_policy_delegate_.reset( |
| 237 new extensions::RendererPermissionsPolicyDelegate( | 239 new extensions::RendererPermissionsPolicyDelegate( |
| 238 extension_dispatcher_.get())); | 240 extension_dispatcher_.get())); |
| 239 prescient_networking_dispatcher_.reset(new PrescientNetworkingDispatcher()); | 241 prescient_networking_dispatcher_.reset(new PrescientNetworkingDispatcher()); |
| 240 net_predictor_.reset(new RendererNetPredictor()); | 242 net_predictor_.reset(new RendererNetPredictor()); |
| 241 #if defined(ENABLE_SPELLCHECK) | 243 #if defined(ENABLE_SPELLCHECK) |
| 242 spellcheck_.reset(new SpellCheck()); | 244 if (!spellcheck_) |
| 245 spellcheck_.reset(new SpellCheck()); | |
| 243 #endif | 246 #endif |
| 244 visited_link_slave_.reset(new visitedlink::VisitedLinkSlave()); | 247 visited_link_slave_.reset(new visitedlink::VisitedLinkSlave()); |
| 245 #if defined(FULL_SAFE_BROWSING) | 248 #if defined(FULL_SAFE_BROWSING) |
| 246 phishing_classifier_.reset(safe_browsing::PhishingClassifierFilter::Create()); | 249 phishing_classifier_.reset(safe_browsing::PhishingClassifierFilter::Create()); |
| 247 #endif | 250 #endif |
| 248 prerender_dispatcher_.reset(new prerender::PrerenderDispatcher()); | 251 prerender_dispatcher_.reset(new prerender::PrerenderDispatcher()); |
| 249 #if defined(ENABLE_WEBRTC) | 252 #if defined(ENABLE_WEBRTC) |
| 250 webrtc_logging_message_filter_ = new WebRtcLoggingMessageFilter( | 253 webrtc_logging_message_filter_ = new WebRtcLoggingMessageFilter( |
| 251 content::RenderThread::Get()->GetIOMessageLoopProxy()); | 254 content::RenderThread::Get()->GetIOMessageLoopProxy()); |
| 252 #endif | 255 #endif |
| 256 search_bouncer_.reset(new SearchBouncer()); | |
| 253 | 257 |
| 254 RenderThread* thread = RenderThread::Get(); | 258 RenderThread* thread = RenderThread::Get(); |
| 255 | 259 |
| 256 thread->AddObserver(chrome_observer_.get()); | 260 thread->AddObserver(chrome_observer_.get()); |
| 257 thread->AddObserver(extension_dispatcher_.get()); | 261 thread->AddObserver(extension_dispatcher_.get()); |
| 258 #if defined(FULL_SAFE_BROWSING) | 262 #if defined(FULL_SAFE_BROWSING) |
| 259 thread->AddObserver(phishing_classifier_.get()); | 263 thread->AddObserver(phishing_classifier_.get()); |
| 260 #endif | 264 #endif |
| 261 #if defined(ENABLE_SPELLCHECK) | 265 #if defined(ENABLE_SPELLCHECK) |
| 262 thread->AddObserver(spellcheck_.get()); | 266 thread->AddObserver(spellcheck_.get()); |
| 263 #endif | 267 #endif |
| 264 thread->AddObserver(visited_link_slave_.get()); | 268 thread->AddObserver(visited_link_slave_.get()); |
| 265 thread->AddObserver(prerender_dispatcher_.get()); | 269 thread->AddObserver(prerender_dispatcher_.get()); |
| 270 thread->AddObserver(search_bouncer_.get()); | |
| 266 | 271 |
| 267 #if defined(ENABLE_WEBRTC) | 272 #if defined(ENABLE_WEBRTC) |
| 268 thread->AddFilter(webrtc_logging_message_filter_.get()); | 273 thread->AddFilter(webrtc_logging_message_filter_.get()); |
| 269 #endif | 274 #endif |
| 270 | 275 |
| 271 thread->RegisterExtension(extensions_v8::ExternalExtension::Get()); | 276 thread->RegisterExtension(extensions_v8::ExternalExtension::Get()); |
| 272 thread->RegisterExtension(extensions_v8::LoadTimesExtension::Get()); | 277 thread->RegisterExtension(extensions_v8::LoadTimesExtension::Get()); |
| 273 | 278 |
| 274 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 279 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 275 if (command_line->HasSwitch(switches::kEnableBenchmarking)) | 280 if (command_line->HasSwitch(switches::kEnableBenchmarking)) |
| (...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 854 // Use an internal error page, if we have one for the status code. | 859 // Use an internal error page, if we have one for the status code. |
| 855 if (!LocalizedError::HasStrings(LocalizedError::kHttpErrorDomain, | 860 if (!LocalizedError::HasStrings(LocalizedError::kHttpErrorDomain, |
| 856 http_status_code)) { | 861 http_status_code)) { |
| 857 return false; | 862 return false; |
| 858 } | 863 } |
| 859 | 864 |
| 860 *error_domain = LocalizedError::kHttpErrorDomain; | 865 *error_domain = LocalizedError::kHttpErrorDomain; |
| 861 return true; | 866 return true; |
| 862 } | 867 } |
| 863 | 868 |
| 869 bool ChromeContentRendererClient::ShouldSuppressErrorPage(const GURL& url) { | |
| 870 // Do not flash an error page if the Instant new tab page fails to load. | |
| 871 return search_bouncer_.get() && search_bouncer_->IsNewTabPage(url); | |
| 872 } | |
| 873 | |
| 864 void ChromeContentRendererClient::GetNavigationErrorStrings( | 874 void ChromeContentRendererClient::GetNavigationErrorStrings( |
| 865 WebKit::WebFrame* frame, | 875 WebKit::WebFrame* frame, |
| 866 const WebKit::WebURLRequest& failed_request, | 876 const WebKit::WebURLRequest& failed_request, |
| 867 const WebKit::WebURLError& error, | 877 const WebKit::WebURLError& error, |
| 868 std::string* error_html, | 878 std::string* error_html, |
| 869 string16* error_description) { | 879 string16* error_description) { |
| 870 const GURL failed_url = error.unreachableURL; | 880 const GURL failed_url = error.unreachableURL; |
| 871 const Extension* extension = NULL; | 881 const Extension* extension = NULL; |
| 872 | 882 |
| 873 if (failed_url.is_valid() && | 883 if (failed_url.is_valid() && |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 935 bool ChromeContentRendererClient::ShouldFork(WebFrame* frame, | 945 bool ChromeContentRendererClient::ShouldFork(WebFrame* frame, |
| 936 const GURL& url, | 946 const GURL& url, |
| 937 const std::string& http_method, | 947 const std::string& http_method, |
| 938 bool is_initial_navigation, | 948 bool is_initial_navigation, |
| 939 bool is_server_redirect, | 949 bool is_server_redirect, |
| 940 bool* send_referrer) { | 950 bool* send_referrer) { |
| 941 DCHECK(!frame->parent()); | 951 DCHECK(!frame->parent()); |
| 942 | 952 |
| 943 // If this is the Instant process, fork all navigations originating from the | 953 // 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 | 954 // 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. | 955 // process if it is an Instant url, or to another process if not. Conversely, |
| 946 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kInstantProcess)) { | 956 // fork if this is a non-Instant process navigating to an Instant url, so that |
| 957 // such navigations can also be bucketed into an Instant renderer. | |
| 958 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kInstantProcess) || | |
| 959 (search_bouncer_.get() && search_bouncer_->ShouldFork(url))) { | |
| 947 *send_referrer = true; | 960 *send_referrer = true; |
| 948 return true; | 961 return true; |
| 949 } | 962 } |
| 950 | 963 |
| 951 // For now, we skip the rest for POST submissions. This is because | 964 // For now, we skip the rest for POST submissions. This is because |
| 952 // http://crbug.com/101395 is more likely to cause compatibility issues | 965 // http://crbug.com/101395 is more likely to cause compatibility issues |
| 953 // with hosted apps and extensions than WebUI pages. We will remove this | 966 // with hosted apps and extensions than WebUI pages. We will remove this |
| 954 // check when cross-process POST submissions are supported. | 967 // check when cross-process POST submissions are supported. |
| 955 if (http_method != "GET") | 968 if (http_method != "GET") |
| 956 return false; | 969 return false; |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1328 // SiteIsolationPolicy is off by default. We would like to activate cross-site | 1341 // SiteIsolationPolicy is off by default. We would like to activate cross-site |
| 1329 // document blocking (for UMA data collection) for normal renderer processes | 1342 // document blocking (for UMA data collection) for normal renderer processes |
| 1330 // running a normal web page from the Internet. We only turn on | 1343 // running a normal web page from the Internet. We only turn on |
| 1331 // SiteIsolationPolicy for a renderer process that does not have the extension | 1344 // SiteIsolationPolicy for a renderer process that does not have the extension |
| 1332 // flag on. | 1345 // flag on. |
| 1333 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 1346 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 1334 return !command_line->HasSwitch(switches::kExtensionProcess); | 1347 return !command_line->HasSwitch(switches::kExtensionProcess); |
| 1335 } | 1348 } |
| 1336 | 1349 |
| 1337 } // namespace chrome | 1350 } // namespace chrome |
| OLD | NEW |