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

Side by Side Diff: content/browser/frame_host/navigator_impl.cc

Issue 562603002: Move PageTransition from //content/public/common to //ui/base (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 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 "content/browser/frame_host/navigator_impl.h" 5 #include "content/browser/frame_host/navigator_impl.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/time/time.h" 8 #include "base/time/time.h"
9 #include "content/browser/frame_host/frame_tree.h" 9 #include "content/browser/frame_host/frame_tree.h"
10 #include "content/browser/frame_host/frame_tree_node.h" 10 #include "content/browser/frame_host/frame_tree_node.h"
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 params->is_post = entry.GetHasPostData(); 129 params->is_post = entry.GetHasPostData();
130 if (entry.GetBrowserInitiatedPostData()) { 130 if (entry.GetBrowserInitiatedPostData()) {
131 params->browser_initiated_post_data.assign( 131 params->browser_initiated_post_data.assign(
132 entry.GetBrowserInitiatedPostData()->front(), 132 entry.GetBrowserInitiatedPostData()->front(),
133 entry.GetBrowserInitiatedPostData()->front() + 133 entry.GetBrowserInitiatedPostData()->front() +
134 entry.GetBrowserInitiatedPostData()->size()); 134 entry.GetBrowserInitiatedPostData()->size());
135 } 135 }
136 136
137 // Set the redirect chain to the navigation's redirects, unless we are 137 // Set the redirect chain to the navigation's redirects, unless we are
138 // returning to a completed navigation (whose previous redirects don't apply). 138 // returning to a completed navigation (whose previous redirects don't apply).
139 if (PageTransitionIsNewNavigation(params->transition)) { 139 if (ui::PageTransitionIsNewNavigation(params->transition)) {
140 params->redirects = entry.GetRedirectChain(); 140 params->redirects = entry.GetRedirectChain();
141 } else { 141 } else {
142 params->redirects.clear(); 142 params->redirects.clear();
143 } 143 }
144 144
145 params->can_load_local_resources = entry.GetCanLoadLocalResources(); 145 params->can_load_local_resources = entry.GetCanLoadLocalResources();
146 params->frame_to_navigate = entry.GetFrameToNavigate(); 146 params->frame_to_navigate = entry.GetFrameToNavigate();
147 params->browser_navigation_start = navigation_start; 147 params->browser_navigation_start = navigation_start;
148 } 148 }
149 149
(...skipping 19 matching lines...) Expand all
169 // is not for the error URL, create a pending entry using the current 169 // is not for the error URL, create a pending entry using the current
170 // SiteInstance, and ensure the address bar updates accordingly. We don't 170 // SiteInstance, and ensure the address bar updates accordingly. We don't
171 // know the referrer or extra headers at this point, but the referrer will 171 // know the referrer or extra headers at this point, but the referrer will
172 // be set properly upon commit. 172 // be set properly upon commit.
173 bool has_browser_initiated_pending_entry = pending_entry && 173 bool has_browser_initiated_pending_entry = pending_entry &&
174 !pending_entry->is_renderer_initiated(); 174 !pending_entry->is_renderer_initiated();
175 if (!has_browser_initiated_pending_entry && !is_error_page) { 175 if (!has_browser_initiated_pending_entry && !is_error_page) {
176 NavigationEntryImpl* entry = NavigationEntryImpl::FromNavigationEntry( 176 NavigationEntryImpl* entry = NavigationEntryImpl::FromNavigationEntry(
177 controller_->CreateNavigationEntry(validated_url, 177 controller_->CreateNavigationEntry(validated_url,
178 content::Referrer(), 178 content::Referrer(),
179 content::PAGE_TRANSITION_LINK, 179 ui::PAGE_TRANSITION_LINK,
180 true /* is_renderer_initiated */, 180 true /* is_renderer_initiated */,
181 std::string(), 181 std::string(),
182 controller_->GetBrowserContext())); 182 controller_->GetBrowserContext()));
183 entry->set_site_instance( 183 entry->set_site_instance(
184 static_cast<SiteInstanceImpl*>( 184 static_cast<SiteInstanceImpl*>(
185 render_frame_host->render_view_host()->GetSiteInstance())); 185 render_frame_host->render_view_host()->GetSiteInstance()));
186 // TODO(creis): If there's a pending entry already, find a safe way to 186 // TODO(creis): If there's a pending entry already, find a safe way to
187 // update it instead of replacing it and copying over things like this. 187 // update it instead of replacing it and copying over things like this.
188 if (pending_entry) { 188 if (pending_entry) {
189 entry->set_transferred_global_request_id( 189 entry->set_transferred_global_request_id(
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 // TODO(creis): Until we mirror the frame tree in the subframe's process, 440 // TODO(creis): Until we mirror the frame tree in the subframe's process,
441 // cross-process subframe navigations happen in a renderer's main frame. 441 // cross-process subframe navigations happen in a renderer's main frame.
442 // Correct the transition type here if we know it is for a subframe. 442 // Correct the transition type here if we know it is for a subframe.
443 NavigationEntryImpl* pending_entry = 443 NavigationEntryImpl* pending_entry =
444 NavigationEntryImpl::FromNavigationEntry( 444 NavigationEntryImpl::FromNavigationEntry(
445 controller_->GetPendingEntry()); 445 controller_->GetPendingEntry());
446 if (!render_frame_host->frame_tree_node()->IsMainFrame() && 446 if (!render_frame_host->frame_tree_node()->IsMainFrame() &&
447 pending_entry && 447 pending_entry &&
448 pending_entry->frame_tree_node_id() == 448 pending_entry->frame_tree_node_id() ==
449 render_frame_host->frame_tree_node()->frame_tree_node_id()) { 449 render_frame_host->frame_tree_node()->frame_tree_node_id()) {
450 params.transition = PAGE_TRANSITION_AUTO_SUBFRAME; 450 params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME;
451 } 451 }
452 } 452 }
453 453
454 if (PageTransitionIsMainFrame(params.transition)) { 454 if (ui::PageTransitionIsMainFrame(params.transition)) {
455 if (delegate_) { 455 if (delegate_) {
456 // When overscroll navigation gesture is enabled, a screenshot of the page 456 // When overscroll navigation gesture is enabled, a screenshot of the page
457 // in its current state is taken so that it can be used during the 457 // in its current state is taken so that it can be used during the
458 // nav-gesture. It is necessary to take the screenshot here, before 458 // nav-gesture. It is necessary to take the screenshot here, before
459 // calling RenderFrameHostManager::DidNavigateMainFrame, because that can 459 // calling RenderFrameHostManager::DidNavigateMainFrame, because that can
460 // change WebContents::GetRenderViewHost to return the new host, instead 460 // change WebContents::GetRenderViewHost to return the new host, instead
461 // of the one that may have just been swapped out. 461 // of the one that may have just been swapped out.
462 if (delegate_->CanOverscrollContent()) { 462 if (delegate_->CanOverscrollContent()) {
463 // Don't take screenshots if we are staying on the same page. We want 463 // Don't take screenshots if we are staying on the same page. We want
464 // in-page navigations to be super fast, and taking a screenshot 464 // in-page navigations to be super fast, and taking a screenshot
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 // UpdateNavigationCommands() called by RendererDidNavigate() to 500 // UpdateNavigationCommands() called by RendererDidNavigate() to
501 // determine whether or not to enable the encoding menu. 501 // determine whether or not to enable the encoding menu.
502 // It's updated only for the main frame. For a subframe, 502 // It's updated only for the main frame. For a subframe,
503 // RenderView::UpdateURL does not set params.contents_mime_type. 503 // RenderView::UpdateURL does not set params.contents_mime_type.
504 // (see http://code.google.com/p/chromium/issues/detail?id=2929 ) 504 // (see http://code.google.com/p/chromium/issues/detail?id=2929 )
505 // TODO(jungshik): Add a test for the encoding menu to avoid 505 // TODO(jungshik): Add a test for the encoding menu to avoid
506 // regressing it again. 506 // regressing it again.
507 // TODO(nasko): Verify the correctness of the above comment, since some of the 507 // TODO(nasko): Verify the correctness of the above comment, since some of the
508 // code doesn't exist anymore. Also, move this code in the 508 // code doesn't exist anymore. Also, move this code in the
509 // PageTransitionIsMainFrame code block above. 509 // PageTransitionIsMainFrame code block above.
510 if (PageTransitionIsMainFrame(params.transition) && delegate_) 510 if (ui::PageTransitionIsMainFrame(params.transition) && delegate_)
511 delegate_->SetMainFrameMimeType(params.contents_mime_type); 511 delegate_->SetMainFrameMimeType(params.contents_mime_type);
512 512
513 LoadCommittedDetails details; 513 LoadCommittedDetails details;
514 bool did_navigate = controller_->RendererDidNavigate(render_frame_host, 514 bool did_navigate = controller_->RendererDidNavigate(render_frame_host,
515 params, &details); 515 params, &details);
516 516
517 // For now, keep track of each frame's URL in its FrameTreeNode. This lets 517 // For now, keep track of each frame's URL in its FrameTreeNode. This lets
518 // us estimate our process count for implementing OOP iframes. 518 // us estimate our process count for implementing OOP iframes.
519 // TODO(creis): Remove this when we track which pages commit in each frame. 519 // TODO(creis): Remove this when we track which pages commit in each frame.
520 render_frame_host->frame_tree_node()->set_current_url(params.url); 520 render_frame_host->frame_tree_node()->set_current_url(params.url);
521 521
522 // Send notification about committed provisional loads. This notification is 522 // Send notification about committed provisional loads. This notification is
523 // different from the NAV_ENTRY_COMMITTED notification which doesn't include 523 // different from the NAV_ENTRY_COMMITTED notification which doesn't include
524 // the actual URL navigated to and isn't sent for AUTO_SUBFRAME navigations. 524 // the actual URL navigated to and isn't sent for AUTO_SUBFRAME navigations.
525 if (details.type != NAVIGATION_TYPE_NAV_IGNORE && delegate_) { 525 if (details.type != NAVIGATION_TYPE_NAV_IGNORE && delegate_) {
526 DCHECK_EQ(!render_frame_host->GetParent(), 526 DCHECK_EQ(!render_frame_host->GetParent(),
527 did_navigate ? details.is_main_frame : false); 527 did_navigate ? details.is_main_frame : false);
528 PageTransition transition_type = params.transition; 528 ui::PageTransition transition_type = params.transition;
529 // Whether or not a page transition was triggered by going backward or 529 // Whether or not a page transition was triggered by going backward or
530 // forward in the history is only stored in the navigation controller's 530 // forward in the history is only stored in the navigation controller's
531 // entry list. 531 // entry list.
532 if (did_navigate && 532 if (did_navigate &&
533 (controller_->GetLastCommittedEntry()->GetTransitionType() & 533 (controller_->GetLastCommittedEntry()->GetTransitionType() &
534 PAGE_TRANSITION_FORWARD_BACK)) { 534 ui::PAGE_TRANSITION_FORWARD_BACK)) {
535 transition_type = PageTransitionFromInt( 535 transition_type = ui::PageTransitionFromInt(
536 params.transition | PAGE_TRANSITION_FORWARD_BACK); 536 params.transition | ui::PAGE_TRANSITION_FORWARD_BACK);
537 } 537 }
538 538
539 delegate_->DidCommitProvisionalLoad(render_frame_host, 539 delegate_->DidCommitProvisionalLoad(render_frame_host,
540 params.url, 540 params.url,
541 transition_type); 541 transition_type);
542 } 542 }
543 543
544 if (!did_navigate) 544 if (!did_navigate)
545 return; // No navigation happened. 545 return; // No navigation happened.
546 546
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 !render_frame_host->GetSiteInstance()->IsRelatedSiteInstance( 586 !render_frame_host->GetSiteInstance()->IsRelatedSiteInstance(
587 current_site_instance)) { 587 current_site_instance)) {
588 return; 588 return;
589 } 589 }
590 590
591 // Delegate to RequestTransferURL because this is just the generic 591 // Delegate to RequestTransferURL because this is just the generic
592 // case where |old_request_id| is empty. 592 // case where |old_request_id| is empty.
593 // TODO(creis): Pass the redirect_chain into this method to support client 593 // TODO(creis): Pass the redirect_chain into this method to support client
594 // redirects. http://crbug.com/311721. 594 // redirects. http://crbug.com/311721.
595 std::vector<GURL> redirect_chain; 595 std::vector<GURL> redirect_chain;
596 RequestTransferURL( 596 RequestTransferURL(render_frame_host,
597 render_frame_host, url, redirect_chain, referrer, PAGE_TRANSITION_LINK, 597 url,
598 disposition, GlobalRequestID(), 598 redirect_chain,
599 should_replace_current_entry, user_gesture); 599 referrer,
600 ui::PAGE_TRANSITION_LINK,
601 disposition,
602 GlobalRequestID(),
603 should_replace_current_entry,
604 user_gesture);
600 } 605 }
601 606
602 void NavigatorImpl::RequestTransferURL( 607 void NavigatorImpl::RequestTransferURL(
603 RenderFrameHostImpl* render_frame_host, 608 RenderFrameHostImpl* render_frame_host,
604 const GURL& url, 609 const GURL& url,
605 const std::vector<GURL>& redirect_chain, 610 const std::vector<GURL>& redirect_chain,
606 const Referrer& referrer, 611 const Referrer& referrer,
607 PageTransition page_transition, 612 ui::PageTransition page_transition,
608 WindowOpenDisposition disposition, 613 WindowOpenDisposition disposition,
609 const GlobalRequestID& transferred_global_request_id, 614 const GlobalRequestID& transferred_global_request_id,
610 bool should_replace_current_entry, 615 bool should_replace_current_entry,
611 bool user_gesture) { 616 bool user_gesture) {
612 GURL dest_url(url); 617 GURL dest_url(url);
613 SiteInstance* current_site_instance = 618 SiteInstance* current_site_instance =
614 GetRenderManager(render_frame_host)->current_frame_host()-> 619 GetRenderManager(render_frame_host)->current_frame_host()->
615 GetSiteInstance(); 620 GetSiteInstance();
616 if (!GetContentClient()->browser()->ShouldAllowOpenURL( 621 if (!GetContentClient()->browser()->ShouldAllowOpenURL(
617 current_site_instance, url)) { 622 current_site_instance, url)) {
(...skipping 13 matching lines...) Expand all
631 params.redirect_chain = redirect_chain; 636 params.redirect_chain = redirect_chain;
632 params.transferred_global_request_id = transferred_global_request_id; 637 params.transferred_global_request_id = transferred_global_request_id;
633 params.should_replace_current_entry = should_replace_current_entry; 638 params.should_replace_current_entry = should_replace_current_entry;
634 params.user_gesture = user_gesture; 639 params.user_gesture = user_gesture;
635 640
636 if (GetRenderManager(render_frame_host)->web_ui()) { 641 if (GetRenderManager(render_frame_host)->web_ui()) {
637 // Web UI pages sometimes want to override the page transition type for 642 // Web UI pages sometimes want to override the page transition type for
638 // link clicks (e.g., so the new tab page can specify AUTO_BOOKMARK for 643 // link clicks (e.g., so the new tab page can specify AUTO_BOOKMARK for
639 // automatically generated suggestions). We don't override other types 644 // automatically generated suggestions). We don't override other types
640 // like TYPED because they have different implications (e.g., autocomplete). 645 // like TYPED because they have different implications (e.g., autocomplete).
641 if (PageTransitionCoreTypeIs(params.transition, PAGE_TRANSITION_LINK)) 646 if (ui::PageTransitionCoreTypeIs(
647 params.transition, ui::PAGE_TRANSITION_LINK))
642 params.transition = 648 params.transition =
643 GetRenderManager(render_frame_host)->web_ui()-> 649 GetRenderManager(render_frame_host)->web_ui()->
644 GetLinkTransitionType(); 650 GetLinkTransitionType();
645 651
646 // Note also that we hide the referrer for Web UI pages. We don't really 652 // Note also that we hide the referrer for Web UI pages. We don't really
647 // want web sites to see a referrer of "chrome://blah" (and some 653 // want web sites to see a referrer of "chrome://blah" (and some
648 // chrome: URLs might have search terms or other stuff we don't want to 654 // chrome: URLs might have search terms or other stuff we don't want to
649 // send to the site), so we send no referrer. 655 // send to the site), so we send no referrer.
650 params.referrer = Referrer(); 656 params.referrer = Referrer();
651 657
(...skipping 24 matching lines...) Expand all
676 controller_->GetBrowserContext(), url); 682 controller_->GetBrowserContext(), url);
677 if ((enabled_bindings & BINDINGS_POLICY_WEB_UI) && 683 if ((enabled_bindings & BINDINGS_POLICY_WEB_UI) &&
678 !is_allowed_in_web_ui_renderer) { 684 !is_allowed_in_web_ui_renderer) {
679 // Log the URL to help us diagnose any future failures of this CHECK. 685 // Log the URL to help us diagnose any future failures of this CHECK.
680 GetContentClient()->SetActiveURL(url); 686 GetContentClient()->SetActiveURL(url);
681 CHECK(0); 687 CHECK(0);
682 } 688 }
683 } 689 }
684 690
685 } // namespace content 691 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/navigator_impl.h ('k') | content/browser/frame_host/render_frame_host_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698