Browse Source

Merge pull request #12900 from electron/make-httpReferrer-docs-consistent

fix broken doc errors
John Kleinschmidt 7 years ago
parent
commit
bbba9ff906
5 changed files with 80 additions and 10 deletions
  1. 69 0
      docs/api/app.md
  2. 1 1
      docs/api/browser-window.md
  3. 2 2
      docs/api/structures/referrer.md
  4. 7 6
      docs/api/web-frame.md
  5. 1 1
      docs/api/webview-tag.md

+ 69 - 0
docs/api/app.md

@@ -758,6 +758,66 @@ app.setJumpList([
 ])
 ```
 
+### `app.makeSingleInstance(callback)` *(Deprecated)*
+
+* `callback` Function
+  * `argv` String[] - An array of the second instance's command line arguments
+  * `workingDirectory` String - The second instance's working directory
+
+Returns `Boolean`.
+
+**Deprecated**: This method has been deprecated and is scheduled for removal.
+Please use `app.requestSingleInstanceLock()` instead.
+
+This method makes your application a Single Instance Application - instead of
+allowing multiple instances of your app to run, this will ensure that only a
+single instance of your app is running, and other instances signal this
+instance and exit.
+
+`callback` will be called by the first instance with `callback(argv, workingDirectory)`
+when a second instance has been executed. `argv` is an Array of the second instance's
+command line arguments, and `workingDirectory` is its current working directory. Usually
+applications respond to this by making their primary window focused and
+non-minimized.
+
+The `callback` is guaranteed to be executed after the `ready` event of `app`
+gets emitted.
+
+This method returns `false` if your process is the primary instance of the
+application and your app should continue loading. And returns `true` if your
+process has sent its parameters to another instance, and you should immediately
+quit.
+
+On macOS the system enforces single instance automatically when users try to open
+a second instance of your app in Finder, and the `open-file` and `open-url`
+events will be emitted for that. However when users start your app in command
+line the system's single instance mechanism will be bypassed and you have to
+use this method to ensure single instance.
+
+An example of activating the window of primary instance when a second instance
+starts:
+
+```javascript
+const {app} = require('electron')
+let myWindow = null
+
+const isSecondInstance = app.makeSingleInstance((commandLine, workingDirectory) => {
+  // Someone tried to run a second instance, we should focus our window.
+  if (myWindow) {
+    if (myWindow.isMinimized()) myWindow.restore()
+    myWindow.focus()
+  }
+})
+
+if (isSecondInstance) {
+  app.quit()
+}
+
+// Create myWindow, load the rest of the app, etc...
+app.on('ready', () => {
+})
+```
+
 ### `app.requestSingleInstanceLock()`
 
 Returns `Boolean`
@@ -818,6 +878,15 @@ holding the single instance lock.  You can request the lock with
 `app.requestSingleInstanceLock()` and release with
 `app.releaseSingleInstanceLock()`
 
+### `app.releaseSingleInstance()` *(Deprecated)*
+
+Releases all locks that were created by `makeSingleInstance`. This will allow
+multiple instances of the application to once again run side by side.
+
+**Deprecated**: This method has been deprecated and is scheduled for removal.
+Please use the `app.requestSingleInstanceLock()` and `app.releaseSingleInstanceLock()`
+methods instead.
+
 ### `app.releaseSingleInstanceLock()`
 
 Releases all locks that were created by `requestSingleInstanceLock`. This will

+ 1 - 1
docs/api/browser-window.md

@@ -1150,7 +1150,7 @@ Same as `webContents.capturePage([rect, ]callback)`.
 
 * `url` String
 * `options` Object (optional)
-  * `httpReferrer` String (optional) - An HTTP Referrer url.
+  * `httpReferrer` (String | [Referrer](structures/referrer.md)) (optional) - An HTTP Referrer url.
   * `userAgent` String (optional) - A user agent originating the request.
   * `extraHeaders` String (optional) - Extra headers separated by "\n"
   * `postData` ([UploadRawData[]](structures/upload-raw-data.md) | [UploadFile[]](structures/upload-file.md) | [UploadFileSystem[]](structures/upload-file-system.md) | [UploadBlob[]](structures/upload-blob.md)) (optional)

+ 2 - 2
docs/api/structures/referrer.md

@@ -3,8 +3,8 @@
 * `url` String - HTTP Referrer URL.
 * `policy` String - Can be `default`, `unsafe-url`,
   `no-referrer-when-downgrade`, `no-referrer`, `origin`,
-  `strict-origin-when-cross-origin`, `same-origin`, `strict-origin`, or
-  `no-referrer`. See the [Referrer-Policy spec][1] for more details on the
+  `strict-origin-when-cross-origin`, `same-origin`, `strict-origin`.
+  See the [Referrer-Policy spec][1] for more details on the
   meaning of these values.
 
 [1]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Referrer-Policy

+ 7 - 6
docs/api/web-frame.md

@@ -237,10 +237,10 @@ renderer process.
 
 ### `webFrame.findFrameByRoutingId(routingId)`
 
-* `routingId` Integer - A unique frame id in the current renderer process.
-  Routing IDs can be retrieved from `WebFrame` instances (`webFrame.routingId`)
-  and are also passed by frame specific `WebContents` navigation events (e.g. 
-  `did-frame-navigate`)
+* `routingId` Integer - An `Integer` representing the unique frame id in the
+   current renderer process. Routing IDs can be retrieved from `WebFrame`
+   instances (`webFrame.routingId`) and are also passed by frame
+   specific `WebContents` navigation events (e.g. `did-frame-navigate`)
   
 Returns `WebFrame` - that has the supplied `routingId`, `null` if not found. 
 
@@ -276,5 +276,6 @@ current renderer process.
 
 ### `webFrame.routingId`
 
-A unique frame id in the current renderer process. Distinct WebFrame instances
-that refer to the same underlying frame will have the same `routingId`.
+An `Integer` representing the unique frame id in the current renderer process.
+Distinct WebFrame instances that refer to the same underlying frame will have
+the same `routingId`.

+ 1 - 1
docs/api/webview-tag.md

@@ -306,7 +306,7 @@ webview.addEventListener('dom-ready', () => {
 
 * `url` URL
 * `options` Object (optional)
-  * `httpReferrer` String (optional) - An HTTP Referrer url.
+  * `httpReferrer` (String | [Referrer](structures/referrer.md)) (optional) - An HTTP Referrer url.
   * `userAgent` String (optional) - A user agent originating the request.
   * `extraHeaders` String (optional) - Extra headers separated by "\n"
   * `postData` ([UploadRawData[]](structures/upload-raw-data.md) | [UploadFile[]](structures/upload-file.md) | [UploadFileSystem[]](structures/upload-file-system.md) | [UploadBlob[]](structures/upload-blob.md)) (optional) -