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

Commit fc9902c

Browse files
committed
Adjust widevine flow for ease of use
Fix #5131 Auditors: @diracdeltas
1 parent 957b748 commit fc9902c

19 files changed

+281
-43
lines changed

app/extensions/brave/about-preferences.html

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<script src='js/about.js'></script>
1414
<script src="ext/l20n.min.js" async></script>
1515
<link rel="localization" href="locales/{locale}/preferences.properties">
16+
<link rel="localization" href="locales/{locale}/common.properties">
1617
<link rel="localization" href="locales/{locale}/bravery.properties">
1718
</head>
1819
<body>

app/extensions/brave/index-dev.html

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<script src="index-load-script.js" defer></script>
1313
<script src="ext/l20n.min.js" async></script>
1414
<link rel="localization" href="locales/{locale}/app.properties">
15+
<link rel="localization" href="locales/{locale}/common.properties">
1516
<link rel="localization" href="locales/{locale}/bravery.properties">
1617
<link rel="localization" href="locales/{locale}/menu.properties">
1718
<link rel="localization" href="locales/{locale}/downloads.properties">

app/extensions/brave/index.html

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<script src="gen/app.entry.js" async></script>
1313
<script src="ext/l20n.min.js" async></script>
1414
<link rel="localization" href="locales/{locale}/app.properties"/>
15+
<link rel="localization" href="locales/{locale}/common.properties"/>
1516
<link rel="localization" href="locales/{locale}/bravery.properties">
1617
<link rel="localization" href="locales/{locale}/menu.properties"/>
1718
<link rel="localization" href="locales/{locale}/downloads.properties"/>

app/extensions/brave/locales/en-US/app.properties

+3-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ inspectElement=Inspect Element
123123
urlCopied=URL copied to clipboard
124124
passwordCopied=Password copied to clipboard
125125
flashInstalled=Flash is already installed and can be enabled in Preferences > Security.
126-
widevineDisabled=Google Widevine can be enabled in Preferences > Security.
127126
goToPrefs=Open Preferences
128127
goToAdobe=Reinstall Flash
129128
allowFlashPlayer=Allow {{origin}} to run Flash Player?
@@ -230,3 +229,6 @@ makeBraveDefault=Ready to make Brave your default Browser?
230229
checkDefaultOnStartup=Always check on startup
231230
useBrave=Use Brave
232231
notNow=Not Now
232+
widevinePanelTitle=Brave needs to install Google Widevine to proceed
233+
installAndAllow=Install and Allow
234+
rememberThisDecision=Remember this decision for {{origin}}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
enableWidevineSubtext=Google Widevine is a piece of Digital Rights Management (DRM) code that we at Brave Software do not own and cannot inspect. The Google Widevine code is loaded from Google servers, not from our servers. It is loaded only when you enable this option. We discourage the use of DRM, but we respect user choice and acknowledge that some Brave users would like to use services that require it.
2+
enableWidevineSubtext2=By clicking this checkbox, you are agreeing to the Google Widevine Terms of Use. You agree that Brave is not responsible for any damages or losses in connection with your use of Google Widevine.

app/extensions/brave/locales/en-US/preferences.properties

+1-2
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,8 @@ lastPass=LastPass&reg;
149149
doNotManageMyPasswords=Don't manage my passwords
150150
usePDFJS=Use HTML5 PDF reader (requires browser restart)
151151
enableFlash=Enable Adobe Flash support (requires browser restart)
152+
widevineSection=Google Widevine Support
152153
enableWidevine=Enable Google Widevine support
153-
enableWidevineSubtext=Google Widevine is a piece of Digital Rights Management (DRM) code that we at Brave Software do not own and cannot inspect. The Google Widevine code is loaded from Google servers, not from our servers. It is loaded only when you enable this option. We discourage the use of DRM, but we respect user choice and acknowledge that some Brave users would like to use services that require it.
154-
enableWidevineSubtext2=By clicking this checkbox, you are agreeing to the Google Widevine Terms of Use. You agree that Brave is not responsible for any damages or losses in connection with your use of Google Widevine.
155154
enableFlashSubtext=Flash support is experimental and requires Pepper Flash to be installed from
156155
enableFlashSubtextLinux=Flash support is experimental and requires the pepperflashplugin-nonfree package.
157156
managePasswords=Manage passwords…

app/locale.js

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ var rendererIdentifiers = function () {
1818
'confirmClearPasswords',
1919
'passwordCopied',
2020
'flashInstalled',
21-
'widevineDisabled',
2221
'goToPrefs',
2322
'goToAdobe',
2423
'allowFlashPlayer',
+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/* This Source Code Form is subject to the terms of the Mozilla Public
2+
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
3+
* You can obtain one at http://mozilla.org/MPL/2.0/. */
4+
5+
/*
6+
* Educates users that this is DRM, why it is not great, and that
7+
* we don't own the code being executed if it is turned on. Provides
8+
* more info URL link to learn about DRM and Google's license URL link.
9+
*/
10+
11+
const React = require('react')
12+
const ImmutableComponent = require('../../../js/components/immutableComponent')
13+
const appConfig = require('../../../js/constants/appConfig')
14+
15+
const widevineInfoStyle = {
16+
paddingBottom: 10
17+
}
18+
const widevineInfoIconStyle = {
19+
padding: 5
20+
}
21+
22+
const subtextStyle = {
23+
marginBottom: 7
24+
}
25+
26+
class WidevineInfo extends ImmutableComponent {
27+
constructor () {
28+
super()
29+
this.onMoreInfo = this.onMoreInfo.bind(this)
30+
this.onViewLicense = this.onViewLicense.bind(this)
31+
}
32+
onMoreInfo () {
33+
this.props.newFrameAction({
34+
location: appConfig.widevine.moreInfoUrl
35+
}, true)
36+
}
37+
onViewLicense () {
38+
this.props.newFrameAction({
39+
location: appConfig.widevine.licenseUrl
40+
}, true)
41+
}
42+
render () {
43+
return <div style={widevineInfoStyle}>
44+
<div style={subtextStyle} className='subtext'>
45+
<span data-l10n-id='enableWidevineSubtext' />
46+
<span style={widevineInfoIconStyle}
47+
className='fa fa-info-circle'
48+
onClick={this.onMoreInfo}
49+
/>
50+
</div>
51+
<div className='subtext'>
52+
<span data-l10n-id='enableWidevineSubtext2' />
53+
<span style={widevineInfoIconStyle}
54+
className='fa fa-info-circle'
55+
onClick={this.onViewLicense}
56+
/>
57+
</div>
58+
</div>
59+
}
60+
}
61+
62+
module.exports = WidevineInfo
+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/* This Source Code Form is subject to the terms of the Mozilla Public
2+
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
3+
* You can obtain one at http://mozilla.org/MPL/2.0/. */
4+
5+
const React = require('react')
6+
const ImmutableComponent = require('../../../js/components/immutableComponent')
7+
const Dialog = require('../../../js/components/dialog')
8+
const Button = require('../../../js/components/button')
9+
const appConfig = require('../../../js/constants/appConfig')
10+
const WidevineInfo = require('./widevineInfo')
11+
const SwitchControl = require('../../../js/components/switchControl')
12+
const windowActions = require('../../../js/actions/windowActions')
13+
const appActions = require('../../../js/actions/appActions')
14+
const siteUtil = require('../../../js/state/siteUtil')
15+
16+
class ImportBrowserDataPanel extends ImmutableComponent {
17+
constructor () {
18+
super()
19+
this.onInstallAndAllow = this.onInstallAndAllow.bind(this)
20+
this.onClickRememberForNetflix = this.onClickRememberForNetflix.bind(this)
21+
}
22+
get origin () {
23+
return siteUtil.getOrigin(this.props.location)
24+
}
25+
onInstallAndAllow () {
26+
appActions.setResourceEnabled(appConfig.resourceNames.WIDEVINE, true)
27+
appActions.changeSiteSetting(this.origin, appConfig.resourceNames.WIDEVINE, this.props.widevinePanelDetail.get('alsoAddRememberSiteSetting') ? 1 : 0)
28+
windowActions.widevinePanelDetailChanged()
29+
}
30+
onClickRememberForNetflix (e) {
31+
windowActions.widevinePanelDetailChanged({
32+
alsoAddRememberSiteSetting: e.target.value
33+
})
34+
}
35+
componentWillUpdate (nextProps) {
36+
if (nextProps.widevineReady && !this.props.widevineReady) {
37+
windowActions.reloadActiveFrame()
38+
}
39+
}
40+
render () {
41+
const isLinux = process.platform === 'linux'
42+
if (isLinux) {
43+
return null
44+
}
45+
return <Dialog onHide={this.props.onHide} className='commonDialog' isClickDismiss>
46+
<div className='commonForm' onClick={(e) => e.stopPropagation()}>
47+
<h2 className='formSection commonFormTitle' data-l10n-id='widevinePanelTitle' />
48+
<div className='formSection'>
49+
<WidevineInfo newFrameAction={windowActions.newFrame} />
50+
</div>
51+
<div className='formSection commonFormButtons'>
52+
<Button l10nId='cancel' className='secondaryAltButton' onClick={this.props.onHide} />
53+
<Button l10nId='installAndAllow' className='primaryButton' onClick={this.onInstallAndAllow} />
54+
</div>
55+
<div className='formSection commonFormBottom'>
56+
<div className='commonFormButtonGroup'>
57+
<SwitchControl id={this.props.prefKey}
58+
rightl10nId='rememberThisDecision'
59+
rightl10nArgs={JSON.stringify({origin: this.origin})}
60+
onClick={this.onClickRememberForNetflix}
61+
checkedOn={this.props.widevinePanelDetail.get('alsoAddRememberSiteSetting')} />
62+
</div>
63+
</div>
64+
</div>
65+
</Dialog>
66+
}
67+
}
68+
69+
module.exports = ImportBrowserDataPanel

docs/state.md

+3
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,9 @@ WindowStore
546546
mergeFavorites: boolean,
547547
cookies: boolean
548548
},
549+
widevinePanelDetail: {
550+
alsoAddRememberSiteSetting: boolean, // True if an allow always rule should be added for the acitve frame as well if installed
551+
},
549552
modalDialogDetail: {
550553
[className]: {
551554
Object // props

docs/windowActions.md

+16
Original file line numberDiff line numberDiff line change
@@ -785,6 +785,16 @@ Sets the selected import browser data
785785

786786

787787

788+
### widevinePanelDetailChanged(widevinePanelDetail)
789+
790+
Widevine popup detail changed
791+
792+
**Parameters**
793+
794+
**widevinePanelDetail**: `Object`, detail of the widevine panel
795+
796+
797+
788798
### setAutofillAddressDetail(currentDetail, originalDetail)
789799

790800
Sets the manage autofill address popup detail
@@ -928,6 +938,12 @@ Set Modal Dialog detail
928938

929939

930940

941+
### reloadActiveFrame()
942+
943+
Reloads the current active frame
944+
945+
946+
931947

932948
* * *
933949

js/about/preferences.js

+8-19
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const settings = require('../constants/settings')
2121
const coinbaseCountries = require('../constants/coinbaseCountries')
2222
const {passwordManagers, extensionIds} = require('../constants/passwordManagers')
2323
const bookmarksToolbarMode = require('../../app/common/constants/bookmarksToolbarMode')
24+
const WidevineInfo = require('../../app/renderer/components/widevineInfo')
2425
const aboutActions = require('./aboutActions')
2526
const getSetting = require('../settings').getSetting
2627
const SortableTable = require('../components/sortableTable')
@@ -1548,25 +1549,13 @@ class SecurityTab extends ImmutableComponent {
15481549
</span>
15491550
</SettingsList>
15501551
{ !isLinux
1551-
? <SettingsList>
1552-
<SettingCheckbox checked={this.props.braveryDefaults.get('widevine')} dataL10nId='enableWidevine' onChange={this.onToggleWidevine} />
1553-
<div className='subtext'>
1554-
<span data-l10n-id='enableWidevineSubtext' />
1555-
<span className='fa fa-info-circle widevineInfoIcon'
1556-
onClick={aboutActions.newFrame.bind(null, {
1557-
location: appConfig.widevine.moreInfoUrl
1558-
}, true)}
1559-
/>
1560-
</div>
1561-
<div className='subtext'>
1562-
<span data-l10n-id='enableWidevineSubtext2' />
1563-
<span className='fa fa-info-circle widevineInfoIcon'
1564-
onClick={aboutActions.newFrame.bind(null, {
1565-
location: appConfig.widevine.licenseUrl
1566-
}, true)}
1567-
/>
1568-
</div>
1569-
</SettingsList>
1552+
? <div>
1553+
<div className='sectionTitle' data-l10n-id='widevineSection' />
1554+
<SettingsList>
1555+
<WidevineInfo newFrameAction={aboutActions.newFrame} />
1556+
<SettingCheckbox checked={this.props.braveryDefaults.get('widevine')} dataL10nId='enableWidevine' onChange={this.onToggleWidevine} />
1557+
</SettingsList>
1558+
</div>
15701559
: null
15711560
}
15721561
<SitePermissionsPage siteSettings={this.props.siteSettings} names={permissionNames} />

js/actions/windowActions.js

+26
Original file line numberDiff line numberDiff line change
@@ -1018,6 +1018,23 @@ const windowActions = {
10181018
})
10191019
},
10201020

1021+
widevineSiteAccessedWithoutInstall: function () {
1022+
dispatch({
1023+
actionType: WindowConstants.WINDOW_WIDEVINE_SITE_ACCESSED_WITHOUT_INSTALL
1024+
})
1025+
},
1026+
1027+
/**
1028+
* Widevine popup detail changed
1029+
* @param {Object} widevinePanelDetail - detail of the widevine panel
1030+
*/
1031+
widevinePanelDetailChanged: function (widevinePanelDetail) {
1032+
dispatch({
1033+
actionType: WindowConstants.WINDOW_WIDEVINE_PANEL_DETAIL_CHANGED,
1034+
widevinePanelDetail
1035+
})
1036+
},
1037+
10211038
/**
10221039
* Sets the manage autofill address popup detail
10231040
* @param {Object} currentDetail - Properties of the address to change to
@@ -1173,6 +1190,15 @@ const windowActions = {
11731190
className,
11741191
props
11751192
})
1193+
},
1194+
1195+
/**
1196+
* Reloads the current active frame
1197+
*/
1198+
reloadActiveFrame: function () {
1199+
dispatch({
1200+
actionType: WindowConstants.WINDOW_RELOAD_ACTIVE_FRAME
1201+
})
11761202
}
11771203
}
11781204

js/components/frame.js

+1-16
Original file line numberDiff line numberDiff line change
@@ -692,22 +692,7 @@ class Frame extends ImmutableComponent {
692692
appActions.hideMessageBox(message)
693693
}
694694
} else {
695-
let message = locale.translation('widevineDisabled')
696-
appActions.showMessageBox({
697-
buttons: [
698-
{text: locale.translation('goToPrefs')},
699-
{text: locale.translation('noThanks')}
700-
],
701-
message: message,
702-
options: {nonce}
703-
})
704-
this.notificationCallbacks[message] = (buttonIndex) => {
705-
if (buttonIndex === 0) {
706-
const location = 'about:preferences#security'
707-
windowActions.newFrame({ location }, true)
708-
}
709-
appActions.hideMessageBox(message)
710-
}
695+
windowActions.widevineSiteAccessedWithoutInstall()
711696
}
712697

713698
ipc.once(messages.NOTIFICATION_RESPONSE + nonce, (e, msg, buttonIndex, persist) => {

js/components/main.js

+17
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ const SiteInfo = require('./siteInfo')
3131
const BraveryPanel = require('./braveryPanel')
3232
const ClearBrowsingDataPanel = require('./clearBrowsingDataPanel')
3333
const ImportBrowserDataPanel = require('../../app/renderer/components/importBrowserDataPanel')
34+
const WidevinePanel = require('../../app/renderer/components/widevinePanel')
3435
const AutofillAddressPanel = require('./autofillAddressPanel')
3536
const AutofillCreditCardPanel = require('./autofillCreditCardPanel')
3637
const AddEditBookmark = require('./addEditBookmark')
@@ -92,6 +93,7 @@ class Main extends ImmutableComponent {
9293
this.onHideBraveryPanel = this.onHideBraveryPanel.bind(this)
9394
this.onHideClearBrowsingDataPanel = this.onHideClearBrowsingDataPanel.bind(this)
9495
this.onHideImportBrowserDataPanel = this.onHideImportBrowserDataPanel.bind(this)
96+
this.onHideWidevinePanel = this.onHideWidevinePanel.bind(this)
9597
this.onHideAutofillAddressPanel = this.onHideAutofillAddressPanel.bind(this)
9698
this.onHideAutofillCreditCardPanel = this.onHideAutofillCreditCardPanel.bind(this)
9799
this.onHideNoScript = this.onHideNoScript.bind(this)
@@ -613,6 +615,10 @@ class Main extends ImmutableComponent {
613615
windowActions.setImportBrowserDataDetail()
614616
}
615617

618+
onHideWidevinePanel () {
619+
windowActions.widevinePanelDetailChanged()
620+
}
621+
616622
onHideAutofillAddressPanel () {
617623
windowActions.setAutofillAddressDetail()
618624
}
@@ -831,6 +837,7 @@ class Main extends ImmutableComponent {
831837
const braveryPanelIsVisible = !braveShieldsDisabled && this.props.windowState.get('braveryPanelDetail')
832838
const clearBrowsingDataPanelIsVisible = this.props.windowState.get('clearBrowsingDataDetail')
833839
const importBrowserDataPanelIsVisible = this.props.windowState.get('importBrowserDataDetail')
840+
const widevinePanelIsVisible = this.props.windowState.get('widevinePanelDetail')
834841
const autofillAddressPanelIsVisible = this.props.windowState.get('autofillAddressDetail')
835842
const autofillCreditCardPanelIsVisible = this.props.windowState.get('autofillCreditCardDetail')
836843
const activeRequestedLocation = this.activeRequestedLocation
@@ -847,6 +854,7 @@ class Main extends ImmutableComponent {
847854
!braveryPanelIsVisible &&
848855
!clearBrowsingDataPanelIsVisible &&
849856
!importBrowserDataPanelIsVisible &&
857+
!widevinePanelIsVisible &&
850858
!autofillAddressPanelIsVisible &&
851859
!autofillCreditCardPanelIsVisible &&
852860
!releaseNotesIsVisible &&
@@ -996,6 +1004,15 @@ class Main extends ImmutableComponent {
9961004
onHide={this.onHideImportBrowserDataPanel} />
9971005
: null
9981006
}
1007+
{
1008+
widevinePanelIsVisible
1009+
? <WidevinePanel
1010+
location={activeFrame && activeFrame.get('location') || ''}
1011+
widevinePanelDetail={this.props.windowState.get('widevinePanelDetail')}
1012+
widevineReady={this.props.appState.getIn([appConfig.resourceNames.WIDEVINE, 'ready'])}
1013+
onHide={this.onHideWidevinePanel} />
1014+
: null
1015+
}
9991016
{
10001017
autofillAddressPanelIsVisible
10011018
? <AutofillAddressPanel

0 commit comments

Comments
 (0)