The sandbox option allows multiple webContents in one renderer process, so using
the only the renderer id to identify WebContents instances is no longer an
option.
WebContents::GetID now returns a 64-bit integer, which is composed of both the
process id(high 32), and the RenderViewHost routing id(low 32). Also add a
`GetProcessID` that retrieves the renderer process id, a requirement in some of
our javascript code.
Add a gyp target that creates a browserify bundle starting with
`lib/sandboxed_renderer/init.js`, which is embedded into the executable using
the `atom_js2c` target.
The goal of this bundle is to provide a very basic environment for preload
scripts where a `require` function is available.
Before invoking js2c, copy all files that must be embedded into the shared
intermediate directory, and modify the js2c wrapper script to include all files
from that directory(which is passed as argument).
This allows the build system to embed files that don't share a common base
directory, such as javascript generated at build time.
- Allow `api::Window` instances to be created from existing `api::WebContents`.
- Override `WebContentsCreated` and `AddNewContents` to wrap renderer-created
`content::WebContents` into `api::WebContents`.
- For `content::WebContents` that should be displayed in new windows, pass the
wrapped `api::WebContents` object to window manager.
- Add an overload to `WebContents::CreateFrom` that accepts a type parameter. If
type is `REMOTE`, initialization is the same as before(a thin wrapper). If
not, the `api::WebContents` will be fully initialized, as if it was created by
`api::WebContents::Create`.
- Move common initialization code to `InitWithSessionAndOptions`.
When `--enable-sandbox` is passed, electron will use chromium sandbox to spawn
all renderers, and every new BrowserWindow will automatically have "sandboxed"
passed as a web preference(since the renderer would not work properly
otherwise).
When "sandboxed" is passed as a web preference for `BrowserWindow`, the newly
created renderer won't run any node.js code/integration, only communicating with
the system via the IPC API of the content module. This is a requirement for
running the renderer under chrome OS-level sandbox.
Beyond that, certain behaviors of AtomBrowserClient are modified when dealing
with sandboxed renderers:
- `OverrideSiteInstanceNavigation` no longer create a new `SiteInstance` for
every navigation. Instead, it reuses the source `SiteInstance` when not
navigating to a different site.
- `CanCreateWindow` will return true and allow javascript access.