Chromium Code Reviews| 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 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 339 browser_plugin_embedder_ax_tree_id_(AXTreeIDRegistry::kNoAXTreeID), | 339 browser_plugin_embedder_ax_tree_id_(AXTreeIDRegistry::kNoAXTreeID), |
| 340 no_create_browser_accessibility_manager_for_testing_(false), | 340 no_create_browser_accessibility_manager_for_testing_(false), |
| 341 web_ui_type_(WebUI::kNoWebUI), | 341 web_ui_type_(WebUI::kNoWebUI), |
| 342 pending_web_ui_type_(WebUI::kNoWebUI), | 342 pending_web_ui_type_(WebUI::kNoWebUI), |
| 343 should_reuse_web_ui_(false), | 343 should_reuse_web_ui_(false), |
| 344 has_selection_(false), | 344 has_selection_(false), |
| 345 last_navigation_previews_state_(PREVIEWS_UNSPECIFIED), | 345 last_navigation_previews_state_(PREVIEWS_UNSPECIFIED), |
| 346 frame_host_binding_(this), | 346 frame_host_binding_(this), |
| 347 waiting_for_init_(renderer_initiated_creation), | 347 waiting_for_init_(renderer_initiated_creation), |
| 348 has_focused_editable_element_(false), | 348 has_focused_editable_element_(false), |
| 349 csp_context_(new CSPContextImpl(this)), | |
| 349 weak_ptr_factory_(this) { | 350 weak_ptr_factory_(this) { |
| 350 frame_tree_->AddRenderViewHostRef(render_view_host_); | 351 frame_tree_->AddRenderViewHostRef(render_view_host_); |
| 351 GetProcess()->AddRoute(routing_id_, this); | 352 GetProcess()->AddRoute(routing_id_, this); |
| 352 g_routing_id_frame_map.Get().insert(std::make_pair( | 353 g_routing_id_frame_map.Get().insert(std::make_pair( |
| 353 RenderFrameHostID(GetProcess()->GetID(), routing_id_), | 354 RenderFrameHostID(GetProcess()->GetID(), routing_id_), |
| 354 this)); | 355 this)); |
| 355 site_instance_->AddObserver(this); | 356 site_instance_->AddObserver(this); |
| 356 GetSiteInstance()->IncrementActiveFrameCount(); | 357 GetSiteInstance()->IncrementActiveFrameCount(); |
| 357 | 358 |
| 358 if (frame_tree_node_->parent()) { | 359 if (frame_tree_node_->parent()) { |
| (...skipping 1477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1836 | 1837 |
| 1837 void RenderFrameHostImpl::OnDidSetFeaturePolicyHeader( | 1838 void RenderFrameHostImpl::OnDidSetFeaturePolicyHeader( |
| 1838 const ParsedFeaturePolicyHeader& parsed_header) { | 1839 const ParsedFeaturePolicyHeader& parsed_header) { |
| 1839 frame_tree_node()->SetFeaturePolicyHeader(parsed_header); | 1840 frame_tree_node()->SetFeaturePolicyHeader(parsed_header); |
| 1840 ResetFeaturePolicy(); | 1841 ResetFeaturePolicy(); |
| 1841 feature_policy_->SetHeaderPolicy(parsed_header); | 1842 feature_policy_->SetHeaderPolicy(parsed_header); |
| 1842 } | 1843 } |
| 1843 | 1844 |
| 1844 void RenderFrameHostImpl::OnDidAddContentSecurityPolicy( | 1845 void RenderFrameHostImpl::OnDidAddContentSecurityPolicy( |
| 1845 const ContentSecurityPolicyHeader& header, | 1846 const ContentSecurityPolicyHeader& header, |
| 1846 const std::vector<ContentSecurityPolicy>& policies) { | 1847 const std::vector<ContentSecurityPolicy>& policies) { |
|
alexmos
2017/02/24 06:40:27
This wasn't in this CL, but I'm a bit confused by
arthursonzogni
2017/02/24 16:13:29
RFC2616, section 4.2 specifies that headers appear
alexmos
2017/03/01 02:22:28
Acknowledged. I didn't know this, and indeed, Bli
arthursonzogni
2017/03/06 15:09:02
I will add a comment.
FYI, the |policies| argument
| |
| 1847 frame_tree_node()->AddContentSecurityPolicy(header, policies); | 1848 frame_tree_node()->AddContentSecurityPolicy(header); |
| 1849 content_security_policies_.insert(content_security_policies_.end(), | |
| 1850 policies.begin(), policies.end()); | |
| 1848 } | 1851 } |
| 1849 | 1852 |
| 1850 void RenderFrameHostImpl::OnEnforceInsecureRequestPolicy( | 1853 void RenderFrameHostImpl::OnEnforceInsecureRequestPolicy( |
| 1851 blink::WebInsecureRequestPolicy policy) { | 1854 blink::WebInsecureRequestPolicy policy) { |
| 1852 frame_tree_node()->SetInsecureRequestPolicy(policy); | 1855 frame_tree_node()->SetInsecureRequestPolicy(policy); |
| 1853 } | 1856 } |
| 1854 | 1857 |
| 1855 void RenderFrameHostImpl::OnUpdateToUniqueOrigin( | 1858 void RenderFrameHostImpl::OnUpdateToUniqueOrigin( |
| 1856 bool is_potentially_trustworthy_unique_origin) { | 1859 bool is_potentially_trustworthy_unique_origin) { |
| 1857 url::Origin origin; | 1860 url::Origin origin; |
| (...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2516 if (!common_params.url.SchemeIs(url::kJavaScriptScheme)) | 2519 if (!common_params.url.SchemeIs(url::kJavaScriptScheme)) |
| 2517 OnDidStartLoading(true); | 2520 OnDidStartLoading(true); |
| 2518 } | 2521 } |
| 2519 | 2522 |
| 2520 void RenderFrameHostImpl::NavigateToInterstitialURL(const GURL& data_url) { | 2523 void RenderFrameHostImpl::NavigateToInterstitialURL(const GURL& data_url) { |
| 2521 DCHECK(data_url.SchemeIs(url::kDataScheme)); | 2524 DCHECK(data_url.SchemeIs(url::kDataScheme)); |
| 2522 CommonNavigationParams common_params( | 2525 CommonNavigationParams common_params( |
| 2523 data_url, Referrer(), ui::PAGE_TRANSITION_LINK, | 2526 data_url, Referrer(), ui::PAGE_TRANSITION_LINK, |
| 2524 FrameMsg_Navigate_Type::DIFFERENT_DOCUMENT, false, false, | 2527 FrameMsg_Navigate_Type::DIFFERENT_DOCUMENT, false, false, |
| 2525 base::TimeTicks::Now(), FrameMsg_UILoadMetricsReportType::NO_REPORT, | 2528 base::TimeTicks::Now(), FrameMsg_UILoadMetricsReportType::NO_REPORT, |
| 2526 GURL(), GURL(), PREVIEWS_OFF, base::TimeTicks::Now(), "GET", nullptr); | 2529 GURL(), GURL(), PREVIEWS_OFF, base::TimeTicks::Now(), "GET", nullptr, |
| 2530 false /* should_bypass_main_world_csp */); | |
| 2527 if (IsBrowserSideNavigationEnabled()) { | 2531 if (IsBrowserSideNavigationEnabled()) { |
| 2528 CommitNavigation(nullptr, nullptr, common_params, RequestNavigationParams(), | 2532 CommitNavigation(nullptr, nullptr, common_params, RequestNavigationParams(), |
| 2529 false); | 2533 false); |
| 2530 } else { | 2534 } else { |
| 2531 Navigate(common_params, StartNavigationParams(), RequestNavigationParams()); | 2535 Navigate(common_params, StartNavigationParams(), RequestNavigationParams()); |
| 2532 } | 2536 } |
| 2533 } | 2537 } |
| 2534 | 2538 |
| 2535 void RenderFrameHostImpl::Stop() { | 2539 void RenderFrameHostImpl::Stop() { |
| 2536 Send(new FrameMsg_Stop(routing_id_)); | 2540 Send(new FrameMsg_Stop(routing_id_)); |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2752 ResetWaitingState(); | 2756 ResetWaitingState(); |
| 2753 | 2757 |
| 2754 Send(new FrameMsg_FailedNavigation(routing_id_, common_params, request_params, | 2758 Send(new FrameMsg_FailedNavigation(routing_id_, common_params, request_params, |
| 2755 has_stale_copy_in_cache, error_code)); | 2759 has_stale_copy_in_cache, error_code)); |
| 2756 | 2760 |
| 2757 // An error page is expected to commit, hence why is_loading_ is set to true. | 2761 // An error page is expected to commit, hence why is_loading_ is set to true. |
| 2758 is_loading_ = true; | 2762 is_loading_ = true; |
| 2759 frame_tree_node_->ResetNavigationRequest(true); | 2763 frame_tree_node_->ResetNavigationRequest(true); |
| 2760 } | 2764 } |
| 2761 | 2765 |
| 2766 void RenderFrameHostImpl::ReportContentSecurityPolicyViolation( | |
| 2767 const CSPViolationParams& violation_params) { | |
| 2768 Send(new FrameMsg_ReportContentSecurityPolicyViolation(routing_id_, | |
| 2769 violation_params)); | |
| 2770 } | |
| 2771 | |
| 2762 void RenderFrameHostImpl::SetUpMojoIfNeeded() { | 2772 void RenderFrameHostImpl::SetUpMojoIfNeeded() { |
| 2763 if (interface_registry_.get()) | 2773 if (interface_registry_.get()) |
| 2764 return; | 2774 return; |
| 2765 | 2775 |
| 2766 interface_registry_ = base::MakeUnique<service_manager::InterfaceRegistry>( | 2776 interface_registry_ = base::MakeUnique<service_manager::InterfaceRegistry>( |
| 2767 mojom::kNavigation_FrameSpec); | 2777 mojom::kNavigation_FrameSpec); |
| 2768 | 2778 |
| 2769 ServiceManagerConnection* service_manager_connection = | 2779 ServiceManagerConnection* service_manager_connection = |
| 2770 BrowserContext::GetServiceManagerConnectionFor( | 2780 BrowserContext::GetServiceManagerConnectionFor( |
| 2771 GetProcess()->GetBrowserContext()); | 2781 GetProcess()->GetBrowserContext()); |
| (...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3423 NavigationEntryImpl::FromNavigationEntry( | 3433 NavigationEntryImpl::FromNavigationEntry( |
| 3424 frame_tree_node()->navigator()->GetController()->GetPendingEntry()); | 3434 frame_tree_node()->navigator()->GetController()->GetPendingEntry()); |
| 3425 if (pending_entry && pending_entry->GetUniqueID() == params.nav_entry_id) { | 3435 if (pending_entry && pending_entry->GetUniqueID() == params.nav_entry_id) { |
| 3426 pending_nav_entry_id = params.nav_entry_id; | 3436 pending_nav_entry_id = params.nav_entry_id; |
| 3427 is_renderer_initiated = pending_entry->is_renderer_initiated(); | 3437 is_renderer_initiated = pending_entry->is_renderer_initiated(); |
| 3428 } | 3438 } |
| 3429 | 3439 |
| 3430 return NavigationHandleImpl::Create( | 3440 return NavigationHandleImpl::Create( |
| 3431 params.url, params.redirects, frame_tree_node_, is_renderer_initiated, | 3441 params.url, params.redirects, frame_tree_node_, is_renderer_initiated, |
| 3432 params.was_within_same_page, base::TimeTicks::Now(), | 3442 params.was_within_same_page, base::TimeTicks::Now(), |
| 3433 pending_nav_entry_id, false); // started_from_context_menu | 3443 pending_nav_entry_id, |
| 3444 false, // started_from_context_menu | |
| 3445 false); // should_bypass_main_world_csp | |
| 3434 } | 3446 } |
| 3435 | 3447 |
| 3436 // Determine if the current NavigationHandle can be used. | 3448 // Determine if the current NavigationHandle can be used. |
| 3437 if (navigation_handle_ && navigation_handle_->GetURL() == params.url) { | 3449 if (navigation_handle_ && navigation_handle_->GetURL() == params.url) { |
| 3438 return std::move(navigation_handle_); | 3450 return std::move(navigation_handle_); |
| 3439 } | 3451 } |
| 3440 | 3452 |
| 3441 // If the URL does not match what the NavigationHandle expects, treat the | 3453 // If the URL does not match what the NavigationHandle expects, treat the |
| 3442 // commit as a new navigation. This can happen when loading a Data | 3454 // commit as a new navigation. This can happen when loading a Data |
| 3443 // navigation with LoadDataWithBaseURL. | 3455 // navigation with LoadDataWithBaseURL. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3475 // Reset any existing NavigationHandle. | 3487 // Reset any existing NavigationHandle. |
| 3476 navigation_handle_.reset(); | 3488 navigation_handle_.reset(); |
| 3477 } | 3489 } |
| 3478 | 3490 |
| 3479 // There is no pending NavigationEntry in these cases, so pass 0 as the | 3491 // There is no pending NavigationEntry in these cases, so pass 0 as the |
| 3480 // pending_nav_entry_id. If the previous handle was a prematurely aborted | 3492 // pending_nav_entry_id. If the previous handle was a prematurely aborted |
| 3481 // navigation loaded via LoadDataWithBaseURL, propagate the entry id. | 3493 // navigation loaded via LoadDataWithBaseURL, propagate the entry id. |
| 3482 return NavigationHandleImpl::Create( | 3494 return NavigationHandleImpl::Create( |
| 3483 params.url, params.redirects, frame_tree_node_, is_renderer_initiated, | 3495 params.url, params.redirects, frame_tree_node_, is_renderer_initiated, |
| 3484 params.was_within_same_page, base::TimeTicks::Now(), | 3496 params.was_within_same_page, base::TimeTicks::Now(), |
| 3485 entry_id_for_data_nav, false); // started_from_context_menu | 3497 entry_id_for_data_nav, |
| 3498 false, // started_from_context_menu | |
| 3499 false); // should_bypass_main_world_csp | |
| 3486 } | 3500 } |
| 3487 | 3501 |
| 3488 } // namespace content | 3502 } // namespace content |
| OLD | NEW |