| 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 702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 713 render_frame_host->frame_tree_node()->current_frame_host()) { | 713 render_frame_host->frame_tree_node()->current_frame_host()) { |
| 714 return; | 714 return; |
| 715 } | 715 } |
| 716 | 716 |
| 717 SiteInstance* current_site_instance = render_frame_host->GetSiteInstance(); | 717 SiteInstance* current_site_instance = render_frame_host->GetSiteInstance(); |
| 718 | 718 |
| 719 // TODO(creis): Pass the redirect_chain into this method to support client | 719 // TODO(creis): Pass the redirect_chain into this method to support client |
| 720 // redirects. http://crbug.com/311721. | 720 // redirects. http://crbug.com/311721. |
| 721 std::vector<GURL> redirect_chain; | 721 std::vector<GURL> redirect_chain; |
| 722 | 722 |
| 723 // Note that unlike RequestTransferURL, this uses the navigating |
| 724 // RenderFrameHost's current SiteInstance, as that's where this navigation |
| 725 // originated. |
| 723 GURL dest_url(url); | 726 GURL dest_url(url); |
| 724 if (!GetContentClient()->browser()->ShouldAllowOpenURL( | 727 if (!GetContentClient()->browser()->ShouldAllowOpenURL( |
| 725 current_site_instance, url)) { | 728 current_site_instance, url)) { |
| 726 dest_url = GURL(url::kAboutBlankURL); | 729 dest_url = GURL(url::kAboutBlankURL); |
| 727 } | 730 } |
| 728 | 731 |
| 729 int frame_tree_node_id = -1; | 732 int frame_tree_node_id = -1; |
| 730 | 733 |
| 731 // Send the navigation to the current FrameTreeNode if it's destined for a | 734 // Send the navigation to the current FrameTreeNode if it's destined for a |
| 732 // subframe in the current tab. We'll assume it's for the main frame | 735 // subframe in the current tab. We'll assume it's for the main frame |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 798 | 801 |
| 799 // Allow the delegate to cancel the transfer. | 802 // Allow the delegate to cancel the transfer. |
| 800 if (!delegate_->ShouldTransferNavigation( | 803 if (!delegate_->ShouldTransferNavigation( |
| 801 render_frame_host->frame_tree_node()->IsMainFrame())) | 804 render_frame_host->frame_tree_node()->IsMainFrame())) |
| 802 return; | 805 return; |
| 803 | 806 |
| 804 GURL dest_url(url); | 807 GURL dest_url(url); |
| 805 Referrer referrer_to_use(referrer); | 808 Referrer referrer_to_use(referrer); |
| 806 FrameTreeNode* node = render_frame_host->frame_tree_node(); | 809 FrameTreeNode* node = render_frame_host->frame_tree_node(); |
| 807 SiteInstance* current_site_instance = render_frame_host->GetSiteInstance(); | 810 SiteInstance* current_site_instance = render_frame_host->GetSiteInstance(); |
| 808 if (!GetContentClient()->browser()->ShouldAllowOpenURL(current_site_instance, | 811 // It is important to pass in the source_site_instance if it is available |
| 809 url)) { | 812 // (such as when navigating a proxy). See https://crbug.com/656752. |
| 810 dest_url = GURL(url::kAboutBlankURL); | 813 if (!GetContentClient()->browser()->ShouldAllowOpenURL( |
| 814 source_site_instance ? source_site_instance : current_site_instance, |
| 815 url)) { |
| 816 // It is important to return here, rather than rewrite the dest_url to |
| 817 // about:blank. The latter won't actually have any effect when |
| 818 // transferring, as NavigateToEntry will think that the transfer is to the |
| 819 // same RFH that started the navigation and let the existing navigation |
| 820 // (for the disallowed URL) proceed. |
| 821 return; |
| 811 } | 822 } |
| 812 | 823 |
| 813 // TODO(creis): Determine if this transfer started as a browser-initiated | 824 // TODO(creis): Determine if this transfer started as a browser-initiated |
| 814 // navigation. See https://crbug.com/495161. | 825 // navigation. See https://crbug.com/495161. |
| 815 bool is_renderer_initiated = true; | 826 bool is_renderer_initiated = true; |
| 816 if (render_frame_host->web_ui()) { | 827 if (render_frame_host->web_ui()) { |
| 817 // Web UI pages sometimes want to override the page transition type for | 828 // Web UI pages sometimes want to override the page transition type for |
| 818 // link clicks (e.g., so the new tab page can specify AUTO_BOOKMARK for | 829 // link clicks (e.g., so the new tab page can specify AUTO_BOOKMARK for |
| 819 // automatically generated suggestions). We don't override other types | 830 // automatically generated suggestions). We don't override other types |
| 820 // like TYPED because they have different implications (e.g., autocomplete). | 831 // like TYPED because they have different implications (e.g., autocomplete). |
| (...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1244 if (navigation_handle) | 1255 if (navigation_handle) |
| 1245 navigation_handle->update_entry_id_for_transfer(entry->GetUniqueID()); | 1256 navigation_handle->update_entry_id_for_transfer(entry->GetUniqueID()); |
| 1246 | 1257 |
| 1247 controller_->SetPendingEntry(std::move(entry)); | 1258 controller_->SetPendingEntry(std::move(entry)); |
| 1248 if (delegate_) | 1259 if (delegate_) |
| 1249 delegate_->NotifyChangedNavigationState(content::INVALIDATE_TYPE_URL); | 1260 delegate_->NotifyChangedNavigationState(content::INVALIDATE_TYPE_URL); |
| 1250 } | 1261 } |
| 1251 } | 1262 } |
| 1252 | 1263 |
| 1253 } // namespace content | 1264 } // namespace content |
| OLD | NEW |