Merge remote-tracking branch 'atom/master'

This commit is contained in:
Plusb Preco 2015-08-21 11:41:07 +09:00
commit ad24c11f32
171 changed files with 4032 additions and 968 deletions

View file

@ -1,6 +1,6 @@
# Accelerator
An accelerator is string that represents a keyboard shortcut, it can contain
An accelerator is a string that represents a keyboard shortcut. It can contain
multiple modifiers and key codes, combined by the `+` character.
Examples:
@ -10,7 +10,7 @@ Examples:
## Platform notice
On Linux and Windows, the `Command` key would not have any effect, you can
On Linux and Windows, the `Command` key does not have any effect so
use `CommandOrControl` which represents `Command` on OS X and `Control` on
Linux and Windows to define some accelerators.

View file

@ -1,8 +1,8 @@
# app
The `app` module is responsible for controlling the application's life time.
The `app` module is responsible for controlling the application's lifecycle.
The example of quitting the whole application when the last window is closed:
The following example shows how to quit the application when the last window is closed:
```javascript
var app = require('app');
@ -13,26 +13,26 @@ app.on('window-all-closed', function() {
## Event: will-finish-launching
Emitted when application has done basic startup. On Windows and Linux it is the
same with `ready` event, on OS X this event represents the
`applicationWillFinishLaunching` message of `NSApplication`, usually you would
setup listeners to `open-file` and `open-url` events here, and start the crash
reporter and auto updater.
Emitted when the application has finished basic startup. On Windows and Linux,
the `will-finish-launching` event is the same as the `ready` event; on OS X,
this event represents the `applicationWillFinishLaunching` notification of `NSApplication`.
You would usually set up listeners for the `open-file` and `open-url` events here,
and start the crash reporter and auto updater.
Under most cases you should just do everything in `ready` event.
In most cases, you should just do everything in the `ready` event handler.
## Event: ready
Emitted when Electron has done everything initialization.
Emitted when Electron has finished initialization.
## Event: window-all-closed
Emitted when all windows have been closed.
This event is only emitted when the application is not going to quit. If a
This event is only emitted when the application is not going to quit. If the
user pressed `Cmd + Q`, or the developer called `app.quit()`, Electron would
first try to close all windows and then emit the `will-quit` event, and in
this case the `window-all-closed` would not be emitted.
first try to close all the windows and then emit the `will-quit` event, and in
this case the `window-all-closed` event would not be emitted.
## Event: before-quit
@ -50,23 +50,23 @@ Emitted when all windows have been closed and the application will quit.
Calling `event.preventDefault()` will prevent the default behaviour, which is
terminating the application.
See description of `window-all-closed` for the differences between `will-quit`
and it.
See the description of the `window-all-closed` event for the differences between the `will-quit`
and `window-all-closed` events.
## Event: quit
Emitted when application is quitting.
Emitted when the application is quitting.
## Event: open-file
* `event` Event
* `path` String
Emitted when user wants to open a file with the application, it usually happens
when the application is already opened and then OS wants to reuse the
application to open file. But it is also emitted when a file is dropped onto the
dock and the application is not yet running. Make sure to listen to open-file
very early in your application startup to handle this case (even before the
Emitted when the user wants to open a file with the application. The `open-file` event
is usually emitted when the application is already open and the OS wants to reuse the
application to open the file. `open-file` is also emitted when a file is dropped onto the
dock and the application is not yet running. Make sure to listen for the `open-file`
event very early in your application startup to handle this case (even before the
`ready` event is emitted).
You should call `event.preventDefault()` if you want to handle this event.
@ -76,16 +76,16 @@ You should call `event.preventDefault()` if you want to handle this event.
* `event` Event
* `url` String
Emitted when user wants to open a URL with the application, this URL scheme
Emitted when the user wants to open a URL with the application. The URL scheme
must be registered to be opened by your application.
You should call `event.preventDefault()` if you want to handle this event.
## Event: activate-with-no-open-windows
Emitted when the application is activated while there is no opened windows. It
usually happens when user has closed all of application's windows and then
click on the application's dock icon.
Emitted when the application is activated while there are no open windows, which
usually happens when the user has closed all of the application's windows and then
clicks on the application's dock icon.
## Event: browser-window-blur
@ -103,7 +103,7 @@ Emitted when a [browserWindow](browser-window.md) gets focused.
### Event: 'select-certificate'
Emitted when client certificate is requested.
Emitted when a client certificate is requested.
* `event` Event
* `webContents` [WebContents](browser-window.md#class-webcontents)
@ -120,24 +120,24 @@ app.on('select-certificate', function(event, host, url, list, callback) {
})
```
`url` corresponds to the navigation entry requesting the client certificate,
`url` corresponds to the navigation entry requesting the client certificate.
`callback` needs to be called with an entry filtered from the list.
`event.preventDefault()` prevents from using the first certificate from
the store.
`event.preventDefault()` prevents the application from using the first certificate
from the store.
### Event: 'gpu-process-crashed'
Emitted when the gpu process is crashed.
Emitted when the gpu process crashes.
## app.quit()
Try to close all windows. The `before-quit` event will first be emitted. If all
windows are successfully closed, the `will-quit` event will be emitted and by
default the application would be terminated.
default the application will terminate.
This method guarantees all `beforeunload` and `unload` handlers are correctly
This method guarantees that all `beforeunload` and `unload` event handlers are correctly
executed. It is possible that a window cancels the quitting by returning
`false` in `beforeunload` handler.
`false` in the `beforeunload` event handler.
## app.getAppPath()
@ -148,19 +148,19 @@ Returns the current application directory.
* `name` String
Retrieves a path to a special directory or file associated with `name`. On
failure an `Error` would throw.
failure an `Error` is thrown.
You can request following paths by the names:
You can request the following paths by the name:
* `home`: User's home directory
* `appData`: Per-user application data directory, by default it is pointed to:
* `appData`: Per-user application data directory, which by default points to:
* `%APPDATA%` on Windows
* `$XDG_CONFIG_HOME` or `~/.config` on Linux
* `~/Library/Application Support` on OS X
* `userData`: The directory for storing your app's configuration files, by
* `userData`: The directory for storing your app's configuration files, which by
default it is the `appData` directory appended with your app's name
* `cache`: Per-user application cache directory, by default it is pointed to:
* `%APPDATA%` on Window, which doesn't has a universal place for cache
* `cache`: Per-user application cache directory, which by default points to:
* `%APPDATA%` on Windows (which doesn't have a universal cache location)
* `$XDG_CACHE_HOME` or `~/.cache` on Linux
* `~/Library/Caches` on OS X
* `userCache`: The directory for placing your app's caches, by default it is the
@ -175,30 +175,30 @@ You can request following paths by the names:
* `name` String
* `path` String
Overrides the `path` to a special directory or file associated with `name`. if
Overrides the `path` to a special directory or file associated with `name`. If
the path specifies a directory that does not exist, the directory will be
created by this method. On failure an `Error` would throw.
created by this method. On failure an `Error` is thrown.
You can only override paths of `name`s defined in `app.getPath`.
By default web pages' cookies and caches will be stored under `userData`
directory, if you want to change this location, you have to override the
`userData` path before the `ready` event of `app` module gets emitted.
By default, web pages' cookies and caches will be stored under the `userData`
directory. If you want to change this location, you have to override the
`userData` path before the `ready` event of the `app` module is emitted.
## app.getVersion()
Returns the version of loaded application, if no version is found in
application's `package.json`, the version of current bundle or executable would
be returned.
Returns the version of the loaded application. If no version is found in the
application's `package.json` file, the version of the current bundle or executable is
returned.
## app.getName()
Returns current application's name, the name in `package.json` would be
used.
Returns the current application's name, which is the name in the application's
`package.json` file.
Usually the `name` field of `package.json` is a short lowercased name, according
to the spec of npm modules. So usually you should also specify a `productName`
field, which is your application's full capitalized name, and it will be
to the npm modules spec. You should usually also specify a `productName`
field, which is your application's full capitalized name, and which will be
preferred over `name` by Electron.
## app.resolveProxy(url, callback)
@ -206,17 +206,17 @@ preferred over `name` by Electron.
* `url` URL
* `callback` Function
Resolves the proxy information for `url`, the `callback` would be called with
`callback(proxy)` when the request is done.
Resolves the proxy information for `url`. The `callback` will be called with
`callback(proxy)` when the request is performed.
## app.addRecentDocument(path)
* `path` String
Adds `path` to recent documents list.
Adds `path` to the recent documents list.
This list is managed by the system, on Windows you can visit the list from task
bar, and on Mac you can visit it from dock menu.
This list is managed by the OS. On Windows you can visit the list from the task
bar, and on OS X you can visit it from dock menu.
## app.clearRecentDocuments()
@ -226,20 +226,20 @@ Clears the recent documents list.
* `tasks` Array - Array of `Task` objects
Adds `tasks` to the [Tasks][tasks] category of JumpList on Windows.
Adds `tasks` to the [Tasks][tasks] category of the JumpList on Windows.
The `tasks` is an array of `Task` objects in following format:
`tasks` is an array of `Task` objects in following format:
* `Task` Object
* `program` String - Path of the program to execute, usually you should
specify `process.execPath` which opens current program
* `arguments` String - The arguments of command line when `program` is
specify `process.execPath` which opens the current program
* `arguments` String - The command line arguments when `program` is
executed
* `title` String - The string to be displayed in a JumpList
* `description` String - Description of this task
* `iconPath` String - The absolute path to an icon to be displayed in a
JumpList, it can be arbitrary resource file that contains an icon, usually
you can specify `process.execPath` to show the icon of the program
JumpList, which can be an arbitrary resource file that contains an icon. You can
usually specify `process.execPath` to show the icon of the program
* `iconIndex` Integer - The icon index in the icon file. If an icon file
consists of two or more icons, set this value to identify the icon. If an
icon file consists of one icon, this value is 0
@ -255,25 +255,25 @@ to control some low-level Chromium behaviors.
## app.commandLine.appendArgument(value)
Append an argument to Chromium's command line. The argument will quoted properly.
Append an argument to Chromium's command line. The argument will be quoted correctly.
**Note:** This will not affect `process.argv`.
## app.dock.bounce([type])
* `type` String - Can be `critical` or `informational`, the default is
* `type` String - Can be `critical` or `informational`. The default is
`informational`
When `critical` is passed, the dock icon will bounce until either the
application becomes active or the request is canceled.
When `informational` is passed, the dock icon will bounce for one second. The
request, though, remains active until either the application becomes active or
When `informational` is passed, the dock icon will bounce for one second. However,
the request remains active until either the application becomes active or
the request is canceled.
An ID representing the request would be returned.
An ID representing the request is returned.
**Note:** This API is only available on Mac.
**Note:** This API is only available on OS X.
## app.dock.cancelBounce(id)
@ -281,7 +281,7 @@ An ID representing the request would be returned.
Cancel the bounce of `id`.
**Note:** This API is only available on Mac.
**Note:** This API is only available on OS X.
## app.dock.setBadge(text)
@ -289,33 +289,33 @@ Cancel the bounce of `id`.
Sets the string to be displayed in the docks badging area.
**Note:** This API is only available on Mac.
**Note:** This API is only available on OS X.
## app.dock.getBadge()
Returns the badge string of the dock.
**Note:** This API is only available on Mac.
**Note:** This API is only available on OS X.
## app.dock.hide()
Hides the dock icon.
**Note:** This API is only available on Mac.
**Note:** This API is only available on OS X.
## app.dock.show()
Shows the dock icon.
**Note:** This API is only available on Mac.
**Note:** This API is only available on OS X.
## app.dock.setMenu(menu)
* `menu` Menu
Sets the application [dock menu][dock-menu].
Sets the application's [dock menu][dock-menu].
**Note:** This API is only available on Mac.
**Note:** This API is only available on OS X.
[dock-menu]:https://developer.apple.com/library/mac/documentation/Carbon/Conceptual/customizing_docktile/concepts/dockconcepts.html#//apple_ref/doc/uid/TP30000986-CH2-TPXREF103
[tasks]:http://msdn.microsoft.com/en-us/library/windows/desktop/dd378460(v=vs.85).aspx#tasks

View file

@ -3,9 +3,9 @@
**This module has only been implemented for OS X.**
Check out [atom/grunt-electron-installer](https://github.com/atom/grunt-electron-installer)
for building a Windows installer for your app.
to build a Windows installer for your app.
The `auto-updater` module is a simple wrap around the
The `auto-updater` module is a simple wrapper around the
[Squirrel.Mac](https://github.com/Squirrel/Squirrel.Mac) framework.
Squirrel.Mac requires that your `.app` folder is signed using the
@ -26,11 +26,11 @@ body so that your server has the context it needs in order to supply the most
suitable update.
The update JSON Squirrel requests should be dynamically generated based on
criteria in the request, and whether an update is required. Squirrel relies
on server side support for determining whether an update is required, see
criteria in the request and whether an update is required. Squirrel relies
on server-side support to determine whether an update is required. See
[Server Support](#server-support).
Squirrel's installer is also designed to be fault tolerant, and ensure that any
Squirrel's installer is designed to be fault tolerant and ensures that any
updates installed are valid.
## Update Requests
@ -40,11 +40,11 @@ update checking. `Accept: application/json` is added to the request headers
because Squirrel is responsible for parsing the response.
For the requirements imposed on the responses and the body format of an update
response see [Server Support](#server-support).
response, see [Server Support](#server-support).
Your update request must *at least* include a version identifier so that the
server can determine whether an update for this specific version is required. It
may also include other identifying criteria such as operating system version or
may also include other identifying criteria, such as operating system version or
username, to allow the server to deliver as fine grained an update as you
would like.
@ -64,7 +64,7 @@ autoUpdater.setFeedUrl('http://mycompany.com/myapp/latest?version=' + app.getVer
Your server should determine whether an update is required based on the
[Update Request](#update-requests) your client issues.
If an update is required your server should respond with a status code of
If an update is required, your server should respond with a status code of
[200 OK](http://tools.ietf.org/html/rfc2616#section-10.2.1) and include the
[update JSON](#update-json-format) in the body. Squirrel **will** download and
install this update, even if the version of the update is the same as the
@ -85,33 +85,33 @@ to the update request provided:
"url": "http://mycompany.com/myapp/releases/myrelease",
"name": "My Release Name",
"notes": "Theses are some release notes innit",
"pub_date": "2013-09-18T12:29:53+01:00",
"pub_date": "2013-09-18T12:29:53+01:00"
}
```
The only required key is "url", the others are optional.
The only required key is "url"; the others are optional.
Squirrel will request "url" with `Accept: application/zip` and only supports
installing ZIP updates. If future update formats are supported their MIME type
will be added to the `Accept` header so that your server can return the
appropriate format.
`pub_date` if present must be formatted according to ISO 8601.
`pub_date` (if present) must be formatted according to ISO 8601.
## Event: error
* `event` Event
* `message` String
Emitted when there is an error updating.
Emitted when there is an error while updating.
## Event: checking-for-update
Emitted when checking for update has started.
Emitted when checking if an update has started.
## Event: update-available
Emitted when there is an available update, the update would be downloaded
Emitted when there is an available update. The update is downloaded
automatically.
## Event: update-not-available
@ -127,17 +127,17 @@ Emitted when there is no available update.
* `updateUrl` String
* `quitAndUpdate` Function
Emitted when update has been downloaded, calling `quitAndUpdate()` would restart
Emitted when an update has been downloaded. Calling `quitAndUpdate()` will restart
the application and install the update.
## autoUpdater.setFeedUrl(url)
* `url` String
Set the `url` and initialize the auto updater. The `url` could not be changed
Set the `url` and initialize the auto updater. The `url` cannot be changed
once it is set.
## autoUpdater.checkForUpdates()
Ask the server whether there is an update, you have to call `setFeedUrl` before
Ask the server whether there is an update. You must call `setFeedUrl` before
using this API.

View file

@ -76,7 +76,14 @@ You can also create a window without chrome by using
textured window. Defaults to `true`.
* `web-preferences` Object - Settings of web page's features
* `javascript` Boolean
* `web-security` Boolean
* `web-security` Boolean - When setting `false`, it will disable the same-origin
policy(Usually using testing websites by people), and set `allow_displaying_insecure_content`
and `allow_running_insecure_content` to `true` if these two options are not
set by user.
* `allow-displaying-insecure-content` Boolean - Allow a https page to display
content like image from http URLs.
* `allow-running-insecure-content` Boolean - Allow a https page to run JavaScript,
CSS or plugins from http URLs.
* `images` Boolean
* `java` Boolean
* `text-areas-are-resizable` Boolean
@ -361,6 +368,19 @@ Sets whether the window should be in fullscreen mode.
Returns whether the window is in fullscreen mode.
### BrowserWindow.setAspectRatio(aspectRatio[, extraSize])
* `aspectRatio` The aspect ratio we want to maintain for some portion of the content view.
* `rect` Object - The extra size to not be included in the aspect ratio to be maintained.
* `width` Integer
* `height` Integer
This will have a window maintain an aspect ratio. The extra size allows a developer to be able to have space, specifified in pixels, not included within the aspect ratio calculations. This API already takes into account the difference between a window's size and it's content size.
Consider a normal window with an HD video player and associated controls. Perhaps there are 15 pixels of controls on the left edge, 25 pixels of controls on the right edge and 50 pixels of controls below the player. In order to maintain a 16:9 aspect ratio (standard aspect ratio for HD @1920x1080) within the player itself we would call this function with arguments of 16/9 and [ 40, 50 ]. The second argument doesn't care where the extra width and height are within the content view — only that they exist. Just sum any extra width and height areas you have within the overall content view.
__Note__: This API is only implemented on OS X.
### BrowserWindow.setBounds(options)
* `options` Object
@ -623,6 +643,39 @@ Sets a 16px overlay onto the current taskbar icon, usually used to convey some s
__Note:__ This API is only available on Windows (Windows 7 and above)
### BrowserWindow.setThumbarButtons(buttons)
* `buttons` Array
* `button` Object
* `icon` [NativeImage](native-image.md) - The icon showing in thumbnail
toolbar.
* `tooltip` String (optional) - The text of the button's tooltip.
* `flags` Array (optional) - Control specific states and behaviors
of the button. By default, it uses `enabled`. It can include following
Strings:
* `enabled` - The button is active and available to the user.
* `disabled` - The button is disabled. It is present, but has a visual
state that indicates that it will not respond to user action.
* `dismissonclick` - When the button is clicked, the taskbar button's
flyout closes immediately.
* `nobackground` - Do not draw a button border, use only the image.
* `hidden` - The button is not shown to the user.
* `noninteractive` - The button is enabled but not interactive; no
pressed button state is drawn. This value is intended for instances
where the button is used in a notification.
* `click` - Function
Add a thumbnail toolbar with a specified set of buttons to the thumbnail image
of a window in a taskbar button layout. Returns a `Boolean` object indicates
whether the thumbnail has been added successfully.
__Note:__ This API is only available on Windows (Windows 7 and above).
The number of buttons in thumbnail toolbar should be no greater than 7 due to
the limited room. Once you setup the thumbnail toolbar, the toolbar cannot be
removed due to the platform's limitation. But you can call the API with an empty
array to clean the buttons.
### BrowserWindow.showDefinitionForSelection()
Shows pop-up dictionary that searches the selected word on the page.
@ -760,7 +813,7 @@ Calling `event.preventDefault()` can prevent creating new windows.
* `event` Event
* `url` String
Emitted when user or the page wants to start an navigation, it can happen when
Emitted when user or the page wants to start a navigation, it can happen when
`window.location` object is changed or user clicks a link in the page.
This event will not emit when the navigation is started programmatically with APIs
@ -875,18 +928,27 @@ Whether the renderer process has crashed.
Overrides the user agent for this page.
### WebContents.getUserAgent()
Returns a `String` represents the user agent for this page.
### WebContents.insertCSS(css)
* `css` String
Injects CSS into this page.
### WebContents.executeJavaScript(code)
### WebContents.executeJavaScript(code[, userGesture])
* `code` String
* `userGesture` Boolean
Evaluates `code` in page.
In browser some HTML APIs like `requestFullScreen` can only be invoked if it
is started by user gesture, by specifying `userGesture` to `true` developers
can ignore this limitation.
### WebContents.setAudioMuted(muted)
+ `muted` Boolean
@ -984,6 +1046,12 @@ size.
* 0 - default
* 1 - none
* 2 - minimum
* `pageSize` String - Specify page size of the generated PDF
* `A4`
* `A3`
* `Legal`
* `Letter`
* `Tabloid`
* `printBackground` Boolean - Whether to print CSS backgrounds.
* `printSelectionOnly` Boolean - Whether to print selection only.
* `landscape` Boolean - `true` for landscape, `false` for portrait.
@ -1010,14 +1078,27 @@ win.webContents.on("did-finish-load", function() {
// Use default printing options
win.webContents.printToPDF({}, function(error, data) {
if (error) throw error;
fs.writeFile(dist, data, function(error) {
fs.writeFile("/tmp/print.pdf", data, function(error) {
if (err)
alert('write pdf file error', error);
throw error;
console.log("Write PDF successfully.");
})
})
});
```
### WebContents.addWorkSpace(path)
* `path` String
Adds the specified path to devtools workspace.
### WebContents.removeWorkSpace(path)
* `path` String
Removes the specified path from devtools workspace.
### WebContents.send(channel[, args...])
* `channel` String
@ -1167,3 +1248,46 @@ Clears the session's HTTP cache.
* `callback` Function - Called when operation is done
Clears the data of web storages.
### Session.setProxy(config, callback)
* `config` String
* `callback` Function - Called when operation is done
Parses the `config` indicating which proxies to use for the session.
```
config = scheme-proxies[";"<scheme-proxies>]
scheme-proxies = [<url-scheme>"="]<proxy-uri-list>
url-scheme = "http" | "https" | "ftp" | "socks"
proxy-uri-list = <proxy-uri>[","<proxy-uri-list>]
proxy-uri = [<proxy-scheme>"://"]<proxy-host>[":"<proxy-port>]
For example:
"http=foopy:80;ftp=foopy2" -- use HTTP proxy "foopy:80" for http://
URLs, and HTTP proxy "foopy2:80" for
ftp:// URLs.
"foopy:80" -- use HTTP proxy "foopy:80" for all URLs.
"foopy:80,bar,direct://" -- use HTTP proxy "foopy:80" for all URLs,
failing over to "bar" if "foopy:80" is
unavailable, and after that using no
proxy.
"socks4://foopy" -- use SOCKS v4 proxy "foopy:1080" for all
URLs.
"http=foopy,socks5://bar.com -- use HTTP proxy "foopy" for http URLs,
and fail over to the SOCKS5 proxy
"bar.com" if "foopy" is unavailable.
"http=foopy,direct:// -- use HTTP proxy "foopy" for http URLs,
and use no proxy if "foopy" is
unavailable.
"http=foopy;socks=foopy2 -- use HTTP proxy "foopy" for http URLs,
and use socks4://foopy2 for all other
URLs.
```
### Session.setDownloadPath(path)
* `path` String - The download location
Sets download saving directory. By default, the download directory will be the
`Downloads` under the respective app folder.

View file

@ -1,7 +1,7 @@
# Supported Chrome command line switches
The following command lines switches in Chrome browser are also supported in
Electron, you can use [app.commandLine.appendSwitch][append-switch] to append
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:
@ -17,11 +17,11 @@ app.on('ready', function() {
## --client-certificate=`path`
Sets `path` of client certificate file.
Sets the `path` of client certificate file.
## --ignore-connections-limit=`domains`
Ignore the connections limit for `domains` list seperated by `,`.
Ignore the connections limit for `domains` list separated by `,`.
## --disable-http-cache
@ -29,11 +29,11 @@ Disables the disk cache for HTTP requests.
## --remote-debugging-port=`port`
Enables remote debug over HTTP on the specified `port`.
Enables remote debugging over HTTP on the specified `port`.
## --proxy-server=`address:port`
Uses a specified proxy server, overrides system settings. This switch only
Use a specified proxy server, which overrides the system setting. This switch only
affects HTTP and HTTPS requests.
## --proxy-pac-url=`url`
@ -42,12 +42,12 @@ Uses the PAC script at the specified `url`.
## --no-proxy-server
Don't use a proxy server, always make direct connections. Overrides any other
Don't use a proxy server and always make direct connections. Overrides any other
proxy server flags that are passed.
## --host-rules=`rules`
Comma-separated list of `rules` that control how hostnames are mapped.
A comma-separated list of `rules` that control how hostnames are mapped.
For example:
@ -60,7 +60,7 @@ For example:
"www.google.com".
These mappings apply to the endpoint host in a net request (the TCP connect
and host resolver in a direct connection, and the `CONNECT` in an http proxy
and host resolver in a direct connection, and the `CONNECT` in an HTTP proxy
connection, and the endpoint host in a `SOCKS` proxy connection).
## --host-resolver-rules=`rules`
@ -77,15 +77,15 @@ Ignores certificate related errors.
## --ppapi-flash-path=`path`
Sets `path` of pepper flash plugin.
Sets the `path` of the pepper flash plugin.
## --ppapi-flash-version=`version`
Sets `version` of pepper flash plugin.
Sets the `version` of the pepper flash plugin.
## --log-net-log=`path`
Enables saving net log events and writes them to `path`.
Enables net log events to be saved and writes them to `path`.
## --v=`log_level`
@ -102,7 +102,7 @@ source files `my_module.*` and `foo*.*`.
Any pattern containing a forward or backward slash will be tested against the
whole pathname and not just the module. E.g. `*/foo/bar/*=2` would change the
logging level for all code in source files under a `foo/bar` directory.
logging level for all code in the source files under a `foo/bar` directory.
To disable all chromium related logs and only enable your application logs you
can do:

View file

@ -1,14 +1,14 @@
# clipboard
The `clipboard` provides methods to do copy/paste operations. An example of
writing a string to clipboard:
The `clipboard` provides methods to perform copy and paste operations. The following example
shows how to write a string to the clipboard:
```javascript
var clipboard = require('clipboard');
clipboard.writeText('Example String');
```
On X Window systems, there is also a selection clipboard, to manipulate in it
On X Window systems, there is also a selection clipboard. To manipulate it
you need to pass `selection` to each method:
```javascript
@ -21,46 +21,46 @@ console.log(clipboard.readText('selection'));
* `type` String
Returns the content in clipboard as plain text.
Returns the content in the clipboard as plain text.
## clipboard.writeText(text[, type])
* `text` String
* `type` String
Writes the `text` into clipboard as plain text.
Writes the `text` into the clipboard as plain text.
## clipboard.readHtml([type])
* `type` String
Returns the content in clipboard as markup.
Returns the content in the clipboard as markup.
## clipboard.writeHtml(markup[, type])
* `markup` String
* `type` String
Writes the `markup` into clipboard.
Writes `markup` into the clipboard.
## clipboard.readImage([type])
* `type` String
Returns the content in clipboard as [NativeImage](native-image.md).
Returns the content in the clipboard as a [NativeImage](native-image.md).
## clipboard.writeImage(image[, type])
* `image` [NativeImage](native-image.md)
* `type` String
Writes the `image` into clipboard.
Writes `image` into the clipboard.
## clipboard.clear([type])
* `type` String
Clears everything in clipboard.
Clears the clipboard.
## clipboard.availableFormats([type])
@ -71,7 +71,7 @@ Returns an array of supported `format` for the clipboard `type`.
* `data` String
* `type` String
Returns whether clipboard supports the format of specified `data`.
Returns whether the clipboard supports the format of specified `data`.
```javascript
var clipboard = require('clipboard');
@ -85,7 +85,7 @@ console.log(clipboard.has('<p>selection</p>'));
* `data` String
* `type` String
Reads the `data` in clipboard.
Reads `data` from the clipboard.
**Note:** This API is experimental and could be removed in future.
@ -101,4 +101,4 @@ Reads the `data` in clipboard.
var clipboard = require('clipboard');
clipboard.write({text: 'test', html: "<b>test</b>"});
```
Writes the `data` iinto clipboard.
Writes `data` into clipboard.

View file

@ -28,10 +28,10 @@ are reached.
Once all child processes have acked to the `getCategories` request, `callback`
is invoked with an array of category groups.
## tracing.startRecording(categoryFilter, options, callback)
## tracing.startRecording(categoryFilter, traceOptions, callback)
* `categoryFilter` String
* `options` Integer
* `traceOptions` String
* `callback` Function
Start recording on all processes.
@ -51,9 +51,23 @@ Examples:
* `test_MyTest*,test_OtherStuff`,
* `"-excluded_category1,-excluded_category2`
`options` controls what kind of tracing is enabled, it could be a OR-ed
combination of `tracing.DEFAULT_OPTIONS`, `tracing.ENABLE_SYSTRACE`,
`tracing.ENABLE_SAMPLING` and `tracing.RECORD_CONTINUOUSLY`.
`traceOptions` controls what kind of tracing is enabled, it is a comma-delimited list.
Possible options are:
* `record-until-full`
* `record-continuously`
* `trace-to-console`
* `enable-sampling`
* `enable-systrace`
The first 3 options are trace recoding modes and hence mutually exclusive.
If more than one trace recording modes appear in the `traceOptions` string,
the last one takes precedence. If none of the trace recording mode is specified,
recording mode is `record-until-full`.
The trace option will first be reset to the default option (record_mode set to
`record-until-full`, enable_sampling and enable_systrace set to false)
before options parsed from `traceOptions` are applied on it.
## tracing.stopRecording(resultFilePath, callback)
@ -75,10 +89,10 @@ Trace data will be written into `resultFilePath` if it is not empty, or into a
temporary file. The actual file path will be passed to `callback` if it's not
null.
## tracing.startMonitoring(categoryFilter, options, callback)
## tracing.startMonitoring(categoryFilter, traceOptions, callback)
* `categoryFilter` String
* `options` Integer
* `traceOptions` String
* `callback` Function
Start monitoring on all processes.
@ -107,7 +121,7 @@ Get the current monitoring traced data.
Child processes typically are caching trace data and only rarely flush and send
trace data back to the main process. That is because it may be an expensive
operation to send the trace data over IPC, and we would like to avoid unneeded
operation to send the trace data over IPC, and we would like to avoid unneeded
runtime overhead of tracing. So, to end tracing, we must asynchronously ask all
child processes to flush any pending trace data.

View file

@ -1,6 +1,6 @@
# crash-reporter
An example of automatically submitting crash reporters to a remote server:
The following is an example of automatically submitting a crash report to a remote server:
```javascript
crashReporter = require('crash-reporter');
@ -18,31 +18,30 @@ crashReporter.start({
* `productName` String, default: Electron
* `companyName` String, default: GitHub, Inc
* `submitUrl` String, default: http://54.249.141.255:1127/post
* URL that crash reports would be sent to as POST
* URL that crash reports will be sent to as POST
* `autoSubmit` Boolean, default: true
* Send the crash report without user interaction
* `ignoreSystemCrashHandler` Boolean, default: false
* `extra` Object
* An object you can define which content will be send along with the report.
* An object you can define that will be sent along with the report.
* Only string properties are sent correctly.
* Nested objects are not supported.
Developers are required to call this method before using other crashReporter APIs.
Developers are required to call this method before using other `crashReporter` APIs.
**Note:** On OS X, electron uses a new `crashpad` client, which is different
with the `breakpad` on Windows and Linux. To enable crash collection feature,
you are required to call `crashReporter.start` API to initialize `crashpad` in
main process and in each renderer process that you wish to collect crash reports.
**Note:** On OS X, Electron uses a new `crashpad` client, which is different
from `breakpad` on Windows and Linux. To enable the crash collection feature,
you are required to call `crashReporter.start` API to initialize `crashpad` in the
main process and in each renderer process from which you wish to collect crash reports.
## crashReporter.getLastCrashReport()
Returns the date and ID of the last crash report, when there was no crash report
sent or the crash reporter is not started, `null` will be returned.
Returns the date and ID of the last crash report. If no crash reports have been
sent or the crash reporter has not been started, `null` is returned.
## crashReporter.getUploadedReports()
Returns all uploaded crash reports, each report contains date and uploaded ID.
Returns all uploaded crash reports. Each report contains the date and uploaded ID.
# crash-reporter payload
@ -54,8 +53,8 @@ The crash reporter will send the following data to the `submitUrl` as `POST`:
* `process_type` String - e.g. 'renderer'
* `ptime` Number
* `_version` String - The version in `package.json`
* `_productName` String - The product name in the crashReporter `options` object
* `_productName` String - The product name in the `crashReporter` `options` object
* `prod` String - Name of the underlying product. In this case Electron
* `_companyName` String - The company name in the crashReporter `options` object
* `_companyName` String - The company name in the `crashReporter` `options` object
* `upload_file_minidump` File - The crashreport as file
* All level one properties of the `extra` object in the crashReporter `options` object
* All level one properties of the `extra` object in the `crashReporter` `options` object

View file

@ -70,7 +70,7 @@ will be passed via `callback(filename)`
* `browserWindow` BrowserWindow
* `options` Object
* `type` String - Can be `"none"`, `"info"`, `"error"`, `"question"` or `"warning"`
* `type` String - Can be `"none"`, `"info"`, `"error"`, `"question"` or `"warning"`. On Windows, "question" displays the same icon as "info", unless if you set an icon using the "icon" option
* `buttons` Array - Array of texts for buttons
* `title` String - Title of the message box, some platforms will not show it
* `message` String - Content of the message box
@ -80,7 +80,12 @@ will be passed via `callback(filename)`
instead of clicking the buttons of the dialog. By default it is the index
of the buttons that have "cancel" or "no" as label, or 0 if there is no such
buttons. On OS X and Windows the index of "Cancel" button will always be
used as `cancelId`, not matter whether it is already specified.
used as `cancelId`, not matter whether it is already specified
* `noLink` Boolean - On Windows Electron would try to figure out which ones of
the `buttons` are common buttons (like "Cancel" or "Yes"), and show the
others as command links in the dialog, this can make the dialog appear in
the style of modern Windows apps. If you don't like this behavior, you can
specify `noLink` to `true`
* `callback` Function
Shows a message box, it will block until the message box is closed. It returns

View file

@ -1,9 +1,9 @@
# global-shortcut
The `global-shortcut` module can register/unregister a global keyboard shortcut
in operating system, so that you can customize the operations for various shortcuts.
Note that the shortcut is global, even if the app does not get focused, it will still work.
You should not use this module until the ready event of app module gets emitted.
with the operating system, so that you can customize the operations for various shortcuts.
Note that the shortcut is global; it will work even if the app does not have the keyboard focus.
You should not use this module until the `ready` event of the app module is emitted.
```javascript
var app = require('app');
@ -37,14 +37,14 @@ app.on('will-quit', function() {
* `accelerator` [Accelerator](accelerator.md)
* `callback` Function
Registers a global shortcut of `accelerator`, the `callback` would be called when
the registered shortcut is pressed by user.
Registers a global shortcut of `accelerator`. The `callback` is called when
the registered shortcut is pressed by the user.
## globalShortcut.isRegistered(accelerator)
* `accelerator` [Accelerator](accelerator.md)
Returns `true` or `false` depending on if the shortcut `accelerator` is registered.
Returns `true` or `false` depending on whether the shortcut `accelerator` is registered.
## globalShortcut.unregister(accelerator)

View file

@ -29,6 +29,8 @@ window.addEventListener('contextmenu', function (e) {
Another example of creating the application menu with the simple template API:
**Note to Window and Linux users** the `selector` member of each menu item is a Mac-only [Accelerator option](https://github.com/atom/electron/blob/master/docs/api/accelerator.md).
```html
<!-- index.html -->
<script>
@ -54,12 +56,12 @@ var template = [
},
{
label: 'Hide Electron',
accelerator: 'Command+H',
accelerator: 'CmdOrCtrl+H',
selector: 'hide:'
},
{
label: 'Hide Others',
accelerator: 'Command+Shift+H',
accelerator: 'CmdOrCtrl+Shift+H',
selector: 'hideOtherApplications:'
},
{
@ -71,7 +73,7 @@ var template = [
},
{
label: 'Quit',
accelerator: 'Command+Q',
accelerator: 'CmdOrCtrl+Q',
selector: 'terminate:'
},
]
@ -81,12 +83,12 @@ var template = [
submenu: [
{
label: 'Undo',
accelerator: 'Command+Z',
accelerator: 'CmdOrCtrl+Z',
selector: 'undo:'
},
{
label: 'Redo',
accelerator: 'Shift+Command+Z',
accelerator: 'Shift+CmdOrCtrl+Z',
selector: 'redo:'
},
{
@ -94,22 +96,22 @@ var template = [
},
{
label: 'Cut',
accelerator: 'Command+X',
accelerator: 'CmdOrCtrl+X',
selector: 'cut:'
},
{
label: 'Copy',
accelerator: 'Command+C',
accelerator: 'CmdOrCtrl+C',
selector: 'copy:'
},
{
label: 'Paste',
accelerator: 'Command+V',
accelerator: 'CmdOrCtrl+V',
selector: 'paste:'
},
{
label: 'Select All',
accelerator: 'Command+A',
accelerator: 'CmdOrCtrl+A',
selector: 'selectAll:'
}
]
@ -119,12 +121,12 @@ var template = [
submenu: [
{
label: 'Reload',
accelerator: 'Command+R',
accelerator: 'CmdOrCtrl+R',
click: function() { remote.getCurrentWindow().reload(); }
},
{
label: 'Toggle DevTools',
accelerator: 'Alt+Command+I',
accelerator: 'Alt+CmdOrCtrl+I',
click: function() { remote.getCurrentWindow().toggleDevTools(); }
},
]
@ -134,12 +136,12 @@ var template = [
submenu: [
{
label: 'Minimize',
accelerator: 'Command+M',
accelerator: 'CmdOrCtrl+M',
selector: 'performMiniaturize:'
},
{
label: 'Close',
accelerator: 'Command+W',
accelerator: 'CmdOrCtrl+W',
selector: 'performClose:'
},
{

View file

@ -137,3 +137,7 @@ Returns the size of the image.
* `option` Boolean
Marks the image as template image.
### NativeImage.isTemplateImage()
Returns whether the image is a template image.

View file

@ -37,6 +37,11 @@ Registers a custom protocol of `scheme`, the `handler` would be called with
You need to return a request job in the `handler` to specify which type of
response you would like to send.
By default the scheme is treated like `http:`, which is parsed differently
from protocols that follows "generic URI syntax" like `file:`, so you probably
want to call `protocol.registerStandardSchemes` to make your scheme treated as
standard scheme.
## protocol.unregisterProtocol(scheme, callback)
* `scheme` String
@ -48,7 +53,11 @@ Unregisters the custom protocol of `scheme`.
* `value` Array
`value` is an array of custom schemes to be registered to the standard.
`value` is an array of custom schemes to be registered as standard schemes.
A standard scheme adheres to what RFC 3986 calls
[generic URI syntax](https://tools.ietf.org/html/rfc3986#section-3). This
includes `file:` and `filesystem:`.
## protocol.isHandledProtocol(scheme, callback)
@ -101,6 +110,9 @@ Create a request job which sends a buffer as response.
## Class: protocol.RequestHttpJob(options)
* `options` Object
* `session` [Session](browser-window.md#class-session) - By default it is
the app's default session, setting it to `null` will create a new session
for the requests
* `url` String
* `method` String - Default is `GET`
* `referrer` String

View file

@ -20,7 +20,8 @@ var win = new BrowserWindow({ width: 800, height: 600 });
win.loadUrl('https://github.com');
```
Note: for the reverse (access renderer process from main process), you can use [webContents.executeJavascript](https://github.com/atom/electron/blob/master/docs/api/browser-window.md#browserwindowwebcontents).
Note: for the reverse (access renderer process from main process), you can use
[webContents.executeJavascript](browser-window.md#webcontents-executejavascript-code).
## Remote objects

View file

@ -25,9 +25,10 @@ app.on('ready', function(){
__Platform limitations:__
* On OS X `clicked` event will be ignored if the tray icon has context menu.
* On Linux app indicator will be used if it is supported, otherwise
`GtkStatusIcon` will be used instead.
* On Linux distributions that only have app indicator support, you have to
install `libappindicator1` to make tray icon work.
* App indicator will only be showed when it has context menu.
* When app indicator is used on Linux, `clicked` event is ignored.
@ -46,7 +47,11 @@ Creates a new tray icon associated with the `image`.
### Event: 'clicked'
* `event`
* `event` Event
* `altKey` Boolean
* `shiftKey` Boolean
* `ctrlKey` Boolean
* `metaKey` Boolean
* `bounds` Object - the bounds of tray icon
* `x` Integer
* `y` Integer
@ -55,13 +60,41 @@ Creates a new tray icon associated with the `image`.
Emitted when the tray icon is clicked.
__Note:__ The `bounds` payload is only implemented on OS X and Windows 7 or newer.
__Note:__ The `bounds` payload is only implemented on OS X and Windows.
### Event: 'right-clicked'
* `event` Event
* `altKey` Boolean
* `shiftKey` Boolean
* `ctrlKey` Boolean
* `metaKey` Boolean
* `bounds` Object - the bounds of tray icon
* `x` Integer
* `y` Integer
* `width` Integer
* `height` Integer
Emitted when the tray icon is right clicked.
__Note:__ This is only implemented on OS X and Windows.
### Event: 'double-clicked'
* `event` Event
* `altKey` Boolean
* `shiftKey` Boolean
* `ctrlKey` Boolean
* `metaKey` Boolean
* `bounds` Object - the bounds of tray icon
* `x` Integer
* `y` Integer
* `width` Integer
* `height` Integer
Emitted when the tray icon is double clicked.
__Note:__ This is only implemented on OS X.
__Note:__ This is only implemented on OS X and Windows.
### Event: 'balloon-show'
@ -82,6 +115,15 @@ closes it.
__Note:__ This is only implemented on Windows.
### Event: 'drop-files'
* `event`
* `files` Array - the file path of dropped files.
Emitted when dragged files are dropped in the tray icon.
__Note:__ This is only implemented on OS X.
### Tray.destroy()
Destroys the tray icon immediately.
@ -131,6 +173,16 @@ Displays a tray balloon.
__Note:__ This is only implemented on Windows.
### Tray.popUpContextMenu([position])
* `position` Object - The pop position
* `x` Integer
* `y` Integer
The `position` is only available on Windows, and it is (0, 0) by default.
__Note:__ This is only implemented on OS X and Windows.
### Tray.setContextMenu(menu)
* `menu` Menu

View file

@ -57,10 +57,17 @@ require('web-frame').setSpellCheckProvider("en-US", true, {
* `scheme` String
Sets the `scheme` as secure scheme.
Registers the `scheme` as secure scheme.
Secure schemes do not trigger mixed content warnings. For example, `https` and
`data` are secure schemes because they cannot be corrupted by active network
attackers.
## webFrame.registerUrlSchemeAsBypassingCsp(scheme)
* `scheme` String
Resources will be loaded from this `scheme` regardless of
page's Content Security Policy.
[spellchecker]: https://github.com/atom/node-spellchecker

View file

@ -130,10 +130,10 @@ If "on", the guest page will have web security disabled.
## Methods
The webview element must be loaded before using the methods.
The webview element must be loaded before using the methods.
**Example**
```javascript
webview.addEventListener("dom-ready", function(){
webview.addEventListener("dom-ready", function() {
webview.openDevTools();
});
```
@ -215,17 +215,24 @@ Whether the renderer process has crashed.
Overrides the user agent for guest page.
### `<webview>`.getUserAgent()
Returns a `String` represents the user agent for guest page.
### `<webview>`.insertCSS(css)
* `css` String
Injects CSS into guest page.
### `<webview>`.executeJavaScript(code)
### `<webview>`.executeJavaScript(code, userGesture)
* `code` String
* `userGesture` Boolean - Default false
Evaluates `code` in guest page.
Evaluates `code` in page. If `userGesture` is set will create user gesture context,
HTML api like `requestFullScreen` which require user action can take advantage
of this option for automation.
### `<webview>`.openDevTools()
@ -308,11 +315,11 @@ Executes editing command `replace` in page.
Executes editing command `replaceMisspelling` in page.
### `<webview>.print([options])`
### `<webview>`.print([options])
Prints webview's web page. Same with `webContents.print([options])`.
### `<webview>.printToPDF(options, callback)`
### `<webview>`.printToPDF(options, callback)
Prints webview's web page as PDF, Same with `webContents.printToPDF(options, callback)`
@ -328,6 +335,15 @@ examples.
## DOM events
### load-commit
* `url` String
* `isMainFrame` Boolean
Fired when a load has committed. This includes navigation within the current
document as well as subframe document-level loads, but does not include
asynchronous resource loads.
### did-finish-load
Fired when the navigation is done, i.e. the spinner of the tab will stop

View file

@ -2,7 +2,7 @@
When `window.open` is called to create a new window in web page, a new instance
of `BrowserWindow` will be created for the `url`, and a proxy will be returned
to `window.open` to let the page to have limited control over it.
to `window.open` to let the page have limited control over it.
The proxy only has some limited standard functionality implemented to be
compatible with traditional web pages, for full control of the created window