Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 105 additions & 0 deletions browsers/chrome-policy.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
---
title: "Chrome policies"
description: "Customize Chrome behavior on Kernel browsers using Chrome enterprise policies"
---

Kernel browsers accept an optional `chrome_policy` object that lets you apply [Chrome enterprise policies](https://chromeenterprise.google/policies/) to the browser at launch. Use this to control startup behavior, default homepages, bookmarks, download UI, notifications, and other browser-level settings.

`chrome_policy` is supported on:

- [`browsers.create()`](/api-reference/browsers/create-a-browser#body-chrome-policy) — on-demand browser sessions
- [`browserPools.create()`](/api-reference/browser-pools/create-a-browser-pool#body-chrome-policy) and [`browserPools.update()`](/api-reference/browser-pools/update-a-browser-pool#body-chrome-policy) — reserved browser pools
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Relative /api-reference/ links will break CI checks

High Severity

All /api-reference/... links in the new browsers/chrome-policy.mdx page (lines 10–11) and the updated browsers/pools/policy-json.mdx (line 6) use relative paths. API reference pages are auto-generated from a remote OpenAPI spec and don't exist locally, so relative links will fail the mint broken-links CI check. These need to be absolute URLs (e.g. https://kernel.sh/docs/api-reference/...). Notably, policy-json.mdx previously had the correct absolute URL and this PR regressed it to a relative one.

Additional Locations (1)
Fix in Cursor Fix in Web

Triggered by learned rule: Use absolute URLs for /api-reference/ links

Reviewed by Cursor Bugbot for commit 1441b9a. Configure here.


Keys are Chrome policy names and values are the corresponding settings.

## On-demand browsers

Pass `chrome_policy` when creating an on-demand browser. The policy is applied at session creation time.

<CodeGroup>
```typescript Typescript/Javascript
import Kernel from '@onkernel/sdk';

const kernel = new Kernel();

const kernelBrowser = await kernel.browsers.create({
chrome_policy: {
HomepageLocation: "https://kernel.sh",
HomepageIsNewTabPage: false,
ShowHomeButton: true,
DownloadBubbleEnabled: false,
},
});
```

```python Python
from kernel import Kernel

kernel = Kernel()

kernel_browser = kernel.browsers.create(
chrome_policy={
"HomepageLocation": "https://kernel.sh",
"HomepageIsNewTabPage": False,
"ShowHomeButton": True,
"DownloadBubbleEnabled": False,
},
)
```
</CodeGroup>

The policy is echoed on `GET /browsers/{id}` and `GET /browsers` responses so you can verify what was applied.

## Reserved browser pools

Pass `chrome_policy` when [creating](/browsers/pools/overview#create-a-pool-of-reserved-browsers) or [updating](/browsers/pools/overview#update-a-pool) a pool. Every browser in the pool launches with the policy applied. See [Custom chrome policies on pools](/browsers/pools/policy-json) for the pool-specific update flow (including `discard_all_idle`).

<CodeGroup>
```typescript Typescript/Javascript
import Kernel from '@onkernel/sdk';

const kernel = new Kernel();

const pool = await kernel.browserPools.create({
name: "my-pool",
size: 5,
chrome_policy: {
DownloadBubbleEnabled: false,
HomepageLocation: "https://example.com",
},
});
```

```python Python
from kernel import Kernel

kernel = Kernel()

pool = kernel.browser_pools.create(
name="my-pool",
size=5,
chrome_policy={
"DownloadBubbleEnabled": False,
"HomepageLocation": "https://example.com",
},
)
```
</CodeGroup>

## Example policies

| Policy | Type | Description |
| --- | --- | --- |
| `HomepageLocation` | `string` | URL loaded when clicking the home button |
| `HomepageIsNewTabPage` | `boolean` | When `false`, the home button navigates to `HomepageLocation` instead of the new tab page |
| `ShowHomeButton` | `boolean` | Shows the home button in the toolbar |
| `NewTabPageLocation` | `string` | URL shown when opening a new tab |
| `RestoreOnStartup` | `integer` | Set to `4` to open a specific list of URLs on browser startup |
| `RestoreOnStartupURLs` | `string[]` | URLs to open when the browser starts. Requires `RestoreOnStartup` set to `4` |
| `BookmarkBarEnabled` | `boolean` | Shows the bookmark bar |
| `ManagedBookmarks` | `array` | Pre-configured bookmarks. Supports folders via nested `children` arrays |
| `DownloadBubbleEnabled` | `boolean` | Controls the download bubble UI. Set to `false` to fall back to the classic download shelf |
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deprecated Chrome policy documented with incorrect behavior

Medium Severity

DownloadBubbleEnabled is a deprecated Chrome policy (removed after Chrome 118). Its table description claims setting it to false falls back to "the classic download shelf," but this Chromium UI element no longer exists in modern Chrome. This references version-specific Chromium implementation details as product documentation and will mislead users since the policy has no effect. It's also used as a prominent example in code samples across both new pages, which compounds the issue.

Additional Locations (2)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit a5e62b0. Configure here.


## Available policies

Any policy listed in the [Chrome Enterprise policy documentation](https://chromeenterprise.google/policies/) can be used in the `chrome_policy` object. Refer to the official docs for the full list of supported policy names, types, and values.
25 changes: 25 additions & 0 deletions browsers/create-a-browser.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,31 @@ print(kernel_browser.session_id)
```
</CodeGroup>

### Customizing the browser

`browsers.create()` accepts options to configure the session at launch — for example, [`chrome_policy`](/browsers/chrome-policy) to apply [Chrome enterprise policies](https://chromeenterprise.google/policies/) and `start_url` to open a specific URL when the browser starts.

<CodeGroup>
```typescript Typescript/Javascript
const kernelBrowser = await kernel.browsers.create({
start_url: "https://example.com",
chrome_policy: {
HomepageLocation: "https://kernel.sh",
DownloadBubbleEnabled: false,
},
});
```

```python Python
kernel_browser = kernel.browsers.create(
start_url="https://example.com",
chrome_policy={
"HomepageLocation": "https://kernel.sh",
"DownloadBubbleEnabled": False,
},
)
```
</CodeGroup>

## 2. Connect to the browser

Expand Down
23 changes: 4 additions & 19 deletions browsers/pools/policy-json.mdx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
---
title: "custom chrome policies"
description: "Customize Chrome behavior in reserved browser pools using Chrome policies"
description: "Apply Chrome enterprise policies to every browser in a reserved pool"
---

Browser pools accept an optional [`chrome_policy`](https://kernel.sh/docs/api-reference/browser-pools/create-a-browser-pool#body-chrome-policy) object that lets you apply [Chrome enterprise policies](https://chromeenterprise.google/policies/) to every browser in the pool. Use this to control startup behavior, default homepages, bookmarks, and other browser-level settings.
Browser pools accept an optional [`chrome_policy`](/api-reference/browser-pools/create-a-browser-pool#body-chrome-policy) object that applies [Chrome enterprise policies](https://chromeenterprise.google/policies/) to every browser in the pool. The same field is also available on on-demand browsers — see [Chrome policies](/browsers/chrome-policy) for the general reference, supported keys, and on-demand usage.

## Setting chrome policies
## Setting chrome policies on a pool

Pass a `chrome_policy` object when [creating](/browsers/pools/overview#create-a-pool-of-reserved-browsers) or [updating](/browsers/pools/overview#update-a-pool) a pool. Keys are Chrome policy names and values are the corresponding settings.

Expand Down Expand Up @@ -112,21 +112,6 @@ You can update `chrome_policy` on an existing pool. Pass `discard_all_idle: true
}
```

## Example policies

The example above demonstrates setting a default homepage and managed bookmarks. Here's what each policy does:

| Policy | Type | Description |
| --- | --- | --- |
| `HomepageLocation` | `string` | URL loaded when clicking the home button |
| `HomepageIsNewTabPage` | `boolean` | When `false`, the home button navigates to `HomepageLocation` instead of the new tab page |
| `ShowHomeButton` | `boolean` | Shows the home button in the toolbar |
| `NewTabPageLocation` | `string` | URL shown when opening a new tab |
| `RestoreOnStartup` | `integer` | Set to `4` to open a specific list of URLs on browser startup |
| `RestoreOnStartupURLs` | `string[]` | URLs to open when the browser starts. Requires `RestoreOnStartup` set to `4` |
| `BookmarkBarEnabled` | `boolean` | Shows the bookmark bar |
| `ManagedBookmarks` | `array` | Pre-configured bookmarks. Supports folders via nested `children` arrays |

## Available policies

Any policy listed in the [Chrome Enterprise policy documentation](https://chromeenterprise.google/policies/) can be used in the `chrome_policy` object. Refer to the official docs for the full list of supported policy names, types, and values.
See [Chrome policies](/browsers/chrome-policy#example-policies) for a reference of commonly used policy keys. Any policy listed in the [Chrome Enterprise policy documentation](https://chromeenterprise.google/policies/) can be used in the `chrome_policy` object.
1 change: 1 addition & 0 deletions docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
"browsers/replays",
"browsers/viewport",
"browsers/gpu-acceleration",
"browsers/chrome-policy",
{
"group": "Auth",
"pages": [
Expand Down
Loading