Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
| 10 #include "content/browser/frame_host/frame_tree.h" | 10 #include "content/browser/frame_host/frame_tree.h" |
| (...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 609 // about:blank should not "use up" a new SiteInstance. The SiteInstance can | 609 // about:blank should not "use up" a new SiteInstance. The SiteInstance can |
| 610 // still be used for a normal web site. | 610 // still be used for a normal web site. |
| 611 if (url == GURL(url::kAboutBlankURL)) | 611 if (url == GURL(url::kAboutBlankURL)) |
| 612 return false; | 612 return false; |
| 613 | 613 |
| 614 // The embedder will then have the opportunity to determine if the URL | 614 // The embedder will then have the opportunity to determine if the URL |
| 615 // should "use up" the SiteInstance. | 615 // should "use up" the SiteInstance. |
| 616 return GetContentClient()->browser()->ShouldAssignSiteForURL(url); | 616 return GetContentClient()->browser()->ShouldAssignSiteForURL(url); |
| 617 } | 617 } |
| 618 | 618 |
| 619 void NavigatorImpl::RequestOpenURL( | 619 void NavigatorImpl::RequestOpenURL(RenderFrameHostImpl* render_frame_host, |
| 620 RenderFrameHostImpl* render_frame_host, | 620 const GURL& url, |
| 621 const GURL& url, | 621 SiteInstance* site_instance, |
| 622 const Referrer& referrer, | 622 const Referrer& referrer, |
| 623 WindowOpenDisposition disposition, | 623 WindowOpenDisposition disposition, |
| 624 bool should_replace_current_entry, | 624 bool should_replace_current_entry, |
| 625 bool user_gesture) { | 625 bool user_gesture) { |
| 626 SiteInstance* current_site_instance = | 626 SiteInstance* current_site_instance = |
| 627 GetRenderManager(render_frame_host)->current_frame_host()-> | 627 GetRenderManager(render_frame_host)->current_frame_host()-> |
| 628 GetSiteInstance(); | 628 GetSiteInstance(); |
| 629 // If this came from a swapped out RenderFrameHost, we only allow the request | 629 // If this came from a swapped out RenderFrameHost, we only allow the request |
| 630 // if we are still in the same BrowsingInstance. | 630 // if we are still in the same BrowsingInstance. |
| 631 // TODO(creis): Move this to RenderFrameProxyHost::OpenURL. | 631 // TODO(creis): Move this to RenderFrameProxyHost::OpenURL. |
|
Charlie Reis
2014/11/20 19:58:43
Side note: There's a lot of cleanup needed here, w
| |
| 632 if (render_frame_host->is_swapped_out() && | 632 if (render_frame_host->is_swapped_out() && |
| 633 !render_frame_host->GetSiteInstance()->IsRelatedSiteInstance( | 633 !render_frame_host->GetSiteInstance()->IsRelatedSiteInstance( |
| 634 current_site_instance)) { | 634 current_site_instance)) { |
| 635 return; | 635 return; |
| 636 } | 636 } |
| 637 | 637 |
| 638 // Delegate to RequestTransferURL because this is just the generic | 638 // Delegate to RequestTransferURL because this is just the generic |
| 639 // case where |old_request_id| is empty. | 639 // case where |old_request_id| is empty. |
| 640 // TODO(creis): Pass the redirect_chain into this method to support client | 640 // TODO(creis): Pass the redirect_chain into this method to support client |
| 641 // redirects. http://crbug.com/311721. | 641 // redirects. http://crbug.com/311721. |
| 642 std::vector<GURL> redirect_chain; | 642 std::vector<GURL> redirect_chain; |
| 643 RequestTransferURL(render_frame_host, | 643 RequestTransferURL(render_frame_host, url, site_instance, redirect_chain, |
| 644 url, | 644 referrer, ui::PAGE_TRANSITION_LINK, disposition, |
| 645 redirect_chain, | 645 GlobalRequestID(), should_replace_current_entry, |
| 646 referrer, | |
| 647 ui::PAGE_TRANSITION_LINK, | |
| 648 disposition, | |
| 649 GlobalRequestID(), | |
| 650 should_replace_current_entry, | |
| 651 user_gesture); | 646 user_gesture); |
| 652 } | 647 } |
| 653 | 648 |
| 654 void NavigatorImpl::RequestTransferURL( | 649 void NavigatorImpl::RequestTransferURL( |
| 655 RenderFrameHostImpl* render_frame_host, | 650 RenderFrameHostImpl* render_frame_host, |
| 656 const GURL& url, | 651 const GURL& url, |
| 652 SiteInstance* site_instance, | |
| 657 const std::vector<GURL>& redirect_chain, | 653 const std::vector<GURL>& redirect_chain, |
| 658 const Referrer& referrer, | 654 const Referrer& referrer, |
| 659 ui::PageTransition page_transition, | 655 ui::PageTransition page_transition, |
| 660 WindowOpenDisposition disposition, | 656 WindowOpenDisposition disposition, |
| 661 const GlobalRequestID& transferred_global_request_id, | 657 const GlobalRequestID& transferred_global_request_id, |
| 662 bool should_replace_current_entry, | 658 bool should_replace_current_entry, |
| 663 bool user_gesture) { | 659 bool user_gesture) { |
| 664 GURL dest_url(url); | 660 GURL dest_url(url); |
| 665 SiteInstance* current_site_instance = | 661 SiteInstance* current_site_instance = |
| 666 GetRenderManager(render_frame_host)->current_frame_host()-> | 662 GetRenderManager(render_frame_host)->current_frame_host()-> |
| 667 GetSiteInstance(); | 663 GetSiteInstance(); |
| 668 if (!GetContentClient()->browser()->ShouldAllowOpenURL( | 664 if (!GetContentClient()->browser()->ShouldAllowOpenURL( |
| 669 current_site_instance, url)) { | 665 current_site_instance, url)) { |
| 670 dest_url = GURL(url::kAboutBlankURL); | 666 dest_url = GURL(url::kAboutBlankURL); |
| 671 } | 667 } |
| 672 | 668 |
| 673 int64 frame_tree_node_id = -1; | 669 int64 frame_tree_node_id = -1; |
| 674 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 670 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 675 switches::kSitePerProcess)) { | 671 switches::kSitePerProcess)) { |
| 676 frame_tree_node_id = | 672 frame_tree_node_id = |
| 677 render_frame_host->frame_tree_node()->frame_tree_node_id(); | 673 render_frame_host->frame_tree_node()->frame_tree_node_id(); |
| 678 } | 674 } |
| 679 OpenURLParams params( | 675 OpenURLParams params( |
| 680 dest_url, referrer, frame_tree_node_id, disposition, page_transition, | 676 dest_url, referrer, frame_tree_node_id, disposition, page_transition, |
| 681 true /* is_renderer_initiated */); | 677 true /* is_renderer_initiated */); |
| 678 params.site_instance = site_instance; | |
| 682 if (redirect_chain.size() > 0) | 679 if (redirect_chain.size() > 0) |
| 683 params.redirect_chain = redirect_chain; | 680 params.redirect_chain = redirect_chain; |
| 684 params.transferred_global_request_id = transferred_global_request_id; | 681 params.transferred_global_request_id = transferred_global_request_id; |
| 685 params.should_replace_current_entry = should_replace_current_entry; | 682 params.should_replace_current_entry = should_replace_current_entry; |
| 686 params.user_gesture = user_gesture; | 683 params.user_gesture = user_gesture; |
| 687 | 684 |
| 688 if (GetRenderManager(render_frame_host)->web_ui()) { | 685 if (GetRenderManager(render_frame_host)->web_ui()) { |
| 689 // Web UI pages sometimes want to override the page transition type for | 686 // Web UI pages sometimes want to override the page transition type for |
| 690 // link clicks (e.g., so the new tab page can specify AUTO_BOOKMARK for | 687 // link clicks (e.g., so the new tab page can specify AUTO_BOOKMARK for |
| 691 // automatically generated suggestions). We don't override other types | 688 // automatically generated suggestions). We don't override other types |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 922 "Navigation.TimeToCommit_ExistingRenderer_BeforeUnloadDiscounted", | 919 "Navigation.TimeToCommit_ExistingRenderer_BeforeUnloadDiscounted", |
| 923 time_to_commit); | 920 time_to_commit); |
| 924 UMA_HISTOGRAM_TIMES( | 921 UMA_HISTOGRAM_TIMES( |
| 925 "Navigation.TimeToURLJobStart_ExistingRenderer_BeforeUnloadDiscounted", | 922 "Navigation.TimeToURLJobStart_ExistingRenderer_BeforeUnloadDiscounted", |
| 926 time_to_network); | 923 time_to_network); |
| 927 } | 924 } |
| 928 navigation_data_.reset(); | 925 navigation_data_.reset(); |
| 929 } | 926 } |
| 930 | 927 |
| 931 } // namespace content | 928 } // namespace content |
| OLD | NEW |