2013-06-04 19:41:37 +02:00
|
|
|
// Copyright (c) 2013 The Chromium Embedded Framework Authors. All rights
|
|
|
|
// reserved. Use of this source code is governed by a BSD-style license that
|
|
|
|
// can be found in the LICENSE file.
|
|
|
|
|
2024-04-30 17:45:07 +02:00
|
|
|
#include "cef/libcef/common/net/scheme_registration.h"
|
2013-06-04 19:41:37 +02:00
|
|
|
|
2021-07-23 18:40:13 +02:00
|
|
|
#include "base/containers/contains.h"
|
2013-06-04 19:41:37 +02:00
|
|
|
#include "content/public/common/url_constants.h"
|
2015-07-16 23:40:01 +02:00
|
|
|
#include "extensions/common/constants.h"
|
2014-06-12 22:28:58 +02:00
|
|
|
#include "url/url_constants.h"
|
2019-04-24 04:50:25 +02:00
|
|
|
#include "url/url_util.h"
|
2013-06-04 19:41:37 +02:00
|
|
|
|
|
|
|
namespace scheme {
|
|
|
|
|
|
|
|
bool IsInternalHandledScheme(const std::string& scheme) {
|
|
|
|
static const char* schemes[] = {
|
2021-09-20 11:06:23 +02:00
|
|
|
url::kAboutScheme,
|
|
|
|
url::kBlobScheme,
|
|
|
|
content::kChromeDevToolsScheme,
|
|
|
|
content::kChromeUIScheme,
|
2022-02-16 22:24:41 +01:00
|
|
|
content::kChromeUIUntrustedScheme,
|
2021-09-20 11:06:23 +02:00
|
|
|
url::kDataScheme,
|
|
|
|
extensions::kExtensionScheme,
|
|
|
|
url::kFileScheme,
|
|
|
|
url::kFileSystemScheme,
|
|
|
|
url::kHttpScheme,
|
|
|
|
url::kHttpsScheme,
|
|
|
|
url::kJavaScriptScheme,
|
|
|
|
url::kWsScheme,
|
|
|
|
url::kWssScheme,
|
2013-06-04 19:41:37 +02:00
|
|
|
};
|
|
|
|
|
2024-01-20 23:48:57 +01:00
|
|
|
for (auto& i : schemes) {
|
|
|
|
if (scheme == i) {
|
2013-06-04 19:41:37 +02:00
|
|
|
return true;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2013-06-04 19:41:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-04-24 04:50:25 +02:00
|
|
|
bool IsStandardScheme(const std::string& scheme) {
|
|
|
|
url::Component scheme_comp(0, scheme.length());
|
|
|
|
return url::IsStandard(scheme.c_str(), scheme_comp);
|
|
|
|
}
|
|
|
|
|
2020-08-14 21:28:23 +02:00
|
|
|
// Should return the same value as SecurityOrigin::isLocal and
|
|
|
|
// SchemeRegistry::shouldTreatURLSchemeAsCorsEnabled.
|
|
|
|
bool IsCorsEnabledScheme(const std::string& scheme) {
|
|
|
|
return base::Contains(url::GetCorsEnabledSchemes(), scheme);
|
|
|
|
}
|
|
|
|
|
2013-06-04 19:41:37 +02:00
|
|
|
} // namespace scheme
|