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