Repository: electron
Issue: Support Extensions in custom protocols
Labels: enhancement :sparkles:

<!--  As an open source project with a dedicated but small maintainer team, it can sometimes take a long time for issues to be addressed so please be patient and we will get back to you as soon as we can.
-->

### Preflight Checklist
<!-- Please ensure you've completed the following steps by replacing [ ] with [x]-->

* [x] I have read the [Contributing Guidelines](https://github.com/electron/electron/blob/master/CONTRIBUTING.md) for this project.
* [x] I agree to follow the [Code of Conduct](https://github.com/electron/electron/blob/master/CODE_OF_CONDUCT.md) that this project adheres to.
* [x] I have searched the issue tracker for a feature request that matches the one I want to file, without success.

### Problem Description
<!-- Is your feature request related to a problem? Please add a clear and concise description of what the problem is. -->

I'm making heavy usage of custom protocol schemes for loading content from p2p protocols as websites in my [Agregore Web Browser](https://github.com/AgregoreWeb/agregore-browser).

I'm currently making heavy use of extensions via an old branch of the electron-extensions module, but I'd like to transition to either using the built in extension support, or something that makes use of it.

Sadly, it looks like the built in extensions are unable to run content scripts or anything else on pages served from custom protocol schemes.

### Proposed Solution
<!-- Describe the solution you'd like in a clear and concise manner -->

It looks like we need to add something which enables the [SCHEME_ALL](https://source.chromium.org/chromium/chromium/src/+/master:extensions/common/url_pattern.h;l=52;bpv=1;bpt=1?q=valid_schemes&ss=chromium%2Fchromium%2Fsrc) flag for valid schemes in `<all_urls>` in extensions, or have some additional code for validating schemes.

Maybe we'd be able to detect the `<all_urls>` flag in the [URLPatternSet](https://github.com/electron/electron/search?q=URLPatternSet) of an extension and enable the flag there?

Sadly it feels like Chrome's extension/custom protocol support really isn't cut out for this use case is valid_schemes is a bitfield rather than a set. 😅 

### Alternatives Considered
<!-- A clear and concise description of any alternative solutions or features you've considered. -->

Maybe we could add a custom [url_pattern_set](https://source.chromium.org/chromium/chromium/src/+/master:extensions/common/url_pattern_set.h;bpv=1;bpt=1) which we can set on extensions which adds support for a set of custom protocols?

Maybe the [CreateUserScript](https://source.chromium.org/chromium/chromium/src/+/master:extensions/common/manifest_handlers/content_scripts_handler.cc;l=106;bpv=1;bpt=1?q=CreateUserScript&ss=chromium%2Fchromium%2Fsrc) code could be modified to account for custom protocols?

It could also be that I misunderstood that `<all_urls>` isn't matching custom protocols, since it looks like it [returns true as soon as it sees it regardless of valid schemes](https://source.chromium.org/chromium/chromium/src/+/master:extensions/common/url_pattern.cc;l=202;drc=d81c5852498699fe3cd812e78d31c77c28e29281;bpv=1;bpt=1) 

### Additional Information
<!-- Add any other context about the problem here. -->

I've created a minimal repo that reproduces this issue here: https://github.com/RangerMauve/electron-custom-protocols-extension-test

You can see that for the `https://` scheme, the page gets modified with an extra "hello world" at the end, but for the custom `example://` scheme, it doesn't. This is with the extension having `<all_urls>` enabled.