| 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 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 617 // about:blank should not "use up" a new SiteInstance. The SiteInstance can | 617 // about:blank should not "use up" a new SiteInstance. The SiteInstance can |
| 618 // still be used for a normal web site. | 618 // still be used for a normal web site. |
| 619 if (url == GURL(url::kAboutBlankURL)) | 619 if (url == GURL(url::kAboutBlankURL)) |
| 620 return false; | 620 return false; |
| 621 | 621 |
| 622 // The embedder will then have the opportunity to determine if the URL | 622 // The embedder will then have the opportunity to determine if the URL |
| 623 // should "use up" the SiteInstance. | 623 // should "use up" the SiteInstance. |
| 624 return GetContentClient()->browser()->ShouldAssignSiteForURL(url); | 624 return GetContentClient()->browser()->ShouldAssignSiteForURL(url); |
| 625 } | 625 } |
| 626 | 626 |
| 627 void NavigatorImpl::RequestOpenURL( | 627 void NavigatorImpl::RequestOpenURL(RenderFrameHostImpl* render_frame_host, |
| 628 RenderFrameHostImpl* render_frame_host, | 628 const GURL& url, |
| 629 const GURL& url, | 629 SiteInstance* source_site_instance, |
| 630 const Referrer& referrer, | 630 const Referrer& referrer, |
| 631 WindowOpenDisposition disposition, | 631 WindowOpenDisposition disposition, |
| 632 bool should_replace_current_entry, | 632 bool should_replace_current_entry, |
| 633 bool user_gesture) { | 633 bool user_gesture) { |
| 634 SiteInstance* current_site_instance = | 634 SiteInstance* current_site_instance = |
| 635 GetRenderManager(render_frame_host)->current_frame_host()-> | 635 GetRenderManager(render_frame_host)->current_frame_host()-> |
| 636 GetSiteInstance(); | 636 GetSiteInstance(); |
| 637 // If this came from a swapped out RenderFrameHost, we only allow the request | 637 // If this came from a swapped out RenderFrameHost, we only allow the request |
| 638 // if we are still in the same BrowsingInstance. | 638 // if we are still in the same BrowsingInstance. |
| 639 // TODO(creis): Move this to RenderFrameProxyHost::OpenURL. | 639 // TODO(creis): Move this to RenderFrameProxyHost::OpenURL. |
| 640 if (render_frame_host->is_swapped_out() && | 640 if (render_frame_host->is_swapped_out() && |
| 641 !render_frame_host->GetSiteInstance()->IsRelatedSiteInstance( | 641 !render_frame_host->GetSiteInstance()->IsRelatedSiteInstance( |
| 642 current_site_instance)) { | 642 current_site_instance)) { |
| 643 return; | 643 return; |
| 644 } | 644 } |
| 645 | 645 |
| 646 // Delegate to RequestTransferURL because this is just the generic | 646 // Delegate to RequestTransferURL because this is just the generic |
| 647 // case where |old_request_id| is empty. | 647 // case where |old_request_id| is empty. |
| 648 // TODO(creis): Pass the redirect_chain into this method to support client | 648 // TODO(creis): Pass the redirect_chain into this method to support client |
| 649 // redirects. http://crbug.com/311721. | 649 // redirects. http://crbug.com/311721. |
| 650 std::vector<GURL> redirect_chain; | 650 std::vector<GURL> redirect_chain; |
| 651 RequestTransferURL(render_frame_host, | 651 RequestTransferURL(render_frame_host, url, source_site_instance, |
| 652 url, | 652 redirect_chain, referrer, ui::PAGE_TRANSITION_LINK, |
| 653 redirect_chain, | 653 disposition, GlobalRequestID(), |
| 654 referrer, | 654 should_replace_current_entry, user_gesture); |
| 655 ui::PAGE_TRANSITION_LINK, | |
| 656 disposition, | |
| 657 GlobalRequestID(), | |
| 658 should_replace_current_entry, | |
| 659 user_gesture); | |
| 660 } | 655 } |
| 661 | 656 |
| 662 void NavigatorImpl::RequestTransferURL( | 657 void NavigatorImpl::RequestTransferURL( |
| 663 RenderFrameHostImpl* render_frame_host, | 658 RenderFrameHostImpl* render_frame_host, |
| 664 const GURL& url, | 659 const GURL& url, |
| 660 SiteInstance* source_site_instance, |
| 665 const std::vector<GURL>& redirect_chain, | 661 const std::vector<GURL>& redirect_chain, |
| 666 const Referrer& referrer, | 662 const Referrer& referrer, |
| 667 ui::PageTransition page_transition, | 663 ui::PageTransition page_transition, |
| 668 WindowOpenDisposition disposition, | 664 WindowOpenDisposition disposition, |
| 669 const GlobalRequestID& transferred_global_request_id, | 665 const GlobalRequestID& transferred_global_request_id, |
| 670 bool should_replace_current_entry, | 666 bool should_replace_current_entry, |
| 671 bool user_gesture) { | 667 bool user_gesture) { |
| 672 GURL dest_url(url); | 668 GURL dest_url(url); |
| 673 SiteInstance* current_site_instance = | 669 SiteInstance* current_site_instance = |
| 674 GetRenderManager(render_frame_host)->current_frame_host()-> | 670 GetRenderManager(render_frame_host)->current_frame_host()-> |
| 675 GetSiteInstance(); | 671 GetSiteInstance(); |
| 676 if (!GetContentClient()->browser()->ShouldAllowOpenURL( | 672 if (!GetContentClient()->browser()->ShouldAllowOpenURL( |
| 677 current_site_instance, url)) { | 673 current_site_instance, url)) { |
| 678 dest_url = GURL(url::kAboutBlankURL); | 674 dest_url = GURL(url::kAboutBlankURL); |
| 679 } | 675 } |
| 680 | 676 |
| 681 int64 frame_tree_node_id = -1; | 677 int64 frame_tree_node_id = -1; |
| 682 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 678 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 683 switches::kSitePerProcess)) { | 679 switches::kSitePerProcess)) { |
| 684 frame_tree_node_id = | 680 frame_tree_node_id = |
| 685 render_frame_host->frame_tree_node()->frame_tree_node_id(); | 681 render_frame_host->frame_tree_node()->frame_tree_node_id(); |
| 686 } | 682 } |
| 687 OpenURLParams params( | 683 OpenURLParams params( |
| 688 dest_url, referrer, frame_tree_node_id, disposition, page_transition, | 684 dest_url, referrer, frame_tree_node_id, disposition, page_transition, |
| 689 true /* is_renderer_initiated */); | 685 true /* is_renderer_initiated */); |
| 686 params.source_site_instance = source_site_instance; |
| 690 if (redirect_chain.size() > 0) | 687 if (redirect_chain.size() > 0) |
| 691 params.redirect_chain = redirect_chain; | 688 params.redirect_chain = redirect_chain; |
| 692 params.transferred_global_request_id = transferred_global_request_id; | 689 params.transferred_global_request_id = transferred_global_request_id; |
| 693 params.should_replace_current_entry = should_replace_current_entry; | 690 params.should_replace_current_entry = should_replace_current_entry; |
| 694 params.user_gesture = user_gesture; | 691 params.user_gesture = user_gesture; |
| 695 | 692 |
| 696 if (GetRenderManager(render_frame_host)->web_ui()) { | 693 if (GetRenderManager(render_frame_host)->web_ui()) { |
| 697 // Web UI pages sometimes want to override the page transition type for | 694 // Web UI pages sometimes want to override the page transition type for |
| 698 // link clicks (e.g., so the new tab page can specify AUTO_BOOKMARK for | 695 // link clicks (e.g., so the new tab page can specify AUTO_BOOKMARK for |
| 699 // automatically generated suggestions). We don't override other types | 696 // automatically generated suggestions). We don't override other types |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 946 "Navigation.TimeToCommit_ExistingRenderer_BeforeUnloadDiscounted", | 943 "Navigation.TimeToCommit_ExistingRenderer_BeforeUnloadDiscounted", |
| 947 time_to_commit); | 944 time_to_commit); |
| 948 UMA_HISTOGRAM_TIMES( | 945 UMA_HISTOGRAM_TIMES( |
| 949 "Navigation.TimeToURLJobStart_ExistingRenderer_BeforeUnloadDiscounted", | 946 "Navigation.TimeToURLJobStart_ExistingRenderer_BeforeUnloadDiscounted", |
| 950 time_to_network); | 947 time_to_network); |
| 951 } | 948 } |
| 952 navigation_data_.reset(); | 949 navigation_data_.reset(); |
| 953 } | 950 } |
| 954 | 951 |
| 955 } // namespace content | 952 } // namespace content |
| OLD | NEW |