nwjs/nw.js

Feat: Custom URL Schema Handlers not only app Protocol Handlers

lemanschik opened this issue · 2 comments

Issue Type

Before opening an issue, please search and see if it has already been raised.

  • Bug Report

  • Feature Request

  • Successfully reproduced against the latest version of NW.js?

Please use our mailing list or Gitter chatroom to ask questions. The issue tracker is only for bugs and feature requests, in English only. Please note that issues without a repro or code snippet are less likely to be resolved.

Current/Missing Behavior

Electron like custom url handler registration

Expected/Proposed Behavior

Lets add the patches from brave to implement custom url handling fast.

We currently have 3 different types of protocol handlers in Brave:

External protocol handler used for handling magnet URLs
External protocol handlers used for oauth flows (cryptocurrency exchanges at the time of writing)
brave:// being an alias for chrome://
Below is a description of changes and patching we've had to do for schemes:

AddAdditionalSchemes is only used for adding brave:// to the same list of URLs as chrome://. Example

GrantRequestScheme - Allows a webui to access it so no reason for that. Example

RegisterURLSchemeAsNotAllowingJavascriptURLs - Registers an URL scheme to not allow manipulation of the loaded page by bookmarklets or javascript: URLs typed in the omnibox. Example

RegisterURLSchemeAsDisplayIsolated - Registers a URL scheme to be treated as display-isolated. This means that pages cannot display these URLs unless they are from the same scheme. For example, pages in another origin cannot create iframes or hyperlinks to URLs with the scheme. Example

CanAddURLToHistory - Prevents a URL from being added to history, note that redirects do not appear in history. So this is probably not needed for oauth related schemes. Example

IsHandledProtocol - Needed for protocol handlers, but not needed for external protocol handlers. Example

ExtensionTabUtil::IsKillURL - This is only needed because brave:// is an alias for chrome:// and an explicit check is made. Example

taken from:
https://github.com/brave/brave-browser/wiki/Adding-a-protocol-scheme-to-Brave

Additional Info

  • Operating System:
  • NW.js Version:
  • Repro Link:
  • Code snippet:
  • Crash report:

Closes