| OLD | NEW |
| 1 # Headless Chromium | 1 # Headless Chromium |
| 2 | 2 |
| 3 Headless Chromium is a library for running Chromium in a headless/server | 3 Headless Chromium allows running Chromium in a headless/server environment. |
| 4 environment. Expected use cases include loading web pages, extracting metadata | 4 Expected use cases include loading web pages, extracting metadata (e.g., the |
| 5 (e.g., the DOM) and generating bitmaps from page contents -- using all the | 5 DOM) and generating bitmaps from page contents -- using all the modern web |
| 6 modern web platform features provided by Chromium and Blink. | 6 platform features provided by Chromium and Blink. |
| 7 | 7 |
| 8 See the [architecture design doc](https://docs.google.com/document/d/11zIkKkLBoc
ofGgoTeeyibB2TZ_k7nR78v7kNelCatUE) | 8 There are two ways to use Headless Chromium: |
| 9 for more information. | |
| 10 | 9 |
| 11 ## Headless shell | 10 ## Usage via the DevTools remote debugging protocol |
| 12 | 11 |
| 13 The headless shell is a sample application which demonstrates the use of the | 12 1. Start a normal Chrome binary with the `--headless` command line flag |
| 14 headless API. To run it, first initialize a headless build configuration: | 13 (Linux-only for now): |
| 14 |
| 15 ``` |
| 16 $ chrome --headless --remote-debugging-port=9222 https://chromium.org |
| 17 ``` |
| 18 |
| 19 Currently you'll also need to use `--disable-gpu` to avoid an error from a |
| 20 missing Mesa library. |
| 21 |
| 22 2. Navigate to `http://localhost:9222` in another browser to open the |
| 23 [DevTools](https://developer.chrome.com/devtools) interface or use a tool such |
| 24 as [Selenium](http://www.seleniumhq.org/) to drive the headless browser. |
| 25 |
| 26 ## Usage as a C++ library |
| 27 |
| 28 Headless Chromium can be built as a library for embedding into a C++ |
| 29 application. This approach is otherwise similar to controlling the browser over |
| 30 a DevTools connection, but it provides more customization points, e.g., for |
| 31 networking and [mojo services](https://docs.google.com/document/d/1Fr6_DJH6OK9rG
3-ibMvRPTNnHsAXPk0VzxxiuJDSK3M/edit#heading=h.qh0udvlk963d). |
| 32 |
| 33 Headless Shell is a sample application which demonstrates the use of the |
| 34 headless C++ API. To run it, first initialize a headless build configuration: |
| 15 | 35 |
| 16 ``` | 36 ``` |
| 17 $ mkdir -p out/Debug | 37 $ mkdir -p out/Debug |
| 18 $ echo 'import("//build/args/headless.gn")' > out/Debug/args.gn | 38 $ echo 'import("//build/args/headless.gn")' > out/Debug/args.gn |
| 19 $ gn gen out/Debug | 39 $ gn gen out/Debug |
| 20 ``` | 40 ``` |
| 21 | 41 |
| 22 Then build the shell: | 42 Then build the shell: |
| 23 | 43 |
| 24 ``` | 44 ``` |
| 25 $ ninja -C out/Debug headless_shell | 45 $ ninja -C out/Debug headless_shell |
| 26 ``` | 46 ``` |
| 27 | 47 |
| 28 After the build completes, the headless shell can be run with the following | 48 After the build completes, Headless Shell can be run with the following command: |
| 29 command: | |
| 30 | 49 |
| 31 ``` | 50 ``` |
| 32 $ out/Debug/headless_shell https://www.google.com | 51 $ out/Debug/headless_shell https://www.google.com |
| 33 ``` | 52 ``` |
| 34 | 53 |
| 35 To attach a [DevTools](https://developer.chrome.com/devtools) debugger to the | 54 To attach a [DevTools](https://developer.chrome.com/devtools) debugger to the |
| 36 shell, start it with an argument specifying the debugging port: | 55 shell, start it with an argument specifying the debugging port: |
| 37 | 56 |
| 38 ``` | 57 ``` |
| 39 $ out/Debug/headless_shell --remote-debugging-port=9222 https://youtube.com | 58 $ out/Debug/headless_shell --remote-debugging-port=9222 https://youtube.com |
| 40 ``` | 59 ``` |
| 41 | 60 |
| 42 Then navigate to `http://127.0.0.1:9222` with your browser. | 61 Then navigate to `http://localhost:9222` with your browser. |
| 43 | 62 |
| 44 ## Embedder API | 63 ## Embedder API |
| 45 | 64 |
| 46 The embedder API allows developers to integrate the headless library into their | 65 The embedder API allows developers to integrate the headless library into their |
| 47 application. The API provides default implementations for low level adaptation | 66 application. The API provides default implementations for low level adaptation |
| 48 points such as networking and the run loop. | 67 points such as networking and the run loop. |
| 49 | 68 |
| 50 The main embedder API classes are: | 69 The main embedder API classes are: |
| 51 | 70 |
| 52 - `HeadlessBrowser::Options::Builder` - Defines the embedding options, e.g.: | 71 - `HeadlessBrowser::Options::Builder` - Defines the embedding options, e.g.: |
| 53 - `SetMessagePump` - Replaces the default base message pump. See | 72 - `SetMessagePump` - Replaces the default base message pump. See |
| 54 `base::MessagePump`. | 73 `base::MessagePump`. |
| 55 - `SetProxyServer` - Configures an HTTP/HTTPS proxy server to be used for | 74 - `SetProxyServer` - Configures an HTTP/HTTPS proxy server to be used for |
| 56 accessing the network. | 75 accessing the network. |
| 57 | 76 |
| 58 ## Client/DevTools API | 77 ## Client/DevTools API |
| 59 | 78 |
| 60 The headless client API is used to drive the browser and interact with loaded | 79 The headless client API is used to drive the browser and interact with loaded |
| 61 web pages. Its main classes are: | 80 web pages. Its main classes are: |
| 62 | 81 |
| 63 - `HeadlessBrowser` - Represents the global headless browser instance. | 82 - `HeadlessBrowser` - Represents the global headless browser instance. |
| 64 - `HeadlessWebContents` - Represents a single "tab" within the browser. | 83 - `HeadlessWebContents` - Represents a single "tab" within the browser. |
| 65 - `HeadlessDevToolsClient` - Provides a C++ interface for inspecting and | 84 - `HeadlessDevToolsClient` - Provides a C++ interface for inspecting and |
| 66 controlling a tab. The API functions corresponds to [DevTools commands](https:
//developer.chrome.com/devtools/docs/debugger-protocol). | 85 controlling a tab. The API functions corresponds to [DevTools commands](https:
//developer.chrome.com/devtools/docs/debugger-protocol). |
| 67 See the [client API documentation](https://docs.google.com/document/d/1rlqcp8n
k-ZQvldNJWdbaMbwfDbJoOXvahPCDoPGOwhQ/edit#) | 86 See the [client API documentation](https://docs.google.com/document/d/1rlqcp8n
k-ZQvldNJWdbaMbwfDbJoOXvahPCDoPGOwhQ/edit#) |
| 68 for more information. | 87 for more information. |
| 69 | 88 |
| 70 ## Documentation | 89 ## Resources and Documentation |
| 90 |
| 91 Mailing list: [headless-dev@chromium.org](https://groups.google.com/a/chromium.o
rg/forum/#!forum/headless-dev) |
| 92 Bug tracker: [Proj=Headless](https://bugs.chromium.org/p/chromium/issues/list?ca
n=2&q=Proj%3DHeadless) |
| 71 | 93 |
| 72 * [Runtime headless mode for Chrome](https://docs.google.com/document/d/1aIJUzQr
3eougZQp90bp4mqGr5gY6hdUice8UPa-Ys90/edit#) | 94 * [Runtime headless mode for Chrome](https://docs.google.com/document/d/1aIJUzQr
3eougZQp90bp4mqGr5gY6hdUice8UPa-Ys90/edit#) |
| 73 * [Virtual Time in Blink](https://docs.google.com/document/d/1y9kdt_zezt7pbey6uz
vt1dgklwc1ob_vy4nzo1zbqmo/edit#heading=h.tn3gd1y9ifml) | 95 * [Virtual Time in Blink](https://docs.google.com/document/d/1y9kdt_zezt7pbey6uz
vt1dgklwc1ob_vy4nzo1zbqmo/edit#heading=h.tn3gd1y9ifml) |
| 74 * [Headless Chrome architecture](https://docs.google.com/document/d/11zIkKkLBoco
fGgoTeeyibB2TZ_k7nR78v7kNelCatUE/edit) | 96 * [Headless Chrome architecture](https://docs.google.com/document/d/11zIkKkLBoco
fGgoTeeyibB2TZ_k7nR78v7kNelCatUE/edit) |
| 75 * [Headless Chrome C++ DevTools API](https://docs.google.com/document/d/1rlqcp8n
k-ZQvldNJWdbaMbwfDbJoOXvahPCDoPGOwhQ/edit#heading=h.ng2bxb15li9a) | 97 * [Headless Chrome C++ DevTools API](https://docs.google.com/document/d/1rlqcp8n
k-ZQvldNJWdbaMbwfDbJoOXvahPCDoPGOwhQ/edit#heading=h.ng2bxb15li9a) |
| 76 * [Session isolation in Headless Chrome](https://docs.google.com/document/d/1XAK
vrxtSEoe65vNghSWC5S3kJ--z2Zpt2UWW1Fi8GiM/edit) | 98 * [Session isolation in Headless Chrome](https://docs.google.com/document/d/1XAK
vrxtSEoe65vNghSWC5S3kJ--z2Zpt2UWW1Fi8GiM/edit) |
| 77 * [Headless Chrome mojo service](https://docs.google.com/document/d/1Fr6_DJH6OK9
rG3-ibMvRPTNnHsAXPk0VzxxiuJDSK3M/edit#heading=h.qh0udvlk963d) | 99 * [Headless Chrome mojo service](https://docs.google.com/document/d/1Fr6_DJH6OK9
rG3-ibMvRPTNnHsAXPk0VzxxiuJDSK3M/edit#heading=h.qh0udvlk963d) |
| 78 * [Controlling BeginFrame through DevTools](https://docs.google.com/document/d/1
LVMYDkfjrrX9PNkrD8pJH5-Np_XUTQHIuJ8IEOirQH4/edit?ts=57d96dbd#heading=h.ndv831lc9
uf0) | 100 * [Controlling BeginFrame through DevTools](https://docs.google.com/document/d/1
LVMYDkfjrrX9PNkrD8pJH5-Np_XUTQHIuJ8IEOirQH4/edit?ts=57d96dbd#heading=h.ndv831lc9
uf0) |
| 79 * [Viewport bounds and scale for screenshots](https://docs.google.com/document/d
/1VTcYz4q_x0f1O5IVrvRX4u1DVd_K34IVUl1VULLTCWw/edit#heading=h.ndv831lc9uf0) | 101 * [Viewport bounds and scale for screenshots](https://docs.google.com/document/d
/1VTcYz4q_x0f1O5IVrvRX4u1DVd_K34IVUl1VULLTCWw/edit#heading=h.ndv831lc9uf0) |
| 80 * [BlinkOn 6 presentation slides](https://docs.google.com/presentation/d/1gqK9F4
lGAY3TZudAtdcxzMQNEE7PcuQrGu83No3l0lw/edit#slide=id.p) | 102 * [BlinkOn 6 presentation slides](https://docs.google.com/presentation/d/1gqK9F4
lGAY3TZudAtdcxzMQNEE7PcuQrGu83No3l0lw/edit#slide=id.p) |
| 103 * [Architecture design doc](https://docs.google.com/document/d/11zIkKkLBocofGgoT
eeyibB2TZ_k7nR78v7kNelCatUE) |
| OLD | NEW |