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/render_frame_host_impl.h" | 5 #include "content/browser/frame_host/render_frame_host_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 835 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
846 DCHECK_EQ(site_instance_.get(), site_instance); | 846 DCHECK_EQ(site_instance_.get(), site_instance); |
847 | 847 |
848 // The renderer process is gone, so this frame can no longer be loading. | 848 // The renderer process is gone, so this frame can no longer be loading. |
849 ResetLoadingState(); | 849 ResetLoadingState(); |
850 | 850 |
851 // Any future UpdateState or UpdateTitle messages from this or a recreated | 851 // Any future UpdateState or UpdateTitle messages from this or a recreated |
852 // process should be ignored until the next commit. | 852 // process should be ignored until the next commit. |
853 set_nav_entry_id(0); | 853 set_nav_entry_id(0); |
854 } | 854 } |
855 | 855 |
| 856 void RenderFrameHostImpl::LogToConsole(const std::string& message) { |
| 857 AddMessageToConsole(CONSOLE_MESSAGE_LEVEL_ERROR, message); |
| 858 } |
| 859 |
| 860 void RenderFrameHostImpl::ReportContentSecurityPolicyViolation( |
| 861 const CSPViolationParams& violation_params) { |
| 862 Send(new FrameMsg_ReportContentSecurityPolicyViolation(routing_id_, |
| 863 violation_params)); |
| 864 } |
| 865 |
| 866 bool RenderFrameHostImpl::SchemeShouldBypassCSP( |
| 867 const base::StringPiece& scheme) { |
| 868 // Blink uses its SchemeRegistry to check if a scheme should be bypassed. |
| 869 // It can't be used on the browser process. It is used for two things: |
| 870 // 1) Bypassing the "chrome-extension" scheme when chrome is built with the |
| 871 // extensions support. |
| 872 // 2) Bypassing arbitrary scheme for testing purpose only in blink and in V8. |
| 873 // TODO(arthursonzogni): url::GetBypassingCSPScheme() is used instead of the |
| 874 // blink::SchemeRegistry. It contains 1) but not 2). |
| 875 const auto& bypassing_schemes = url::GetCSPBypassingSchemes(); |
| 876 return std::find(bypassing_schemes.begin(), bypassing_schemes.end(), |
| 877 scheme) != bypassing_schemes.end(); |
| 878 } |
| 879 |
856 bool RenderFrameHostImpl::CreateRenderFrame(int proxy_routing_id, | 880 bool RenderFrameHostImpl::CreateRenderFrame(int proxy_routing_id, |
857 int opener_routing_id, | 881 int opener_routing_id, |
858 int parent_routing_id, | 882 int parent_routing_id, |
859 int previous_sibling_routing_id) { | 883 int previous_sibling_routing_id) { |
860 TRACE_EVENT0("navigation", "RenderFrameHostImpl::CreateRenderFrame"); | 884 TRACE_EVENT0("navigation", "RenderFrameHostImpl::CreateRenderFrame"); |
861 DCHECK(!IsRenderFrameLive()) << "Creating frame twice"; | 885 DCHECK(!IsRenderFrameLive()) << "Creating frame twice"; |
862 | 886 |
863 // The process may (if we're sharing a process with another host that already | 887 // The process may (if we're sharing a process with another host that already |
864 // initialized it) or may not (we have our own process or the old process | 888 // initialized it) or may not (we have our own process or the old process |
865 // crashed) have been initialized. Calling Init multiple times will be | 889 // crashed) have been initialized. Calling Init multiple times will be |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1043 if (frame_tree_node_->current_frame_host() == this) { | 1067 if (frame_tree_node_->current_frame_host() == this) { |
1044 delegate_->CreateNewWindow(GetSiteInstance(), render_view_route_id, | 1068 delegate_->CreateNewWindow(GetSiteInstance(), render_view_route_id, |
1045 main_frame_route_id, main_frame_widget_route_id, | 1069 main_frame_route_id, main_frame_widget_route_id, |
1046 *validated_params, session_storage_namespace); | 1070 *validated_params, session_storage_namespace); |
1047 } | 1071 } |
1048 | 1072 |
1049 // Our caller (RenderWidgetHelper::OnCreateNewWindowOnUI) will send | 1073 // Our caller (RenderWidgetHelper::OnCreateNewWindowOnUI) will send |
1050 // ViewMsg_Close if the above step did not adopt |main_frame_route_id|. | 1074 // ViewMsg_Close if the above step did not adopt |main_frame_route_id|. |
1051 } | 1075 } |
1052 | 1076 |
| 1077 void RenderFrameHostImpl::SetLastCommittedOrigin(const url::Origin& origin) { |
| 1078 last_committed_origin_ = origin; |
| 1079 CSPContext::SetSelf(origin); |
| 1080 } |
| 1081 |
1053 void RenderFrameHostImpl::OnDetach() { | 1082 void RenderFrameHostImpl::OnDetach() { |
1054 frame_tree_->RemoveFrame(frame_tree_node_); | 1083 frame_tree_->RemoveFrame(frame_tree_node_); |
1055 } | 1084 } |
1056 | 1085 |
1057 void RenderFrameHostImpl::OnFrameFocused() { | 1086 void RenderFrameHostImpl::OnFrameFocused() { |
1058 delegate_->SetFocusedFrame(frame_tree_node_, GetSiteInstance()); | 1087 delegate_->SetFocusedFrame(frame_tree_node_, GetSiteInstance()); |
1059 } | 1088 } |
1060 | 1089 |
1061 void RenderFrameHostImpl::OnOpenURL(const FrameHostMsg_OpenURL_Params& params) { | 1090 void RenderFrameHostImpl::OnOpenURL(const FrameHostMsg_OpenURL_Params& params) { |
1062 GURL validated_url(params.url); | 1091 GURL validated_url(params.url); |
(...skipping 739 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1802 void RenderFrameHostImpl::OnDidSetFeaturePolicyHeader( | 1831 void RenderFrameHostImpl::OnDidSetFeaturePolicyHeader( |
1803 const ParsedFeaturePolicyHeader& parsed_header) { | 1832 const ParsedFeaturePolicyHeader& parsed_header) { |
1804 frame_tree_node()->SetFeaturePolicyHeader(parsed_header); | 1833 frame_tree_node()->SetFeaturePolicyHeader(parsed_header); |
1805 ResetFeaturePolicy(); | 1834 ResetFeaturePolicy(); |
1806 feature_policy_->SetHeaderPolicy(parsed_header); | 1835 feature_policy_->SetHeaderPolicy(parsed_header); |
1807 } | 1836 } |
1808 | 1837 |
1809 void RenderFrameHostImpl::OnDidAddContentSecurityPolicy( | 1838 void RenderFrameHostImpl::OnDidAddContentSecurityPolicy( |
1810 const ContentSecurityPolicyHeader& header, | 1839 const ContentSecurityPolicyHeader& header, |
1811 const std::vector<ContentSecurityPolicy>& policies) { | 1840 const std::vector<ContentSecurityPolicy>& policies) { |
1812 frame_tree_node()->AddContentSecurityPolicy(header, policies); | 1841 frame_tree_node()->AddContentSecurityPolicy(header); |
| 1842 for (const ContentSecurityPolicy& policy : policies) |
| 1843 AddContentSecurityPolicy(policy); |
1813 } | 1844 } |
1814 | 1845 |
1815 void RenderFrameHostImpl::OnEnforceInsecureRequestPolicy( | 1846 void RenderFrameHostImpl::OnEnforceInsecureRequestPolicy( |
1816 blink::WebInsecureRequestPolicy policy) { | 1847 blink::WebInsecureRequestPolicy policy) { |
1817 frame_tree_node()->SetInsecureRequestPolicy(policy); | 1848 frame_tree_node()->SetInsecureRequestPolicy(policy); |
1818 } | 1849 } |
1819 | 1850 |
1820 void RenderFrameHostImpl::OnUpdateToUniqueOrigin( | 1851 void RenderFrameHostImpl::OnUpdateToUniqueOrigin( |
1821 bool is_potentially_trustworthy_unique_origin) { | 1852 bool is_potentially_trustworthy_unique_origin) { |
1822 url::Origin origin; | 1853 url::Origin origin; |
(...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2474 OnDidStartLoading(true); | 2505 OnDidStartLoading(true); |
2475 } | 2506 } |
2476 } | 2507 } |
2477 | 2508 |
2478 void RenderFrameHostImpl::NavigateToInterstitialURL(const GURL& data_url) { | 2509 void RenderFrameHostImpl::NavigateToInterstitialURL(const GURL& data_url) { |
2479 DCHECK(data_url.SchemeIs(url::kDataScheme)); | 2510 DCHECK(data_url.SchemeIs(url::kDataScheme)); |
2480 CommonNavigationParams common_params( | 2511 CommonNavigationParams common_params( |
2481 data_url, Referrer(), ui::PAGE_TRANSITION_LINK, | 2512 data_url, Referrer(), ui::PAGE_TRANSITION_LINK, |
2482 FrameMsg_Navigate_Type::DIFFERENT_DOCUMENT, false, false, | 2513 FrameMsg_Navigate_Type::DIFFERENT_DOCUMENT, false, false, |
2483 base::TimeTicks::Now(), FrameMsg_UILoadMetricsReportType::NO_REPORT, | 2514 base::TimeTicks::Now(), FrameMsg_UILoadMetricsReportType::NO_REPORT, |
2484 GURL(), GURL(), PREVIEWS_OFF, base::TimeTicks::Now(), "GET", nullptr); | 2515 GURL(), GURL(), PREVIEWS_OFF, base::TimeTicks::Now(), "GET", nullptr, |
| 2516 false /* should_bypass_main_world_csp */); |
2485 if (IsBrowserSideNavigationEnabled()) { | 2517 if (IsBrowserSideNavigationEnabled()) { |
2486 CommitNavigation(nullptr, nullptr, common_params, RequestNavigationParams(), | 2518 CommitNavigation(nullptr, nullptr, common_params, RequestNavigationParams(), |
2487 false); | 2519 false); |
2488 } else { | 2520 } else { |
2489 Navigate(common_params, StartNavigationParams(), RequestNavigationParams()); | 2521 Navigate(common_params, StartNavigationParams(), RequestNavigationParams()); |
2490 } | 2522 } |
2491 } | 2523 } |
2492 | 2524 |
2493 void RenderFrameHostImpl::Stop() { | 2525 void RenderFrameHostImpl::Stop() { |
2494 Send(new FrameMsg_Stop(routing_id_)); | 2526 Send(new FrameMsg_Stop(routing_id_)); |
(...skipping 907 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3402 NavigationEntryImpl::FromNavigationEntry( | 3434 NavigationEntryImpl::FromNavigationEntry( |
3403 frame_tree_node()->navigator()->GetController()->GetPendingEntry()); | 3435 frame_tree_node()->navigator()->GetController()->GetPendingEntry()); |
3404 if (pending_entry && pending_entry->GetUniqueID() == params.nav_entry_id) { | 3436 if (pending_entry && pending_entry->GetUniqueID() == params.nav_entry_id) { |
3405 pending_nav_entry_id = params.nav_entry_id; | 3437 pending_nav_entry_id = params.nav_entry_id; |
3406 is_renderer_initiated = pending_entry->is_renderer_initiated(); | 3438 is_renderer_initiated = pending_entry->is_renderer_initiated(); |
3407 } | 3439 } |
3408 | 3440 |
3409 return NavigationHandleImpl::Create( | 3441 return NavigationHandleImpl::Create( |
3410 params.url, params.redirects, frame_tree_node_, is_renderer_initiated, | 3442 params.url, params.redirects, frame_tree_node_, is_renderer_initiated, |
3411 params.was_within_same_page, base::TimeTicks::Now(), | 3443 params.was_within_same_page, base::TimeTicks::Now(), |
3412 pending_nav_entry_id, false); // started_from_context_menu | 3444 pending_nav_entry_id, |
| 3445 false, // started_from_context_menu |
| 3446 false); // should_bypass_main_world_csp |
3413 } | 3447 } |
3414 | 3448 |
3415 // Determine if the current NavigationHandle can be used. | 3449 // Determine if the current NavigationHandle can be used. |
3416 if (navigation_handle_ && navigation_handle_->GetURL() == params.url) { | 3450 if (navigation_handle_ && navigation_handle_->GetURL() == params.url) { |
3417 return std::move(navigation_handle_); | 3451 return std::move(navigation_handle_); |
3418 } | 3452 } |
3419 | 3453 |
3420 // If the URL does not match what the NavigationHandle expects, treat the | 3454 // If the URL does not match what the NavigationHandle expects, treat the |
3421 // commit as a new navigation. This can happen when loading a Data | 3455 // commit as a new navigation. This can happen when loading a Data |
3422 // navigation with LoadDataWithBaseURL. | 3456 // navigation with LoadDataWithBaseURL. |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3454 // Reset any existing NavigationHandle. | 3488 // Reset any existing NavigationHandle. |
3455 navigation_handle_.reset(); | 3489 navigation_handle_.reset(); |
3456 } | 3490 } |
3457 | 3491 |
3458 // There is no pending NavigationEntry in these cases, so pass 0 as the | 3492 // There is no pending NavigationEntry in these cases, so pass 0 as the |
3459 // pending_nav_entry_id. If the previous handle was a prematurely aborted | 3493 // pending_nav_entry_id. If the previous handle was a prematurely aborted |
3460 // navigation loaded via LoadDataWithBaseURL, propagate the entry id. | 3494 // navigation loaded via LoadDataWithBaseURL, propagate the entry id. |
3461 return NavigationHandleImpl::Create( | 3495 return NavigationHandleImpl::Create( |
3462 params.url, params.redirects, frame_tree_node_, is_renderer_initiated, | 3496 params.url, params.redirects, frame_tree_node_, is_renderer_initiated, |
3463 params.was_within_same_page, base::TimeTicks::Now(), | 3497 params.was_within_same_page, base::TimeTicks::Now(), |
3464 entry_id_for_data_nav, false); // started_from_context_menu | 3498 entry_id_for_data_nav, |
| 3499 false, // started_from_context_menu |
| 3500 false); // should_bypass_main_world_csp |
3465 } | 3501 } |
3466 | 3502 |
3467 } // namespace content | 3503 } // namespace content |
OLD | NEW |