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 755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
766 params.should_replace_current_entry = should_replace_current_entry; | 766 params.should_replace_current_entry = should_replace_current_entry; |
767 params.user_gesture = user_gesture; | 767 params.user_gesture = user_gesture; |
768 | 768 |
769 // RequestOpenURL is used only for local frames, so we can get here only if | 769 // RequestOpenURL is used only for local frames, so we can get here only if |
770 // the navigation is initiated by a frame in the same SiteInstance as this | 770 // the navigation is initiated by a frame in the same SiteInstance as this |
771 // frame. Note that navigations on RenderFrameProxies do not use | 771 // frame. Note that navigations on RenderFrameProxies do not use |
772 // RequestOpenURL and go through RequestTransferURL instead. | 772 // RequestOpenURL and go through RequestTransferURL instead. |
773 params.source_site_instance = current_site_instance; | 773 params.source_site_instance = current_site_instance; |
774 | 774 |
775 if (render_frame_host->web_ui()) { | 775 if (render_frame_host->web_ui()) { |
776 // Web UI pages sometimes want to override the page transition type for | 776 // Note that we hide the referrer for Web UI pages. We don't really want |
777 // link clicks (e.g., so the new tab page can specify AUTO_BOOKMARK for | 777 // web sites to see a referrer of "chrome://blah" (and some chrome: URLs |
778 // automatically generated suggestions). We don't override other types | 778 // might have search terms or other stuff we don't want to send to the |
779 // like TYPED because they have different implications (e.g., autocomplete). | 779 // site), so we send no referrer. |
780 if (ui::PageTransitionCoreTypeIs( | |
781 params.transition, ui::PAGE_TRANSITION_LINK)) | |
782 params.transition = render_frame_host->web_ui()->GetLinkTransitionType(); | |
783 | |
784 // Note also that we hide the referrer for Web UI pages. We don't really | |
785 // want web sites to see a referrer of "chrome://blah" (and some | |
786 // chrome: URLs might have search terms or other stuff we don't want to | |
787 // send to the site), so we send no referrer. | |
788 params.referrer = Referrer(); | 780 params.referrer = Referrer(); |
789 | 781 |
790 // Navigations in Web UI pages count as browser-initiated navigations. | 782 // Navigations in Web UI pages count as browser-initiated navigations. |
791 params.is_renderer_initiated = false; | 783 params.is_renderer_initiated = false; |
792 } | 784 } |
793 | 785 |
794 GetContentClient()->browser()->OverrideOpenURLParams(current_site_instance, | 786 GetContentClient()->browser()->OverrideNavigationParams( |
795 ¶ms); | 787 current_site_instance, ¶ms.transition, ¶ms.is_renderer_initiated, |
| 788 ¶ms.referrer); |
796 | 789 |
797 if (delegate_) | 790 if (delegate_) |
798 delegate_->RequestOpenURL(render_frame_host, params); | 791 delegate_->RequestOpenURL(render_frame_host, params); |
799 } | 792 } |
800 | 793 |
801 void NavigatorImpl::RequestTransferURL( | 794 void NavigatorImpl::RequestTransferURL( |
802 RenderFrameHostImpl* render_frame_host, | 795 RenderFrameHostImpl* render_frame_host, |
803 const GURL& url, | 796 const GURL& url, |
804 SiteInstance* source_site_instance, | 797 SiteInstance* source_site_instance, |
805 const std::vector<GURL>& redirect_chain, | 798 const std::vector<GURL>& redirect_chain, |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
839 // transferring, as NavigateToEntry will think that the transfer is to the | 832 // transferring, as NavigateToEntry will think that the transfer is to the |
840 // same RFH that started the navigation and let the existing navigation | 833 // same RFH that started the navigation and let the existing navigation |
841 // (for the disallowed URL) proceed. | 834 // (for the disallowed URL) proceed. |
842 return; | 835 return; |
843 } | 836 } |
844 | 837 |
845 // TODO(creis): Determine if this transfer started as a browser-initiated | 838 // TODO(creis): Determine if this transfer started as a browser-initiated |
846 // navigation. See https://crbug.com/495161. | 839 // navigation. See https://crbug.com/495161. |
847 bool is_renderer_initiated = true; | 840 bool is_renderer_initiated = true; |
848 if (render_frame_host->web_ui()) { | 841 if (render_frame_host->web_ui()) { |
849 // Web UI pages sometimes want to override the page transition type for | 842 // Note that we hide the referrer for Web UI pages. We don't really want |
850 // link clicks (e.g., so the new tab page can specify AUTO_BOOKMARK for | 843 // web sites to see a referrer of "chrome://blah" (and some chrome: URLs |
851 // automatically generated suggestions). We don't override other types | 844 // might have search terms or other stuff we don't want to send to the |
852 // like TYPED because they have different implications (e.g., autocomplete). | 845 // site), so we send no referrer. |
853 if (ui::PageTransitionCoreTypeIs(page_transition, ui::PAGE_TRANSITION_LINK)) | |
854 page_transition = render_frame_host->web_ui()->GetLinkTransitionType(); | |
855 | |
856 // Note also that we hide the referrer for Web UI pages. We don't really | |
857 // want web sites to see a referrer of "chrome://blah" (and some | |
858 // chrome: URLs might have search terms or other stuff we don't want to | |
859 // send to the site), so we send no referrer. | |
860 referrer_to_use = Referrer(); | 846 referrer_to_use = Referrer(); |
861 | 847 |
862 // Navigations in Web UI pages count as browser-initiated navigations. | 848 // Navigations in Web UI pages count as browser-initiated navigations. |
863 is_renderer_initiated = false; | 849 is_renderer_initiated = false; |
864 } | 850 } |
865 | 851 |
| 852 GetContentClient()->browser()->OverrideNavigationParams( |
| 853 current_site_instance, &page_transition, &is_renderer_initiated, |
| 854 &referrer_to_use); |
| 855 |
866 // Create a NavigationEntry for the transfer, without making it the pending | 856 // Create a NavigationEntry for the transfer, without making it the pending |
867 // entry. Subframe transfers should only be possible in OOPIF-enabled modes, | 857 // entry. Subframe transfers should only be possible in OOPIF-enabled modes, |
868 // and should have a clone of the last committed entry with a | 858 // and should have a clone of the last committed entry with a |
869 // FrameNavigationEntry for the target frame. Main frame transfers should | 859 // FrameNavigationEntry for the target frame. Main frame transfers should |
870 // have a new NavigationEntry. | 860 // have a new NavigationEntry. |
871 // TODO(creis): Make this unnecessary by creating (and validating) the params | 861 // TODO(creis): Make this unnecessary by creating (and validating) the params |
872 // directly, passing them to the destination RenderFrameHost. See | 862 // directly, passing them to the destination RenderFrameHost. See |
873 // https://crbug.com/536906. | 863 // https://crbug.com/536906. |
874 std::unique_ptr<NavigationEntryImpl> entry; | 864 std::unique_ptr<NavigationEntryImpl> entry; |
875 if (!node->IsMainFrame()) { | 865 if (!node->IsMainFrame()) { |
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1277 if (navigation_handle) | 1267 if (navigation_handle) |
1278 navigation_handle->update_entry_id_for_transfer(entry->GetUniqueID()); | 1268 navigation_handle->update_entry_id_for_transfer(entry->GetUniqueID()); |
1279 | 1269 |
1280 controller_->SetPendingEntry(std::move(entry)); | 1270 controller_->SetPendingEntry(std::move(entry)); |
1281 if (delegate_) | 1271 if (delegate_) |
1282 delegate_->NotifyChangedNavigationState(content::INVALIDATE_TYPE_URL); | 1272 delegate_->NotifyChangedNavigationState(content::INVALIDATE_TYPE_URL); |
1283 } | 1273 } |
1284 } | 1274 } |
1285 | 1275 |
1286 } // namespace content | 1276 } // namespace content |
OLD | NEW |