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

Commit

Permalink
Merge pull request #12431 from brave/fix/12408
Browse files Browse the repository at this point in the history
Fix PDF reloading
  • Loading branch information
bsclifton authored Dec 29, 2017
2 parents 470ae67 + eb8d253 commit f7d8df6
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions app/renderer/components/frame/frame.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,16 @@ const appConfig = require('../../../../js/constants/appConfig')
const messages = require('../../../../js/constants/messages')
const config = require('../../../../js/constants/config')

const pdfjsOrigin = `chrome-extension://${config.PDFJSExtensionId}/`

function isTorrentViewerURL (url) {
const isEnabled = getSetting(settings.TORRENT_VIEWER_ENABLED)
return isEnabled && isSourceMagnetUrl(url)
}

function isPDFJSURL (url) {
const pdfjsOrigin = `chrome-extension://${config.PDFJSExtensionId}/`
return url && url.startsWith(pdfjsOrigin)
}

class Frame extends React.Component {
constructor (props) {
super(props)
Expand Down Expand Up @@ -288,7 +291,9 @@ class Frame extends React.Component {
if (this.props.tabUrl !== this.props.location &&
!this.isAboutPage() &&
!isTorrentViewerURL(this.props.location)) {
appActions.loadURLRequested(this.props.tabId, this.props.location)
} else if (isPDFJSURL(this.props.location)) {
appActions.loadURLRequested(this.props.tabId,
UrlUtil.getLocationIfPDF(this.props.location))
} else {
tabActions.reload(this.props.tabId)
}
Expand Down Expand Up @@ -620,7 +625,7 @@ class Frame extends React.Component {
}, 250)
}

if (url.startsWith(pdfjsOrigin)) {
if (isPDFJSURL(url)) {
let displayLocation = UrlUtil.getLocationIfPDF(url)
windowActions.setSecurityState(this.props.tabId, {
secure: urlParse(displayLocation).protocol === 'https:',
Expand Down

0 comments on commit f7d8df6

Please sign in to comment.