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

Add support for Google Widevine for Netflix support #5106

Merged
merged 1 commit into from
Oct 25, 2016
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
39 changes: 27 additions & 12 deletions app/extensions.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const browserActions = require('./browser/extensions/browserActions')
const extensionActions = require('./common/actions/extensionActions')
const config = require('../js/constants/config')
const appConfig = require('../js/constants/appConfig')
const {fileUrl} = require('../js/lib/appUrlUtil')
const {getAppUrl, getExtensionsPath, getIndexHTML} = require('../js/lib/appUrlUtil')
const {getSetting} = require('../js/settings')
Expand All @@ -9,6 +10,7 @@ const extensionStates = require('../js/constants/extensionStates')
const {passwordManagers, extensionIds} = require('../js/constants/passwordManagers')
const appStore = require('../js/stores/appStore')
const extensionState = require('./common/state/extensionState')
const appActions = require('../js/actions/appActions')
const fs = require('fs')
const path = require('path')

Expand Down Expand Up @@ -175,6 +177,11 @@ const extensionInfo = {
installInfo: {}
}

const isExtension = (componentId) =>
componentId !== config.widevineComponentId
const isWidevine = (componentId) =>
componentId === config.widevineComponentId

module.exports.init = () => {
browserActions.init()

Expand All @@ -191,11 +198,15 @@ module.exports.init = () => {
componentUpdater.on('component-update-updated', (e, extensionId, version) => {
// console.log('update-updated', extensionId, version)
})
componentUpdater.on('component-ready', (e, extensionId, extensionPath) => {
// console.log('component-ready', extensionId, extensionPath)
componentUpdater.on('component-ready', (e, componentId, extensionPath) => {
// console.log('component-ready', componentId, extensionPath)
// Re-setup the loadedExtensions info if it exists
extensionInfo.setState(extensionId, extensionStates.REGISTERED)
loadExtension(extensionId, extensionPath)
extensionInfo.setState(componentId, extensionStates.REGISTERED)
if (isExtension(componentId)) {
loadExtension(componentId, extensionPath)
} else if (isWidevine(componentId)) {
appActions.resourceReady(appConfig.resourceNames.WIDEVINE)
}
})
componentUpdater.on('component-not-updated', () => {
// console.log('update-not-updated')
Expand Down Expand Up @@ -262,7 +273,7 @@ module.exports.init = () => {
session.defaultSession.extensions.disable(extensionId)
}

let registerExtension = (extensionId) => {
let registerComponent = (extensionId) => {
if (!extensionInfo.isRegistered(extensionId) && !extensionInfo.isRegistering(extensionId)) {
extensionInfo.setState(extensionId, extensionStates.REGISTERING)
componentUpdater.registerComponent(extensionId)
Expand All @@ -280,33 +291,37 @@ module.exports.init = () => {
extensionInfo.setState(config.braveExtensionId, extensionStates.REGISTERED)
loadExtension(config.braveExtensionId, getExtensionsPath('brave'), generateBraveManifest(), 'component')

let registerExtensions = () => {
let registerComponents = () => {
if (getSetting(settings.PDFJS_ENABLED)) {
registerExtension(config.PDFJSExtensionId)
registerComponent(config.PDFJSExtensionId)
} else {
disableExtension(config.PDFJSExtensionId)
}

const activePasswordManager = getSetting(settings.ACTIVE_PASSWORD_MANAGER)
if (activePasswordManager === passwordManagers.ONE_PASSWORD) {
registerExtension(extensionIds[passwordManagers.ONE_PASSWORD])
registerComponent(extensionIds[passwordManagers.ONE_PASSWORD])
} else {
disableExtension(extensionIds[passwordManagers.ONE_PASSWORD])
}

if (activePasswordManager === passwordManagers.DASHLANE) {
registerExtension(extensionIds[passwordManagers.DASHLANE])
registerComponent(extensionIds[passwordManagers.DASHLANE])
} else {
disableExtension(extensionIds[passwordManagers.DASHLANE])
}

if (activePasswordManager === passwordManagers.LAST_PASS) {
registerExtension(extensionIds[passwordManagers.LAST_PASS])
registerComponent(extensionIds[passwordManagers.LAST_PASS])
} else {
disableExtension(extensionIds[passwordManagers.LAST_PASS])
}

if (appStore.getState().getIn(['widevine', 'enabled'])) {
registerComponent(config.widevineComponentId)
}
}

registerExtensions()
appStore.addChangeListener(registerExtensions)
registerComponents()
appStore.addChangeListener(registerComponents)
}
3 changes: 3 additions & 0 deletions app/extensions/brave/locales/en-US/app.properties
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,13 @@ inspectElement=Inspect Element
urlCopied=URL copied to clipboard
passwordCopied=Password copied to clipboard
flashInstalled=Flash is already installed and can be enabled in Preferences > Security.
widevineDisabled=Google Widevine can be enabled in Preferences > Security.
goToPrefs=Open Preferences
goToAdobe=Reinstall Flash
allowFlashPlayer=Allow {{origin}} to run Flash Player?
ledgerBackupText=Your ledger keys are {{paymentId}} and {{passphrase}}
allowWidevine=Allow {{origin}} to run Google Widevine?

error=Error
caseSensitivity=Match case
nameField=Title
Expand Down
4 changes: 4 additions & 0 deletions app/extensions/brave/locales/en-US/preferences.properties
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ lastPass=LastPass®
doNotManageMyPasswords=Don't manage my passwords
usePDFJS=Use HTML5 PDF reader (requires browser restart)
enableFlash=Enable Adobe Flash support (requires browser restart)
enableWidevine=Enable Google Widevine support
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.
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.
enableFlashSubtext=Flash support is experimental and requires Pepper Flash to be installed from
enableFlashSubtextLinux=Flash support is experimental and requires the pepperflashplugin-nonfree package.
managePasswords=Manage passwords…
Expand Down Expand Up @@ -217,6 +220,7 @@ protocolRegistrationPermission=Protocol registration
shieldsUp=All Brave Shields
ledgerPaymentsShown=Brave Payments
flash=Run Adobe Flash Player
widevine=Run Google Widevine
allowOnce=Allow once
allowUntilRestart=Allow until restart
flashAllowAlways=Allow until {{time}}
Expand Down
2 changes: 2 additions & 0 deletions app/locale.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ var rendererIdentifiers = function () {
'confirmClearPasswords',
'passwordCopied',
'flashInstalled',
'widevineDisabled',
'goToPrefs',
'goToAdobe',
'allowFlashPlayer',
'allowWidevine',
'about',
'aboutApp',
'quit',
Expand Down
10 changes: 10 additions & 0 deletions docs/appActions.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,16 @@ Sets whether the resource is enabled or not.



### resourceReady(resourceName)

Indicates a resource is ready

**Parameters**

**resourceName**: `string`, 'widevine'



### addResourceCount(resourceName, count)

Checks how many resources were blocked.
Expand Down
5 changes: 5 additions & 0 deletions docs/state.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ AppStore
httpsEverywhere: boolean,
fingerprintingProtection: boolean,
flash: (number|boolean), // approval expiration time if allowed, false if never allow
widevine: (number|boolean), // false = block widevine, 0 = allow once, 1 = allow always
ledgerPayments: boolean, // False if site should not be paid by the ledger. Defaults to true.
ledgerPaymentsShown: boolean, // False if site should not be paid by the ledger and should not be shown in the UI. Defaults to true.
runInsecureContent: boolean // Allow active mixed content
Expand Down Expand Up @@ -116,6 +117,10 @@ AppStore
flash: {
enabled: boolean // Enable flash
},
widevine: {
enabled: boolean, // true if widevine is installed and enabled
ready: boolean // true if widevine is in a ready state
},
defaultWindowHeight: number,
defaultWindowWidth: number,
updates: {
Expand Down
39 changes: 38 additions & 1 deletion js/about/preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const httpsEverywhere = appConfig.resourceNames.HTTPS_EVERYWHERE
const safeBrowsing = appConfig.resourceNames.SAFE_BROWSING
const noScript = appConfig.resourceNames.NOSCRIPT
const flash = appConfig.resourceNames.FLASH
const widevine = appConfig.resourceNames.WIDEVINE

const isDarwin = navigator.platform === 'MacIntel'
const isWindows = navigator.platform && navigator.platform.includes('Win')
Expand All @@ -62,7 +63,8 @@ const permissionNames = {
'fullscreenPermission': ['boolean'],
'openExternalPermission': ['boolean'],
'protocolRegistrationPermission': ['boolean'],
'flash': ['boolean', 'number']
'flash': ['boolean', 'number'],
'widevine': ['boolean', 'number']
}

const braveryPermissionNames = {
Expand Down Expand Up @@ -1341,6 +1343,14 @@ class SitePermissionsPage extends React.Component {
time: new Date(granted).toLocaleString()
}
}
} else if (name === 'widevine') {
if (granted === 1) {
statusText = 'alwaysAllow'
} else if (granted === 0) {
statusText = 'allowOnce'
} else {
statusText = 'alwaysDeny'
}
} else if (name === 'noScript' && typeof granted === 'number') {
if (granted === 1) {
statusText = 'allowUntilRestart'
Expand Down Expand Up @@ -1454,9 +1464,14 @@ class SecurityTab extends ImmutableComponent {
aboutActions.setResourceEnabled(flash, e.target.value)
ipc.send(messages.PREFS_RESTART, flash, e.target.value)
}
onToggleWidevine (e) {
aboutActions.setResourceEnabled(widevine, e.target.value)
}
render () {
const lastPassPreferencesUrl = ('chrome-extension://' + extensionIds[passwordManagers.LAST_PASS] + '/tabDialog.html?dialog=preferences&cmd=open')

const isLinux = navigator.appVersion.indexOf('Linux') !== -1

return <div>
<div className='sectionTitle' data-l10n-id='privateData' />
<SettingsList dataL10nId='privateDataMessage'>
Expand Down Expand Up @@ -1524,6 +1539,28 @@ class SecurityTab extends ImmutableComponent {
}
</span>
</SettingsList>
{ !isLinux
? <SettingsList>
<SettingCheckbox checked={this.props.braveryDefaults.get('widevine')} dataL10nId='enableWidevine' onChange={this.onToggleWidevine} />
<div className='subtext'>
<span data-l10n-id='enableWidevineSubtext' />
<span className='fa fa-info-circle widevineInfoIcon'
onClick={aboutActions.newFrame.bind(null, {
location: appConfig.widevine.moreInfoUrl
}, true)}
/>
</div>
<div className='subtext'>
<span data-l10n-id='enableWidevineSubtext2' />
<span className='fa fa-info-circle widevineInfoIcon'
onClick={aboutActions.newFrame.bind(null, {
location: appConfig.widevine.licenseUrl
}, true)}
/>
</div>
</SettingsList>
: null
}
<SitePermissionsPage siteSettings={this.props.siteSettings} names={permissionNames} />
</div>
}
Expand Down
11 changes: 11 additions & 0 deletions js/actions/appActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,17 @@ const appActions = {
})
},

/**
* Indicates a resource is ready
* @param {string} resourceName - 'widevine'
*/
resourceReady: function (resourceName) {
AppDispatcher.dispatch({
actionType: AppConstants.APP_RESOURCE_READY,
resourceName
})
},

/**
* Checks how many resources were blocked.
* @param {string} resourceName - 'adblock', 'trackingProtection', or 'httpsEverywhere'
Expand Down
Loading