Commit d0f7494a authored by Frédéric Wang's avatar Frédéric Wang Committed by Chromium LUCI CQ

Remove API SchemeRegistry::ShouldTreatURLSchemeAsNoAccess()

This CL replaces the only use of ShouldTreatURLSchemeAsNoAccess() with a
direct call to the corresponding url::GetNoAccessSchemes() API. This
removes the need to store a copy of the no-access schemes in
SchemeRegistry, which is not kept in sync with the one from url_utils.
In particular, this improves consistency between SecurityOrigin's
ShouldTreatAsOpaqueOrigin and SchemeHostPort's and fixes the following
DCHECK failure when running the test
SecurityOrigin.StandardNoAccessScheme added in crbug.com/2602402:

[FATAL:security_origin.cc(158)] Check failed: url::SchemeHostPort(protocol.Utf8(), host.Utf8(), port, url::SchemeHostPort::CHECK_CANONICALIZATION) .IsValid().
base::debug::CollectStackTrace()
base::debug::StackTrace::StackTrace()
logging::LogMessage::~LogMessage()
logging::LogMessage::~LogMessage()
blink::SecurityOrigin::SecurityOrigin()
blink::SecurityOrigin::SecurityOrigin()
blink::SecurityOrigin::CreateWithReferenceOrigin()
blink::SecurityOrigin::CreateFromString()
blink::SecurityOriginTest_StandardNoAccessScheme_Test::TestBody()

Bug: 888079, 1021779, 1020201
Change-Id: I7d8481389bd64ccc09f60b31ca6d7291ebedaa7b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2637593Reviewed-by: default avatarMike West <mkwst@chromium.org>
Reviewed-by: default avatarŁukasz Anforowicz <lukasza@chromium.org>
Commit-Queue: Frédéric Wang <fwang@igalia.com>
Cr-Commit-Position: refs/heads/master@{#845075}
parent b95a3cd5
......@@ -69,8 +69,6 @@ class URLSchemesRegistry final {
service_worker_schemes({"http", "https"}),
fetch_api_schemes({"http", "https"}),
allowed_in_referrer_schemes({"http", "https"}) {
for (auto& scheme : url::GetNoAccessSchemes())
schemes_with_unique_origins.insert(scheme.c_str());
for (auto& scheme : url::GetCorsEnabledSchemes())
cors_enabled_schemes.insert(scheme.c_str());
for (auto& scheme : url::GetCSPBypassingSchemes()) {
......@@ -91,7 +89,6 @@ class URLSchemesRegistry final {
// Particularly, Strings inside them shouldn't be copied, as it modifies
// reference counts of StringImpls (IsolatedCopy() should be taken instead).
URLSchemesSet display_isolated_url_schemes;
URLSchemesSet schemes_with_unique_origins;
URLSchemesSet empty_document_schemes;
URLSchemesSet schemes_forbidden_from_domain_relaxation;
URLSchemesSet not_allowing_javascript_urls_schemes;
......@@ -130,13 +127,6 @@ URLSchemesRegistry& GetMutableURLSchemesRegistry() {
} // namespace
bool SchemeRegistry::ShouldTreatURLSchemeAsNoAccess(const String& scheme) {
DCHECK_EQ(scheme, scheme.LowerASCII());
if (scheme.IsEmpty())
return false;
return GetURLSchemesRegistry().schemes_with_unique_origins.Contains(scheme);
}
void SchemeRegistry::RegisterURLSchemeAsDisplayIsolated(const String& scheme) {
DCHECK_EQ(scheme, scheme.LowerASCII());
GetMutableURLSchemesRegistry().display_isolated_url_schemes.insert(scheme);
......
......@@ -51,8 +51,6 @@ class PLATFORM_EXPORT SchemeRegistry {
public:
static bool ShouldTreatURLSchemeAsRestrictingMixedContent(const String&);
static bool ShouldTreatURLSchemeAsNoAccess(const String&);
// Display-isolated schemes can only be displayed (in the sense of
// SecurityOrigin::canDisplay) by documents from the same scheme.
static void RegisterURLSchemeAsDisplayIsolated(const String&);
......
......@@ -115,7 +115,8 @@ static bool ShouldTreatAsOpaqueOrigin(const KURL& url) {
relevant_url.ProtocolIs("ftp")) &&
relevant_url.Host().IsEmpty()));
if (SchemeRegistry::ShouldTreatURLSchemeAsNoAccess(relevant_url.Protocol()))
if (base::Contains(url::GetNoAccessSchemes(),
relevant_url.Protocol().Ascii()))
return true;
// Nonstandard schemes and unregistered schemes aren't known to contain hosts
......
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