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

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: Handle TemplateURL change Created 7 years, 3 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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
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_)
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 581 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 // 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.
858 if (!LocalizedError::HasStrings(LocalizedError::kHttpErrorDomain, 863 if (!LocalizedError::HasStrings(LocalizedError::kHttpErrorDomain,
859 http_status_code)) { 864 http_status_code)) {
860 return false; 865 return false;
861 } 866 }
862 867
863 *error_domain = LocalizedError::kHttpErrorDomain; 868 *error_domain = LocalizedError::kHttpErrorDomain;
864 return true; 869 return true;
865 } 870 }
866 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
867 void ChromeContentRendererClient::GetNavigationErrorStrings( 877 void ChromeContentRendererClient::GetNavigationErrorStrings(
868 WebKit::WebFrame* frame, 878 WebKit::WebFrame* frame,
869 const WebKit::WebURLRequest& failed_request, 879 const WebKit::WebURLRequest& failed_request,
870 const WebKit::WebURLError& error, 880 const WebKit::WebURLError& error,
871 std::string* error_html, 881 std::string* error_html,
872 string16* error_description) { 882 string16* error_description) {
873 const GURL failed_url = error.unreachableURL; 883 const GURL failed_url = error.unreachableURL;
874 const Extension* extension = NULL; 884 const Extension* extension = NULL;
875 885
876 if (failed_url.is_valid() && 886 if (failed_url.is_valid() &&
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
937 bool ChromeContentRendererClient::ShouldFork(WebFrame* frame, 947 bool ChromeContentRendererClient::ShouldFork(WebFrame* frame,
938 const GURL& url, 948 const GURL& url,
939 const std::string& http_method, 949 const std::string& http_method,
940 bool is_initial_navigation, 950 bool is_initial_navigation,
941 bool is_server_redirect, 951 bool is_server_redirect,
942 bool* send_referrer) { 952 bool* send_referrer) {
943 DCHECK(!frame->parent()); 953 DCHECK(!frame->parent());
944 954
945 // If this is the Instant process, fork all navigations originating from the 955 // If this is the Instant process, fork all navigations originating from the
946 // renderer. The destination page will then be bucketed back to this Instant 956 // renderer. The destination page will then be bucketed back to this Instant
947 // process if it is an Instant url, or to another process if not. 957 // process if it is an Instant url, or to another process if not. Conversely,
948 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kInstantProcess)) 958 // fork if this is a non-Instant process navigating to an Instant url, so that
959 // such navigations can also be bucketed into an Instant renderer.
960 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kInstantProcess) ||
961 (search_bouncer_.get() && search_bouncer_->ShouldFork(url))) {
949 return true; 962 return true;
963 }
950 964
951 // For now, we skip the rest for POST submissions. This is because 965 // For now, we skip the rest for POST submissions. This is because
952 // http://crbug.com/101395 is more likely to cause compatibility issues 966 // http://crbug.com/101395 is more likely to cause compatibility issues
953 // with hosted apps and extensions than WebUI pages. We will remove this 967 // with hosted apps and extensions than WebUI pages. We will remove this
954 // check when cross-process POST submissions are supported. 968 // check when cross-process POST submissions are supported.
955 if (http_method != "GET") 969 if (http_method != "GET")
956 return false; 970 return false;
957 971
958 // If this is the Signin process, fork all navigations originating from the 972 // If this is the Signin process, fork all navigations originating from the
959 // renderer. The destination page will then be bucketed back to this Signin 973 // renderer. The destination page will then be bucketed back to this Signin
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
1325 // SiteIsolationPolicy is off by default. We would like to activate cross-site 1339 // SiteIsolationPolicy is off by default. We would like to activate cross-site
1326 // document blocking (for UMA data collection) for normal renderer processes 1340 // document blocking (for UMA data collection) for normal renderer processes
1327 // running a normal web page from the Internet. We only turn on 1341 // running a normal web page from the Internet. We only turn on
1328 // SiteIsolationPolicy for a renderer process that does not have the extension 1342 // SiteIsolationPolicy for a renderer process that does not have the extension
1329 // flag on. 1343 // flag on.
1330 CommandLine* command_line = CommandLine::ForCurrentProcess(); 1344 CommandLine* command_line = CommandLine::ForCurrentProcess();
1331 return !command_line->HasSwitch(switches::kExtensionProcess); 1345 return !command_line->HasSwitch(switches::kExtensionProcess);
1332 } 1346 }
1333 1347
1334 } // namespace chrome 1348 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698