From 8dfe39ffc2ed6bcb8b179bddf2633388b3c5426f Mon Sep 17 00:00:00 2001 From: Brian Clifton Date: Fri, 29 Dec 2017 14:41:06 -0700 Subject: [PATCH] Merge pull request #12431 from brave/fix/12408 Fix PDF reloading --- app/renderer/components/frame/frame.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/app/renderer/components/frame/frame.js b/app/renderer/components/frame/frame.js index 237f883e2e6..87d647e97a8 100644 --- a/app/renderer/components/frame/frame.js +++ b/app/renderer/components/frame/frame.js @@ -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) @@ -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) } @@ -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:',