Add support and enable out-of-Blink CORS (fixes issue #2716)

It can still be disabled for a short time by passing
`--disable-features=OutOfBlinkCors` on the command-line.
This commit is contained in:
Marshall Greenblatt
2020-08-14 15:28:23 -04:00
parent 4c3785756f
commit 1119d2723c
17 changed files with 1387 additions and 40 deletions

View File

@@ -244,12 +244,6 @@ bool AlloyMainDelegate::BasicStartupComplete(int* exit_code) {
std::vector<std::string> disable_features;
if (network::features::kOutOfBlinkCors.default_state ==
base::FEATURE_ENABLED_BY_DEFAULT) {
// TODO: Add support for out-of-Blink CORS (see issue #2716)
disable_features.push_back(network::features::kOutOfBlinkCors.name);
}
#if defined(OS_WIN)
if (features::kCalculateNativeWinOcclusion.default_state ==
base::FEATURE_ENABLED_BY_DEFAULT) {

View File

@@ -8,6 +8,7 @@
#include "libcef/common/net/scheme_info.h"
#include "libcef/features/runtime.h"
#include "base/stl_util.h"
#include "content/public/common/url_constants.h"
#include "extensions/common/constants.h"
#include "net/net_buildflags.h"
@@ -86,4 +87,10 @@ bool IsStandardScheme(const std::string& scheme) {
return url::IsStandard(scheme.c_str(), scheme_comp);
}
// Should return the same value as SecurityOrigin::isLocal and
// SchemeRegistry::shouldTreatURLSchemeAsCorsEnabled.
bool IsCorsEnabledScheme(const std::string& scheme) {
return base::Contains(url::GetCorsEnabledSchemes(), scheme);
}
} // namespace scheme

View File

@@ -22,6 +22,9 @@ bool IsInternalHandledScheme(const std::string& scheme);
// Returns true if the specified |scheme| is a registered standard scheme.
bool IsStandardScheme(const std::string& scheme);
// Returns true if the specified |scheme| is a registered CORS enabled scheme.
bool IsCorsEnabledScheme(const std::string& scheme);
} // namespace scheme
#endif // CEF_LIBCEF_COMMON_NET_SCHEME_REGISTRATION_H_