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

Commit

Permalink
Fix PDF reloading
Browse files Browse the repository at this point in the history
fix #12408

Test plan:
1. load any PDF
2. hit reload
3. it should reload the PDF instead of 'file not found'
  • Loading branch information
diracdeltas committed Dec 28, 2017
1 parent 119e4e7 commit eb8d253
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 eb8d253

Please sign in to comment.