Add option to enable fetch support for custom schemes (issue #2579)

This commit is contained in:
Alexander Guettler
2019-02-04 22:31:31 +00:00
committed by Marshall Greenblatt
parent 667d190547
commit a72e00a7b9
16 changed files with 517 additions and 21 deletions

View File

@@ -81,6 +81,9 @@ class CefContentClient : public content::ContentClient,
// A scheme that can bypass Content-Security-Policy (CSP) checks. This value
// should be false in most cases where |is_standard| is true.
bool is_csp_bypassing;
// A scheme that can perform fetch request.
bool is_fetch_enabled;
};
typedef std::list<SchemeInfo> SchemeInfoList;

View File

@@ -31,7 +31,8 @@ bool CefSchemeRegistrarImpl::AddCustomScheme(const CefString& scheme_name,
bool is_display_isolated,
bool is_secure,
bool is_cors_enabled,
bool is_csp_bypassing) {
bool is_csp_bypassing,
bool is_fetch_enabled) {
const std::string& scheme = base::ToLowerASCII(scheme_name.ToString());
if (scheme::IsInternalHandledScheme(scheme) ||
registered_schemes_.find(scheme) != registered_schemes_.end()) {
@@ -54,8 +55,8 @@ bool CefSchemeRegistrarImpl::AddCustomScheme(const CefString& scheme_name,
schemes_.csp_bypassing_schemes.push_back(scheme);
CefContentClient::SchemeInfo scheme_info = {
scheme, is_standard, is_local, is_display_isolated,
is_secure, is_cors_enabled, is_csp_bypassing};
scheme, is_standard, is_local, is_display_isolated,
is_secure, is_cors_enabled, is_csp_bypassing, is_fetch_enabled};
CefContentClient::Get()->AddCustomScheme(scheme_info);
return true;

View File

@@ -24,7 +24,8 @@ class CefSchemeRegistrarImpl : public CefSchemeRegistrar {
bool is_display_isolated,
bool is_secure,
bool is_cors_enabled,
bool is_csp_bypassing) override;
bool is_csp_bypassing,
bool is_fetch_enabled) override;
void GetSchemes(content::ContentClient::Schemes* schemes);

View File

@@ -216,6 +216,10 @@ void RegisterURLSchemeAsSecure(const blink::WebString& scheme) {
blink::SchemeRegistry::RegisterURLSchemeAsSecure(scheme);
}
void RegisterURLSchemeAsSupportingFetchAPI(const blink::WebString& scheme) {
blink::SchemeRegistry::RegisterURLSchemeAsSupportingFetchAPI(scheme);
}
struct CefScriptForbiddenScope::Impl {
blink::ScriptForbiddenScope scope_;
};

View File

@@ -69,6 +69,9 @@ BLINK_EXPORT bool IsScriptForbidden();
BLINK_EXPORT void RegisterURLSchemeAsLocal(const blink::WebString& scheme);
BLINK_EXPORT void RegisterURLSchemeAsSecure(const blink::WebString& scheme);
BLINK_EXPORT void RegisterURLSchemeAsSupportingFetchAPI(
const blink::WebString& scheme);
// Wrapper for blink::ScriptForbiddenScope.
class BLINK_EXPORT CefScriptForbiddenScope final {
public:

View File

@@ -269,6 +269,8 @@ void CefContentRendererClient::WebKitInitialized() {
blink::WebSecurityPolicy::RegisterURLSchemeAsDisplayIsolated(scheme);
if (info.is_secure)
blink_glue::RegisterURLSchemeAsSecure(scheme);
if (info.is_fetch_enabled)
blink_glue::RegisterURLSchemeAsSupportingFetchAPI(scheme);
}
}