From dae68be2ce8209a8c18dcd745a8b1215d1e13ae6 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 28 Apr 2016 09:38:05 -0700 Subject: [PATCH 01/31] Remove deprecated APIs --- lib/browser/api/app.js | 53 +------------------------------ lib/browser/api/auto-updater.js | 5 --- lib/browser/api/browser-window.js | 28 ---------------- lib/browser/api/ipc.js | 5 --- lib/browser/api/tray.js | 7 ---- lib/browser/api/web-contents.js | 8 ----- lib/common/api/native-image.js | 8 +---- lib/renderer/api/web-frame.js | 6 ---- lib/renderer/web-view/web-view.js | 3 -- 9 files changed, 2 insertions(+), 121 deletions(-) diff --git a/lib/browser/api/app.js b/lib/browser/api/app.js index 0487270ce7b3..f8a4d3e2913e 100644 --- a/lib/browser/api/app.js +++ b/lib/browser/api/app.js @@ -1,7 +1,7 @@ 'use strict' const electron = require('electron') -const {deprecate, session, Menu} = electron +const {session, Menu} = electron const EventEmitter = require('events').EventEmitter const bindings = process.atomBinding('app') @@ -63,61 +63,10 @@ for (i = 0, len = ref1.length; i < len; i++) { fn(ref1[i]) } -// Deprecated. -app.getHomeDir = deprecate('app.getHomeDir', 'app.getPath', function () { - return this.getPath('home') -}) -app.getDataPath = deprecate('app.getDataPath', 'app.getPath', function () { - return this.getPath('userData') -}) -app.setDataPath = deprecate('app.setDataPath', 'app.setPath', function (path) { - return this.setPath('userData', path) -}) -app.resolveProxy = deprecate('app.resolveProxy', 'session.defaultSession.resolveProxy', function (url, callback) { - return session.defaultSession.resolveProxy(url, callback) -}) -deprecate.rename(app, 'terminate', 'quit') -deprecate.event(app, 'finish-launching', 'ready', function () { - // give default app a chance to setup default menu. - setImmediate(() => { - this.emit('finish-launching') - }) -}) -deprecate.event(app, 'activate-with-no-open-windows', 'activate', function (event, hasVisibleWindows) { - if (!hasVisibleWindows) { - return this.emit('activate-with-no-open-windows', event) - } -}) -deprecate.event(app, 'select-certificate', 'select-client-certificate') -if (process.platform === 'win32') { - app.isAeroGlassEnabled = deprecate('app.isAeroGlassEnabled', 'systemPreferences.isAeroGlassEnabled', function () { - return electron.systemPreferences.isAeroGlassEnabled() - }) -} else if (process.platform === 'darwin') { - app.isDarkMode = deprecate('app.isDarkMode', 'systemPreferences.isDarkMode', function () { - return electron.systemPreferences.isDarkMode() - }) - app.on = app.addListener = function (event, listener) { - if (event === 'platform-theme-changed') { - deprecate.warn('platform-theme-changed event', "systemPreferences.subscribeNotification('AppleInterfaceThemeChangedNotification', callback)") - electron.systemPreferences.subscribeNotification('AppleInterfaceThemeChangedNotification', function () { - app.emit('platform-theme-changed') - }) - } - EventEmitter.prototype.addListener.call(app, event, listener) - } -} - // Wrappers for native classes. var wrapDownloadItem = function (downloadItem) { // downloadItem is an EventEmitter. Object.setPrototypeOf(downloadItem, EventEmitter.prototype) - - // Deprecated. - deprecate.property(downloadItem, 'url', 'getURL') - deprecate.property(downloadItem, 'filename', 'getFilename') - deprecate.property(downloadItem, 'mimeType', 'getMimeType') - return deprecate.rename(downloadItem, 'getUrl', 'getURL') } downloadItemBindings._setWrapDownloadItem(wrapDownloadItem) diff --git a/lib/browser/api/auto-updater.js b/lib/browser/api/auto-updater.js index 2b5133070f41..f99d3218e430 100644 --- a/lib/browser/api/auto-updater.js +++ b/lib/browser/api/auto-updater.js @@ -1,7 +1,2 @@ -const deprecate = require('electron').deprecate const autoUpdater = process.platform === 'win32' ? require('./auto-updater/auto-updater-win') : require('./auto-updater/auto-updater-native') - -// Deprecated. -deprecate.rename(autoUpdater, 'setFeedUrl', 'setFeedURL') - module.exports = autoUpdater diff --git a/lib/browser/api/browser-window.js b/lib/browser/api/browser-window.js index c9d63278f974..7eec5c1cc441 100644 --- a/lib/browser/api/browser-window.js +++ b/lib/browser/api/browser-window.js @@ -196,34 +196,6 @@ BrowserWindow.prototype.inspectServiceWorker = function () { return this.webContents.inspectServiceWorker() } -// Deprecated. -deprecate.member(BrowserWindow, 'undo', 'webContents') -deprecate.member(BrowserWindow, 'redo', 'webContents') -deprecate.member(BrowserWindow, 'cut', 'webContents') -deprecate.member(BrowserWindow, 'copy', 'webContents') -deprecate.member(BrowserWindow, 'paste', 'webContents') -deprecate.member(BrowserWindow, 'selectAll', 'webContents') -deprecate.member(BrowserWindow, 'reloadIgnoringCache', 'webContents') -deprecate.member(BrowserWindow, 'isLoading', 'webContents') -deprecate.member(BrowserWindow, 'isWaitingForResponse', 'webContents') -deprecate.member(BrowserWindow, 'stop', 'webContents') -deprecate.member(BrowserWindow, 'isCrashed', 'webContents') -deprecate.member(BrowserWindow, 'print', 'webContents') -deprecate.member(BrowserWindow, 'printToPDF', 'webContents') -deprecate.rename(BrowserWindow, 'restart', 'reload') -deprecate.rename(BrowserWindow, 'loadUrl', 'loadURL') -deprecate.rename(BrowserWindow, 'getUrl', 'getURL') - -BrowserWindow.prototype.executeJavaScriptInDevTools = deprecate('executeJavaScriptInDevTools', 'devToolsWebContents.executeJavaScript', function (code) { - var ref1 - return (ref1 = this.devToolsWebContents) != null ? ref1.executeJavaScript(code) : void 0 -}) - -BrowserWindow.prototype.getPageTitle = deprecate('getPageTitle', 'webContents.getTitle', function () { - var ref1 - return (ref1 = this.webContents) != null ? ref1.getTitle() : void 0 -}) - const isDeprecatedKey = function (key) { return key.indexOf('-') >= 0 } diff --git a/lib/browser/api/ipc.js b/lib/browser/api/ipc.js index cdba49c82485..6b7f04d2aed2 100644 --- a/lib/browser/api/ipc.js +++ b/lib/browser/api/ipc.js @@ -1,7 +1,2 @@ -const deprecate = require('electron').deprecate const ipcMain = require('electron').ipcMain - -// This module is deprecated, we mirror everything from ipcMain. -deprecate.warn('ipc module', 'require("electron").ipcMain') - module.exports = ipcMain diff --git a/lib/browser/api/tray.js b/lib/browser/api/tray.js index ce67dbe117a2..5142120a5695 100644 --- a/lib/browser/api/tray.js +++ b/lib/browser/api/tray.js @@ -1,16 +1,9 @@ -const deprecate = require('electron').deprecate const EventEmitter = require('events').EventEmitter const Tray = process.atomBinding('tray').Tray Object.setPrototypeOf(Tray.prototype, EventEmitter.prototype) Tray.prototype._init = function () { - // Deprecated. - deprecate.rename(this, 'popContextMenu', 'popUpContextMenu') - deprecate.event(this, 'clicked', 'click') - deprecate.event(this, 'double-clicked', 'double-click') - deprecate.event(this, 'right-clicked', 'right-click') - return deprecate.event(this, 'balloon-clicked', 'balloon-click') } Tray.prototype.setContextMenu = function (menu) { diff --git a/lib/browser/api/web-contents.js b/lib/browser/api/web-contents.js index 823351ebe116..0ccb51b19b09 100644 --- a/lib/browser/api/web-contents.js +++ b/lib/browser/api/web-contents.js @@ -1,7 +1,6 @@ 'use strict' const EventEmitter = require('events').EventEmitter -const deprecate = require('electron').deprecate const ipcMain = require('electron').ipcMain const NavigationController = require('electron').NavigationController const Menu = require('electron').Menu @@ -160,13 +159,6 @@ let wrapWebContents = function (webContents) { }) }) - // Deprecated. - deprecate.rename(webContents, 'loadUrl', 'loadURL') - deprecate.rename(webContents, 'getUrl', 'getURL') - deprecate.event(webContents, 'page-title-set', 'page-title-updated', function (...args) { - return this.emit.apply(this, ['page-title-set'].concat(args)) - }) - webContents.printToPDF = function (options, callback) { var printingSetting printingSetting = { diff --git a/lib/common/api/native-image.js b/lib/common/api/native-image.js index ebb06138210e..614298f51a0e 100644 --- a/lib/common/api/native-image.js +++ b/lib/common/api/native-image.js @@ -1,7 +1 @@ -const deprecate = require('electron').deprecate -const nativeImage = process.atomBinding('native_image') - -// Deprecated. -deprecate.rename(nativeImage, 'createFromDataUrl', 'createFromDataURL') - -module.exports = nativeImage +module.exports = process.atomBinding('native_image') diff --git a/lib/renderer/api/web-frame.js b/lib/renderer/api/web-frame.js index 4a152d4f3646..81855c391f8f 100644 --- a/lib/renderer/api/web-frame.js +++ b/lib/renderer/api/web-frame.js @@ -1,6 +1,5 @@ 'use strict' -const deprecate = require('electron').deprecate const EventEmitter = require('events').EventEmitter const webFrame = process.atomBinding('web_frame').webFrame @@ -11,9 +10,4 @@ Object.setPrototypeOf(webFrame, EventEmitter.prototype) // Lots of webview would subscribe to webFrame's events. webFrame.setMaxListeners(0) -// Deprecated. -deprecate.rename(webFrame, 'registerUrlSchemeAsSecure', 'registerURLSchemeAsSecure') -deprecate.rename(webFrame, 'registerUrlSchemeAsBypassingCSP', 'registerURLSchemeAsBypassingCSP') -deprecate.rename(webFrame, 'registerUrlSchemeAsPrivileged', 'registerURLSchemeAsPrivileged') - module.exports = webFrame diff --git a/lib/renderer/web-view/web-view.js b/lib/renderer/web-view/web-view.js index 20f5f07465b5..bfe5197295c0 100644 --- a/lib/renderer/web-view/web-view.js +++ b/lib/renderer/web-view/web-view.js @@ -1,6 +1,5 @@ 'use strict' -const deprecate = require('electron').deprecate const webFrame = require('electron').webFrame const remote = require('electron').remote const ipcRenderer = require('electron').ipcRenderer @@ -432,8 +431,6 @@ var registerWebViewElement = function () { return internal.webContents } - // Deprecated. - deprecate.rename(proto, 'getUrl', 'getURL') window.WebView = webFrame.registerEmbedderCustomElement('webview', { prototype: proto }) From 0342db9328211a5d79ac930b0e1b29fa4f1cf521 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 28 Apr 2016 09:39:37 -0700 Subject: [PATCH 02/31] Remove hyphenated options --- lib/renderer/override.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/renderer/override.js b/lib/renderer/override.js index db56eadd3484..bb09a9981dce 100644 --- a/lib/renderer/override.js +++ b/lib/renderer/override.js @@ -85,9 +85,8 @@ window.open = function (url, frameName, features) { } options = {} - // TODO remove hyphenated options in both of the following arrays for 1.0 - const ints = ['x', 'y', 'width', 'height', 'min-width', 'minWidth', 'max-width', 'maxWidth', 'min-height', 'minHeight', 'max-height', 'maxHeight', 'zoom-factor', 'zoomFactor'] - const webPreferences = ['zoom-factor', 'zoomFactor', 'node-integration', 'nodeIntegration', 'preload'] + const ints = ['x', 'y', 'width', 'height', 'minWidth', 'maxWidth', 'minHeight', 'maxHeight', 'zoomFactor'] + const webPreferences = ['zoomFactor', 'nodeIntegration', 'preload'] const disposition = 'new-window' // Make sure to get rid of excessive whitespace in the property name From 6f0471f6cb129edc758929079c66ca62ea9211b4 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 28 Apr 2016 09:42:06 -0700 Subject: [PATCH 03/31] Remove deprecated options check in BrowserWindow --- atom/browser/api/atom_api_window.cc | 18 ---------- lib/browser/api/browser-window.js | 55 +---------------------------- 2 files changed, 1 insertion(+), 72 deletions(-) diff --git a/atom/browser/api/atom_api_window.cc b/atom/browser/api/atom_api_window.cc index ae5eec64cf93..2ef065bf51c9 100644 --- a/atom/browser/api/atom_api_window.cc +++ b/atom/browser/api/atom_api_window.cc @@ -52,11 +52,6 @@ namespace api { namespace { -// This function is implemented in JavaScript -using DeprecatedOptionsCheckCallback = - base::Callback)>; -DeprecatedOptionsCheckCallback g_deprecated_options_check; - void OnCapturePageDone( v8::Isolate* isolate, const base::Callback& callback, @@ -304,13 +299,6 @@ mate::WrappableBase* Window::New(v8::Isolate* isolate, mate::Arguments* args) { options = mate::Dictionary::CreateEmpty(isolate); } - std::string deprecation_message = g_deprecated_options_check.Run( - options.GetHandle()); - if (deprecation_message.length() > 0) { - args->ThrowError(deprecation_message); - return nullptr; - } - return new Window(isolate, options); } @@ -822,10 +810,6 @@ v8::Local Window::From(v8::Isolate* isolate, return v8::Null(isolate); } -void SetDeprecatedOptionsCheck(const DeprecatedOptionsCheckCallback& callback) { - g_deprecated_options_check = callback; -} - } // namespace api } // namespace atom @@ -848,8 +832,6 @@ void Initialize(v8::Local exports, v8::Local unused, mate::Dictionary dict(isolate, exports); dict.Set("BrowserWindow", browser_window); - dict.SetMethod("_setDeprecatedOptionsCheck", - &atom::api::SetDeprecatedOptionsCheck); } } // namespace diff --git a/lib/browser/api/browser-window.js b/lib/browser/api/browser-window.js index 7eec5c1cc441..e433580ba638 100644 --- a/lib/browser/api/browser-window.js +++ b/lib/browser/api/browser-window.js @@ -1,9 +1,8 @@ 'use strict' const ipcMain = require('electron').ipcMain -const deprecate = require('electron').deprecate const EventEmitter = require('events').EventEmitter -const {BrowserWindow, _setDeprecatedOptionsCheck} = process.atomBinding('window') +const {BrowserWindow} = process.atomBinding('window') Object.setPrototypeOf(BrowserWindow.prototype, EventEmitter.prototype) @@ -196,56 +195,4 @@ BrowserWindow.prototype.inspectServiceWorker = function () { return this.webContents.inspectServiceWorker() } -const isDeprecatedKey = function (key) { - return key.indexOf('-') >= 0 -} - -// Map deprecated key with hyphens to camel case key -const getNonDeprecatedKey = function (deprecatedKey) { - return deprecatedKey.replace(/-./g, function (match) { - return match[1].toUpperCase() - }) -} - -// TODO Remove for 1.0 -const checkForDeprecatedOptions = function (options) { - if (!options) return '' - - let keysToCheck = Object.keys(options) - if (options.webPreferences) { - keysToCheck = keysToCheck.concat(Object.keys(options.webPreferences)) - } - - // Check options for keys with hyphens in them - let deprecatedKey = keysToCheck.filter(isDeprecatedKey)[0] - if (deprecatedKey) { - try { - deprecate.warn(deprecatedKey, getNonDeprecatedKey(deprecatedKey)) - } catch (error) { - // Return error message so it can be rethrown via C++ - return error.message - } - } - - let webPreferenceOption - if (options.hasOwnProperty('nodeIntegration')) { - webPreferenceOption = 'nodeIntegration' - } else if (options.hasOwnProperty('preload')) { - webPreferenceOption = 'preload' - } else if (options.hasOwnProperty('zoomFactor')) { - webPreferenceOption = 'zoomFactor' - } - if (webPreferenceOption) { - try { - deprecate.warn(`options.${webPreferenceOption}`, `options.webPreferences.${webPreferenceOption}`) - } catch (error) { - // Return error message so it can be rethrown via C++ - return error.message - } - } - - return '' -} -_setDeprecatedOptionsCheck(checkForDeprecatedOptions) - module.exports = BrowserWindow From a6cf7a10954c2615f6c6721a92ca21f4508efdc4 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 28 Apr 2016 09:48:13 -0700 Subject: [PATCH 04/31] Remove deprecated crashReporter.start options --- lib/common/api/crash-reporter.js | 15 +++------------ spec/api-crash-reporter-spec.js | 6 +++--- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/lib/common/api/crash-reporter.js b/lib/common/api/crash-reporter.js index f10887550113..e62c7cdf95f9 100644 --- a/lib/common/api/crash-reporter.js +++ b/lib/common/api/crash-reporter.js @@ -10,7 +10,7 @@ var CrashReporter = (function () { function CrashReporter () {} CrashReporter.prototype.start = function (options) { - var app, args, autoSubmit, companyName, deprecate, env, extra, ignoreSystemCrashHandler, start, submitURL + var app, args, autoSubmit, companyName, env, extra, ignoreSystemCrashHandler, start, submitURL if (options == null) { options = {} } @@ -21,14 +21,6 @@ var CrashReporter = (function () { ignoreSystemCrashHandler = options.ignoreSystemCrashHandler extra = options.extra - // Deprecated. - deprecate = electron.deprecate - if (options.submitUrl) { - if (submitURL == null) { - submitURL = options.submitUrl - } - deprecate.warn('submitUrl', 'submitURL') - } app = (process.type === 'browser' ? electron : electron.remote).app if (this.productName == null) { this.productName = app.getName() @@ -52,11 +44,10 @@ var CrashReporter = (function () { extra._version = app.getVersion() } if (companyName == null) { - deprecate.log('companyName is now a required option to crashReporter.start') - return + throw new Error('companyName is a required option to crashReporter.start') } if (submitURL == null) { - deprecate.log('submitURL is now a required option to crashReporter.start') + throw new Error('submitURL is a required option to crashReporter.start') return } start = () => { diff --git a/spec/api-crash-reporter-spec.js b/spec/api-crash-reporter-spec.js index e5a3223eed8f..4bf02af2ef5d 100644 --- a/spec/api-crash-reporter-spec.js +++ b/spec/api-crash-reporter-spec.js @@ -75,18 +75,18 @@ describe('crash-reporter module', function () { }) }) - describe('.start(options)', function () { + describe.only('.start(options)', function () { it('requires that the companyName and submitURL options be specified', function () { assert.throws(function () { crashReporter.start({ companyName: 'Missing submitURL' }) - }) + }, /submitURL is a required option to crashReporter\.start/) assert.throws(function () { crashReporter.start({ submitURL: 'Missing companyName' }) - }) + }, /companyName is a required option to crashReporter\.start/) }) }) }) From d988cae16d8d6ee45474033ab8cb72d00e01918b Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 28 Apr 2016 09:49:48 -0700 Subject: [PATCH 05/31] Remove deprecated ipc module --- lib/renderer/api/ipc.js | 27 --------------------------- 1 file changed, 27 deletions(-) delete mode 100644 lib/renderer/api/ipc.js diff --git a/lib/renderer/api/ipc.js b/lib/renderer/api/ipc.js deleted file mode 100644 index 25519a308daf..000000000000 --- a/lib/renderer/api/ipc.js +++ /dev/null @@ -1,27 +0,0 @@ -const ipcRenderer = require('electron').ipcRenderer -const deprecate = require('electron').deprecate -const EventEmitter = require('events').EventEmitter - -// This module is deprecated, we mirror everything from ipcRenderer. -deprecate.warn('ipc module', 'require("electron").ipcRenderer') - -// Routes events of ipcRenderer. -var ipc = new EventEmitter() - -ipcRenderer.emit = function (channel, event, ...args) { - ipc.emit.apply(ipc, [channel].concat(args)) - return EventEmitter.prototype.emit.apply(ipcRenderer, arguments) -} - -// Deprecated. -for (var method in ipcRenderer) { - if (method.startsWith('send')) { - ipc[method] = ipcRenderer[method] - } -} - -deprecate.rename(ipc, 'sendChannel', 'send') - -deprecate.rename(ipc, 'sendChannelSync', 'sendSync') - -module.exports = ipc From bf91410a22c06f4649117245af0606b3b59d043a Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 28 Apr 2016 09:50:33 -0700 Subject: [PATCH 06/31] Remove deprecated main process ipc module --- lib/browser/api/ipc.js | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 lib/browser/api/ipc.js diff --git a/lib/browser/api/ipc.js b/lib/browser/api/ipc.js deleted file mode 100644 index 6b7f04d2aed2..000000000000 --- a/lib/browser/api/ipc.js +++ /dev/null @@ -1,2 +0,0 @@ -const ipcMain = require('electron').ipcMain -module.exports = ipcMain From dafa14fe42f3c6b52534e5c9f041386a180791ea Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 28 Apr 2016 09:52:22 -0700 Subject: [PATCH 07/31] Don't export deprecate API --- lib/common/api/exports/electron.js | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/lib/common/api/exports/electron.js b/lib/common/api/exports/electron.js index 3bef1f0c50f6..25ef2640d599 100644 --- a/lib/common/api/exports/electron.js +++ b/lib/common/api/exports/electron.js @@ -29,12 +29,6 @@ exports.defineProperties = function (exports) { return require('../crash-reporter') } }, - deprecations: { - enumerable: true, - get: function () { - return require('../deprecations') - } - }, nativeImage: { enumerable: true, get: function () { @@ -53,11 +47,6 @@ exports.defineProperties = function (exports) { get: function () { return require('../callbacks-registry') } - }, - deprecate: { - get: function () { - return require('../deprecate') - } } }) } From 2ce4237083d1b21d3f38e74d88016a3d3725fdb4 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 28 Apr 2016 09:54:22 -0700 Subject: [PATCH 08/31] Remove hideInternalModules API --- lib/browser/init.js | 4 ---- lib/common/api/exports/electron.js | 14 -------------- lib/common/init.js | 5 ----- lib/renderer/init.js | 4 ---- 4 files changed, 27 deletions(-) diff --git a/lib/browser/init.js b/lib/browser/init.js index fc4f90c399ba..df670ece7100 100644 --- a/lib/browser/init.js +++ b/lib/browser/init.js @@ -18,10 +18,6 @@ require('../common/init') var globalPaths = Module.globalPaths -if (!process.env.ELECTRON_HIDE_INTERNAL_MODULES) { - globalPaths.push(path.join(__dirname, 'api')) -} - // Expose public APIs. globalPaths.push(path.join(__dirname, 'api', 'exports')) diff --git a/lib/common/api/exports/electron.js b/lib/common/api/exports/electron.js index 25ef2640d599..65da6c5d2b91 100644 --- a/lib/common/api/exports/electron.js +++ b/lib/common/api/exports/electron.js @@ -1,20 +1,6 @@ -// Do not expose the internal modules to `require`. -const hideInternalModules = function () { - var globalPaths = require('module').globalPaths - if (globalPaths.length === 3) { - // Remove the "common/api/lib" and "browser-or-renderer/api/lib". - return globalPaths.splice(0, 2) - } -} - // Attaches properties to |exports|. exports.defineProperties = function (exports) { return Object.defineProperties(exports, { - hideInternalModules: { - enumerable: true, - value: hideInternalModules - }, - // Common modules, please sort with alphabet order. clipboard: { // Must be enumerable, otherwise it woulde be invisible to remote module. diff --git a/lib/common/init.js b/lib/common/init.js index 11c098d3ce5c..1b90b9343441 100644 --- a/lib/common/init.js +++ b/lib/common/init.js @@ -12,11 +12,6 @@ process.atomBinding = function (name) { } } -if (!process.env.ELECTRON_HIDE_INTERNAL_MODULES) { - // Add common/api/lib to module search paths. - Module.globalPaths.push(path.join(__dirname, 'api')) -} - // setImmediate and process.nextTick makes use of uv_check and uv_prepare to // run the callbacks, however since we only run uv loop on requests, the // callbacks wouldn't be called until something else activated the uv loop, diff --git a/lib/renderer/init.js b/lib/renderer/init.js index a9f4acc5cbfe..fadf95256865 100644 --- a/lib/renderer/init.js +++ b/lib/renderer/init.js @@ -16,10 +16,6 @@ require('../common/init') var globalPaths = Module.globalPaths -if (!process.env.ELECTRON_HIDE_INTERNAL_MODULES) { - globalPaths.push(path.join(__dirname, 'api')) -} - // Expose public APIs. globalPaths.push(path.join(__dirname, 'api', 'exports')) From 1e140fb32c024c83aa6966755a175f7fc70ec69a Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 28 Apr 2016 09:57:55 -0700 Subject: [PATCH 09/31] Remove ipc.js files --- filenames.gypi | 2 -- 1 file changed, 2 deletions(-) diff --git a/filenames.gypi b/filenames.gypi index 1c2139497567..f2a8615a61b6 100644 --- a/filenames.gypi +++ b/filenames.gypi @@ -18,7 +18,6 @@ 'lib/browser/api/dialog.js', 'lib/browser/api/exports/electron.js', 'lib/browser/api/global-shortcut.js', - 'lib/browser/api/ipc.js', 'lib/browser/api/ipc-main.js', 'lib/browser/api/menu.js', 'lib/browser/api/menu-item.js', @@ -58,7 +57,6 @@ 'lib/renderer/web-view/web-view-constants.js', 'lib/renderer/api/desktop-capturer.js', 'lib/renderer/api/exports/electron.js', - 'lib/renderer/api/ipc.js', 'lib/renderer/api/ipc-renderer.js', 'lib/renderer/api/remote.js', 'lib/renderer/api/screen.js', From ef801d5543eb59c59a6aa6428313367b39186209 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 28 Apr 2016 09:58:04 -0700 Subject: [PATCH 10/31] Remove .only call --- spec/api-crash-reporter-spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/api-crash-reporter-spec.js b/spec/api-crash-reporter-spec.js index 4bf02af2ef5d..b4f63fe1ef27 100644 --- a/spec/api-crash-reporter-spec.js +++ b/spec/api-crash-reporter-spec.js @@ -75,7 +75,7 @@ describe('crash-reporter module', function () { }) }) - describe.only('.start(options)', function () { + describe('.start(options)', function () { it('requires that the companyName and submitURL options be specified', function () { assert.throws(function () { crashReporter.start({ From bea232f53aae354cd0adf43ead628f60fbb7e306 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 28 Apr 2016 09:58:59 -0700 Subject: [PATCH 11/31] Update specs for internal module require --- spec/api-app-spec.js | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/spec/api-app-spec.js b/spec/api-app-spec.js index 1c20ef8e4523..d631d9ae830c 100644 --- a/spec/api-app-spec.js +++ b/spec/api-app-spec.js @@ -9,21 +9,10 @@ const app = remote.require('electron').app const BrowserWindow = remote.require('electron').BrowserWindow describe('electron module', function () { - it('allows old style require by default', function () { - require('shell') - }) - - it('can prevent exposing internal modules to require', function (done) { - const electron = require('electron') - const clipboard = require('clipboard') - assert.equal(typeof clipboard, 'object') - electron.hideInternalModules() - try { + it('prevents exposing internal modules to require', function () { + assert.throws(function () { require('clipboard') - } catch (err) { - assert.equal(err.message, "Cannot find module 'clipboard'") - done() - } + }, /Cannot find module 'clipboard'/) }) }) From 4cb620c195061a20371f2ec7f9d1a21368296937 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 28 Apr 2016 10:02:34 -0700 Subject: [PATCH 12/31] Remove support for translating hyphenated options --- atom/browser/api/atom_api_window.cc | 49 ----------------------------- 1 file changed, 49 deletions(-) diff --git a/atom/browser/api/atom_api_window.cc b/atom/browser/api/atom_api_window.cc index 2ef065bf51c9..e2eb44ff48c5 100644 --- a/atom/browser/api/atom_api_window.cc +++ b/atom/browser/api/atom_api_window.cc @@ -61,52 +61,6 @@ void OnCapturePageDone( callback.Run(gfx::Image::CreateFrom1xBitmap(bitmap)); } -// Converts min-width to minWidth, returns false if no conversion is needed. -bool TranslateOldKey(const std::string& key, std::string* new_key) { - if (key.find('-') == std::string::npos) - return false; - new_key->reserve(key.size()); - bool next_upper_case = false; - for (char c : key) { - if (c == '-') { - next_upper_case = true; - } else if (next_upper_case) { - new_key->push_back(base::ToUpperASCII(c)); - next_upper_case = false; - } else { - new_key->push_back(c); - } - } - return true; -} - -// Converts min-width to minWidth recursively in the dictionary. -void TranslateOldOptions(v8::Isolate* isolate, v8::Local options) { - auto context = isolate->GetCurrentContext(); - auto maybe_keys = options->GetOwnPropertyNames(context); - if (maybe_keys.IsEmpty()) - return; - std::vector keys; - if (!mate::ConvertFromV8(isolate, maybe_keys.ToLocalChecked(), &keys)) - return; - mate::Dictionary dict(isolate, options); - for (const auto& key : keys) { - v8::Local value; - if (!dict.Get(key, &value)) // Shouldn't happen, but guard it anyway. - continue; - // Go recursively. - v8::Local sub_options; - if (mate::ConvertFromV8(isolate, value, &sub_options)) - TranslateOldOptions(isolate, sub_options); - // Translate key. - std::string new_key; - if (TranslateOldKey(key, &new_key)) { - dict.Set(new_key, value); - dict.Delete(key); - } - } -} - // Converts binary data to Buffer. v8::Local ToBuffer(v8::Isolate* isolate, void* val, int size) { auto buffer = node::Buffer::Copy(isolate, static_cast(val), size); @@ -120,9 +74,6 @@ v8::Local ToBuffer(v8::Isolate* isolate, void* val, int size) { Window::Window(v8::Isolate* isolate, const mate::Dictionary& options) { - // Be compatible with old style field names like min-width. - TranslateOldOptions(isolate, options.GetHandle()); - // Use options.webPreferences to create WebContents. mate::Dictionary web_preferences = mate::Dictionary::CreateEmpty(isolate); options.Get(options::kWebPreferences, &web_preferences); From 58473f41abb18ce55736c5baae2f71867294fe6a Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 28 Apr 2016 10:04:39 -0700 Subject: [PATCH 13/31] Remove deprecated BrowserWindow options specs --- spec/api-browser-window-spec.js | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/spec/api-browser-window-spec.js b/spec/api-browser-window-spec.js index e76821020bdc..a8dd8a3780cc 100644 --- a/spec/api-browser-window-spec.js +++ b/spec/api-browser-window-spec.js @@ -880,24 +880,4 @@ describe('browser-window module', function () { w.loadURL(server.url) }) }) - - describe('deprecated options', function () { - it('throws a deprecation error for option keys using hyphens instead of camel case', function () { - assert.throws(function () { - return new BrowserWindow({'min-width': 500}) - }, 'min-width is deprecated. Use minWidth instead.') - }) - - it('throws a deprecation error for webPreference keys using hyphens instead of camel case', function () { - assert.throws(function () { - return new BrowserWindow({webPreferences: {'node-integration': false}}) - }, 'node-integration is deprecated. Use nodeIntegration instead.') - }) - - it('throws a deprecation error for option keys that should be set on webPreferences', function () { - assert.throws(function () { - return new BrowserWindow({zoomFactor: 1}) - }, 'options.zoomFactor is deprecated. Use options.webPreferences.zoomFactor instead.') - }) - }) }) From 7ad86a12b4c067bfd4e3aa18a5bbdf2cb12886e2 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 28 Apr 2016 10:10:47 -0700 Subject: [PATCH 14/31] Remove empty _init --- lib/browser/api/tray.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/browser/api/tray.js b/lib/browser/api/tray.js index 5142120a5695..729e430ee3fd 100644 --- a/lib/browser/api/tray.js +++ b/lib/browser/api/tray.js @@ -3,9 +3,6 @@ const Tray = process.atomBinding('tray').Tray Object.setPrototypeOf(Tray.prototype, EventEmitter.prototype) -Tray.prototype._init = function () { -} - Tray.prototype.setContextMenu = function (menu) { this._setContextMenu(menu) From 16d4c436cbc731012d55b600a7b81afc85d9eb1a Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 28 Apr 2016 10:14:42 -0700 Subject: [PATCH 15/31] Keep exporting deprecate/deprecations --- lib/common/api/exports/electron.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/common/api/exports/electron.js b/lib/common/api/exports/electron.js index 65da6c5d2b91..1e9c2d71f3b7 100644 --- a/lib/common/api/exports/electron.js +++ b/lib/common/api/exports/electron.js @@ -33,6 +33,16 @@ exports.defineProperties = function (exports) { get: function () { return require('../callbacks-registry') } + }, + deprecate: { + get: function () { + return require('../deprecate') + } + }, + deprecations: { + get: function () { + return require('../deprecations') + } } }) } From d627ead273dbaf651850985447f4bbac006457e8 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 28 Apr 2016 10:17:52 -0700 Subject: [PATCH 16/31] Remove linter errors --- lib/browser/api/app.js | 2 +- lib/common/api/crash-reporter.js | 1 - lib/common/init.js | 2 -- 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/browser/api/app.js b/lib/browser/api/app.js index f8a4d3e2913e..025b6275fd36 100644 --- a/lib/browser/api/app.js +++ b/lib/browser/api/app.js @@ -1,7 +1,7 @@ 'use strict' const electron = require('electron') -const {session, Menu} = electron +const {Menu} = electron const EventEmitter = require('events').EventEmitter const bindings = process.atomBinding('app') diff --git a/lib/common/api/crash-reporter.js b/lib/common/api/crash-reporter.js index e62c7cdf95f9..21e352e7e510 100644 --- a/lib/common/api/crash-reporter.js +++ b/lib/common/api/crash-reporter.js @@ -48,7 +48,6 @@ var CrashReporter = (function () { } if (submitURL == null) { throw new Error('submitURL is a required option to crashReporter.start') - return } start = () => { binding.start(this.productName, companyName, submitURL, autoSubmit, ignoreSystemCrashHandler, extra) diff --git a/lib/common/init.js b/lib/common/init.js index 1b90b9343441..257249f0a639 100644 --- a/lib/common/init.js +++ b/lib/common/init.js @@ -1,6 +1,4 @@ -const path = require('path') const timers = require('timers') -const Module = require('module') process.atomBinding = function (name) { try { From 814ae7b4a4ddca8d7257326f40ebe3421549300a Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 28 Apr 2016 10:21:58 -0700 Subject: [PATCH 17/31] :art: --- lib/browser/api/auto-updater.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/browser/api/auto-updater.js b/lib/browser/api/auto-updater.js index f99d3218e430..f838a26f2cea 100644 --- a/lib/browser/api/auto-updater.js +++ b/lib/browser/api/auto-updater.js @@ -1,2 +1,5 @@ -const autoUpdater = process.platform === 'win32' ? require('./auto-updater/auto-updater-win') : require('./auto-updater/auto-updater-native') -module.exports = autoUpdater +if (process.platform === 'win32') { + module.exports = require('./auto-updater/auto-updater-win') +} else { + module.exports = require('./auto-updater/auto-updater-native') +} From 30b60516feb857fbf37174ffc110cf0dd2163b36 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 28 Apr 2016 11:07:34 -0700 Subject: [PATCH 18/31] Initialize session explicitly --- lib/browser/api/app.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/browser/api/app.js b/lib/browser/api/app.js index 025b6275fd36..1a989dc35861 100644 --- a/lib/browser/api/app.js +++ b/lib/browser/api/app.js @@ -1,9 +1,11 @@ 'use strict' -const electron = require('electron') -const {Menu} = electron +const {Menu} = require('electron') const EventEmitter = require('events').EventEmitter +// Initialize session +require('electron').session + const bindings = process.atomBinding('app') const downloadItemBindings = process.atomBinding('download_item') const app = bindings.app From 722a07de86d32807dd0968ff0cf0b7bb93f88d97 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 28 Apr 2016 11:15:39 -0700 Subject: [PATCH 19/31] Add explicit call to deprecate.log --- spec/api-deprecations-spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/api-deprecations-spec.js b/spec/api-deprecations-spec.js index 375de5895fee..4d78856ebae5 100644 --- a/spec/api-deprecations-spec.js +++ b/spec/api-deprecations-spec.js @@ -14,9 +14,9 @@ describe('deprecations', function () { messages.push(message) }) - require('electron').webFrame.registerUrlSchemeAsSecure('some-scheme') + require('electron').deprecate.log('this is deprecated') - assert.deepEqual(messages, ['registerUrlSchemeAsSecure is deprecated. Use registerURLSchemeAsSecure instead.']) + assert.deepEqual(messages, ['this is deprecated']) }) it('throws an exception if no deprecation handler is specified', function () { From 0eefb282ca8a8eddacca6c55c77d1abd51cdb2b2 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 28 Apr 2016 11:17:03 -0700 Subject: [PATCH 20/31] Test no handler via call to deprecate.log --- spec/api-deprecations-spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/api-deprecations-spec.js b/spec/api-deprecations-spec.js index 4d78856ebae5..5b618ac90165 100644 --- a/spec/api-deprecations-spec.js +++ b/spec/api-deprecations-spec.js @@ -21,7 +21,7 @@ describe('deprecations', function () { it('throws an exception if no deprecation handler is specified', function () { assert.throws(function () { - require('electron').webFrame.registerUrlSchemeAsPrivileged('some-scheme') - }, 'registerUrlSchemeAsPrivileged is deprecated. Use registerURLSchemeAsPrivileged instead.') + require('electron').deprecate.log('this is deprecated') + }, /this is deprecated/) }) }) From 4d6b95aa525f075c4548fb48768b36af1eeb62f3 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 28 Apr 2016 11:21:52 -0700 Subject: [PATCH 21/31] Tweak spec description --- spec/api-app-spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/api-app-spec.js b/spec/api-app-spec.js index d631d9ae830c..b78700fae9ee 100644 --- a/spec/api-app-spec.js +++ b/spec/api-app-spec.js @@ -9,7 +9,7 @@ const app = remote.require('electron').app const BrowserWindow = remote.require('electron').BrowserWindow describe('electron module', function () { - it('prevents exposing internal modules to require', function () { + it('does not expose internal modules to require', function () { assert.throws(function () { require('clipboard') }, /Cannot find module 'clipboard'/) From 609f5dcaaf8f1c265f3a727b354d4fe25bcc0d81 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 28 Apr 2016 11:31:00 -0700 Subject: [PATCH 22/31] Update read path to something that exists --- spec/asar-spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/asar-spec.js b/spec/asar-spec.js index a0cb7b4aabd2..f9c4e98ae8fa 100644 --- a/spec/asar-spec.js +++ b/spec/asar-spec.js @@ -17,7 +17,7 @@ describe('asar package', function () { it('does not leak fd', function () { var readCalls = 1 while (readCalls <= 10000) { - fs.readFileSync(path.join(process.resourcesPath, 'electron.asar', 'renderer', 'api', 'ipc.js')) + fs.readFileSync(path.join(process.resourcesPath, 'electron.asar', 'renderer', 'api', 'ipc-renderer.js')) readCalls++ } }) From 14661819c25efee1d343bf9ac0c8a8037658d255 Mon Sep 17 00:00:00 2001 From: deepak1556 Date: Mon, 2 May 2016 13:15:57 +0530 Subject: [PATCH 23/31] move session wrapper to webcontents --- lib/browser/api/app.js | 3 --- lib/browser/api/session.js | 8 -------- lib/browser/api/web-contents.js | 7 +++++++ 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/lib/browser/api/app.js b/lib/browser/api/app.js index 1a989dc35861..6ddac05efa99 100644 --- a/lib/browser/api/app.js +++ b/lib/browser/api/app.js @@ -3,9 +3,6 @@ const {Menu} = require('electron') const EventEmitter = require('events').EventEmitter -// Initialize session -require('electron').session - const bindings = process.atomBinding('app') const downloadItemBindings = process.atomBinding('download_item') const app = bindings.app diff --git a/lib/browser/api/session.js b/lib/browser/api/session.js index 47e00bd0462f..9c42f3645603 100644 --- a/lib/browser/api/session.js +++ b/lib/browser/api/session.js @@ -1,4 +1,3 @@ -const EventEmitter = require('events').EventEmitter const bindings = process.atomBinding('session') const PERSIST_PREFIX = 'persist:' @@ -24,10 +23,3 @@ Object.defineProperty(exports, 'defaultSession', { return bindings.fromPartition('', false) } }) - -var wrapSession = function (session) { - // session is an EventEmitter. - Object.setPrototypeOf(session, EventEmitter.prototype) -} - -bindings._setWrapSession(wrapSession) diff --git a/lib/browser/api/web-contents.js b/lib/browser/api/web-contents.js index 0ccb51b19b09..c706954b64bd 100644 --- a/lib/browser/api/web-contents.js +++ b/lib/browser/api/web-contents.js @@ -7,6 +7,7 @@ const Menu = require('electron').Menu const binding = process.atomBinding('web_contents') const debuggerBinding = process.atomBinding('debugger') +const sessionBinding = process.atomBinding('session') let nextId = 0 @@ -211,8 +212,14 @@ let wrapDebugger = function (webContentsDebugger) { Object.setPrototypeOf(webContentsDebugger, EventEmitter.prototype) } +var wrapSession = function (session) { + // session is an EventEmitter. + Object.setPrototypeOf(session, EventEmitter.prototype) +} + binding._setWrapWebContents(wrapWebContents) debuggerBinding._setWrapDebugger(wrapDebugger) +sessionBinding._setWrapSession(wrapSession) module.exports.create = function (options) { if (options == null) { From f2d8eadf4e654a42f20bdbd569d9f399a21332cf Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Mon, 2 May 2016 09:31:42 -0700 Subject: [PATCH 24/31] Remove deprecated prototol APIs --- lib/browser/api/protocol.js | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/lib/browser/api/protocol.js b/lib/browser/api/protocol.js index dac679f43e44..8e89055b73ad 100644 --- a/lib/browser/api/protocol.js +++ b/lib/browser/api/protocol.js @@ -4,28 +4,4 @@ if (!app.isReady()) { throw new Error('Can not initialize protocol module before app is ready') } -const protocol = process.atomBinding('protocol').protocol - -// Warn about removed APIs. -var logAndThrow = function (callback, message) { - console.error(message) - if (callback) { - return callback(new Error(message)) - } else { - throw new Error(message) - } -} - -protocol.registerProtocol = function (scheme, handler, callback) { - return logAndThrow(callback, 'registerProtocol API has been replaced by the register[File/Http/Buffer/String]Protocol API family, please switch to the new APIs.') -} - -protocol.isHandledProtocol = function (scheme, callback) { - return logAndThrow(callback, 'isHandledProtocol API has been replaced by isProtocolHandled.') -} - -protocol.interceptProtocol = function (scheme, handler, callback) { - return logAndThrow(callback, 'interceptProtocol API has been replaced by the intercept[File/Http/Buffer/String]Protocol API family, please switch to the new APIs.') -} - -module.exports = protocol +module.exports = process.atomBinding('protocol').protocol From 56cd57872cd5f6f7198b38201428845ae8b554ba Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Mon, 2 May 2016 09:32:52 -0700 Subject: [PATCH 25/31] Remove BrowserWindow events now on WebContents --- lib/browser/api/browser-window.js | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/lib/browser/api/browser-window.js b/lib/browser/api/browser-window.js index e433580ba638..6da2fdadb46a 100644 --- a/lib/browser/api/browser-window.js +++ b/lib/browser/api/browser-window.js @@ -95,17 +95,6 @@ BrowserWindow.prototype._init = function () { // Notify the creation of the window. app.emit('browser-window-created', {}, this) - // Be compatible with old APIs. - this.webContents.on('devtools-focused', () => { - this.emit('devtools-focused') - }) - this.webContents.on('devtools-opened', () => { - this.emit('devtools-opened') - }) - this.webContents.on('devtools-closed', () => { - this.emit('devtools-closed') - }) - Object.defineProperty(this, 'devToolsWebContents', { enumerable: true, configurable: false, From 76853801051be1dfbe94cb855567b5c901f9f12d Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Mon, 2 May 2016 16:52:59 -0700 Subject: [PATCH 26/31] Remove crashed event forwarding --- lib/browser/api/browser-window.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/lib/browser/api/browser-window.js b/lib/browser/api/browser-window.js index 6da2fdadb46a..1cfd84bebc56 100644 --- a/lib/browser/api/browser-window.js +++ b/lib/browser/api/browser-window.js @@ -43,11 +43,6 @@ BrowserWindow.prototype._init = function () { } }) - // Forward the crashed event. - this.webContents.on('crashed', () => { - this.emit('crashed') - }) - // Change window title to page title. this.webContents.on('page-title-updated', (event, title) => { // The page-title-updated event is not emitted immediately (see #3645), so From 446da677b56f19ce3e480652551ce293c5c45b52 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 3 May 2016 09:10:31 +0900 Subject: [PATCH 27/31] Remove NativeImage.toDataUrl --- atom/common/api/atom_api_native_image.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/atom/common/api/atom_api_native_image.cc b/atom/common/api/atom_api_native_image.cc index 1c90fe7080fb..e440f9c518bd 100644 --- a/atom/common/api/atom_api_native_image.cc +++ b/atom/common/api/atom_api_native_image.cc @@ -318,7 +318,6 @@ void NativeImage::BuildPrototype( .SetMethod("toJpeg", &NativeImage::ToJPEG) .SetMethod("getNativeHandle", &NativeImage::GetNativeHandle) .SetMethod("toDataURL", &NativeImage::ToDataURL) - .SetMethod("toDataUrl", &NativeImage::ToDataURL) // deprecated. .SetMethod("isEmpty", &NativeImage::IsEmpty) .SetMethod("getSize", &NativeImage::GetSize) .SetMethod("setTemplateImage", &NativeImage::SetTemplateImage) From fd432ddbc988fd489fc283e479ea9406dbd132db Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 3 May 2016 09:16:39 +0900 Subject: [PATCH 28/31] Fix the toDataUrl call in desktopCapturer --- lib/browser/desktop-capturer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/browser/desktop-capturer.js b/lib/browser/desktop-capturer.js index 5e8ad3e7328c..21993a9fd71d 100644 --- a/lib/browser/desktop-capturer.js +++ b/lib/browser/desktop-capturer.js @@ -45,7 +45,7 @@ desktopCapturer.emit = function (event, name, sources) { results.push({ id: source.id, name: source.name, - thumbnail: source.thumbnail.toDataUrl() + thumbnail: source.thumbnail.toDataURL() }) } return results From 28f1aef7b4ecae339ef2d59a959906217fd2255c Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Wed, 4 May 2016 18:17:27 +0900 Subject: [PATCH 29/31] Remove ELECTRON_HIDE_INTERNAL_MODULES in docs --- docs/api/environment-variables.md | 4 ---- docs/api/synopsis.md | 19 ------------------- 2 files changed, 23 deletions(-) diff --git a/docs/api/environment-variables.md b/docs/api/environment-variables.md index 7339661b09fe..e01afff5fa76 100644 --- a/docs/api/environment-variables.md +++ b/docs/api/environment-variables.md @@ -52,7 +52,3 @@ Don't attach to current console session. ## `ELECTRON_FORCE_WINDOW_MENU_BAR` _Linux_ Don't use global menu bar on Linux. - -## `ELECTRON_HIDE_INTERNAL_MODULES` - -Turns off compatibility mode for old built-in modules like `require('ipc')`. diff --git a/docs/api/synopsis.md b/docs/api/synopsis.md index a2aa58f57f17..fc2ce943932c 100644 --- a/docs/api/synopsis.md +++ b/docs/api/synopsis.md @@ -61,25 +61,6 @@ const {app, BrowserWindow} = require('electron') However if you are using plain JavaScript, you have to wait until Chrome fully supports ES6. -## Disable old styles of using built-in modules - -Before v0.35.0, all built-in modules have to be used in the form of -`require('module-name')`, though it has [many disadvantages][issue-387], we are -still supporting it for compatibility with old apps. - -To disable the old styles completely, you can set the -`ELECTRON_HIDE_INTERNAL_MODULES` environment variable: - -```javascript -process.env.ELECTRON_HIDE_INTERNAL_MODULES = 'true' -``` - -Or call the `hideInternalModules` API: - -```javascript -require('electron').hideInternalModules() -``` - [gui]: https://en.wikipedia.org/wiki/Graphical_user_interface [destructuring-assignment]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment [issue-387]: https://github.com/electron/electron/issues/387 From ef459c7676ea0fe45c5e5caf34e35e4dd9f1a59f Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Fri, 6 May 2016 09:06:03 -0700 Subject: [PATCH 30/31] Remove support for options now on webPreferences --- atom/browser/api/atom_api_window.cc | 9 --------- 1 file changed, 9 deletions(-) diff --git a/atom/browser/api/atom_api_window.cc b/atom/browser/api/atom_api_window.cc index e2eb44ff48c5..aba453e50b9c 100644 --- a/atom/browser/api/atom_api_window.cc +++ b/atom/browser/api/atom_api_window.cc @@ -78,15 +78,6 @@ Window::Window(v8::Isolate* isolate, const mate::Dictionary& options) { mate::Dictionary web_preferences = mate::Dictionary::CreateEmpty(isolate); options.Get(options::kWebPreferences, &web_preferences); - // Be compatible with old options which are now in web_preferences. - v8::Local value; - if (options.Get(options::kNodeIntegration, &value)) - web_preferences.Set(options::kNodeIntegration, value); - if (options.Get(options::kPreloadScript, &value)) - web_preferences.Set(options::kPreloadScript, value); - if (options.Get(options::kZoomFactor, &value)) - web_preferences.Set(options::kZoomFactor, value); - // Copy the backgroundColor to webContents. if (options.Get(options::kBackgroundColor, &value)) web_preferences.Set(options::kBackgroundColor, value); From 767c2357080bda8c01dd62b47c4cf03d97eb8921 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sat, 7 May 2016 10:38:41 +0900 Subject: [PATCH 31/31] Fix compilation error --- atom/browser/api/atom_api_window.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/atom/browser/api/atom_api_window.cc b/atom/browser/api/atom_api_window.cc index aba453e50b9c..399b4d36d2ec 100644 --- a/atom/browser/api/atom_api_window.cc +++ b/atom/browser/api/atom_api_window.cc @@ -79,6 +79,7 @@ Window::Window(v8::Isolate* isolate, const mate::Dictionary& options) { options.Get(options::kWebPreferences, &web_preferences); // Copy the backgroundColor to webContents. + v8::Local value; if (options.Get(options::kBackgroundColor, &value)) web_preferences.Set(options::kBackgroundColor, value);