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 850 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
861 DCHECK_EQ(site_instance_.get(), site_instance); | 861 DCHECK_EQ(site_instance_.get(), site_instance); |
862 | 862 |
863 // The renderer process is gone, so this frame can no longer be loading. | 863 // The renderer process is gone, so this frame can no longer be loading. |
864 ResetLoadingState(); | 864 ResetLoadingState(); |
865 | 865 |
866 // Any future UpdateState or UpdateTitle messages from this or a recreated | 866 // Any future UpdateState or UpdateTitle messages from this or a recreated |
867 // process should be ignored until the next commit. | 867 // process should be ignored until the next commit. |
868 set_nav_entry_id(0); | 868 set_nav_entry_id(0); |
869 } | 869 } |
870 | 870 |
| 871 void RenderFrameHostImpl::LogToConsole(const std::string& message) { |
| 872 AddMessageToConsole(CONSOLE_MESSAGE_LEVEL_ERROR, message); |
| 873 } |
| 874 |
| 875 void RenderFrameHostImpl::ReportContentSecurityPolicyViolation( |
| 876 const CSPViolationParams& violation_params) { |
| 877 Send(new FrameMsg_ReportContentSecurityPolicyViolation(routing_id_, |
| 878 violation_params)); |
| 879 } |
| 880 |
| 881 bool RenderFrameHostImpl::SchemeShouldBypassCSP( |
| 882 const base::StringPiece& scheme) { |
| 883 // Blink uses its SchemeRegistry to check if a scheme should be bypassed. |
| 884 // It can't be used on the browser process. It is used for two things: |
| 885 // 1) Bypassing the "chrome-extension" scheme when chrome is built with the |
| 886 // extensions support. |
| 887 // 2) Bypassing arbitrary scheme for testing purpose only in blink and in V8. |
| 888 // TODO(arthursonzogni): url::GetBypassingCSPScheme() is used instead of the |
| 889 // blink::SchemeRegistry. It contains 1) but not 2). |
| 890 const auto& bypassing_schemes = url::GetCSPBypassingSchemes(); |
| 891 return std::find(bypassing_schemes.begin(), bypassing_schemes.end(), |
| 892 scheme) != bypassing_schemes.end(); |
| 893 } |
| 894 |
871 bool RenderFrameHostImpl::CreateRenderFrame(int proxy_routing_id, | 895 bool RenderFrameHostImpl::CreateRenderFrame(int proxy_routing_id, |
872 int opener_routing_id, | 896 int opener_routing_id, |
873 int parent_routing_id, | 897 int parent_routing_id, |
874 int previous_sibling_routing_id) { | 898 int previous_sibling_routing_id) { |
875 TRACE_EVENT0("navigation", "RenderFrameHostImpl::CreateRenderFrame"); | 899 TRACE_EVENT0("navigation", "RenderFrameHostImpl::CreateRenderFrame"); |
876 DCHECK(!IsRenderFrameLive()) << "Creating frame twice"; | 900 DCHECK(!IsRenderFrameLive()) << "Creating frame twice"; |
877 | 901 |
878 // The process may (if we're sharing a process with another host that already | 902 // The process may (if we're sharing a process with another host that already |
879 // initialized it) or may not (we have our own process or the old process | 903 // initialized it) or may not (we have our own process or the old process |
880 // crashed) have been initialized. Calling Init multiple times will be | 904 // crashed) have been initialized. Calling Init multiple times will be |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1059 if (frame_tree_node_->current_frame_host() == this) { | 1083 if (frame_tree_node_->current_frame_host() == this) { |
1060 delegate_->CreateNewWindow(GetSiteInstance(), render_view_route_id, | 1084 delegate_->CreateNewWindow(GetSiteInstance(), render_view_route_id, |
1061 main_frame_route_id, main_frame_widget_route_id, | 1085 main_frame_route_id, main_frame_widget_route_id, |
1062 *validated_params, session_storage_namespace); | 1086 *validated_params, session_storage_namespace); |
1063 } | 1087 } |
1064 | 1088 |
1065 // Our caller (RenderWidgetHelper::OnCreateNewWindowOnUI) will send | 1089 // Our caller (RenderWidgetHelper::OnCreateNewWindowOnUI) will send |
1066 // ViewMsg_Close if the above step did not adopt |main_frame_route_id|. | 1090 // ViewMsg_Close if the above step did not adopt |main_frame_route_id|. |
1067 } | 1091 } |
1068 | 1092 |
| 1093 void RenderFrameHostImpl::SetLastCommittedOrigin(const url::Origin& origin) { |
| 1094 last_committed_origin_ = origin; |
| 1095 CSPContext::SetSelf(origin); |
| 1096 } |
| 1097 |
1069 void RenderFrameHostImpl::OnDetach() { | 1098 void RenderFrameHostImpl::OnDetach() { |
1070 frame_tree_->RemoveFrame(frame_tree_node_); | 1099 frame_tree_->RemoveFrame(frame_tree_node_); |
1071 } | 1100 } |
1072 | 1101 |
1073 void RenderFrameHostImpl::OnFrameFocused() { | 1102 void RenderFrameHostImpl::OnFrameFocused() { |
1074 delegate_->SetFocusedFrame(frame_tree_node_, GetSiteInstance()); | 1103 delegate_->SetFocusedFrame(frame_tree_node_, GetSiteInstance()); |
1075 } | 1104 } |
1076 | 1105 |
1077 void RenderFrameHostImpl::OnOpenURL(const FrameHostMsg_OpenURL_Params& params) { | 1106 void RenderFrameHostImpl::OnOpenURL(const FrameHostMsg_OpenURL_Params& params) { |
1078 GURL validated_url(params.url); | 1107 GURL validated_url(params.url); |
(...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1824 void RenderFrameHostImpl::OnDidSetFeaturePolicyHeader( | 1853 void RenderFrameHostImpl::OnDidSetFeaturePolicyHeader( |
1825 const ParsedFeaturePolicyHeader& parsed_header) { | 1854 const ParsedFeaturePolicyHeader& parsed_header) { |
1826 frame_tree_node()->SetFeaturePolicyHeader(parsed_header); | 1855 frame_tree_node()->SetFeaturePolicyHeader(parsed_header); |
1827 ResetFeaturePolicy(); | 1856 ResetFeaturePolicy(); |
1828 feature_policy_->SetHeaderPolicy(parsed_header); | 1857 feature_policy_->SetHeaderPolicy(parsed_header); |
1829 } | 1858 } |
1830 | 1859 |
1831 void RenderFrameHostImpl::OnDidAddContentSecurityPolicy( | 1860 void RenderFrameHostImpl::OnDidAddContentSecurityPolicy( |
1832 const ContentSecurityPolicyHeader& header, | 1861 const ContentSecurityPolicyHeader& header, |
1833 const std::vector<ContentSecurityPolicy>& policies) { | 1862 const std::vector<ContentSecurityPolicy>& policies) { |
1834 frame_tree_node()->AddContentSecurityPolicy(header, policies); | 1863 frame_tree_node()->AddContentSecurityPolicy(header); |
| 1864 for (const ContentSecurityPolicy& policy : policies) |
| 1865 AddContentSecurityPolicy(policy); |
1835 } | 1866 } |
1836 | 1867 |
1837 void RenderFrameHostImpl::OnEnforceInsecureRequestPolicy( | 1868 void RenderFrameHostImpl::OnEnforceInsecureRequestPolicy( |
1838 blink::WebInsecureRequestPolicy policy) { | 1869 blink::WebInsecureRequestPolicy policy) { |
1839 frame_tree_node()->SetInsecureRequestPolicy(policy); | 1870 frame_tree_node()->SetInsecureRequestPolicy(policy); |
1840 } | 1871 } |
1841 | 1872 |
1842 void RenderFrameHostImpl::OnUpdateToUniqueOrigin( | 1873 void RenderFrameHostImpl::OnUpdateToUniqueOrigin( |
1843 bool is_potentially_trustworthy_unique_origin) { | 1874 bool is_potentially_trustworthy_unique_origin) { |
1844 url::Origin origin; | 1875 url::Origin origin; |
(...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2512 } | 2543 } |
2513 } | 2544 } |
2514 | 2545 |
2515 void RenderFrameHostImpl::NavigateToInterstitialURL(const GURL& data_url) { | 2546 void RenderFrameHostImpl::NavigateToInterstitialURL(const GURL& data_url) { |
2516 DCHECK(data_url.SchemeIs(url::kDataScheme)); | 2547 DCHECK(data_url.SchemeIs(url::kDataScheme)); |
2517 CommonNavigationParams common_params( | 2548 CommonNavigationParams common_params( |
2518 data_url, Referrer(), ui::PAGE_TRANSITION_LINK, | 2549 data_url, Referrer(), ui::PAGE_TRANSITION_LINK, |
2519 FrameMsg_Navigate_Type::DIFFERENT_DOCUMENT, false, false, | 2550 FrameMsg_Navigate_Type::DIFFERENT_DOCUMENT, false, false, |
2520 base::TimeTicks::Now(), FrameMsg_UILoadMetricsReportType::NO_REPORT, | 2551 base::TimeTicks::Now(), FrameMsg_UILoadMetricsReportType::NO_REPORT, |
2521 GURL(), GURL(), PREVIEWS_OFF, base::TimeTicks::Now(), "GET", nullptr, | 2552 GURL(), GURL(), PREVIEWS_OFF, base::TimeTicks::Now(), "GET", nullptr, |
2522 base::Optional<SourceLocation>()); | 2553 base::Optional<SourceLocation>(), |
| 2554 CSPDisposition::CHECK /* should_check_main_world_csp */); |
2523 if (IsBrowserSideNavigationEnabled()) { | 2555 if (IsBrowserSideNavigationEnabled()) { |
2524 CommitNavigation(nullptr, nullptr, common_params, RequestNavigationParams(), | 2556 CommitNavigation(nullptr, nullptr, common_params, RequestNavigationParams(), |
2525 false); | 2557 false); |
2526 } else { | 2558 } else { |
2527 Navigate(common_params, StartNavigationParams(), RequestNavigationParams()); | 2559 Navigate(common_params, StartNavigationParams(), RequestNavigationParams()); |
2528 } | 2560 } |
2529 } | 2561 } |
2530 | 2562 |
2531 void RenderFrameHostImpl::Stop() { | 2563 void RenderFrameHostImpl::Stop() { |
2532 Send(new FrameMsg_Stop(routing_id_)); | 2564 Send(new FrameMsg_Stop(routing_id_)); |
(...skipping 894 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3427 NavigationEntryImpl::FromNavigationEntry( | 3459 NavigationEntryImpl::FromNavigationEntry( |
3428 frame_tree_node()->navigator()->GetController()->GetPendingEntry()); | 3460 frame_tree_node()->navigator()->GetController()->GetPendingEntry()); |
3429 if (pending_entry && pending_entry->GetUniqueID() == params.nav_entry_id) { | 3461 if (pending_entry && pending_entry->GetUniqueID() == params.nav_entry_id) { |
3430 pending_nav_entry_id = params.nav_entry_id; | 3462 pending_nav_entry_id = params.nav_entry_id; |
3431 is_renderer_initiated = pending_entry->is_renderer_initiated(); | 3463 is_renderer_initiated = pending_entry->is_renderer_initiated(); |
3432 } | 3464 } |
3433 | 3465 |
3434 return NavigationHandleImpl::Create( | 3466 return NavigationHandleImpl::Create( |
3435 params.url, params.redirects, frame_tree_node_, is_renderer_initiated, | 3467 params.url, params.redirects, frame_tree_node_, is_renderer_initiated, |
3436 params.was_within_same_document, base::TimeTicks::Now(), | 3468 params.was_within_same_document, base::TimeTicks::Now(), |
3437 pending_nav_entry_id, false); // started_from_context_menu | 3469 pending_nav_entry_id, |
| 3470 false, // started_from_context_menu |
| 3471 CSPDisposition::CHECK); // should_check_main_world_csp |
3438 } | 3472 } |
3439 | 3473 |
3440 // Determine if the current NavigationHandle can be used. | 3474 // Determine if the current NavigationHandle can be used. |
3441 if (navigation_handle_ && navigation_handle_->GetURL() == params.url) { | 3475 if (navigation_handle_ && navigation_handle_->GetURL() == params.url) { |
3442 return std::move(navigation_handle_); | 3476 return std::move(navigation_handle_); |
3443 } | 3477 } |
3444 | 3478 |
3445 // If the URL does not match what the NavigationHandle expects, treat the | 3479 // If the URL does not match what the NavigationHandle expects, treat the |
3446 // commit as a new navigation. This can happen when loading a Data | 3480 // commit as a new navigation. This can happen when loading a Data |
3447 // navigation with LoadDataWithBaseURL. | 3481 // navigation with LoadDataWithBaseURL. |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3479 // Reset any existing NavigationHandle. | 3513 // Reset any existing NavigationHandle. |
3480 navigation_handle_.reset(); | 3514 navigation_handle_.reset(); |
3481 } | 3515 } |
3482 | 3516 |
3483 // There is no pending NavigationEntry in these cases, so pass 0 as the | 3517 // There is no pending NavigationEntry in these cases, so pass 0 as the |
3484 // pending_nav_entry_id. If the previous handle was a prematurely aborted | 3518 // pending_nav_entry_id. If the previous handle was a prematurely aborted |
3485 // navigation loaded via LoadDataWithBaseURL, propagate the entry id. | 3519 // navigation loaded via LoadDataWithBaseURL, propagate the entry id. |
3486 return NavigationHandleImpl::Create( | 3520 return NavigationHandleImpl::Create( |
3487 params.url, params.redirects, frame_tree_node_, is_renderer_initiated, | 3521 params.url, params.redirects, frame_tree_node_, is_renderer_initiated, |
3488 params.was_within_same_document, base::TimeTicks::Now(), | 3522 params.was_within_same_document, base::TimeTicks::Now(), |
3489 entry_id_for_data_nav, false); // started_from_context_menu | 3523 entry_id_for_data_nav, |
| 3524 false, // started_from_context_menu |
| 3525 CSPDisposition::CHECK); // should_check_main_world_csp |
3490 } | 3526 } |
3491 | 3527 |
3492 void RenderFrameHostImpl::BeforeUnloadTimeout() { | 3528 void RenderFrameHostImpl::BeforeUnloadTimeout() { |
3493 if (render_view_host_->GetDelegate()->ShouldIgnoreUnresponsiveRenderer()) | 3529 if (render_view_host_->GetDelegate()->ShouldIgnoreUnresponsiveRenderer()) |
3494 return; | 3530 return; |
3495 | 3531 |
3496 SimulateBeforeUnloadAck(); | 3532 SimulateBeforeUnloadAck(); |
3497 } | 3533 } |
3498 | 3534 |
3499 #if defined(OS_ANDROID) | 3535 #if defined(OS_ANDROID) |
(...skipping 14 matching lines...) Expand all Loading... |
3514 service_manager::mojom::InterfaceProviderPtr provider; | 3550 service_manager::mojom::InterfaceProviderPtr provider; |
3515 BindInterfaceRegistryForRenderFrameHost(mojo::MakeRequest(&provider), this); | 3551 BindInterfaceRegistryForRenderFrameHost(mojo::MakeRequest(&provider), this); |
3516 java_interfaces_.reset(new service_manager::InterfaceProvider); | 3552 java_interfaces_.reset(new service_manager::InterfaceProvider); |
3517 java_interfaces_->Bind(std::move(provider)); | 3553 java_interfaces_->Bind(std::move(provider)); |
3518 } | 3554 } |
3519 return java_interfaces_.get(); | 3555 return java_interfaces_.get(); |
3520 } | 3556 } |
3521 #endif | 3557 #endif |
3522 | 3558 |
3523 } // namespace content | 3559 } // namespace content |
OLD | NEW |