Merge pull request #13050 from electron/3.0.0-deprecations

chore: removal of 3.0.0 deprecations
This commit is contained in:
Charles Kerr 2018-05-30 09:25:36 +02:00 committed by GitHub
commit b89fe86fa1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
32 changed files with 76 additions and 421 deletions

View file

@ -1,17 +1,8 @@
const {EventEmitter} = require('events')
const {deprecate} = require('electron')
const {screen, Screen} = process.atomBinding('screen')
// Screen is an EventEmitter.
Object.setPrototypeOf(Screen.prototype, EventEmitter.prototype)
EventEmitter.call(screen)
const nativeFn = screen.getMenuBarHeight
screen.getMenuBarHeight = function () {
if (!process.noDeprecations) {
deprecate.warn('screen.getMenuBarHeight', 'screen.getPrimaryDisplay().workArea')
}
return nativeFn.call(this)
}
module.exports = screen

View file

@ -20,18 +20,3 @@ Object.setPrototypeOf(Cookies.prototype, EventEmitter.prototype)
Session.prototype._init = function () {
app.emit('session-created', this)
}
Session.prototype.setCertificateVerifyProc = function (verifyProc) {
if (verifyProc != null && verifyProc.length > 2) {
// TODO(kevinsawicki): Remove in 2.0, deprecate before then with warnings
this._setCertificateVerifyProc(({hostname, certificate, verificationResult}, cb) => {
verifyProc(hostname, certificate, (result) => {
// Disabled due to false positive in StandardJS
// eslint-disable-next-line standard/no-callback-literal
cb(result ? 0 : -2)
})
})
} else {
this._setCertificateVerifyProc(verifyProc)
}
}

View file

@ -1,20 +1,6 @@
const {EventEmitter} = require('events')
const {deprecate} = require('electron')
const {Tray} = process.atomBinding('tray')
Object.setPrototypeOf(Tray.prototype, EventEmitter.prototype)
// TODO(codebytere): remove in 3.0
const nativeSetHighlightMode = Tray.prototype.setHighlightMode
Tray.prototype.setHighlightMode = function (param) {
if (!process.noDeprecations && typeof param === 'boolean') {
if (param) {
deprecate.warn('tray.setHighlightMode(true)', `tray.setHighlightMode("on")`)
} else {
deprecate.warn('tray.setHighlightMode(false)', `tray.setHighlightMode("off")`)
}
}
return nativeSetHighlightMode.call(this, param)
}
module.exports = Tray

View file

@ -165,14 +165,6 @@ for (const method of webFrameMethodsWithResult) {
}
}
const nativeOpenDevTools = WebContents.prototype.openDevTools
WebContents.prototype.openDevTools = function (params) {
if (!process.noDeprecations && params && 'detach' in params) {
deprecate.warn('webContents.openDevTools({detach: true})', `webContents.openDevTools({mode: 'detach'})`)
}
return nativeOpenDevTools.call(this, params)
}
// Make sure WebContents::executeJavaScript would run the code only when the
// WebContents has been loaded.
WebContents.prototype.executeJavaScript = function (code, hasUserGesture, callback) {

View file

@ -217,7 +217,7 @@ const attachGuest = function (event, elementInstanceId, guestInstanceId, params)
plugins: params.plugins,
zoomFactor: embedder._getZoomFactor(),
webSecurity: !params.disablewebsecurity,
blinkFeatures: params.blinkfeatures,
enableBlinkFeatures: params.blinkfeatures,
disableBlinkFeatures: params.disableblinkfeatures
}

View file

@ -2,41 +2,8 @@ if (process.platform === 'linux' && process.type === 'renderer') {
// On Linux we could not access clipboard in renderer process.
module.exports = require('electron').remote.clipboard
} else {
const {deprecate} = require('electron')
const clipboard = process.atomBinding('clipboard')
// TODO(codebytere): remove in 3.0
clipboard.readHtml = function () {
if (!process.noDeprecations) {
deprecate.warn('clipboard.readHtml', 'clipboard.readHTML')
}
return clipboard.readHTML()
}
// TODO(codebytere): remove in 3.0
clipboard.writeHtml = function () {
if (!process.noDeprecations) {
deprecate.warn('clipboard.writeHtml', 'clipboard.writeHTML')
}
return clipboard.writeHTML()
}
// TODO(codebytere): remove in 3.0
clipboard.readRtf = function () {
if (!process.noDeprecations) {
deprecate.warn('clipboard.readRtf', 'clipboard.writeRTF')
}
return clipboard.readRTF()
}
// TODO(codebytere): remove in 3.0
clipboard.writeRtf = function () {
if (!process.noDeprecations) {
deprecate.warn('clipboard.writeRtf', 'clipboard.writeRTF')
}
return clipboard.writeRTF()
}
// Read/write to find pasteboard over IPC since only main process is notified
// of changes
if (process.platform === 'darwin' && process.type === 'renderer') {

View file

@ -4,7 +4,7 @@ const {spawn} = require('child_process')
const os = require('os')
const path = require('path')
const electron = require('electron')
const {app, deprecate} = process.type === 'browser' ? electron : electron.remote
const {app} = process.type === 'browser' ? electron : electron.remote
const binding = process.atomBinding('crash_reporter')
class CrashReporter {
@ -21,12 +21,7 @@ class CrashReporter {
} = options
if (uploadToServer == null) {
if (options.autoSubmit) {
deprecate.warn('autoSubmit', 'uploadToServer')
uploadToServer = options.autoSubmit
} else {
uploadToServer = true
}
uploadToServer = true
}
if (ignoreSystemCrashHandler == null) ignoreSystemCrashHandler = false

View file

@ -31,7 +31,7 @@ const {
warnAboutDisabledWebSecurity,
warnAboutInsecureContentAllowed,
warnAboutExperimentalFeatures,
warnAboutBlinkFeatures,
warnAboutEnableBlinkFeatures,
warnAboutInsecureResources,
warnAboutInsecureCSP,
warnAboutAllowedPopups,
@ -177,7 +177,7 @@ window.addEventListener('load', function loadHandler () {
warnAboutInsecureResources()
warnAboutInsecureContentAllowed()
warnAboutExperimentalFeatures()
warnAboutBlinkFeatures()
warnAboutEnableBlinkFeatures()
warnAboutInsecureCSP()
warnAboutAllowedPopups()
}

View file

@ -91,9 +91,9 @@ const getWebPreferences = function () {
}
}
const moreInformation = '\nFor more information and help, consult ' +
'https://electronjs.org/docs/tutorial/security.\n' +
'This warning will not show up once the app is packaged.'
const moreInformation = `\nFor more information and help, consult
https://electronjs.org/docs/tutorial/security.\n This warning will not show up
once the app is packaged.`
module.exports = {
shouldLogSecurityWarnings,
@ -119,11 +119,10 @@ module.exports = {
return
}
let warning = 'This renderer process loads resources using insecure protocols. ' +
'This exposes users of this app to unnecessary security risks. ' +
'Consider loading the following resources over HTTPS or FTPS. \n' +
resources + '\n' +
moreInformation
const warning = `This renderer process loads resources using insecure
protocols.This exposes users of this app to unnecessary security risks.
Consider loading the following resources over HTTPS or FTPS. \n ${resources}
\n ${moreInformation}`
console.warn('%cElectron Security Warning (Insecure Resources)',
'font-weight: bold;', warning)
@ -137,10 +136,9 @@ module.exports = {
*/
warnAboutNodeWithRemoteContent: () => {
if (getIsRemoteProtocol()) {
let warning = 'This renderer process has Node.js integration enabled ' +
'and attempted to load remote content. This exposes users of this app to severe ' +
'security risks.\n' +
moreInformation
const warning = `This renderer process has Node.js integration enabled
and attempted to load remote content. This exposes users of this app to
severe security risks.\n ${moreInformation}`
console.warn('%cElectron Security Warning (Node.js Integration with Remote Content)',
'font-weight: bold;', warning)
@ -162,9 +160,8 @@ module.exports = {
const webPreferences = getWebPreferences()
if (!webPreferences || webPreferences.webSecurity !== false) return
let warning = 'This renderer process has "webSecurity" disabled. ' +
'This exposes users of this app to severe security risks.\n' +
moreInformation
const warning = `This renderer process has "webSecurity" disabled. This
exposes users of this app to severe security risks.\n ${moreInformation}`
console.warn('%cElectron Security Warning (Disabled webSecurity)',
'font-weight: bold;', warning)
@ -180,10 +177,9 @@ module.exports = {
*/
warnAboutInsecureCSP: () => {
if (isUnsafeEvalEnabled()) {
let warning = 'This renderer process has either no Content Security Policy set ' +
'or a policy with "unsafe-eval" enabled. This exposes users of this ' +
'app to unnecessary security risks.\n' +
moreInformation
const warning = `This renderer process has either no Content Security
Policy set or a policy with "unsafe-eval" enabled. This exposes users of
this app to unnecessary security risks.\n ${moreInformation}`
console.warn('%cElectron Security Warning (Insecure Content-Security-Policy)',
'font-weight: bold;', warning)
@ -199,9 +195,9 @@ module.exports = {
const webPreferences = getWebPreferences()
if (!webPreferences || !webPreferences.allowRunningInsecureContent) return
let warning = 'This renderer process has "allowRunningInsecureContent" ' +
'enabled. This exposes users of this app to severe security risks.\n' +
moreInformation
const warning = `This renderer process has "allowRunningInsecureContent"
enabled. This exposes users of this app to severe security risks.\n
${moreInformation}`
console.warn('%cElectron Security Warning (allowRunningInsecureContent)',
'font-weight: bold;', warning)
@ -219,33 +215,32 @@ module.exports = {
return
}
let warning = 'This renderer process has "experimentalFeatures" ' +
'enabled. This exposes users of this app to some security risk. ' +
'If you do not need this feature, you should disable it.\n' +
moreInformation
const warning = `This renderer process has "experimentalFeatures" enabled.
This exposes users of this app to some security risk. If you do not need
this feature, you should disable it.\n ${moreInformation}`
console.warn('%cElectron Security Warning (experimentalFeatures)',
'font-weight: bold;', warning)
},
/**
* #10 on the checklist: Do not use blinkFeatures
* #10 on the checklist: Do not use enableBlinkFeatures
*
* Logs a warning message about blinkFeatures
* Logs a warning message about enableBlinkFeatures
*/
warnAboutBlinkFeatures: () => {
warnAboutEnableBlinkFeatures: () => {
const webPreferences = getWebPreferences()
if (!webPreferences || !webPreferences.blinkFeatures ||
(webPreferences.blinkFeatures.length && webPreferences.blinkFeatures.length === 0)) {
if (webPreferences === null ||
!webPreferences.hasOwnProperty('enableBlinkFeatures') ||
webPreferences.enableBlinkFeatures.length === 0) {
return
}
let warning = 'This renderer process has additional "blinkFeatures" ' +
'enabled. This exposes users of this app to some security risk. ' +
'If you do not need this feature, you should disable it.\n' +
moreInformation
const warning = `This renderer process has additional "enableBlinkFeatures"
enabled. This exposes users of this app to some security risk. If you do not
need this feature, you should disable it.\n ${moreInformation}`
console.warn('%cElectron Security Warning (blinkFeatures)',
console.warn('%cElectron Security Warning (enableBlinkFeatures)',
'font-weight: bold;', warning)
},
@ -262,10 +257,10 @@ module.exports = {
return
}
let warning = 'A <webview> has "allowpopups" set to true. ' +
'This exposes users of this app to some security risk, since popups are just ' +
'BrowserWindows. If you do not need this feature, you should disable it.\n' +
moreInformation
const warning = `A <webview> has "allowpopups" set to true. This exposes
users of this app to some security risk, since popups are just
BrowserWindows. If you do not need this feature, you should disable it.\n
${moreInformation}`
console.warn('%cElectron Security Warning (allowpopups)',
'font-weight: bold;', warning)