navigator_impl.cc revision e5d81f57cb97b3b6b7fccc9c5610d21eb81db09d
1// Copyright 2013 The Chromium Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5#include "content/browser/frame_host/navigator_impl.h" 6 7#include "base/command_line.h" 8#include "content/browser/frame_host/frame_tree.h" 9#include "content/browser/frame_host/frame_tree_node.h" 10#include "content/browser/frame_host/navigation_controller_impl.h" 11#include "content/browser/frame_host/navigation_entry_impl.h" 12#include "content/browser/frame_host/navigator_delegate.h" 13#include "content/browser/frame_host/render_frame_host_impl.h" 14#include "content/browser/renderer_host/render_view_host_impl.h" 15#include "content/browser/site_instance_impl.h" 16#include "content/browser/webui/web_ui_controller_factory_registry.h" 17#include "content/browser/webui/web_ui_impl.h" 18#include "content/common/frame_messages.h" 19#include "content/common/view_messages.h" 20#include "content/public/browser/browser_context.h" 21#include "content/public/browser/content_browser_client.h" 22#include "content/public/browser/global_request_id.h" 23#include "content/public/browser/invalidate_type.h" 24#include "content/public/browser/navigation_controller.h" 25#include "content/public/browser/navigation_details.h" 26#include "content/public/browser/page_navigator.h" 27#include "content/public/browser/render_view_host.h" 28#include "content/public/common/bindings_policy.h" 29#include "content/public/common/content_client.h" 30#include "content/public/common/content_switches.h" 31#include "content/public/common/url_constants.h" 32#include "content/public/common/url_utils.h" 33 34namespace content { 35 36namespace { 37 38FrameMsg_Navigate_Type::Value GetNavigationType( 39 BrowserContext* browser_context, const NavigationEntryImpl& entry, 40 NavigationController::ReloadType reload_type) { 41 switch (reload_type) { 42 case NavigationControllerImpl::RELOAD: 43 return FrameMsg_Navigate_Type::RELOAD; 44 case NavigationControllerImpl::RELOAD_IGNORING_CACHE: 45 return FrameMsg_Navigate_Type::RELOAD_IGNORING_CACHE; 46 case NavigationControllerImpl::RELOAD_ORIGINAL_REQUEST_URL: 47 return FrameMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL; 48 case NavigationControllerImpl::NO_RELOAD: 49 break; // Fall through to rest of function. 50 } 51 52 // |RenderViewImpl::PopulateStateFromPendingNavigationParams| differentiates 53 // between |RESTORE_WITH_POST| and |RESTORE|. 54 if (entry.restore_type() == 55 NavigationEntryImpl::RESTORE_LAST_SESSION_EXITED_CLEANLY) { 56 if (entry.GetHasPostData()) 57 return FrameMsg_Navigate_Type::RESTORE_WITH_POST; 58 return FrameMsg_Navigate_Type::RESTORE; 59 } 60 61 return FrameMsg_Navigate_Type::NORMAL; 62} 63 64void MakeNavigateParams(const NavigationEntryImpl& entry, 65 const NavigationControllerImpl& controller, 66 NavigationController::ReloadType reload_type, 67 FrameMsg_Navigate_Params* params) { 68 params->page_id = entry.GetPageID(); 69 params->should_clear_history_list = entry.should_clear_history_list(); 70 params->should_replace_current_entry = entry.should_replace_entry(); 71 if (entry.should_clear_history_list()) { 72 // Set the history list related parameters to the same values a 73 // NavigationController would return before its first navigation. This will 74 // fully clear the RenderView's view of the session history. 75 params->pending_history_list_offset = -1; 76 params->current_history_list_offset = -1; 77 params->current_history_list_length = 0; 78 } else { 79 params->pending_history_list_offset = controller.GetIndexOfEntry(&entry); 80 params->current_history_list_offset = 81 controller.GetLastCommittedEntryIndex(); 82 params->current_history_list_length = controller.GetEntryCount(); 83 } 84 params->url = entry.GetURL(); 85 if (!entry.GetBaseURLForDataURL().is_empty()) { 86 params->base_url_for_data_url = entry.GetBaseURLForDataURL(); 87 params->history_url_for_data_url = entry.GetVirtualURL(); 88 } 89 params->referrer = entry.GetReferrer(); 90 params->transition = entry.GetTransitionType(); 91 params->page_state = entry.GetPageState(); 92 params->navigation_type = 93 GetNavigationType(controller.GetBrowserContext(), entry, reload_type); 94 params->request_time = base::Time::Now(); 95 params->extra_headers = entry.extra_headers(); 96 params->transferred_request_child_id = 97 entry.transferred_global_request_id().child_id; 98 params->transferred_request_request_id = 99 entry.transferred_global_request_id().request_id; 100 params->is_overriding_user_agent = entry.GetIsOverridingUserAgent(); 101 // Avoid downloading when in view-source mode. 102 params->allow_download = !entry.IsViewSourceMode(); 103 params->is_post = entry.GetHasPostData(); 104 if (entry.GetBrowserInitiatedPostData()) { 105 params->browser_initiated_post_data.assign( 106 entry.GetBrowserInitiatedPostData()->front(), 107 entry.GetBrowserInitiatedPostData()->front() + 108 entry.GetBrowserInitiatedPostData()->size()); 109 } 110 111 params->redirects = entry.redirect_chain(); 112 113 params->can_load_local_resources = entry.GetCanLoadLocalResources(); 114 params->frame_to_navigate = entry.GetFrameToNavigate(); 115} 116 117RenderFrameHostManager* GetRenderManager(RenderFrameHostImpl* rfh) { 118 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess)) 119 return rfh->frame_tree_node()->render_manager(); 120 121 return rfh->frame_tree_node()->frame_tree()->root()->render_manager(); 122} 123 124} // namespace 125 126 127NavigatorImpl::NavigatorImpl( 128 NavigationControllerImpl* navigation_controller, 129 NavigatorDelegate* delegate) 130 : controller_(navigation_controller), 131 delegate_(delegate) { 132} 133 134void NavigatorImpl::DidStartProvisionalLoad( 135 RenderFrameHostImpl* render_frame_host, 136 int parent_routing_id, 137 const GURL& url) { 138 bool is_error_page = (url.spec() == kUnreachableWebDataURL); 139 bool is_iframe_srcdoc = (url.spec() == kAboutSrcDocURL); 140 GURL validated_url(url); 141 RenderProcessHost* render_process_host = render_frame_host->GetProcess(); 142 render_process_host->FilterURL(false, &validated_url); 143 144 bool is_main_frame = render_frame_host->frame_tree_node()->IsMainFrame(); 145 NavigationEntryImpl* pending_entry = 146 NavigationEntryImpl::FromNavigationEntry(controller_->GetPendingEntry()); 147 if (is_main_frame) { 148 // If there is no browser-initiated pending entry for this navigation and it 149 // is not for the error URL, create a pending entry using the current 150 // SiteInstance, and ensure the address bar updates accordingly. We don't 151 // know the referrer or extra headers at this point, but the referrer will 152 // be set properly upon commit. 153 bool has_browser_initiated_pending_entry = pending_entry && 154 !pending_entry->is_renderer_initiated(); 155 if (!has_browser_initiated_pending_entry && !is_error_page) { 156 NavigationEntryImpl* entry = NavigationEntryImpl::FromNavigationEntry( 157 controller_->CreateNavigationEntry(validated_url, 158 content::Referrer(), 159 content::PAGE_TRANSITION_LINK, 160 true /* is_renderer_initiated */, 161 std::string(), 162 controller_->GetBrowserContext())); 163 entry->set_site_instance( 164 static_cast<SiteInstanceImpl*>( 165 render_frame_host->render_view_host()->GetSiteInstance())); 166 // TODO(creis): If there's a pending entry already, find a safe way to 167 // update it instead of replacing it and copying over things like this. 168 if (pending_entry) { 169 entry->set_transferred_global_request_id( 170 pending_entry->transferred_global_request_id()); 171 entry->set_should_replace_entry(pending_entry->should_replace_entry()); 172 entry->set_redirect_chain(pending_entry->redirect_chain()); 173 } 174 controller_->SetPendingEntry(entry); 175 if (delegate_) 176 delegate_->NotifyChangedNavigationState(content::INVALIDATE_TYPE_URL); 177 } 178 } 179 180 if (delegate_) { 181 // Notify the observer about the start of the provisional load. 182 delegate_->DidStartProvisionalLoad( 183 render_frame_host, parent_routing_id, 184 validated_url, is_error_page, is_iframe_srcdoc); 185 } 186} 187 188 189void NavigatorImpl::DidFailProvisionalLoadWithError( 190 RenderFrameHostImpl* render_frame_host, 191 const FrameHostMsg_DidFailProvisionalLoadWithError_Params& params) { 192 VLOG(1) << "Failed Provisional Load: " << params.url.possibly_invalid_spec() 193 << ", error_code: " << params.error_code 194 << ", error_description: " << params.error_description 195 << ", showing_repost_interstitial: " << 196 params.showing_repost_interstitial 197 << ", frame_id: " << render_frame_host->GetRoutingID(); 198 GURL validated_url(params.url); 199 RenderProcessHost* render_process_host = render_frame_host->GetProcess(); 200 render_process_host->FilterURL(false, &validated_url); 201 202 if (net::ERR_ABORTED == params.error_code) { 203 // EVIL HACK ALERT! Ignore failed loads when we're showing interstitials. 204 // This means that the interstitial won't be torn down properly, which is 205 // bad. But if we have an interstitial, go back to another tab type, and 206 // then load the same interstitial again, we could end up getting the first 207 // interstitial's "failed" message (as a result of the cancel) when we're on 208 // the second one. We can't tell this apart, so we think we're tearing down 209 // the current page which will cause a crash later on. 210 // 211 // http://code.google.com/p/chromium/issues/detail?id=2855 212 // Because this will not tear down the interstitial properly, if "back" is 213 // back to another tab type, the interstitial will still be somewhat alive 214 // in the previous tab type. If you navigate somewhere that activates the 215 // tab with the interstitial again, you'll see a flash before the new load 216 // commits of the interstitial page. 217 FrameTreeNode* root = 218 render_frame_host->frame_tree_node()->frame_tree()->root(); 219 if (root->render_manager()->interstitial_page() != NULL) { 220 LOG(WARNING) << "Discarding message during interstitial."; 221 return; 222 } 223 224 // We used to cancel the pending renderer here for cross-site downloads. 225 // However, it's not safe to do that because the download logic repeatedly 226 // looks for this WebContents based on a render ID. Instead, we just 227 // leave the pending renderer around until the next navigation event 228 // (Navigate, DidNavigate, etc), which will clean it up properly. 229 // 230 // TODO(creis): Find a way to cancel any pending RFH here. 231 } 232 233 // Do not usually clear the pending entry if one exists, so that the user's 234 // typed URL is not lost when a navigation fails or is aborted. However, in 235 // cases that we don't show the pending entry (e.g., renderer-initiated 236 // navigations in an existing tab), we don't keep it around. That prevents 237 // spoofs on in-page navigations that don't go through 238 // DidStartProvisionalLoadForFrame. 239 // In general, we allow the view to clear the pending entry and typed URL if 240 // the user requests (e.g., hitting Escape with focus in the address bar). 241 // Note: don't touch the transient entry, since an interstitial may exist. 242 if (controller_->GetPendingEntry() != controller_->GetVisibleEntry()) 243 controller_->DiscardPendingEntry(); 244 245 if (delegate_) 246 delegate_->DidFailProvisionalLoadWithError(render_frame_host, params); 247} 248 249void NavigatorImpl::DidFailLoadWithError( 250 RenderFrameHostImpl* render_frame_host, 251 const GURL& url, 252 int error_code, 253 const base::string16& error_description) { 254 if (delegate_) { 255 delegate_->DidFailLoadWithError( 256 render_frame_host, url, error_code, 257 error_description); 258 } 259} 260 261void NavigatorImpl::DidRedirectProvisionalLoad( 262 RenderFrameHostImpl* render_frame_host, 263 int32 page_id, 264 const GURL& source_url, 265 const GURL& target_url) { 266 // TODO(creis): Remove this method and have the pre-rendering code listen to 267 // WebContentsObserver::DidGetRedirectForResourceRequest instead. 268 // See http://crbug.com/78512. 269 GURL validated_source_url(source_url); 270 GURL validated_target_url(target_url); 271 RenderProcessHost* render_process_host = render_frame_host->GetProcess(); 272 render_process_host->FilterURL(false, &validated_source_url); 273 render_process_host->FilterURL(false, &validated_target_url); 274 NavigationEntry* entry; 275 if (page_id == -1) { 276 entry = controller_->GetPendingEntry(); 277 } else { 278 entry = controller_->GetEntryWithPageID( 279 render_frame_host->GetSiteInstance(), page_id); 280 } 281 if (!entry || entry->GetURL() != validated_source_url) 282 return; 283 284 if (delegate_) { 285 delegate_->DidRedirectProvisionalLoad( 286 render_frame_host, validated_target_url); 287 } 288} 289 290bool NavigatorImpl::NavigateToEntry( 291 RenderFrameHostImpl* render_frame_host, 292 const NavigationEntryImpl& entry, 293 NavigationController::ReloadType reload_type) { 294 TRACE_EVENT0("browser", "NavigatorImpl::NavigateToEntry"); 295 296 // The renderer will reject IPC messages with URLs longer than 297 // this limit, so don't attempt to navigate with a longer URL. 298 if (entry.GetURL().spec().size() > GetMaxURLChars()) { 299 LOG(WARNING) << "Refusing to load URL as it exceeds " << GetMaxURLChars() 300 << " characters."; 301 return false; 302 } 303 304 RenderFrameHostManager* manager = 305 render_frame_host->frame_tree_node()->render_manager(); 306 RenderFrameHostImpl* dest_render_frame_host = manager->Navigate(entry); 307 if (!dest_render_frame_host) 308 return false; // Unable to create the desired RenderFrameHost. 309 310 // Make sure no code called via RFHM::Navigate clears the pending entry. 311 CHECK_EQ(controller_->GetPendingEntry(), &entry); 312 313 // For security, we should never send non-Web-UI URLs to a Web UI renderer. 314 // Double check that here. 315 int enabled_bindings = 316 dest_render_frame_host->render_view_host()->GetEnabledBindings(); 317 bool is_allowed_in_web_ui_renderer = 318 WebUIControllerFactoryRegistry::GetInstance()->IsURLAcceptableForWebUI( 319 controller_->GetBrowserContext(), entry.GetURL()); 320 if ((enabled_bindings & BINDINGS_POLICY_WEB_UI) && 321 !is_allowed_in_web_ui_renderer) { 322 // Log the URL to help us diagnose any future failures of this CHECK. 323 GetContentClient()->SetActiveURL(entry.GetURL()); 324 CHECK(0); 325 } 326 327 // Notify observers that we will navigate in this RenderFrame. 328 if (delegate_) 329 delegate_->AboutToNavigateRenderFrame(dest_render_frame_host); 330 331 // Used for page load time metrics. 332 current_load_start_ = base::TimeTicks::Now(); 333 334 // Navigate in the desired RenderFrameHost. 335 FrameMsg_Navigate_Params navigate_params; 336 MakeNavigateParams(entry, *controller_, reload_type, &navigate_params); 337 dest_render_frame_host->Navigate(navigate_params); 338 339 // Make sure no code called via RFH::Navigate clears the pending entry. 340 CHECK_EQ(controller_->GetPendingEntry(), &entry); 341 342 if (entry.GetPageID() == -1) { 343 // HACK!! This code suppresses javascript: URLs from being added to 344 // session history, which is what we want to do for javascript: URLs that 345 // do not generate content. What we really need is a message from the 346 // renderer telling us that a new page was not created. The same message 347 // could be used for mailto: URLs and the like. 348 if (entry.GetURL().SchemeIs(kJavaScriptScheme)) 349 return false; 350 } 351 352 // Notify observers about navigation. 353 if (delegate_) { 354 delegate_->DidStartNavigationToPendingEntry(render_frame_host, 355 entry.GetURL(), 356 reload_type); 357 } 358 359 return true; 360} 361 362bool NavigatorImpl::NavigateToPendingEntry( 363 RenderFrameHostImpl* render_frame_host, 364 NavigationController::ReloadType reload_type) { 365 return NavigateToEntry( 366 render_frame_host, 367 *NavigationEntryImpl::FromNavigationEntry(controller_->GetPendingEntry()), 368 reload_type); 369} 370 371base::TimeTicks NavigatorImpl::GetCurrentLoadStart() { 372 return current_load_start_; 373} 374 375void NavigatorImpl::DidNavigate( 376 RenderFrameHostImpl* render_frame_host, 377 const FrameHostMsg_DidCommitProvisionalLoad_Params& input_params) { 378 FrameHostMsg_DidCommitProvisionalLoad_Params params(input_params); 379 FrameTree* frame_tree = render_frame_host->frame_tree_node()->frame_tree(); 380 bool use_site_per_process = 381 CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess); 382 383 if (use_site_per_process) { 384 // TODO(creis): Until we mirror the frame tree in the subframe's process, 385 // cross-process subframe navigations happen in a renderer's main frame. 386 // Correct the transition type here if we know it is for a subframe. 387 NavigationEntryImpl* pending_entry = 388 NavigationEntryImpl::FromNavigationEntry( 389 controller_->GetPendingEntry()); 390 if (!render_frame_host->frame_tree_node()->IsMainFrame() && 391 pending_entry && 392 pending_entry->frame_tree_node_id() == 393 render_frame_host->frame_tree_node()->frame_tree_node_id()) { 394 params.transition = PAGE_TRANSITION_AUTO_SUBFRAME; 395 } 396 } 397 398 if (PageTransitionIsMainFrame(params.transition)) { 399 if (delegate_) { 400 // When overscroll navigation gesture is enabled, a screenshot of the page 401 // in its current state is taken so that it can be used during the 402 // nav-gesture. It is necessary to take the screenshot here, before 403 // calling RenderFrameHostManager::DidNavigateMainFrame, because that can 404 // change WebContents::GetRenderViewHost to return the new host, instead 405 // of the one that may have just been swapped out. 406 if (delegate_->CanOverscrollContent()) 407 controller_->TakeScreenshot(); 408 409 // Run tasks that must execute just before the commit. 410 delegate_->DidNavigateMainFramePreCommit(params); 411 } 412 413 if (!use_site_per_process) 414 frame_tree->root()->render_manager()->DidNavigateFrame(render_frame_host); 415 } 416 417 // When using --site-per-process, we notify the RFHM for all navigations, 418 // not just main frame navigations. 419 if (use_site_per_process) { 420 FrameTreeNode* frame = render_frame_host->frame_tree_node(); 421 frame->render_manager()->DidNavigateFrame(render_frame_host); 422 } 423 424 // Update the site of the SiteInstance if it doesn't have one yet, unless 425 // assigning a site is not necessary for this URL. In that case, the 426 // SiteInstance can still be considered unused until a navigation to a real 427 // page. 428 SiteInstanceImpl* site_instance = 429 static_cast<SiteInstanceImpl*>(render_frame_host->GetSiteInstance()); 430 if (!site_instance->HasSite() && 431 ShouldAssignSiteForURL(params.url)) { 432 site_instance->SetSite(params.url); 433 } 434 435 // Need to update MIME type here because it's referred to in 436 // UpdateNavigationCommands() called by RendererDidNavigate() to 437 // determine whether or not to enable the encoding menu. 438 // It's updated only for the main frame. For a subframe, 439 // RenderView::UpdateURL does not set params.contents_mime_type. 440 // (see http://code.google.com/p/chromium/issues/detail?id=2929 ) 441 // TODO(jungshik): Add a test for the encoding menu to avoid 442 // regressing it again. 443 // TODO(nasko): Verify the correctness of the above comment, since some of the 444 // code doesn't exist anymore. Also, move this code in the 445 // PageTransitionIsMainFrame code block above. 446 if (PageTransitionIsMainFrame(params.transition) && delegate_) 447 delegate_->SetMainFrameMimeType(params.contents_mime_type); 448 449 LoadCommittedDetails details; 450 bool did_navigate = controller_->RendererDidNavigate(render_frame_host, 451 params, &details); 452 453 // For now, keep track of each frame's URL in its FrameTreeNode. This lets 454 // us estimate our process count for implementing OOP iframes. 455 // TODO(creis): Remove this when we track which pages commit in each frame. 456 render_frame_host->frame_tree_node()->set_current_url(params.url); 457 458 // Send notification about committed provisional loads. This notification is 459 // different from the NAV_ENTRY_COMMITTED notification which doesn't include 460 // the actual URL navigated to and isn't sent for AUTO_SUBFRAME navigations. 461 if (details.type != NAVIGATION_TYPE_NAV_IGNORE && delegate_) { 462 // For AUTO_SUBFRAME navigations, an event for the main frame is generated 463 // that is not recorded in the navigation history. For the purpose of 464 // tracking navigation events, we treat this event as a sub frame navigation 465 // event. 466 bool is_main_frame = did_navigate ? details.is_main_frame : false; 467 PageTransition transition_type = params.transition; 468 // Whether or not a page transition was triggered by going backward or 469 // forward in the history is only stored in the navigation controller's 470 // entry list. 471 if (did_navigate && 472 (controller_->GetLastCommittedEntry()->GetTransitionType() & 473 PAGE_TRANSITION_FORWARD_BACK)) { 474 transition_type = PageTransitionFromInt( 475 params.transition | PAGE_TRANSITION_FORWARD_BACK); 476 } 477 478 delegate_->DidCommitProvisionalLoad(render_frame_host, 479 params.frame_unique_name, 480 is_main_frame, 481 params.url, 482 transition_type); 483 } 484 485 if (!did_navigate) 486 return; // No navigation happened. 487 488 // DO NOT ADD MORE STUFF TO THIS FUNCTION! Your component should either listen 489 // for the appropriate notification (best) or you can add it to 490 // DidNavigateMainFramePostCommit / DidNavigateAnyFramePostCommit (only if 491 // necessary, please). 492 493 // Run post-commit tasks. 494 if (delegate_) { 495 if (details.is_main_frame) 496 delegate_->DidNavigateMainFramePostCommit(details, params); 497 498 delegate_->DidNavigateAnyFramePostCommit( 499 render_frame_host, details, params); 500 } 501} 502 503bool NavigatorImpl::ShouldAssignSiteForURL(const GURL& url) { 504 // about:blank should not "use up" a new SiteInstance. The SiteInstance can 505 // still be used for a normal web site. 506 if (url == GURL(kAboutBlankURL)) 507 return false; 508 509 // The embedder will then have the opportunity to determine if the URL 510 // should "use up" the SiteInstance. 511 return GetContentClient()->browser()->ShouldAssignSiteForURL(url); 512} 513 514void NavigatorImpl::RequestOpenURL( 515 RenderFrameHostImpl* render_frame_host, 516 const GURL& url, 517 const Referrer& referrer, 518 WindowOpenDisposition disposition, 519 bool should_replace_current_entry, 520 bool user_gesture) { 521 SiteInstance* current_site_instance = 522 GetRenderManager(render_frame_host)->current_frame_host()-> 523 GetSiteInstance(); 524 // If this came from a swapped out RenderViewHost, we only allow the request 525 // if we are still in the same BrowsingInstance. 526 if (render_frame_host->render_view_host()->IsSwappedOut() && 527 !render_frame_host->GetSiteInstance()->IsRelatedSiteInstance( 528 current_site_instance)) { 529 return; 530 } 531 532 // Delegate to RequestTransferURL because this is just the generic 533 // case where |old_request_id| is empty. 534 // TODO(creis): Pass the redirect_chain into this method to support client 535 // redirects. http://crbug.com/311721. 536 std::vector<GURL> redirect_chain; 537 RequestTransferURL( 538 render_frame_host, url, redirect_chain, referrer, PAGE_TRANSITION_LINK, 539 disposition, GlobalRequestID(), 540 should_replace_current_entry, user_gesture); 541} 542 543void NavigatorImpl::RequestTransferURL( 544 RenderFrameHostImpl* render_frame_host, 545 const GURL& url, 546 const std::vector<GURL>& redirect_chain, 547 const Referrer& referrer, 548 PageTransition page_transition, 549 WindowOpenDisposition disposition, 550 const GlobalRequestID& transferred_global_request_id, 551 bool should_replace_current_entry, 552 bool user_gesture) { 553 GURL dest_url(url); 554 SiteInstance* current_site_instance = 555 GetRenderManager(render_frame_host)->current_frame_host()-> 556 GetSiteInstance(); 557 if (!GetContentClient()->browser()->ShouldAllowOpenURL( 558 current_site_instance, url)) { 559 dest_url = GURL(kAboutBlankURL); 560 } 561 562 int64 frame_tree_node_id = -1; 563 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess)) { 564 frame_tree_node_id = 565 render_frame_host->frame_tree_node()->frame_tree_node_id(); 566 } 567 OpenURLParams params( 568 dest_url, referrer, frame_tree_node_id, disposition, page_transition, 569 true /* is_renderer_initiated */); 570 if (redirect_chain.size() > 0) 571 params.redirect_chain = redirect_chain; 572 params.transferred_global_request_id = transferred_global_request_id; 573 params.should_replace_current_entry = should_replace_current_entry; 574 params.user_gesture = user_gesture; 575 576 if (GetRenderManager(render_frame_host)->web_ui()) { 577 // Web UI pages sometimes want to override the page transition type for 578 // link clicks (e.g., so the new tab page can specify AUTO_BOOKMARK for 579 // automatically generated suggestions). We don't override other types 580 // like TYPED because they have different implications (e.g., autocomplete). 581 if (PageTransitionCoreTypeIs(params.transition, PAGE_TRANSITION_LINK)) 582 params.transition = 583 GetRenderManager(render_frame_host)->web_ui()-> 584 GetLinkTransitionType(); 585 586 // Note also that we hide the referrer for Web UI pages. We don't really 587 // want web sites to see a referrer of "chrome://blah" (and some 588 // chrome: URLs might have search terms or other stuff we don't want to 589 // send to the site), so we send no referrer. 590 params.referrer = Referrer(); 591 592 // Navigations in Web UI pages count as browser-initiated navigations. 593 params.is_renderer_initiated = false; 594 } 595 596 if (delegate_) 597 delegate_->RequestOpenURL(render_frame_host, params); 598} 599 600} // namespace content 601