Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.

Custom Schemes don't work with fetch()

Post Reply
User avatar
salvadordf
Posts: 4057
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Custom Schemes don't work with fetch()

Post by salvadordf »

After some digging in CEF3 code I found some references to blink::SchemeRegistry::RegisterURLSchemeAsLocal, blink::SchemeRegistry::RegisterURLSchemeAsSecure and blink::WebSecurityPolicy::RegisterURLSchemeAsDisplayIsolated but none to blink::SchemeRegistry::RegisterURLSchemeAsSupportingFetchAPI.

I've never seen that part of the CEF3 code before and I could be wrong but it seems that it's not implemented in CEF3. I'll ask in the CEF3 forum to be sure.
User avatar
salvadordf
Posts: 4057
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Custom Schemes don't work with fetch()

Post by salvadordf »

The CEF3 project maintainer has suggested that you use a http/https scheme instead of using a custom scheme.
http://magpcss.org/ceforum/viewtopic.php?f=7&t=16069

I just uploaded a fix for the CefRegisterSchemeHandlerFactory function and the TCefSchemeHandlerFactoryOwn class so you can test this.

CefRegisterSchemeHandlerFactory calls cef_register_scheme_handler_factory and these are the code comments for that function :

Code: Select all

///
// Register a scheme handler factory with the global request context. An NULL
// |domain_name| value for a standard scheme will cause the factory to match all
// domain names. The |domain_name| value will be ignored for non-standard
// schemes. If |scheme_name| is a built-in scheme and no handler is returned by
// |factory| then the built-in scheme handler factory will be called. If
// |scheme_name| is a custom scheme then you must also implement the
// cef_app_t::on_register_custom_schemes() function in all processes. This
// function may be called multiple times to change or remove the factory that
// matches the specified |scheme_name| and optional |domain_name|. Returns false
// (0) if an error occurs. This function may be called on any thread in the
// browser process. Using this function is equivalent to calling cef_request_tCo
// ntext::cef_request_context_get_global_context()->register_scheme_handler_fact
// ory().
///
Call CefRegisterSchemeHandlerFactory with 'http' or 'https' as the SchemeName parameter.
The DomainName parameter can be a domain or '' to match all domain names.
If you want to use a resource handler, assign it to the handler parameter but it can be NIL if you want the built-in handler to be used.

If I understand it correctly, if you use http or https you don't need to use GlobalCEFApp.OnRegCustomSchemes.
Post Reply