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

Commit

Permalink
Fix flash detection
Browse files Browse the repository at this point in the history
Fix #2384 and Fix #2378

When it was not installed it was infinite looping with no message, when it was installed and not enabled it was infinite looping.  Both on myspace.com
I shortened the message for Flash because the important part gets cut off on macOS
notifications.

Auditors: @diracdeltas, @aekeus
  • Loading branch information
bbondy committed Jul 4, 2016
1 parent d04b6c4 commit f7f389b
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 23 deletions.
2 changes: 1 addition & 1 deletion app/extensions/brave/locales/en-US/app.properties
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ findResultMatches[other]={{numberOfMatches}} matches
inspectElement=Inspect Element
urlCopied=URL copied to clipboard
passwordCopied=Password copied to clipboard
flashInstalled=Flash is already installed. You can enable it in Preferences > Security.
flashInstalled=Flash can be enabled in Preferences > Security.

error=Error
caseSensitivity=Match case
Expand Down
13 changes: 1 addition & 12 deletions app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const keytar = require('keytar')
const settings = require('../js/constants/settings')
const siteSettings = require('../js/state/siteSettings')
const spellCheck = require('./spellCheck')
const flash = require('./flash')
const flash = require('../js/flash')
const contentSettings = require('../js/state/contentSettings')

// Used to collect the per window state when shutting down the application
Expand Down Expand Up @@ -421,17 +421,6 @@ app.on('ready', () => {
})
})

ipcMain.on(messages.SHOW_FLASH_INSTALLED_MESSAGE, (e) => {
flash.checkFlashInstalled((installed) => {
if (installed) {
if (BrowserWindow.getFocusedWindow()) {
BrowserWindow.getFocusedWindow().webContents.send(messages.SHOW_NOTIFICATION,
locale.translation('flashInstalled'))
}
}
})
})

ipcMain.on(messages.MOVE_SITE, (e, sourceDetail, destinationDetail, prepend, destinationIsParent) => {
appActions.moveSite(Immutable.fromJS(sourceDetail), Immutable.fromJS(destinationDetail), prepend, destinationIsParent)
})
Expand Down
22 changes: 15 additions & 7 deletions js/components/frame.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const { isFrameError } = require('../lib/errorUtil')
const locale = require('../l10n')
const appConfig = require('../constants/appConfig')
const { getSiteSettingsForHostPattern } = require('../state/siteSettings')
const flash = require('../flash')

const WEBRTC_DEFAULT = 'default'
const WEBRTC_DISABLE_NON_PROXY = 'disable_non_proxied_udp'
Expand Down Expand Up @@ -546,8 +547,14 @@ class Frame extends ImmutableComponent {
}
}
} else {
ipc.send(messages.SHOW_FLASH_INSTALLED_MESSAGE)
windowActions.loadUrl(this.props.frame, adobeUrl)
flash.checkFlashInstalled((installed) => {
if (installed) {
remote.getCurrentWindow().webContents.send(messages.SHOW_NOTIFICATION,
locale.translation('flashInstalled'))
} else {
windowActions.loadUrl(this.props.frame, adobeUrl)
}
})
}
ipc.once(messages.NOTIFICATION_RESPONSE + nonce, (e, msg, buttonIndex, persist) => {
const cb = this.notificationCallbacks[msg]
Expand All @@ -562,12 +569,13 @@ class Frame extends ImmutableComponent {
// 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) {
const currentUrl = urlParse(this.props.frame.get('location'))
if ((e.url.includes('//get.adobe.com/flashplayer') ||
e.url.includes('//www.adobe.com/go/getflash')) &&
['http:', 'https:'].includes(currentUrl.protocol) &&
!currentUrl.hostname.includes('.adobe.com')) {
interceptFlash(e.url)
e.url.includes('//www.adobe.com/go/getflash'))) {
const currentProvisionalUrl = urlParse(this.props.frame.get('provisionalLocation'))
if (['http:', 'https:'].includes(currentProvisionalUrl.protocol) &&
!currentProvisionalUrl.hostname.includes('.adobe.com')) {
interceptFlash(e.url)
}
}
windowActions.onWebviewLoadStart(this.props.frame, e.url)
const isSecure = parsedUrl.protocol === 'https:' && !this.allowRunningInsecureContent()
Expand Down
1 change: 0 additions & 1 deletion js/constants/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ const messages = {
LOGIN_REQUIRED: _, /** @arg {Object} details of the login required request */
LOGIN_RESPONSE: _,
NOTIFICATION_RESPONSE: _, /** @arg {string} message, @arg {number} buttonId, @arg {boolean} persist */
SHOW_FLASH_INSTALLED_MESSAGE: _,
// Downloads
SHOW_DOWNLOADS_TOOLBAR: _, /** Ensures the downloads toolbar is visible */
HIDE_DOWNLOADS_TOOLBAR: _, /** Hides the downloads toolbar */
Expand Down
14 changes: 12 additions & 2 deletions app/flash.js → js/flash.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,20 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */

const electron = require('electron')
const app = electron.app
const fs = require('fs')
const path = require('path')
let electron
let app
try {
electron = require('electron')
} catch (e) {
electron = global.require('electron')
}
if (process.type === 'browser') {
app = electron.app
} else {
app = electron.remote.app
}

module.exports.init = () => {
// TODO: This only works if sync currently
Expand Down

1 comment on commit f7f389b

@diracdeltas
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

++, thanks for taking this.

Please sign in to comment.