From 167f11e797227283effc765ef064ac5249367250 Mon Sep 17 00:00:00 2001 From: Robo Date: Sat, 21 Nov 2015 02:20:51 +0530 Subject: [PATCH 01/18] protocol: handle http responses with no content --- atom/browser/net/url_request_fetch_job.cc | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/atom/browser/net/url_request_fetch_job.cc b/atom/browser/net/url_request_fetch_job.cc index a8a16e286b30..24a72226606e 100644 --- a/atom/browser/net/url_request_fetch_job.cc +++ b/atom/browser/net/url_request_fetch_job.cc @@ -181,6 +181,11 @@ void URLRequestFetchJob::Kill() { bool URLRequestFetchJob::ReadRawData(net::IOBuffer* dest, int dest_size, int* bytes_read) { + if (GetResponseCode() == 204) { + *bytes_read = 0; + request()->set_received_response_content_length(prefilter_bytes_read()); + return true; + } pending_buffer_ = dest; pending_buffer_size_ = dest_size; SetStatus(net::URLRequestStatus(net::URLRequestStatus::IO_PENDING, 0)); @@ -207,6 +212,14 @@ int URLRequestFetchJob::GetResponseCode() const { } void URLRequestFetchJob::OnURLFetchComplete(const net::URLFetcher* source) { + if (!response_info_) { + // Since we notify header completion only after first write there will be + // no response object constructed for http respones with no content 204. + // We notify header completion here. + HeadersCompleted(); + return; + } + pending_buffer_ = nullptr; pending_buffer_size_ = 0; NotifyDone(fetcher_->GetStatus()); From baab0486f05d447bb93aaaef663ff4ba3e13d1be Mon Sep 17 00:00:00 2001 From: Eran Tiktin Date: Sun, 22 Nov 2015 23:44:20 +0200 Subject: [PATCH 02/18] Add documentation for --proxy-bypass-list Depends on atom/brightray#179 --- docs/api/chrome-command-line-switches.md | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/docs/api/chrome-command-line-switches.md b/docs/api/chrome-command-line-switches.md index c1adf3c425f8..ad7fafbe14f5 100644 --- a/docs/api/chrome-command-line-switches.md +++ b/docs/api/chrome-command-line-switches.md @@ -1,9 +1,9 @@ # Supported Chrome command line switches -This page lists the command line switches used by the Chrome browser that are also supported by -Electron. You can use [app.commandLine.appendSwitch][append-switch] to append -them in your app's main script before the [ready][ready] event of [app][app] -module is emitted: +This page lists the command line switches used by the Chrome browser that are +also supported by Electron. You can use +[app.commandLine.appendSwitch][append-switch] to append them in your app's main +script before the [ready][ready] event of [app][app] module is emitted: ```javascript const app = require('electron').app; @@ -47,6 +47,20 @@ only affects requests with HTTP protocol, including HTTPS and WebSocket requests. It is also noteworthy that not all proxy servers support HTTPS and WebSocket requests. +## --proxy-bypass-list=`hosts` + +Instructs Electron to bypass the proxy server for the given semi-colon-separated +list of hosts. This flag has an effect only if used in tandem with +`--proxy-server`. + +For example: + +`app.commandLine.appendSwitch('proxy-bypass-list', ';*.google.com;*foo.com;1.2.3.4:5678')` + +Will use the proxy server for all hosts except for local addresses (localhost, +127.0.0.1 etc.), google.com subdomains, hosts that contain the suffix foo.com +and anything at 1.2.3.4:5678. + ## --proxy-pac-url=`url` Uses the PAC script at the specified `url`. From a4a14a5f0ef0ff3c1423720005f461a42bf4cd25 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 24 Nov 2015 15:14:48 +0800 Subject: [PATCH 03/18] Update brightray for #3458 --- vendor/brightray | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/brightray b/vendor/brightray index d4fab33427eb..77eca8fcbc18 160000 --- a/vendor/brightray +++ b/vendor/brightray @@ -1 +1 @@ -Subproject commit d4fab33427eb728a553896527f1931887ce6d9d9 +Subproject commit 77eca8fcbc18d2244b356045295f4472492cedb7 From 24e892dd17e51fbc984b828fcd9d2c91ee4cfeae Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 24 Nov 2015 18:39:16 +0800 Subject: [PATCH 04/18] Update brightray for #3550 --- vendor/brightray | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/brightray b/vendor/brightray index 77eca8fcbc18..8893a279435a 160000 --- a/vendor/brightray +++ b/vendor/brightray @@ -1 +1 @@ -Subproject commit 77eca8fcbc18d2244b356045295f4472492cedb7 +Subproject commit 8893a279435af82e3c2d4b4afe4d9d069f8a2820 From b9fd095b046856f07f58adbbf1dbee074b9bc0d7 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 24 Nov 2015 18:40:50 +0800 Subject: [PATCH 05/18] docs: Mark code blocks --- docs/api/chrome-command-line-switches.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/docs/api/chrome-command-line-switches.md b/docs/api/chrome-command-line-switches.md index ad7fafbe14f5..edeba0c9ad1b 100644 --- a/docs/api/chrome-command-line-switches.md +++ b/docs/api/chrome-command-line-switches.md @@ -55,11 +55,13 @@ list of hosts. This flag has an effect only if used in tandem with For example: -`app.commandLine.appendSwitch('proxy-bypass-list', ';*.google.com;*foo.com;1.2.3.4:5678')` +```javascript +app.commandLine.appendSwitch('proxy-bypass-list', ';*.google.com;*foo.com;1.2.3.4:5678')` +``` -Will use the proxy server for all hosts except for local addresses (localhost, -127.0.0.1 etc.), google.com subdomains, hosts that contain the suffix foo.com -and anything at 1.2.3.4:5678. +Will use the proxy server for all hosts except for local addresses (`localhost`, +`127.0.0.1` etc.), `google.com` subdomains, hosts that contain the suffix +`foo.com` and anything at `1.2.3.4:5678`. ## --proxy-pac-url=`url` From 4acbd3e03f95d1a908d6d2a191d150f01def37a4 Mon Sep 17 00:00:00 2001 From: laiso Date: Tue, 24 Nov 2015 21:02:14 +0900 Subject: [PATCH 06/18] s/loadUrl/loadURL/g in docs-translations/ --- docs-translations/es/api/synopsis.md | 2 +- docs-translations/es/tutorial/application-packaging.md | 2 +- docs-translations/es/tutorial/online-offline-events.md | 4 ++-- docs-translations/es/tutorial/using-pepper-flash-plugin.md | 2 +- docs-translations/pt-BR/tutorial/application-packaging.md | 4 ++-- docs-translations/pt-BR/tutorial/online-offline-events.md | 4 ++-- .../pt-BR/tutorial/using-pepper-flash-plugin.md | 2 +- docs-translations/zh-CN/tutorial/online-offline-events.md | 6 +++--- docs-translations/zh-TW/api/synopsis.md | 2 +- docs-translations/zh-TW/tutorial/online-offline-events.md | 4 ++-- 10 files changed, 16 insertions(+), 16 deletions(-) diff --git a/docs-translations/es/api/synopsis.md b/docs-translations/es/api/synopsis.md index eb4fcb39f636..534fafcf2f7c 100644 --- a/docs-translations/es/api/synopsis.md +++ b/docs-translations/es/api/synopsis.md @@ -25,7 +25,7 @@ var window = null; app.on('ready', function() { window = new BrowserWindow({width: 800, height: 600}); - window.loadUrl('https://github.com'); + window.loadURL('https://github.com'); }); ``` diff --git a/docs-translations/es/tutorial/application-packaging.md b/docs-translations/es/tutorial/application-packaging.md index 56698c1aaecb..c0cca7ecd916 100644 --- a/docs-translations/es/tutorial/application-packaging.md +++ b/docs-translations/es/tutorial/application-packaging.md @@ -70,7 +70,7 @@ También puedes mostrar una página web contenida en un `asar` utilizando `Brows ```javascript var BrowserWindow = require('browser-window'); var win = new BrowserWindow({width: 800, height: 600}); -win.loadUrl('file:///path/to/example.asar/static/index.html'); +win.loadURL('file:///path/to/example.asar/static/index.html'); ``` ### API Web diff --git a/docs-translations/es/tutorial/online-offline-events.md b/docs-translations/es/tutorial/online-offline-events.md index 0e43f9b16109..450702e2f84c 100644 --- a/docs-translations/es/tutorial/online-offline-events.md +++ b/docs-translations/es/tutorial/online-offline-events.md @@ -12,7 +12,7 @@ var onlineStatusWindow; app.on('ready', function() { onlineStatusWindow = new BrowserWindow({ width: 0, height: 0, show: false }); - onlineStatusWindow.loadUrl('file://' + __dirname + '/online-status.html'); + onlineStatusWindow.loadURL('file://' + __dirname + '/online-status.html'); }); ``` @@ -50,7 +50,7 @@ var onlineStatusWindow; app.on('ready', function() { onlineStatusWindow = new BrowserWindow({ width: 0, height: 0, show: false }); - onlineStatusWindow.loadUrl('file://' + __dirname + '/online-status.html'); + onlineStatusWindow.loadURL('file://' + __dirname + '/online-status.html'); }); ipc.on('online-status-changed', function(event, status) { diff --git a/docs-translations/es/tutorial/using-pepper-flash-plugin.md b/docs-translations/es/tutorial/using-pepper-flash-plugin.md index 53d2d024c1d1..4e45524fb6af 100644 --- a/docs-translations/es/tutorial/using-pepper-flash-plugin.md +++ b/docs-translations/es/tutorial/using-pepper-flash-plugin.md @@ -46,7 +46,7 @@ app.on('ready', function() { 'plugins': true } }); - mainWindow.loadUrl('file://' + __dirname + '/index.html'); + mainWindow.loadURL('file://' + __dirname + '/index.html'); // Something else }); ``` diff --git a/docs-translations/pt-BR/tutorial/application-packaging.md b/docs-translations/pt-BR/tutorial/application-packaging.md index f55cbb2f7d64..209188b2f5f9 100644 --- a/docs-translations/pt-BR/tutorial/application-packaging.md +++ b/docs-translations/pt-BR/tutorial/application-packaging.md @@ -71,7 +71,7 @@ Você também pode renderizar uma página web apartir de um arquivo `asar` utili ```javascript var BrowserWindow = require('browser-window'); var win = new BrowserWindow({width: 800, height: 600}); -win.loadUrl('file:///path/to/example.asar/static/index.html'); +win.loadURL('file:///path/to/example.asar/static/index.html'); ``` ### API Web @@ -155,4 +155,4 @@ Depois de executar o comando, além do `app.asar`, há também `app.asar.unpacked` pasta gerada que contém os arquivos descompactados, você deve copiá-lo juntamente com `app.asar` quando enviá-lo para os usuários. -Mais informações no repositório [asar](https://github.com/atom/asar) \ No newline at end of file +Mais informações no repositório [asar](https://github.com/atom/asar) diff --git a/docs-translations/pt-BR/tutorial/online-offline-events.md b/docs-translations/pt-BR/tutorial/online-offline-events.md index 294a62e7a81c..8cdc1a6647e5 100644 --- a/docs-translations/pt-BR/tutorial/online-offline-events.md +++ b/docs-translations/pt-BR/tutorial/online-offline-events.md @@ -13,7 +13,7 @@ var onlineStatusWindow; app.on('ready', function() { onlineStatusWindow = new BrowserWindow({ width: 0, height: 0, show: false }); - onlineStatusWindow.loadUrl('file://' + __dirname + '/online-status.html'); + onlineStatusWindow.loadURL('file://' + __dirname + '/online-status.html'); }); ``` @@ -53,7 +53,7 @@ var onlineStatusWindow; app.on('ready', function() { onlineStatusWindow = new BrowserWindow({ width: 0, height: 0, show: false }); - onlineStatusWindow.loadUrl('file://' + __dirname + '/online-status.html'); + onlineStatusWindow.loadURL('file://' + __dirname + '/online-status.html'); }); ipc.on('online-status-changed', function(event, status) { diff --git a/docs-translations/pt-BR/tutorial/using-pepper-flash-plugin.md b/docs-translations/pt-BR/tutorial/using-pepper-flash-plugin.md index dfcca01a5c7e..e5222ba0772d 100644 --- a/docs-translations/pt-BR/tutorial/using-pepper-flash-plugin.md +++ b/docs-translations/pt-BR/tutorial/using-pepper-flash-plugin.md @@ -54,7 +54,7 @@ app.on('ready', function() { 'plugins': true } }); - mainWindow.loadUrl('file://' + __dirname + '/index.html'); + mainWindow.loadURL('file://' + __dirname + '/index.html'); // Algo mais }); ``` diff --git a/docs-translations/zh-CN/tutorial/online-offline-events.md b/docs-translations/zh-CN/tutorial/online-offline-events.md index de292490f0be..764b81aa5d2f 100644 --- a/docs-translations/zh-CN/tutorial/online-offline-events.md +++ b/docs-translations/zh-CN/tutorial/online-offline-events.md @@ -9,7 +9,7 @@ var onlineStatusWindow; app.on('ready', function() { onlineStatusWindow = new BrowserWindow({ width: 0, height: 0, show: false }); - onlineStatusWindow.loadUrl('file://' + __dirname + '/online-status.html'); + onlineStatusWindow.loadURL('file://' + __dirname + '/online-status.html'); }); ```` @@ -43,7 +43,7 @@ var onlineStatusWindow; app.on('ready', function() { onlineStatusWindow = new BrowserWindow({ width: 0, height: 0, show: false }); - onlineStatusWindow.loadUrl('file://' + __dirname + '/online-status.html'); + onlineStatusWindow.loadURL('file://' + __dirname + '/online-status.html'); }); ipc.on('online-status-changed', function(event, status) { @@ -69,4 +69,4 @@ ipc.on('online-status-changed', function(event, status) { -```` \ No newline at end of file +```` diff --git a/docs-translations/zh-TW/api/synopsis.md b/docs-translations/zh-TW/api/synopsis.md index 484f5e353847..e28d1fd8cb0d 100644 --- a/docs-translations/zh-TW/api/synopsis.md +++ b/docs-translations/zh-TW/api/synopsis.md @@ -20,7 +20,7 @@ var window = null; app.on('ready', function() { window = new BrowserWindow({width: 800, height: 600}); - window.loadUrl('https://github.com'); + window.loadURL('https://github.com'); }); ``` diff --git a/docs-translations/zh-TW/tutorial/online-offline-events.md b/docs-translations/zh-TW/tutorial/online-offline-events.md index a4366f88a03a..234a02710eb7 100644 --- a/docs-translations/zh-TW/tutorial/online-offline-events.md +++ b/docs-translations/zh-TW/tutorial/online-offline-events.md @@ -12,7 +12,7 @@ var onlineStatusWindow; app.on('ready', function() { onlineStatusWindow = new BrowserWindow({ width: 0, height: 0, show: false }); - onlineStatusWindow.loadUrl('file://' + __dirname + '/online-status.html'); + onlineStatusWindow.loadURL('file://' + __dirname + '/online-status.html'); }); ``` @@ -50,7 +50,7 @@ var onlineStatusWindow; app.on('ready', function() { onlineStatusWindow = new BrowserWindow({ width: 0, height: 0, show: false }); - onlineStatusWindow.loadUrl('file://' + __dirname + '/online-status.html'); + onlineStatusWindow.loadURL('file://' + __dirname + '/online-status.html'); }); ipc.on('online-status-changed', function(event, status) { From 0f5a3baff4f6d1bcfb1ff9efbb05eff9d5e14ebc Mon Sep 17 00:00:00 2001 From: Ryan Prichard Date: Tue, 24 Nov 2015 16:49:52 -0600 Subject: [PATCH 07/18] Fix https://github.com/atom/electron/issues/3565 by adding a typeof --- atom/browser/lib/rpc-server.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/atom/browser/lib/rpc-server.coffee b/atom/browser/lib/rpc-server.coffee index ce63d9189664..d9b1047bc807 100644 --- a/atom/browser/lib/rpc-server.coffee +++ b/atom/browser/lib/rpc-server.coffee @@ -107,7 +107,7 @@ unwrapArgs = (sender, args) -> # style function and the caller didn't pass a callback. callFunction = (event, func, caller, args) -> funcMarkedAsync = v8Util.getHiddenValue(func, 'asynchronous') - funcPassedCallback = args[args.length - 1] is 'function' + funcPassedCallback = typeof args[args.length - 1] is 'function' try if funcMarkedAsync and not funcPassedCallback From 789380dfad09ca59950bb8228f3edb3ac5dc039d Mon Sep 17 00:00:00 2001 From: Paul Betts Date: Wed, 25 Nov 2015 15:54:30 -0800 Subject: [PATCH 08/18] Ensure calling webview.send will not block the renderer When the browser process is busy, calling webview.send (a method that appears on its face to be non-blocking) will actually block, because most webview methods are remoted to a guest view instance in the browser. Instead, define a few methods which will instead send its call over an async IPC message. --- atom/browser/lib/rpc-server.coffee | 8 ++++++++ atom/renderer/lib/web-view/web-view.coffee | 24 +++++++++++++++------- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/atom/browser/lib/rpc-server.coffee b/atom/browser/lib/rpc-server.coffee index ce63d9189664..8a67d2112ece 100644 --- a/atom/browser/lib/rpc-server.coffee +++ b/atom/browser/lib/rpc-server.coffee @@ -221,3 +221,11 @@ ipcMain.on 'ATOM_BROWSER_GUEST_WEB_CONTENTS', (event, guestInstanceId) -> ipcMain.on 'ATOM_BROWSER_LIST_MODULES', (event) -> event.returnValue = (name for name of electron) + +ipcMain.on 'ATOM_BROWSER_ASYNC_CALL_TO_GUEST_VIEW', (event, guestInstanceId, method, args...) -> + try + guestViewManager = require './guest-view-manager' + guest = guestViewManager.getGuest(guestInstanceId) + guest[method].apply(guest, args) + catch e + event.returnValue = exceptionToMeta e diff --git a/atom/renderer/lib/web-view/web-view.coffee b/atom/renderer/lib/web-view/web-view.coffee index 5e3f7d6bae56..720e6e84c5d4 100644 --- a/atom/renderer/lib/web-view/web-view.coffee +++ b/atom/renderer/lib/web-view/web-view.coffee @@ -1,4 +1,4 @@ -{deprecate, webFrame, remote} = require 'electron' +{deprecate, webFrame, remote, ipcRenderer} = require 'electron' v8Util = process.atomBinding 'v8_util' guestViewInternal = require './guest-view-internal' @@ -270,8 +270,6 @@ registerWebViewElement = -> 'isCrashed' 'setUserAgent' 'getUserAgent' - 'executeJavaScript' - 'insertCSS' 'openDevTools' 'closeDevTools' 'isDevToolsOpened' @@ -289,20 +287,32 @@ registerWebViewElement = -> 'unselect' 'replace' 'replaceMisspelling' - 'send' 'getId' 'inspectServiceWorker' 'print' 'printToPDF' - 'sendInputEvent' + ] + + nonblockMethods = [ + 'send', + 'sendInputEvent', + 'executeJavaScript', + 'insertCSS' ] # Forward proto.foo* method calls to WebViewImpl.foo*. - createHandler = (m) -> + createBlockHandler = (m) -> (args...) -> internal = v8Util.getHiddenValue this, 'internal' internal.webContents[m] args... - proto[m] = createHandler m for m in methods + proto[m] = createBlockHandler m for m in methods + + createNonBlockHandler = (m) -> + (args...) -> + internal = v8Util.getHiddenValue this, 'internal' + ipcRenderer.send('ATOM_BROWSER_ASYNC_CALL_TO_GUEST_VIEW', internal.guestInstanceId, m, args...) + + proto[m] = createNonBlockHandler m for m in nonblockMethods # Deprecated. deprecate.rename proto, 'getUrl', 'getURL' From 9c62be8fc998856fb6f5dbf032f85cacd3818659 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 26 Nov 2015 11:06:56 +0800 Subject: [PATCH 09/18] Improve the deprecation notice for ipc module Close #3577. --- atom/browser/api/lib/ipc.coffee | 2 +- atom/renderer/api/lib/ipc.coffee | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/atom/browser/api/lib/ipc.coffee b/atom/browser/api/lib/ipc.coffee index 8019a385dd90..018cb6bb0437 100644 --- a/atom/browser/api/lib/ipc.coffee +++ b/atom/browser/api/lib/ipc.coffee @@ -1,6 +1,6 @@ {deprecate, ipcMain} = require 'electron' # This module is deprecated, we mirror everything from ipcMain. -deprecate.warn 'ipc module', 'ipcMain module' +deprecate.warn 'ipc module', 'require("electron").ipcMain' module.exports = ipcMain diff --git a/atom/renderer/api/lib/ipc.coffee b/atom/renderer/api/lib/ipc.coffee index b0e951d70e48..edd7d29b6f06 100644 --- a/atom/renderer/api/lib/ipc.coffee +++ b/atom/renderer/api/lib/ipc.coffee @@ -2,7 +2,7 @@ {EventEmitter} = require 'events' # This module is deprecated, we mirror everything from ipcRenderer. -deprecate.warn 'ipc module', 'ipcRenderer module' +deprecate.warn 'ipc module', 'require("electron").ipcRenderer' # Routes events of ipcRenderer. ipc = new EventEmitter From 6c1878d15b8c34f1441565ebacaaf34247276b30 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 26 Nov 2015 13:55:59 +0800 Subject: [PATCH 10/18] mac: Clears the delegate when window is going to be closed Since EL Capitan it is possible that the methods of delegate would get called after the window has been closed. Refs atom/atom#9584. --- atom/browser/native_window_mac.mm | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/atom/browser/native_window_mac.mm b/atom/browser/native_window_mac.mm index 7959eb04f55b..42894c107de4 100644 --- a/atom/browser/native_window_mac.mm +++ b/atom/browser/native_window_mac.mm @@ -192,6 +192,11 @@ bool ScopedDisableResize::disable_resize_ = false; - (void)windowWillClose:(NSNotification*)notification { shell_->NotifyWindowClosed(); + + // Clears the delegate when window is going to be closed, since EL Capitan it + // is possible that the methods of delegate would get called after the window + // has been closed. + [shell_->GetNativeWindow() setDelegate:nil]; } - (BOOL)windowShouldClose:(id)window { From b0d4aa211df8778d97047268c3e86e576adc7d39 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 26 Nov 2015 13:57:48 +0800 Subject: [PATCH 11/18] Fix compatibility with activate-with-no-open-windows event --- atom/browser/api/lib/app.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/atom/browser/api/lib/app.coffee b/atom/browser/api/lib/app.coffee index a2fdb847e1c5..4d1803a0296f 100644 --- a/atom/browser/api/lib/app.coffee +++ b/atom/browser/api/lib/app.coffee @@ -54,7 +54,7 @@ deprecate.event app, 'finish-launching', 'ready', -> setImmediate => # give default app a chance to setup default menu. @emit 'finish-launching' deprecate.event app, 'activate-with-no-open-windows', 'activate', (event, hasVisibleWindows) -> - @emit 'activate-with-no-open-windows' if not hasVisibleWindows + @emit 'activate-with-no-open-windows', event if not hasVisibleWindows deprecate.event app, 'select-certificate', 'select-client-certificate' # Wrappers for native classes. From fe4638ef332295e5a8b9e3b901060c37e2a96627 Mon Sep 17 00:00:00 2001 From: Vincent Quagliaro Date: Thu, 26 Nov 2015 09:05:02 +0100 Subject: [PATCH 12/18] :memo: open-file and open-url events are only available on OS X --- docs/api/app.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/api/app.md b/docs/api/app.md index 00aade7c54ab..cf4284586d1d 100644 --- a/docs/api/app.md +++ b/docs/api/app.md @@ -66,7 +66,7 @@ the `will-quit` and `window-all-closed` events. Emitted when the application is quitting. -### Event: 'open-file' +### Event: 'open-file' _OS X_ Returns: @@ -82,7 +82,9 @@ handle this case (even before the `ready` event is emitted). You should call `event.preventDefault()` if you want to handle this event. -### Event: 'open-url' +On Windows, you have to parse `process.argv` to get the filepath. + +### Event: 'open-url' _OS X_ Returns: From 5ee9e6144560294eaf6a2451e67f906ea4821e53 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 26 Nov 2015 19:10:43 +0800 Subject: [PATCH 13/18] Update brightray for #1369 --- vendor/brightray | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/brightray b/vendor/brightray index 8893a279435a..57842edb817c 160000 --- a/vendor/brightray +++ b/vendor/brightray @@ -1 +1 @@ -Subproject commit 8893a279435af82e3c2d4b4afe4d9d069f8a2820 +Subproject commit 57842edb817cc1ae38a02fd7f266dd6aa3afbb45 From b1e6d4f64c6aa841650340c87d743b794572bb24 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 26 Nov 2015 20:15:35 +0800 Subject: [PATCH 14/18] Check ELECTRON_RUN_AS_NODE env var --- atom/app/atom_main.cc | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/atom/app/atom_main.cc b/atom/app/atom_main.cc index 26dcb9421266..88bb137bae0f 100644 --- a/atom/app/atom_main.cc +++ b/atom/app/atom_main.cc @@ -36,10 +36,27 @@ #include "base/at_exit.h" #include "base/i18n/icu_util.h" -#if defined(OS_WIN) - namespace { +const char* kRunAsNode = "ELECTRON_RUN_AS_NODE"; +const char* kOldRunAsNode = "ATOM_SHELL_INTERNAL_RUN_AS_NODE"; + +bool IsEnvSet(const char* name) { +#if defined(OS_WIN) + size_t required_size; + getenv_s(&required_size, nullptr, 0, name); + return required_size != 0; +#else + char* indicator = getenv(name); + return indicator && indicator[0] != '\0'; +#endif +} + +bool IsRunAsNode() { + return IsEnvSet(kRunAsNode) || IsEnvSet(kOldRunAsNode); +} + +#if defined(OS_WIN) // Win8.1 supports monitor-specific DPI scaling. bool SetProcessDpiAwarenessWrapper(PROCESS_DPI_AWARENESS value) { typedef HRESULT(WINAPI *SetProcessDpiAwarenessPtr)(PROCESS_DPI_AWARENESS); @@ -77,9 +94,11 @@ void EnableHighDPISupport() { SetProcessDPIAwareWrapper(); } } +#endif } // namespace +#if defined(OS_WIN) int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t* cmd, int) { int argc = 0; wchar_t** wargv = ::CommandLineToArgvW(::GetCommandLineW(), &argc); @@ -131,16 +150,12 @@ int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t* cmd, int) { } } - std::string node_indicator, crash_service_indicator; - if (env->GetVar("ATOM_SHELL_INTERNAL_RUN_AS_NODE", &node_indicator) && - node_indicator == "1") { + if (IsRunAsNode()) { // Now that argv conversion is done, we can finally start. base::AtExitManager atexit_manager; base::i18n::InitializeICU(); return atom::NodeMain(argc, argv); - } else if (env->GetVar("ATOM_SHELL_INTERNAL_CRASH_SERVICE", - &crash_service_indicator) && - crash_service_indicator == "1") { + } else if (IsEnvSet("ATOM_SHELL_INTERNAL_CRASH_SERVICE")) { return crash_service::Main(cmd); } @@ -164,8 +179,7 @@ int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t* cmd, int) { #elif defined(OS_LINUX) // defined(OS_WIN) int main(int argc, const char* argv[]) { - char* node_indicator = getenv("ATOM_SHELL_INTERNAL_RUN_AS_NODE"); - if (node_indicator != NULL && strcmp(node_indicator, "1") == 0) { + if (IsRunAsNode()) { base::i18n::InitializeICU(); base::AtExitManager atexit_manager; return atom::NodeMain(argc, const_cast(argv)); @@ -182,8 +196,7 @@ int main(int argc, const char* argv[]) { #else // defined(OS_LINUX) int main(int argc, const char* argv[]) { - char* node_indicator = getenv("ATOM_SHELL_INTERNAL_RUN_AS_NODE"); - if (node_indicator != NULL && strcmp(node_indicator, "1") == 0) { + if (IsRunAsNode()) { return AtomInitializeICUandStartNode(argc, const_cast(argv)); } From 6534a0e616471c6bd577282f84e750c16ff699cf Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 26 Nov 2015 20:37:48 +0800 Subject: [PATCH 15/18] docs: Add Environment Variables --- docs/README.md | 1 + docs/api/environment-variables.md | 32 +++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 docs/api/environment-variables.md diff --git a/docs/README.md b/docs/README.md index 9b6372524bd3..917f4050b3d3 100644 --- a/docs/README.md +++ b/docs/README.md @@ -30,6 +30,7 @@ select the tag that matches your version. * [Synopsis](api/synopsis.md) * [Process Object](api/process.md) * [Supported Chrome Command Line Switches](api/chrome-command-line-switches.md) +* [Environment Variables](api/environment-variables.md) ### Custom DOM Elements: diff --git a/docs/api/environment-variables.md b/docs/api/environment-variables.md new file mode 100644 index 000000000000..76cf4304e53b --- /dev/null +++ b/docs/api/environment-variables.md @@ -0,0 +1,32 @@ +# Environment variables + +Some behaviors of Electron are controlled by environment variables, because they +are initialized earlier than command line and the app's code. + +## `ELECTRON_RUN_AS_NODE` + +Starts the process as a normal Node.js process. + +## `ELECTRON_ENABLE_LOGGING` + +Prints Chrome's internal logging to console. + +## `ELECTRON_ENABLE_STACK_DUMPING` + +When Electron crashed, prints the stack trace to console. + +This environment variable will not work if `crashReporter` is started. + +## `ELECTRON_DEFAULT_ERROR_MODE` _Windows_ + +Shows Windows's crash dialog when Electron crashed. + +This environment variable will not work if `crashReporter` is started. + +## `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')`. From 682b48095a3110a6ed891f076cb1983c809a3ddc Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 26 Nov 2015 20:44:07 +0800 Subject: [PATCH 16/18] docs: Add example --- docs/api/environment-variables.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/docs/api/environment-variables.md b/docs/api/environment-variables.md index 76cf4304e53b..b5d3ff3f6f7b 100644 --- a/docs/api/environment-variables.md +++ b/docs/api/environment-variables.md @@ -3,6 +3,20 @@ Some behaviors of Electron are controlled by environment variables, because they are initialized earlier than command line and the app's code. +Examples on POSIX shells: + +```bash +$ export ELECTRON_ENABLE_LOGGING=true +$ electron +``` + +on Windows console: + +```powershell +> set ELECTRON_ENABLE_LOGGING=true +> electron +``` + ## `ELECTRON_RUN_AS_NODE` Starts the process as a normal Node.js process. From 59402eb23fb1cd87bd92e8bea618c2f2321fe105 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 26 Nov 2015 21:02:55 +0800 Subject: [PATCH 17/18] Add ELECTRON_NO_ATTACH_CONSOLE env var Close #1556. --- atom/app/atom_main.cc | 13 +++++++------ docs/api/environment-variables.md | 4 ++++ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/atom/app/atom_main.cc b/atom/app/atom_main.cc index 88bb137bae0f..5b5df448dfa8 100644 --- a/atom/app/atom_main.cc +++ b/atom/app/atom_main.cc @@ -5,7 +5,6 @@ #include "atom/app/atom_main.h" #include -#include #if defined(OS_WIN) #include @@ -57,6 +56,12 @@ bool IsRunAsNode() { } #if defined(OS_WIN) +bool IsCygwin() { + std::string os; + scoped_ptr env(base::Environment::Create()); + return env->GetVar("OS", &os) && os == "cygwin"; +} + // Win8.1 supports monitor-specific DPI scaling. bool SetProcessDpiAwarenessWrapper(PROCESS_DPI_AWARENESS value) { typedef HRESULT(WINAPI *SetProcessDpiAwarenessPtr)(PROCESS_DPI_AWARENESS); @@ -103,17 +108,13 @@ int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t* cmd, int) { int argc = 0; wchar_t** wargv = ::CommandLineToArgvW(::GetCommandLineW(), &argc); - scoped_ptr env(base::Environment::Create()); - // Make output work in console if we are not in cygiwn. - std::string os; - if (env->GetVar("OS", &os) && os != "cygwin") { + if (!IsCygwin() && !IsEnvSet("ELECTRON_NO_ATTACH_CONSOLE")) { AttachConsole(ATTACH_PARENT_PROCESS); FILE* dontcare; freopen_s(&dontcare, "CON", "w", stdout); freopen_s(&dontcare, "CON", "w", stderr); - freopen_s(&dontcare, "CON", "r", stdin); } // Convert argv to to UTF8 diff --git a/docs/api/environment-variables.md b/docs/api/environment-variables.md index b5d3ff3f6f7b..6b000aaa1080 100644 --- a/docs/api/environment-variables.md +++ b/docs/api/environment-variables.md @@ -37,6 +37,10 @@ Shows Windows's crash dialog when Electron crashed. This environment variable will not work if `crashReporter` is started. +## `ELECTRON_NO_ATTACH_CONSOLE` _Windows_ + +Don't attach to current console session. + ## `ELECTRON_FORCE_WINDOW_MENU_BAR` _Linux_ Don't use global menu bar on Linux. From 932cd92bf6dded7756196254f5d7593fc5d2e14d Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 27 Nov 2015 10:30:51 +0800 Subject: [PATCH 18/18] Fix wrong deprecation wrappers of BrowserWindow --- atom/browser/api/lib/browser-window.coffee | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/atom/browser/api/lib/browser-window.coffee b/atom/browser/api/lib/browser-window.coffee index 4cdffae87a60..d693a6d93403 100644 --- a/atom/browser/api/lib/browser-window.coffee +++ b/atom/browser/api/lib/browser-window.coffee @@ -90,16 +90,18 @@ deprecate.member BrowserWindow, 'copy', 'webContents' deprecate.member BrowserWindow, 'paste', 'webContents' deprecate.member BrowserWindow, 'selectAll', 'webContents' deprecate.member BrowserWindow, 'reloadIgnoringCache', 'webContents' -deprecate.member BrowserWindow, 'getPageTitle', 'webContents' deprecate.member BrowserWindow, 'isLoading', 'webContents' deprecate.member BrowserWindow, 'isWaitingForResponse', 'webContents' deprecate.member BrowserWindow, 'stop', 'webContents' deprecate.member BrowserWindow, 'isCrashed', 'webContents' -deprecate.member BrowserWindow, 'executeJavaScriptInDevTools', '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::executeJavaScriptInDevTools = deprecate 'executeJavaScriptInDevTools', 'devToolsWebContents.executeJavaScript', (code) -> + @devToolsWebContents?.executeJavaScript code +BrowserWindow::getPageTitle = deprecate 'getPageTitle', 'webContents.getTitle', -> + @webContents?.getTitle() module.exports = BrowserWindow