Commit db08e18f authored by Mohamed Abdelhalim's avatar Mohamed Abdelhalim Committed by Commit Bot

Navigation: Remove NavigationHandleImpl usages 3.

This is the 3rd CL of multiple CLs to remove the usages of
NavigationHandleImpl completely and replace it with NavigationRequest.

This CL replaces NavigationHandleImpl in MixedContentNavigationThrottle
and NavigationHandleImplBrowserTest with NavigationRequest, and renames
NavigationHandleImplBrowserTest to NavigationRequestBrowserTest.

Bug: 995268
Change-Id: Ia0d76dda052f4cea67586cafdc51635a4a3c8a1d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1803447
Commit-Queue: Mohamed Abdelhalim <zetamoo@chromium.org>
Reviewed-by: default avatarArthur Sonzogni <arthursonzogni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#697560}
parent 77a24110
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include "base/stl_util.h" #include "base/stl_util.h"
#include "content/browser/frame_host/frame_tree.h" #include "content/browser/frame_host/frame_tree.h"
#include "content/browser/frame_host/frame_tree_node.h" #include "content/browser/frame_host/frame_tree_node.h"
#include "content/browser/frame_host/navigation_handle_impl.h" #include "content/browser/frame_host/navigation_request.h"
#include "content/browser/frame_host/render_frame_host_delegate.h" #include "content/browser/frame_host/render_frame_host_delegate.h"
#include "content/browser/renderer_host/render_view_host_impl.h" #include "content/browser/renderer_host/render_view_host_impl.h"
#include "content/common/frame_messages.h" #include "content/common/frame_messages.h"
...@@ -67,7 +67,7 @@ bool DoesOriginSchemeRestrictMixedContent(const url::Origin& origin) { ...@@ -67,7 +67,7 @@ bool DoesOriginSchemeRestrictMixedContent(const url::Origin& origin) {
return origin.scheme() == url::kHttpsScheme; return origin.scheme() == url::kHttpsScheme;
} }
void UpdateRendererOnMixedContentFound(NavigationHandleImpl* navigation_handle, void UpdateRendererOnMixedContentFound(NavigationRequest* navigation_request,
const GURL& mixed_content_url, const GURL& mixed_content_url,
bool was_allowed, bool was_allowed,
bool for_redirect) { bool for_redirect) {
...@@ -75,17 +75,19 @@ void UpdateRendererOnMixedContentFound(NavigationHandleImpl* navigation_handle, ...@@ -75,17 +75,19 @@ void UpdateRendererOnMixedContentFound(NavigationHandleImpl* navigation_handle,
// mixed content for now. Once/if the browser should also check form submits // mixed content for now. Once/if the browser should also check form submits
// for mixed content than this will be allowed to happen and this DCHECK // for mixed content than this will be allowed to happen and this DCHECK
// should be updated. // should be updated.
DCHECK(navigation_handle->frame_tree_node()->parent()); DCHECK(navigation_request->frame_tree_node()->parent());
RenderFrameHost* rfh = RenderFrameHost* rfh =
navigation_handle->frame_tree_node()->current_frame_host(); navigation_request->frame_tree_node()->current_frame_host();
FrameMsg_MixedContentFound_Params params; FrameMsg_MixedContentFound_Params params;
params.main_resource_url = mixed_content_url; params.main_resource_url = mixed_content_url;
params.mixed_content_url = navigation_handle->GetURL(); params.mixed_content_url = navigation_request->GetURL();
params.request_context_type = navigation_handle->request_context_type(); params.request_context_type = navigation_request->request_context_type();
params.was_allowed = was_allowed; params.was_allowed = was_allowed;
params.had_redirect = for_redirect; params.had_redirect = for_redirect;
if (navigation_handle->source_location()) if (navigation_request->common_params().source_location) {
params.source_location = navigation_handle->source_location().value(); params.source_location =
navigation_request->common_params().source_location.value();
}
rfh->Send(new FrameMsg_MixedContentFound(rfh->GetRoutingID(), params)); rfh->Send(new FrameMsg_MixedContentFound(rfh->GetRoutingID(), params));
} }
...@@ -135,13 +137,12 @@ const char* MixedContentNavigationThrottle::GetNameForLogging() { ...@@ -135,13 +137,12 @@ const char* MixedContentNavigationThrottle::GetNameForLogging() {
// Based off of MixedContentChecker::shouldBlockFetch. // Based off of MixedContentChecker::shouldBlockFetch.
bool MixedContentNavigationThrottle::ShouldBlockNavigation(bool for_redirect) { bool MixedContentNavigationThrottle::ShouldBlockNavigation(bool for_redirect) {
NavigationHandleImpl* handle_impl = NavigationRequest* request = NavigationRequest::From(navigation_handle());
static_cast<NavigationHandleImpl*>(navigation_handle()); FrameTreeNode* node = request->frame_tree_node();
FrameTreeNode* node = handle_impl->frame_tree_node();
// Find the parent node where mixed content is characterized, if any. // Find the parent node where mixed content is characterized, if any.
FrameTreeNode* mixed_content_node = FrameTreeNode* mixed_content_node =
InWhichFrameIsContentMixed(node, handle_impl->GetURL()); InWhichFrameIsContentMixed(node, request->GetURL());
if (!mixed_content_node) { if (!mixed_content_node) {
MaybeSendBlinkFeatureUsageReport(); MaybeSendBlinkFeatureUsageReport();
return false; return false;
...@@ -150,8 +151,8 @@ bool MixedContentNavigationThrottle::ShouldBlockNavigation(bool for_redirect) { ...@@ -150,8 +151,8 @@ bool MixedContentNavigationThrottle::ShouldBlockNavigation(bool for_redirect) {
// From this point on we know this is not a main frame navigation and that // From this point on we know this is not a main frame navigation and that
// there is mixed content. Now let's decide if it's OK to proceed with it. // there is mixed content. Now let's decide if it's OK to proceed with it.
ReportBasicMixedContentFeatures(handle_impl->request_context_type(), ReportBasicMixedContentFeatures(request->request_context_type(),
handle_impl->mixed_content_context_type()); request->mixed_content_context_type());
// If we're in strict mode, we'll automagically fail everything, and // If we're in strict mode, we'll automagically fail everything, and
// intentionally skip the client/embedder checks in order to prevent degrading // intentionally skip the client/embedder checks in order to prevent degrading
...@@ -166,11 +167,12 @@ bool MixedContentNavigationThrottle::ShouldBlockNavigation(bool for_redirect) { ...@@ -166,11 +167,12 @@ bool MixedContentNavigationThrottle::ShouldBlockNavigation(bool for_redirect) {
prefs.strict_mixed_content_checking || block_all_mixed_content; prefs.strict_mixed_content_checking || block_all_mixed_content;
blink::WebMixedContentContextType mixed_context_type = blink::WebMixedContentContextType mixed_context_type =
handle_impl->mixed_content_context_type(); request->mixed_content_context_type();
if (!ShouldTreatURLSchemeAsCorsEnabled(handle_impl->GetURL())) if (!ShouldTreatURLSchemeAsCorsEnabled(request->GetURL())) {
mixed_context_type = mixed_context_type =
blink::WebMixedContentContextType::kOptionallyBlockable; blink::WebMixedContentContextType::kOptionallyBlockable;
}
bool allowed = false; bool allowed = false;
RenderFrameHostDelegate* frame_host_delegate = RenderFrameHostDelegate* frame_host_delegate =
...@@ -179,7 +181,7 @@ bool MixedContentNavigationThrottle::ShouldBlockNavigation(bool for_redirect) { ...@@ -179,7 +181,7 @@ bool MixedContentNavigationThrottle::ShouldBlockNavigation(bool for_redirect) {
case blink::WebMixedContentContextType::kOptionallyBlockable: case blink::WebMixedContentContextType::kOptionallyBlockable:
allowed = !strict_mode; allowed = !strict_mode;
if (allowed) { if (allowed) {
frame_host_delegate->PassiveInsecureContentFound(handle_impl->GetURL()); frame_host_delegate->PassiveInsecureContentFound(request->GetURL());
frame_host_delegate->DidDisplayInsecureContent(); frame_host_delegate->DidDisplayInsecureContent();
} }
break; break;
...@@ -193,16 +195,15 @@ bool MixedContentNavigationThrottle::ShouldBlockNavigation(bool for_redirect) { ...@@ -193,16 +195,15 @@ bool MixedContentNavigationThrottle::ShouldBlockNavigation(bool for_redirect) {
bool should_ask_delegate = bool should_ask_delegate =
!strict_mode && (!prefs.strictly_block_blockable_mixed_content || !strict_mode && (!prefs.strictly_block_blockable_mixed_content ||
prefs.allow_running_insecure_content); prefs.allow_running_insecure_content);
allowed = allowed = should_ask_delegate &&
should_ask_delegate && frame_host_delegate->ShouldAllowRunningInsecureContent(
frame_host_delegate->ShouldAllowRunningInsecureContent( navigation_handle()->GetWebContents(),
handle_impl->GetWebContents(), prefs.allow_running_insecure_content,
prefs.allow_running_insecure_content, mixed_content_node->current_origin(), request->GetURL());
mixed_content_node->current_origin(), handle_impl->GetURL());
if (allowed) { if (allowed) {
const GURL& origin_url = mixed_content_node->current_origin().GetURL(); const GURL& origin_url = mixed_content_node->current_origin().GetURL();
frame_host_delegate->DidRunInsecureContent(origin_url, frame_host_delegate->DidRunInsecureContent(origin_url,
handle_impl->GetURL()); request->GetURL());
GetContentClient()->browser()->RecordURLMetric( GetContentClient()->browser()->RecordURLMetric(
"ContentSettings.MixedScript.RanMixedScript", origin_url); "ContentSettings.MixedScript.RanMixedScript", origin_url);
mixed_content_features_.insert( mixed_content_features_.insert(
...@@ -222,8 +223,8 @@ bool MixedContentNavigationThrottle::ShouldBlockNavigation(bool for_redirect) { ...@@ -222,8 +223,8 @@ bool MixedContentNavigationThrottle::ShouldBlockNavigation(bool for_redirect) {
break; break;
}; };
UpdateRendererOnMixedContentFound( UpdateRendererOnMixedContentFound(request, mixed_content_node->current_url(),
handle_impl, mixed_content_node->current_url(), allowed, for_redirect); allowed, for_redirect);
MaybeSendBlinkFeatureUsageReport(); MaybeSendBlinkFeatureUsageReport();
return !allowed; return !allowed;
...@@ -287,9 +288,8 @@ FrameTreeNode* MixedContentNavigationThrottle::InWhichFrameIsContentMixed( ...@@ -287,9 +288,8 @@ FrameTreeNode* MixedContentNavigationThrottle::InWhichFrameIsContentMixed(
void MixedContentNavigationThrottle::MaybeSendBlinkFeatureUsageReport() { void MixedContentNavigationThrottle::MaybeSendBlinkFeatureUsageReport() {
if (!mixed_content_features_.empty()) { if (!mixed_content_features_.empty()) {
NavigationHandleImpl* handle_impl = NavigationRequest* request = NavigationRequest::From(navigation_handle());
static_cast<NavigationHandleImpl*>(navigation_handle()); RenderFrameHost* rfh = request->frame_tree_node()->current_frame_host();
RenderFrameHost* rfh = handle_impl->frame_tree_node()->current_frame_host();
rfh->Send(new FrameMsg_BlinkFeatureUsageReport(rfh->GetRoutingID(), rfh->Send(new FrameMsg_BlinkFeatureUsageReport(rfh->GetRoutingID(),
mixed_content_features_)); mixed_content_features_));
mixed_content_features_.clear(); mixed_content_features_.clear();
......
...@@ -119,13 +119,7 @@ class CONTENT_EXPORT NavigationHandleImpl : public NavigationHandle { ...@@ -119,13 +119,7 @@ class CONTENT_EXPORT NavigationHandleImpl : public NavigationHandle {
mojom::TransferrableURLLoaderPtr transferrable_loader) override; mojom::TransferrableURLLoaderPtr transferrable_loader) override;
blink::mojom::RequestContextType request_context_type() const { blink::mojom::RequestContextType request_context_type() const {
DCHECK_GE(state(), NavigationRequest::PROCESSING_WILL_START_REQUEST); return navigation_request_->request_context_type();
return navigation_request_->begin_params()->request_context_type;
}
blink::WebMixedContentContextType mixed_content_context_type() const {
DCHECK_GE(state(), NavigationRequest::PROCESSING_WILL_START_REQUEST);
return navigation_request_->begin_params()->mixed_content_context_type;
} }
// Get the unique id from the NavigationEntry associated with this // Get the unique id from the NavigationEntry associated with this
......
...@@ -480,6 +480,16 @@ class CONTENT_EXPORT NavigationRequest : public NavigationURLLoaderDelegate, ...@@ -480,6 +480,16 @@ class CONTENT_EXPORT NavigationRequest : public NavigationURLLoaderDelegate,
// expose the NavigationHandle when navigating to an InterstitialPage. // expose the NavigationHandle when navigating to an InterstitialPage.
NavigatorDelegate* GetDelegate() const; NavigatorDelegate* GetDelegate() const;
blink::mojom::RequestContextType request_context_type() const {
DCHECK_GE(handle_state_, PROCESSING_WILL_START_REQUEST);
return begin_params_->request_context_type;
}
blink::WebMixedContentContextType mixed_content_context_type() const {
DCHECK_GE(handle_state_, PROCESSING_WILL_START_REQUEST);
return begin_params_->mixed_content_context_type;
}
private: private:
friend class NavigationRequestTest; friend class NavigationRequestTest;
......
...@@ -925,7 +925,7 @@ test("content_browsertests") { ...@@ -925,7 +925,7 @@ test("content_browsertests") {
"../browser/frame_host/frame_tree_browsertest.cc", "../browser/frame_host/frame_tree_browsertest.cc",
"../browser/frame_host/interstitial_page_impl_browsertest.cc", "../browser/frame_host/interstitial_page_impl_browsertest.cc",
"../browser/frame_host/navigation_controller_impl_browsertest.cc", "../browser/frame_host/navigation_controller_impl_browsertest.cc",
"../browser/frame_host/navigation_handle_impl_browsertest.cc", "../browser/frame_host/navigation_request_browsertest.cc",
"../browser/frame_host/render_document_host_browsertest.cc", "../browser/frame_host/render_document_host_browsertest.cc",
"../browser/frame_host/render_frame_host_impl_browsertest.cc", "../browser/frame_host/render_frame_host_impl_browsertest.cc",
"../browser/frame_host/render_frame_host_manager_browsertest.cc", "../browser/frame_host/render_frame_host_manager_browsertest.cc",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment