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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
(...skipping 717 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
728 render_frame_host->frame_tree_node()->current_frame_host()) { | 728 render_frame_host->frame_tree_node()->current_frame_host()) { |
729 return; | 729 return; |
730 } | 730 } |
731 | 731 |
732 SiteInstance* current_site_instance = render_frame_host->GetSiteInstance(); | 732 SiteInstance* current_site_instance = render_frame_host->GetSiteInstance(); |
733 | 733 |
734 // TODO(creis): Pass the redirect_chain into this method to support client | 734 // TODO(creis): Pass the redirect_chain into this method to support client |
735 // redirects. http://crbug.com/311721. | 735 // redirects. http://crbug.com/311721. |
736 std::vector<GURL> redirect_chain; | 736 std::vector<GURL> redirect_chain; |
737 | 737 |
| 738 // Note that unlike RequestTransferURL, this uses the navigating |
| 739 // RenderFrameHost's current SiteInstance, as that's where this navigation |
| 740 // originated. |
738 GURL dest_url(url); | 741 GURL dest_url(url); |
739 if (!GetContentClient()->browser()->ShouldAllowOpenURL( | 742 if (!GetContentClient()->browser()->ShouldAllowOpenURL( |
740 current_site_instance, url)) { | 743 current_site_instance, url)) { |
741 dest_url = GURL(url::kAboutBlankURL); | 744 dest_url = GURL(url::kAboutBlankURL); |
742 } | 745 } |
743 | 746 |
744 int frame_tree_node_id = -1; | 747 int frame_tree_node_id = -1; |
745 | 748 |
746 // Send the navigation to the current FrameTreeNode if it's destined for a | 749 // Send the navigation to the current FrameTreeNode if it's destined for a |
747 // subframe in the current tab. We'll assume it's for the main frame | 750 // subframe in the current tab. We'll assume it's for the main frame |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
815 | 818 |
816 // Allow the delegate to cancel the transfer. | 819 // Allow the delegate to cancel the transfer. |
817 if (!delegate_->ShouldTransferNavigation( | 820 if (!delegate_->ShouldTransferNavigation( |
818 render_frame_host->frame_tree_node()->IsMainFrame())) | 821 render_frame_host->frame_tree_node()->IsMainFrame())) |
819 return; | 822 return; |
820 | 823 |
821 GURL dest_url(url); | 824 GURL dest_url(url); |
822 Referrer referrer_to_use(referrer); | 825 Referrer referrer_to_use(referrer); |
823 FrameTreeNode* node = render_frame_host->frame_tree_node(); | 826 FrameTreeNode* node = render_frame_host->frame_tree_node(); |
824 SiteInstance* current_site_instance = render_frame_host->GetSiteInstance(); | 827 SiteInstance* current_site_instance = render_frame_host->GetSiteInstance(); |
825 if (!GetContentClient()->browser()->ShouldAllowOpenURL(current_site_instance, | 828 // It is important to pass in the source_site_instance if it is available |
826 url)) { | 829 // (such as when navigating a proxy). See https://crbug.com/656752. |
827 dest_url = GURL(url::kAboutBlankURL); | 830 if (!GetContentClient()->browser()->ShouldAllowOpenURL( |
| 831 source_site_instance ? source_site_instance : current_site_instance, |
| 832 url)) { |
| 833 // It is important to return here, rather than rewrite the dest_url to |
| 834 // about:blank. The latter won't actually have any effect when |
| 835 // transferring, as NavigateToEntry will think that the transfer is to the |
| 836 // same RFH that started the navigation and let the existing navigation |
| 837 // (for the disallowed URL) proceed. |
| 838 return; |
828 } | 839 } |
829 | 840 |
830 // TODO(creis): Determine if this transfer started as a browser-initiated | 841 // TODO(creis): Determine if this transfer started as a browser-initiated |
831 // navigation. See https://crbug.com/495161. | 842 // navigation. See https://crbug.com/495161. |
832 bool is_renderer_initiated = true; | 843 bool is_renderer_initiated = true; |
833 if (render_frame_host->web_ui()) { | 844 if (render_frame_host->web_ui()) { |
834 // Web UI pages sometimes want to override the page transition type for | 845 // Web UI pages sometimes want to override the page transition type for |
835 // link clicks (e.g., so the new tab page can specify AUTO_BOOKMARK for | 846 // link clicks (e.g., so the new tab page can specify AUTO_BOOKMARK for |
836 // automatically generated suggestions). We don't override other types | 847 // automatically generated suggestions). We don't override other types |
837 // like TYPED because they have different implications (e.g., autocomplete). | 848 // like TYPED because they have different implications (e.g., autocomplete). |
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1261 if (navigation_handle) | 1272 if (navigation_handle) |
1262 navigation_handle->update_entry_id_for_transfer(entry->GetUniqueID()); | 1273 navigation_handle->update_entry_id_for_transfer(entry->GetUniqueID()); |
1263 | 1274 |
1264 controller_->SetPendingEntry(std::move(entry)); | 1275 controller_->SetPendingEntry(std::move(entry)); |
1265 if (delegate_) | 1276 if (delegate_) |
1266 delegate_->NotifyChangedNavigationState(content::INVALIDATE_TYPE_URL); | 1277 delegate_->NotifyChangedNavigationState(content::INVALIDATE_TYPE_URL); |
1267 } | 1278 } |
1268 } | 1279 } |
1269 | 1280 |
1270 } // namespace content | 1281 } // namespace content |
OLD | NEW |