Commit d3be52b7 authored by Carlos IL's avatar Carlos IL Committed by Commit Bot

Added parameters to mixed content autoupgrade experiment.

Added parameters to experiment to allow only upgrading blockable
content or optionally blockable content.

Will be added in follow-up CLs:
-LayoutTests
-Fallback to HTTP (handled from //content)
-Metrics

Change-Id: I3d3922fc017413b5374404427deae310ecf30bb1
Reviewed-on: https://chromium-review.googlesource.com/c/1251628
Commit-Queue: Carlos IL <carlosil@chromium.org>
Reviewed-by: default avatarMike West <mkwst@chromium.org>
Cr-Commit-Position: refs/heads/master@{#597605}
parent de5d41b4
...@@ -106,5 +106,10 @@ const char kAutofillPreviewStyleExperimentBgColorParameterName[] = "bg_color"; ...@@ -106,5 +106,10 @@ const char kAutofillPreviewStyleExperimentBgColorParameterName[] = "bg_color";
const char kAutofillPreviewStyleExperimentColorParameterName[] = "color"; const char kAutofillPreviewStyleExperimentColorParameterName[] = "color";
const char kMixedContentAutoupgradeModeParamName[] = "mode";
const char kMixedContentAutoupgradeModeBlockable[] = "blockable";
const char kMixedContentAutoupgradeModeOptionallyBlockable[] =
"optionally-blockable";
} // namespace features } // namespace features
} // namespace blink } // namespace blink
...@@ -38,6 +38,11 @@ BLINK_COMMON_EXPORT extern const char ...@@ -38,6 +38,11 @@ BLINK_COMMON_EXPORT extern const char
BLINK_COMMON_EXPORT extern const char BLINK_COMMON_EXPORT extern const char
kAutofillPreviewStyleExperimentColorParameterName[]; kAutofillPreviewStyleExperimentColorParameterName[];
BLINK_COMMON_EXPORT extern const char kMixedContentAutoupgradeModeParamName[];
BLINK_COMMON_EXPORT extern const char kMixedContentAutoupgradeModeBlockable[];
BLINK_COMMON_EXPORT extern const char
kMixedContentAutoupgradeModeOptionallyBlockable[];
} // namespace features } // namespace features
} // namespace blink } // namespace blink
......
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
#include <memory> #include <memory>
#include "base/auto_reset.h" #include "base/auto_reset.h"
#include "base/feature_list.h" #include "base/feature_list.h"
#include "base/metrics/field_trial_params.h"
#include "base/metrics/histogram_macros.h" #include "base/metrics/histogram_macros.h"
#include "base/unguessable_token.h" #include "base/unguessable_token.h"
#include "services/network/public/mojom/request_context_frame_type.mojom-blink.h" #include "services/network/public/mojom/request_context_frame_type.mojom-blink.h"
...@@ -46,6 +47,8 @@ ...@@ -46,6 +47,8 @@
#include "third_party/blink/public/platform/modules/fetch/fetch_api_request.mojom-shared.h" #include "third_party/blink/public/platform/modules/fetch/fetch_api_request.mojom-shared.h"
#include "third_party/blink/public/platform/modules/service_worker/web_service_worker_network_provider.h" #include "third_party/blink/public/platform/modules/service_worker/web_service_worker_network_provider.h"
#include "third_party/blink/public/platform/task_type.h" #include "third_party/blink/public/platform/task_type.h"
#include "third_party/blink/public/platform/web_mixed_content.h"
#include "third_party/blink/public/platform/web_mixed_content_context_type.h"
#include "third_party/blink/public/platform/web_url_request.h" #include "third_party/blink/public/platform/web_url_request.h"
#include "third_party/blink/public/web/commit_result.mojom-shared.h" #include "third_party/blink/public/web/commit_result.mojom-shared.h"
#include "third_party/blink/public/web/web_frame_load_type.h" #include "third_party/blink/public/web/web_frame_load_type.h"
...@@ -111,6 +114,35 @@ ...@@ -111,6 +114,35 @@
using blink::WebURLRequest; using blink::WebURLRequest;
namespace {
bool ShouldAutoupgrade(blink::WebMixedContentContextType type) {
if (!base::FeatureList::IsEnabled(
blink::features::kMixedContentAutoupgrade) ||
type == blink::WebMixedContentContextType::kNotMixedContent) {
return false;
}
std::string autoupgrade_mode = base::GetFieldTrialParamValueByFeature(
blink::features::kMixedContentAutoupgrade,
blink::features::kMixedContentAutoupgradeModeParamName);
if (autoupgrade_mode ==
blink::features::kMixedContentAutoupgradeModeBlockable) {
return type == blink::WebMixedContentContextType::kBlockable ||
type == blink::WebMixedContentContextType::kShouldBeBlockable;
}
if (autoupgrade_mode ==
blink::features::kMixedContentAutoupgradeModeOptionallyBlockable) {
return type == blink::WebMixedContentContextType::kOptionallyBlockable;
}
// Otherwise we default to autoupgrading all mixed content.
return true;
}
} // namespace
namespace blink { namespace blink {
using namespace HTMLNames; using namespace HTMLNames;
...@@ -1673,9 +1705,16 @@ void FrameLoader::UpgradeInsecureRequest(ResourceRequest& resource_request, ...@@ -1673,9 +1705,16 @@ void FrameLoader::UpgradeInsecureRequest(ResourceRequest& resource_request,
return; return;
if (!(origin_context->GetSecurityContext().GetInsecureRequestPolicy() & if (!(origin_context->GetSecurityContext().GetInsecureRequestPolicy() &
kUpgradeInsecureRequests) && kUpgradeInsecureRequests)) {
!base::FeatureList::IsEnabled(features::kMixedContentAutoupgrade)) { mojom::RequestContextType context = resource_request.GetRequestContext();
return; // TODO(carlosil): Handle strict_mixed_content_checking_for_plugin
// correctly.
if (context == mojom::RequestContextType::UNSPECIFIED ||
!origin_context->Url().ProtocolIs("https") ||
!ShouldAutoupgrade(
WebMixedContent::ContextTypeFromRequestContext(context, false))) {
return;
}
} }
// Nested frames are always upgraded on the browser process. // Nested frames are always upgraded on the browser process.
......
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