#include "third_party/blink/renderer/core/loader/mixed_content_checker.h"
#include <optional>
#include "base/containers/contains.h"
#include "base/feature_list.h"
#include "base/metrics/field_trial_params.h"
#include "build/build_config.h"
#include "build/chromecast_buildflags.h"
#include "services/network/public/cpp/features.h"
#include "services/network/public/cpp/is_potentially_trustworthy.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/common/security_context/insecure_request_policy.h"
#include "third_party/blink/public/mojom/devtools/inspector_issue.mojom-blink.h"
#include "third_party/blink/public/mojom/fetch/fetch_api_request.mojom-blink.h"
#include "third_party/blink/public/mojom/frame/frame.mojom-blink.h"
#include "third_party/blink/public/mojom/loader/mixed_content.mojom-blink.h"
#include "third_party/blink/public/mojom/loader/request_context_frame_type.mojom-blink.h"
#include "third_party/blink/public/mojom/security_context/insecure_request_policy.mojom-blink.h"
#include "third_party/blink/public/platform/web_content_settings_client.h"
#include "third_party/blink/public/platform/web_security_origin.h"
#include "third_party/blink/public/platform/web_worker_fetch_context.h"
#include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/frame/frame.h"
#include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/frame/local_frame_client.h"
#include "third_party/blink/renderer/core/frame/settings.h"
#include "third_party/blink/renderer/core/inspector/console_message.h"
#include "third_party/blink/renderer/core/inspector/inspector_audits_issue.h"
#include "third_party/blink/renderer/core/loader/document_loader.h"
#include "third_party/blink/renderer/core/loader/frame_fetch_context.h"
#include "third_party/blink/renderer/core/loader/worker_fetch_context.h"
#include "third_party/blink/renderer/core/probe/core_probes.h"
#include "third_party/blink/renderer/core/workers/worker_global_scope.h"
#include "third_party/blink/renderer/core/workers/worker_or_worklet_global_scope.h"
#include "third_party/blink/renderer/core/workers/worker_settings.h"
#include "third_party/blink/renderer/platform/heap/garbage_collected.h"
#include "third_party/blink/renderer/platform/instrumentation/use_counter.h"
#include "third_party/blink/renderer/platform/loader/fetch/resource_fetcher_properties.h"
#include "third_party/blink/renderer/platform/loader/mixed_content.h"
#include "third_party/blink/renderer/platform/network/network_utils.h"
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
#include "third_party/blink/renderer/platform/weborigin/scheme_registry.h"
#include "third_party/blink/renderer/platform/weborigin/security_origin.h"
#include "third_party/blink/renderer/platform/wtf/text/string_builder.h"
namespace blink {
namespace {
KURL MainResourceUrlForFrame(Frame* frame) { … }
const char* RequestContextName(mojom::blink::RequestContextType context) { … }
bool IsWebSocketAllowedInFrame(const BaseFetchContext& fetch_context,
const SecurityContext* security_context,
Settings* settings,
const KURL& url) { … }
bool IsWebSocketAllowedInWorker(const WorkerFetchContext& fetch_context,
WorkerSettings* settings,
const KURL& url) { … }
bool IsUrlPotentiallyTrustworthy(const KURL& url) { … }
}
static bool IsInsecureUrl(const KURL& url) { … }
static void MeasureStricterVersionOfIsMixedContent(Frame& frame,
const KURL& url,
const LocalFrame* source) { … }
bool RequestIsSubframeSubresource(Frame* frame) { … }
bool MixedContentChecker::IsMixedContent(const SecurityOrigin* security_origin,
const KURL& url) { … }
bool MixedContentChecker::IsMixedContent(const String& origin_protocol,
const KURL& url) { … }
bool MixedContentChecker::IsMixedContent(
const FetchClientSettingsObject& settings,
const KURL& url) { … }
Frame* MixedContentChecker::InWhichFrameIsContentMixed(LocalFrame* frame,
const KURL& url) { … }
ConsoleMessage* MixedContentChecker::CreateConsoleMessageAboutFetch(
const KURL& main_resource_url,
const KURL& url,
mojom::blink::RequestContextType request_context,
bool allowed,
std::unique_ptr<SourceLocation> source_location) { … }
void MixedContentChecker::Count(
Frame* frame,
mojom::blink::RequestContextType request_context,
const LocalFrame* source) { … }
bool MixedContentChecker::ShouldBlockFetch(
LocalFrame* frame,
mojom::blink::RequestContextType request_context,
network::mojom::blink::IPAddressSpace target_address_space,
const KURL& url_before_redirects,
ResourceRequest::RedirectStatus redirect_status,
const KURL& url,
const String& devtools_id,
ReportingDisposition reporting_disposition,
mojom::blink::ContentSecurityNotifier& notifier) { … }
bool MixedContentChecker::ShouldBlockFetchOnWorker(
WorkerFetchContext& worker_fetch_context,
mojom::blink::RequestContextType request_context,
const KURL& url_before_redirects,
ResourceRequest::RedirectStatus redirect_status,
const KURL& url,
ReportingDisposition reporting_disposition,
bool is_worklet_global_scope) { … }
ConsoleMessage* MixedContentChecker::CreateConsoleMessageAboutWebSocket(
const KURL& main_resource_url,
const KURL& url,
bool allowed) { … }
bool MixedContentChecker::IsWebSocketAllowed(
const FrameFetchContext& frame_fetch_context,
LocalFrame* frame,
const KURL& url) { … }
bool MixedContentChecker::IsWebSocketAllowed(
WorkerFetchContext& worker_fetch_context,
const KURL& url) { … }
bool MixedContentChecker::IsMixedFormAction(
LocalFrame* frame,
const KURL& url,
ReportingDisposition reporting_disposition) { … }
bool MixedContentChecker::ShouldAutoupgrade(
const FetchClientSettingsObject* fetch_client_settings_object,
mojom::blink::RequestContextType type,
WebContentSettingsClient* settings_client,
const ResourceRequest& resource_request,
ExecutionContext* execution_context_for_logging) { … }
void MixedContentChecker::HandleCertificateError(
const ResourceResponse& response,
mojom::blink::RequestContextType request_context,
MixedContent::CheckModeForPlugin check_mode_for_plugin,
mojom::blink::ContentSecurityNotifier& notifier) { … }
void MixedContentChecker::MixedContentFound(
LocalFrame* frame,
const KURL& main_resource_url,
const KURL& mixed_content_url,
mojom::blink::RequestContextType request_context,
bool was_allowed,
const KURL& url_before_redirects,
bool had_redirect,
std::unique_ptr<SourceLocation> source_location) { … }
ConsoleMessage* MixedContentChecker::CreateConsoleMessageAboutFetchAutoupgrade(
const KURL& main_resource_url,
const KURL& mixed_content_url) { … }
ConsoleMessage*
MixedContentChecker::CreateConsoleMessageAboutFetchIPAddressNoAutoupgrade(
const KURL& main_resource_url,
const KURL& mixed_content_url) { … }
mojom::blink::MixedContentContextType
MixedContentChecker::ContextTypeForInspector(LocalFrame* frame,
const ResourceRequest& request) { … }
void MixedContentChecker::UpgradeInsecureRequest(
ResourceRequest& resource_request,
const FetchClientSettingsObject* fetch_client_settings_object,
ExecutionContext* execution_context_for_logging,
mojom::RequestContextFrameType frame_type,
WebContentSettingsClient* settings_client) { … }
MixedContent::CheckModeForPlugin MixedContentChecker::DecideCheckModeForPlugin(
Settings* settings) { … }
}