Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
follow magnet links
Browse files Browse the repository at this point in the history
  • Loading branch information
dcposch committed Nov 2, 2016
1 parent cd60539 commit 0834c98
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion js/components/frame.js
Original file line number Diff line number Diff line change
Expand Up @@ -908,7 +908,17 @@ class Frame extends ImmutableComponent {
}

const loadStart = (e) => {
// We have two kinds of special URLs: magnet links and about pages
// When the user clicks on a magnet link, navigate to the corresponding local URL
// (The address bar will still show the magnet URL. See appUrlUtil.getSourceMagnetUrl.)
if (isSourceMagnetUrl(e.url)) {
var targetURL = getTargetMagnetUrl(e.url)
// Return right away. loadStart will be called again with targetURL
return windowActions.loadUrl(this.frame, targetURL)
}

const parsedUrl = urlParse(e.url)

// Instead of telling person to install Flash, ask them if they want to
// run Flash if it's installed.
if (e.isMainFrame && !e.isErrorPage && !e.isFrameSrcDoc) {
Expand Down Expand Up @@ -941,6 +951,7 @@ class Frame extends ImmutableComponent {
this.webview.executeJavaScript('Navigator.prototype.__defineGetter__("doNotTrack", () => {return 1});')
}
}

const loadEnd = (savePage) => {
windowActions.onWebviewLoadEnd(
this.frame,
Expand Down Expand Up @@ -971,6 +982,7 @@ class Frame extends ImmutableComponent {
interceptFlash(false, undefined, hack.redirectURL)
}
}

const loadFail = (e, provisionLoadFailure = false) => {
if (isFrameError(e.errorCode)) {
// temporary workaround for https://github.com/brave/browser-laptop/issues/1817
Expand Down Expand Up @@ -1001,14 +1013,14 @@ class Frame extends ImmutableComponent {
windowActions.setNavigated(this.webview.getURL(), this.props.frameKey, true)
}
}

this.webview.addEventListener('load-commit', (e) => {
loadStart(e)
})
this.webview.addEventListener('load-start', (e) => {
// XXX: loadstart probably does not need to be called twice anymore.
loadStart(e)
})

this.webview.addEventListener('did-navigate', (e) => {
if (this.props.findbarShown) {
this.props.onFindHide()
Expand Down

0 comments on commit 0834c98

Please sign in to comment.