Remove PlatformFile from profile_browsertest
[chromium-blink-merge.git] / content / browser / frame_host / navigator_impl.cc
bloba9836089cc21893d628cd9861c2d7f10aea22410
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.
5 #include "content/browser/frame_host/navigator_impl.h"
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"
34 namespace content {
36 namespace {
38 FrameMsg_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.
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;
61 return FrameMsg_Navigate_Type::NORMAL;
64 void 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();
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();
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());
111 params->redirects = entry.redirect_chain();
113 params->can_load_local_resources = entry.GetCanLoadLocalResources();
114 params->frame_to_navigate = entry.GetFrameToNavigate();
117 RenderFrameHostManager* GetRenderManager(RenderFrameHostImpl* rfh) {
118 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess))
119 return rfh->frame_tree_node()->render_manager();
121 return rfh->frame_tree_node()->frame_tree()->root()->render_manager();
124 } // namespace
127 NavigatorImpl::NavigatorImpl(
128 NavigationControllerImpl* navigation_controller,
129 NavigatorDelegate* delegate)
130 : controller_(navigation_controller),
131 delegate_(delegate) {
134 void 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);
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());
174 controller_->SetPendingEntry(entry);
175 if (delegate_)
176 delegate_->NotifyChangedNavigationState(content::INVALIDATE_TYPE_URL);
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);
189 void 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);
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.
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;
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.
230 // TODO(creis): Find a way to cancel any pending RFH here.
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();
245 if (delegate_)
246 delegate_->DidFailProvisionalLoadWithError(render_frame_host, params);
249 void 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);
261 void 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);
281 if (!entry || entry->GetURL() != validated_source_url)
282 return;
284 if (delegate_) {
285 delegate_->DidRedirectProvisionalLoad(
286 render_frame_host, validated_target_url);
290 bool NavigatorImpl::NavigateToEntry(
291 RenderFrameHostImpl* render_frame_host,
292 const NavigationEntryImpl& entry,
293 NavigationController::ReloadType reload_type) {
294 TRACE_EVENT0("browser", "NavigatorImpl::NavigateToEntry");
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;
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.
310 // Make sure no code called via RFHM::Navigate clears the pending entry.
311 CHECK_EQ(controller_->GetPendingEntry(), &entry);
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);
327 // Notify observers that we will navigate in this RenderFrame.
328 if (delegate_)
329 delegate_->AboutToNavigateRenderFrame(dest_render_frame_host);
331 // Used for page load time metrics.
332 current_load_start_ = base::TimeTicks::Now();
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);
339 // Make sure no code called via RFH::Navigate clears the pending entry.
340 CHECK_EQ(controller_->GetPendingEntry(), &entry);
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;
352 // Notify observers about navigation.
353 if (delegate_) {
354 delegate_->DidStartNavigationToPendingEntry(render_frame_host,
355 entry.GetURL(),
356 reload_type);
359 return true;
362 bool 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);
371 base::TimeTicks NavigatorImpl::GetCurrentLoadStart() {
372 return current_load_start_;
375 void 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);
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;
398 if (PageTransitionIsMainFrame(params.transition)) {
399 // When overscroll navigation gesture is enabled, a screenshot of the page
400 // in its current state is taken so that it can be used during the
401 // nav-gesture. It is necessary to take the screenshot here, before calling
402 // RenderFrameHostManager::DidNavigateMainFrame, because that can change
403 // WebContents::GetRenderViewHost to return the new host, instead of the one
404 // that may have just been swapped out.
405 if (delegate_ && delegate_->CanOverscrollContent())
406 controller_->TakeScreenshot();
408 if (!use_site_per_process)
409 frame_tree->root()->render_manager()->DidNavigateFrame(render_frame_host);
412 // When using --site-per-process, we notify the RFHM for all navigations,
413 // not just main frame navigations.
414 if (use_site_per_process) {
415 FrameTreeNode* frame = render_frame_host->frame_tree_node();
416 frame->render_manager()->DidNavigateFrame(render_frame_host);
419 // Update the site of the SiteInstance if it doesn't have one yet, unless
420 // assigning a site is not necessary for this URL. In that case, the
421 // SiteInstance can still be considered unused until a navigation to a real
422 // page.
423 SiteInstanceImpl* site_instance =
424 static_cast<SiteInstanceImpl*>(render_frame_host->GetSiteInstance());
425 if (!site_instance->HasSite() &&
426 ShouldAssignSiteForURL(params.url)) {
427 site_instance->SetSite(params.url);
430 // Need to update MIME type here because it's referred to in
431 // UpdateNavigationCommands() called by RendererDidNavigate() to
432 // determine whether or not to enable the encoding menu.
433 // It's updated only for the main frame. For a subframe,
434 // RenderView::UpdateURL does not set params.contents_mime_type.
435 // (see http://code.google.com/p/chromium/issues/detail?id=2929 )
436 // TODO(jungshik): Add a test for the encoding menu to avoid
437 // regressing it again.
438 // TODO(nasko): Verify the correctness of the above comment, since some of the
439 // code doesn't exist anymore. Also, move this code in the
440 // PageTransitionIsMainFrame code block above.
441 if (PageTransitionIsMainFrame(params.transition) && delegate_)
442 delegate_->SetMainFrameMimeType(params.contents_mime_type);
444 LoadCommittedDetails details;
445 bool did_navigate = controller_->RendererDidNavigate(render_frame_host,
446 params, &details);
448 // For now, keep track of each frame's URL in its FrameTreeNode. This lets
449 // us estimate our process count for implementing OOP iframes.
450 // TODO(creis): Remove this when we track which pages commit in each frame.
451 render_frame_host->frame_tree_node()->set_current_url(params.url);
453 // Send notification about committed provisional loads. This notification is
454 // different from the NAV_ENTRY_COMMITTED notification which doesn't include
455 // the actual URL navigated to and isn't sent for AUTO_SUBFRAME navigations.
456 if (details.type != NAVIGATION_TYPE_NAV_IGNORE && delegate_) {
457 // For AUTO_SUBFRAME navigations, an event for the main frame is generated
458 // that is not recorded in the navigation history. For the purpose of
459 // tracking navigation events, we treat this event as a sub frame navigation
460 // event.
461 bool is_main_frame = did_navigate ? details.is_main_frame : false;
462 PageTransition transition_type = params.transition;
463 // Whether or not a page transition was triggered by going backward or
464 // forward in the history is only stored in the navigation controller's
465 // entry list.
466 if (did_navigate &&
467 (controller_->GetLastCommittedEntry()->GetTransitionType() &
468 PAGE_TRANSITION_FORWARD_BACK)) {
469 transition_type = PageTransitionFromInt(
470 params.transition | PAGE_TRANSITION_FORWARD_BACK);
473 delegate_->DidCommitProvisionalLoad(render_frame_host,
474 params.frame_unique_name,
475 is_main_frame,
476 params.url,
477 transition_type);
480 if (!did_navigate)
481 return; // No navigation happened.
483 // DO NOT ADD MORE STUFF TO THIS FUNCTION! Your component should either listen
484 // for the appropriate notification (best) or you can add it to
485 // DidNavigateMainFramePostCommit / DidNavigateAnyFramePostCommit (only if
486 // necessary, please).
488 // Run post-commit tasks.
489 if (delegate_) {
490 if (details.is_main_frame)
491 delegate_->DidNavigateMainFramePostCommit(details, params);
493 delegate_->DidNavigateAnyFramePostCommit(
494 render_frame_host, details, params);
498 bool NavigatorImpl::ShouldAssignSiteForURL(const GURL& url) {
499 // about:blank should not "use up" a new SiteInstance. The SiteInstance can
500 // still be used for a normal web site.
501 if (url == GURL(kAboutBlankURL))
502 return false;
504 // The embedder will then have the opportunity to determine if the URL
505 // should "use up" the SiteInstance.
506 return GetContentClient()->browser()->ShouldAssignSiteForURL(url);
509 void NavigatorImpl::RequestOpenURL(
510 RenderFrameHostImpl* render_frame_host,
511 const GURL& url,
512 const Referrer& referrer,
513 WindowOpenDisposition disposition,
514 bool should_replace_current_entry,
515 bool user_gesture) {
516 SiteInstance* current_site_instance =
517 GetRenderManager(render_frame_host)->current_frame_host()->
518 GetSiteInstance();
519 // If this came from a swapped out RenderViewHost, we only allow the request
520 // if we are still in the same BrowsingInstance.
521 if (render_frame_host->render_view_host()->IsSwappedOut() &&
522 !render_frame_host->GetSiteInstance()->IsRelatedSiteInstance(
523 current_site_instance)) {
524 return;
527 // Delegate to RequestTransferURL because this is just the generic
528 // case where |old_request_id| is empty.
529 // TODO(creis): Pass the redirect_chain into this method to support client
530 // redirects. http://crbug.com/311721.
531 std::vector<GURL> redirect_chain;
532 RequestTransferURL(
533 render_frame_host, url, redirect_chain, referrer, PAGE_TRANSITION_LINK,
534 disposition, GlobalRequestID(),
535 should_replace_current_entry, user_gesture);
538 void NavigatorImpl::RequestTransferURL(
539 RenderFrameHostImpl* render_frame_host,
540 const GURL& url,
541 const std::vector<GURL>& redirect_chain,
542 const Referrer& referrer,
543 PageTransition page_transition,
544 WindowOpenDisposition disposition,
545 const GlobalRequestID& transferred_global_request_id,
546 bool should_replace_current_entry,
547 bool user_gesture) {
548 GURL dest_url(url);
549 SiteInstance* current_site_instance =
550 GetRenderManager(render_frame_host)->current_frame_host()->
551 GetSiteInstance();
552 if (!GetContentClient()->browser()->ShouldAllowOpenURL(
553 current_site_instance, url)) {
554 dest_url = GURL(kAboutBlankURL);
557 int64 frame_tree_node_id = -1;
558 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess)) {
559 frame_tree_node_id =
560 render_frame_host->frame_tree_node()->frame_tree_node_id();
562 OpenURLParams params(
563 dest_url, referrer, frame_tree_node_id, disposition, page_transition,
564 true /* is_renderer_initiated */);
565 if (redirect_chain.size() > 0)
566 params.redirect_chain = redirect_chain;
567 params.transferred_global_request_id = transferred_global_request_id;
568 params.should_replace_current_entry = should_replace_current_entry;
569 params.user_gesture = user_gesture;
571 if (GetRenderManager(render_frame_host)->web_ui()) {
572 // Web UI pages sometimes want to override the page transition type for
573 // link clicks (e.g., so the new tab page can specify AUTO_BOOKMARK for
574 // automatically generated suggestions). We don't override other types
575 // like TYPED because they have different implications (e.g., autocomplete).
576 if (PageTransitionCoreTypeIs(params.transition, PAGE_TRANSITION_LINK))
577 params.transition =
578 GetRenderManager(render_frame_host)->web_ui()->
579 GetLinkTransitionType();
581 // Note also that we hide the referrer for Web UI pages. We don't really
582 // want web sites to see a referrer of "chrome://blah" (and some
583 // chrome: URLs might have search terms or other stuff we don't want to
584 // send to the site), so we send no referrer.
585 params.referrer = Referrer();
587 // Navigations in Web UI pages count as browser-initiated navigations.
588 params.is_renderer_initiated = false;
591 if (delegate_)
592 delegate_->RequestOpenURL(render_frame_host, params);
595 } // namespace content