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

Converts WidevinePanel into redux component #9488

Merged
merged 1 commit into from
Jun 19, 2017
Merged
Show file tree
Hide file tree
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
14 changes: 3 additions & 11 deletions app/renderer/components/main/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const siteSettings = require('../../../../js/state/siteSettings')
const debounce = require('../../../../js/lib/debounce')
const {isSourceAboutUrl} = require('../../../../js/lib/appUrlUtil')
const {getCurrentWindowId, isMaximized, isFocused, isFullScreen} = require('../../currentWindow')
const {isDarwin, isWindows} = require('../../../common/lib/platformUtil')
const {isDarwin, isWindows, isLinux} = require('../../../common/lib/platformUtil')

class Main extends ImmutableComponent {
constructor () {
Expand All @@ -78,7 +78,6 @@ class Main extends ImmutableComponent {
this.onHideSiteInfo = this.onHideSiteInfo.bind(this)
this.onHideBraveryPanel = this.onHideBraveryPanel.bind(this)
this.onHideClearBrowsingDataPanel = this.onHideClearBrowsingDataPanel.bind(this)
this.onHideWidevinePanel = this.onHideWidevinePanel.bind(this)
this.onHideAutofillAddressPanel = this.onHideAutofillAddressPanel.bind(this)
this.onHideAutofillCreditCardPanel = this.onHideAutofillCreditCardPanel.bind(this)
this.onHideReleaseNotes = this.onHideReleaseNotes.bind(this)
Expand Down Expand Up @@ -540,12 +539,6 @@ class Main extends ImmutableComponent {
windowActions.setClearBrowsingDataPanelVisible(false)
}

onHideWidevinePanel () {
windowActions.widevinePanelDetailChanged({
shown: false
})
}

onHideAutofillAddressPanel () {
windowActions.setAutofillAddressDetail()
}
Expand Down Expand Up @@ -666,7 +659,7 @@ class Main extends ImmutableComponent {
this.props.windowState.get('braveryPanelDetail')
const clearBrowsingDataPanelIsVisible = this.props.windowState.getIn(['ui', 'isClearBrowsingDataPanelVisible'])
const importBrowserDataPanelIsVisible = this.props.windowState.get('importBrowserDataDetail')
const widevinePanelIsVisible = this.props.windowState.getIn(['widevinePanelDetail', 'shown'])
const widevinePanelIsVisible = this.props.windowState.getIn(['widevinePanelDetail', 'shown']) && !isLinux()
const autofillAddressPanelIsVisible = this.props.windowState.get('autofillAddressDetail')
const autofillCreditCardPanelIsVisible = this.props.windowState.get('autofillCreditCardDetail')
const noScriptIsVisible = this.props.windowState.getIn(['ui', 'noScriptInfo', 'isVisible']) &&
Expand Down Expand Up @@ -740,8 +733,7 @@ class Main extends ImmutableComponent {
{
widevinePanelIsVisible
? <WidevinePanel
widevinePanelDetail={this.props.windowState.get('widevinePanelDetail')}
widevineReady={this.props.appState.getIn([appConfig.resourceNames.WIDEVINE, 'ready'])}

onHide={this.onHideWidevinePanel} />
: null
}
Expand Down
51 changes: 32 additions & 19 deletions app/renderer/components/main/widevinePanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const React = require('react')
const {StyleSheet, css} = require('aphrodite/no-important')

// Components
const ImmutableComponent = require('../immutableComponent')
const ReduxComponent = require('../reduxComponent')
const Dialog = require('../common/dialog')
const Button = require('../common/button')
const WidevineInfo = require('./widevineInfo')
Expand All @@ -32,39 +32,52 @@ const siteUtil = require('../../../../js/state/siteUtil')
// Styles
const commonStyles = require('../styles/commonStyles')

class WidevinePanel extends ImmutableComponent {
constructor () {
super()
class WidevinePanel extends React.Component {
constructor (props) {
super(props)
this.onInstallAndAllow = this.onInstallAndAllow.bind(this)
this.onClickRememberForNetflix = this.onClickRememberForNetflix.bind(this)
}
get origin () {
return siteUtil.getOrigin(this.props.widevinePanelDetail.get('location'))
}

onInstallAndAllow () {
appActions.setResourceEnabled(appConfig.resourceNames.WIDEVINE, true)
this.props.onHide()
this.onHide()
// The site permissions that is set if this.props.widevinePanelDetail.get('alsoAddRememberSiteSetting') is handled once the resource is ready
// in main.js. This is so that the reload doesn't happen until it is ready.
}

onClickRememberForNetflix (e) {
windowActions.widevinePanelDetailChanged({
alsoAddRememberSiteSetting: e.target.value
})
}

onHide () {
windowActions.widevinePanelDetailChanged({
shown: false
})
}

mergeProps (state, ownProps) {
const currentWindow = state.get('currentWindow')
const widevinePanelDetail = currentWindow.get('widevinePanelDetail')

const props = {}
props.origin = siteUtil.getOrigin(widevinePanelDetail.get('location'))
props.alsoAddRememberSiteSetting = widevinePanelDetail.get('alsoAddRememberSiteSetting')

return props
}

render () {
const isLinux = process.platform === 'linux'
if (isLinux) {
return null
}
/*
Removed 'isClickDismiss' from Dialog.
Installing Widevine influences globally, not specific to a tab,
like Adobe Flash. Removing isClickDismiss would make it clear that
the third party software which we discourage from using is going
to be installed on the computer.
*/
return <Dialog onHide={this.props.onHide} testId='widevinePanelDialog'>
return <Dialog onHide={this.onHide} testId='widevinePanelDialog'>
<CommonFormLarge onClick={(e) => e.stopPropagation()}>
<CommonFormTitle data-l10n-id='widevinePanelTitle' />
<CommonFormSection>
Expand All @@ -74,7 +87,7 @@ class WidevinePanel extends ImmutableComponent {
<Button className='whiteButton'
l10nId='cancel'
testId='cancelButton'
onClick={this.props.onHide}
onClick={this.onHide}
/>
<Button className='primaryButton'
l10nId='installAndAllow'
Expand All @@ -84,24 +97,24 @@ class WidevinePanel extends ImmutableComponent {
<CommonFormBottomWrapper>
<div className={css(styles.flexJustifyCenter)}>
{/* TODO: refactor switchControl.js to remove commonStyles.noPadding */}
<SwitchControl id={this.props.prefKey}
<SwitchControl
className={css(commonStyles.noPadding)}
rightl10nId='rememberThisDecision'
rightl10nArgs={JSON.stringify({origin: this.origin})}
rightl10nArgs={JSON.stringify({origin: this.props.origin})}
onClick={this.onClickRememberForNetflix}
checkedOn={this.props.widevinePanelDetail.get('alsoAddRememberSiteSetting')} />
checkedOn={this.props.alsoAddRememberSiteSetting} />
</div>
</CommonFormBottomWrapper>
</CommonFormLarge>
</Dialog>
}
}

module.exports = ReduxComponent.connect(WidevinePanel)

const styles = StyleSheet.create({
flexJustifyCenter: {
display: 'flex',
justifyContent: 'center'
}
})

module.exports = WidevinePanel