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

Fix PDF reloading #12431

Merged
merged 1 commit into from
Dec 29, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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