Merge remote-tracking branch 'refs/remotes/atom/master'

This commit is contained in:
Plusb Preco 2015-11-27 12:19:47 +09:00
commit 43b73a0ced
24 changed files with 175 additions and 54 deletions

View file

@ -5,7 +5,6 @@
#include "atom/app/atom_main.h"
#include <stdlib.h>
#include <string.h>
#if defined(OS_WIN)
#include <stdio.h>
@ -36,10 +35,33 @@
#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)
bool IsCygwin() {
std::string os;
scoped_ptr<base::Environment> 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);
@ -77,24 +99,22 @@ 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);
scoped_ptr<base::Environment> 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
@ -131,16 +151,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 +180,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<char**>(argv));
@ -182,8 +197,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<char**>(argv));
}

View file

@ -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.

View file

@ -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

View file

@ -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

View file

@ -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
@ -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

View file

@ -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 {

View file

@ -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());

View file

@ -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

View file

@ -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'

View file

@ -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');
});
```

View file

@ -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

View file

@ -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) {

View file

@ -46,7 +46,7 @@ app.on('ready', function() {
'plugins': true
}
});
mainWindow.loadUrl('file://' + __dirname + '/index.html');
mainWindow.loadURL('file://' + __dirname + '/index.html');
// Something else
});
```

View file

@ -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

View file

@ -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) {

View file

@ -54,7 +54,7 @@ app.on('ready', function() {
'plugins': true
}
});
mainWindow.loadUrl('file://' + __dirname + '/index.html');
mainWindow.loadURL('file://' + __dirname + '/index.html');
// Algo mais
});
```

View file

@ -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) {

View file

@ -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');
});
```

View file

@ -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) {

View file

@ -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:

View file

@ -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:

View file

@ -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,22 @@ 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:
```javascript
app.commandLine.appendSwitch('proxy-bypass-list', '<local>;*.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`.

View file

@ -0,0 +1,50 @@
# Environment variables
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.
## `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_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.
## `ELECTRON_HIDE_INTERNAL_MODULES`
Turns off compatibility mode for old built-in modules like `require('ipc')`.

2
vendor/brightray vendored

@ -1 +1 @@
Subproject commit d4fab33427eb728a553896527f1931887ce6d9d9
Subproject commit 57842edb817cc1ae38a02fd7f266dd6aa3afbb45