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

Commit

Permalink
Follow-up of #8751
Browse files Browse the repository at this point in the history
Auditors: @bbondy, @bsclifton
  • Loading branch information
darkdh committed May 9, 2017
1 parent 66083b0 commit e0dccf5
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 15 deletions.
16 changes: 9 additions & 7 deletions app/browser/reducers/autoplayReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ const locale = require('../../locale')
const messages = require('../../../js/constants/messages')
const urlParse = require('../../common/urlParse')

const showAutoplayMessageBox = (location, tabId) => {
const showAutoplayMessageBox = (tabId) => {
const tab = webContents.fromTabID(tabId)
if (!tab || tab.isDestroyed()) {
return
}
const location = tab.getURL()
const origin = getOrigin(location)
const originSettings = siteSettings.getSiteSettingsForURL(AppStore.getState().get('siteSettings'), origin)
if (originSettings && originSettings.get('noAutoplay') === true) {
Expand Down Expand Up @@ -46,11 +51,8 @@ const showAutoplayMessageBox = (location, tabId) => {
if (buttonIndex === 0) {
appActions.changeSiteSetting(ruleKey, 'noAutoplay', false)

if (tabId) {
const tab = webContents.fromTabID(tabId)
if (tab && !tab.isDestroyed()) {
return tab.reload()
}
if (tab && !tab.isDestroyed()) {
tab.reload()
}
} else {
if (persist) {
Expand All @@ -65,7 +67,7 @@ const autoplayReducer = (state, action, immutableAction) => {
action = immutableAction || makeImmutable(action)
switch (action.get('actionType')) {
case appConstants.APP_AUTOPLAY_BLOCKED:
showAutoplayMessageBox(action.get('location'), action.get('tabId'))
showAutoplayMessageBox(action.get('tabId'))
break
}
return state
Expand Down
4 changes: 1 addition & 3 deletions docs/appActions.md
Original file line number Diff line number Diff line change
Expand Up @@ -1036,14 +1036,12 @@ because ESC was pressed.



### autoplayBlocked(location, tabId)
### autoplayBlocked(tabId)

Notifies autoplay has been blocked

**Parameters**

**location**: `string`, Location of current frame

**tabId**: `number`, Tab id of current frame


Expand Down
4 changes: 1 addition & 3 deletions js/actions/appActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -1296,13 +1296,11 @@ const appActions = {

/**
* Notifies autoplay has been blocked
* @param {string} location - Location of current frame
* @param {number} tabId - Tab id of current frame
*/
autoplayBlocked: function (location, tabId) {
autoplayBlocked: function (tabId) {
AppDispatcher.dispatch({
actionType: appConstants.APP_AUTOPLAY_BLOCKED,
location,
tabId
})
}
Expand Down
2 changes: 1 addition & 1 deletion js/components/frame.js
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ class Frame extends React.Component {
windowActions.setBlockedBy(this.frame, 'noScript', e.details[1])
}
if (e.details[0] === 'autoplay') {
appActions.autoplayBlocked(this.frame.get('location'), this.frame.get('tabId'))
appActions.autoplayBlocked(this.frame.get('tabId'))
}
})
this.webview.addEventListener('did-block-run-insecure-content', (e) => {
Expand Down
2 changes: 1 addition & 1 deletion js/flash.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ module.exports.showFlashMessageBox = (location, tabId) => {
if (tabId) {
const tab = webContents.fromTabID(tabId)
if (tab && !tab.isDestroyed()) {
return tab.reload()
tab.reload()
}
}
} else {
Expand Down

1 comment on commit e0dccf5

@bsclifton
Copy link
Member

Choose a reason for hiding this comment

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

++

Please sign in to comment.