Skip to content

Commit

Permalink
Hide open link confirmation popup (fixes #435)
Browse files Browse the repository at this point in the history
  • Loading branch information
filips123 committed Jan 19, 2024
1 parent 89b9d8d commit ffdc981
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions native/userchrome/profile/chrome/pwa/content/browser.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,7 @@ class PwaBrowser {
const menuItem = this.createElement(document, 'toolbarbutton', {
class: 'subviewbutton',
shortcut: 'Ctrl+Shift+N',
label: 'New default browser',
onclick: 'MailIntegration._launchExternalUrl(makeURI("about:newtab"))'
label: 'New default browser'
});

menuItem.onclick = () => MailIntegration._launchExternalUrl(makeURI(startURL));
Expand Down Expand Up @@ -464,6 +463,15 @@ class PwaBrowser {

if (ChromeLoader.INITIALIZED_BROWSER) return;

// Allow opening HTTP links without confirmation popup
// This applies to all ways of opening HTTP links in default browser
const { nsContentDispatchChooser } = ChromeUtils.import('resource://gre/modules/ContentDispatchChooser.jsm');
nsContentDispatchChooser.prototype._hasProtocolHandlerPermissionOriginal = nsContentDispatchChooser.prototype._hasProtocolHandlerPermission;
nsContentDispatchChooser.prototype._hasProtocolHandlerPermission = function(scheme, principal, triggeredExternally) {
if (scheme === 'http' || scheme === 'https') return true;
return this._hasProtocolHandlerPermissionOriginal(scheme, principal, triggeredExternally);
};

// Handle blocking out-of-scope URLs and redirecting them to the main browser
Services.obs.addObserver(subject => {
const httpChannel = subject.QueryInterface(Ci.nsIHttpChannel);
Expand Down

0 comments on commit ffdc981

Please sign in to comment.