|
| 1 | +--- |
| 2 | +title: "Chrome policies" |
| 3 | +description: "Customize Chrome behavior on Kernel browsers using Chrome enterprise policies" |
| 4 | +--- |
| 5 | + |
| 6 | +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. |
| 7 | + |
| 8 | +`chrome_policy` is supported on: |
| 9 | + |
| 10 | +- [`browsers.create()`](https://kernel.sh/docs/api-reference/browsers/create-a-browser#body-chrome-policy) — on-demand browser sessions |
| 11 | +- [`browserPools.create()`](https://kernel.sh/docs/api-reference/browser-pools/create-a-browser-pool#body-chrome-policy) and [`browserPools.update()`](https://kernel.sh/docs/api-reference/browser-pools/update-a-browser-pool#body-chrome-policy) — reserved browser pools |
| 12 | + |
| 13 | +Keys are Chrome policy names and values are the corresponding settings. |
| 14 | + |
| 15 | +## On-demand browsers |
| 16 | + |
| 17 | +Pass `chrome_policy` when creating an on-demand browser. The policy is applied at session creation time. |
| 18 | + |
| 19 | +<CodeGroup> |
| 20 | +```typescript Typescript/Javascript |
| 21 | +import Kernel from '@onkernel/sdk'; |
| 22 | + |
| 23 | +const kernel = new Kernel(); |
| 24 | + |
| 25 | +const kernelBrowser = await kernel.browsers.create({ |
| 26 | + chrome_policy: { |
| 27 | + HomepageLocation: "https://kernel.sh", |
| 28 | + HomepageIsNewTabPage: false, |
| 29 | + ShowHomeButton: true, |
| 30 | + DownloadBubbleEnabled: false, |
| 31 | + }, |
| 32 | +}); |
| 33 | +``` |
| 34 | + |
| 35 | +```python Python |
| 36 | +from kernel import Kernel |
| 37 | + |
| 38 | +kernel = Kernel() |
| 39 | + |
| 40 | +kernel_browser = kernel.browsers.create( |
| 41 | + chrome_policy={ |
| 42 | + "HomepageLocation": "https://kernel.sh", |
| 43 | + "HomepageIsNewTabPage": False, |
| 44 | + "ShowHomeButton": True, |
| 45 | + "DownloadBubbleEnabled": False, |
| 46 | + }, |
| 47 | +) |
| 48 | +``` |
| 49 | +</CodeGroup> |
| 50 | + |
| 51 | +The policy is echoed on `GET /browsers/{id}` and `GET /browsers` responses so you can verify what was applied. |
| 52 | + |
| 53 | +## Reserved browser pools |
| 54 | + |
| 55 | +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`). |
| 56 | + |
| 57 | +<CodeGroup> |
| 58 | +```typescript Typescript/Javascript |
| 59 | +import Kernel from '@onkernel/sdk'; |
| 60 | + |
| 61 | +const kernel = new Kernel(); |
| 62 | + |
| 63 | +const pool = await kernel.browserPools.create({ |
| 64 | + name: "my-configured-pool", |
| 65 | + size: 5, |
| 66 | + chrome_policy: { |
| 67 | + HomepageLocation: "https://kernel.sh", |
| 68 | + HomepageIsNewTabPage: false, |
| 69 | + ShowHomeButton: true, |
| 70 | + NewTabPageLocation: "https://kernel.sh/docs", |
| 71 | + RestoreOnStartup: 4, |
| 72 | + RestoreOnStartupURLs: ["https://kernel.sh"], |
| 73 | + BookmarkBarEnabled: true, |
| 74 | + ManagedBookmarks: [ |
| 75 | + { toplevel_name: "Company Resources" }, |
| 76 | + { name: "Dashboard", url: "https://example.com/dashboard" }, |
| 77 | + { name: "Documentation", url: "https://example.com/docs" }, |
| 78 | + { |
| 79 | + name: "Tools", |
| 80 | + children: [ |
| 81 | + { name: "Jira Board", url: "https://example.com/jira" }, |
| 82 | + { name: "Slack", url: "https://example.com/slack" }, |
| 83 | + { name: "GitHub PRs", url: "https://example.com/github" }, |
| 84 | + { name: "Runbooks", url: "https://example.com/runbooks" } |
| 85 | + ] |
| 86 | + } |
| 87 | + ] |
| 88 | + } |
| 89 | +}); |
| 90 | +``` |
| 91 | + |
| 92 | +```python Python |
| 93 | +from kernel import Kernel |
| 94 | + |
| 95 | +kernel = Kernel() |
| 96 | + |
| 97 | +pool = kernel.browser_pools.create( |
| 98 | + name="my-configured-pool", |
| 99 | + size=5, |
| 100 | + chrome_policy={ |
| 101 | + "HomepageLocation": "https://kernel.sh", |
| 102 | + "HomepageIsNewTabPage": False, |
| 103 | + "ShowHomeButton": True, |
| 104 | + "NewTabPageLocation": "https://kernel.sh/docs", |
| 105 | + "RestoreOnStartup": 4, |
| 106 | + "RestoreOnStartupURLs": ["https://kernel.sh"], |
| 107 | + "BookmarkBarEnabled": True, |
| 108 | + "ManagedBookmarks": [ |
| 109 | + {"toplevel_name": "Company Resources"}, |
| 110 | + {"name": "Dashboard", "url": "https://example.com/dashboard"}, |
| 111 | + {"name": "Documentation", "url": "https://example.com/docs"}, |
| 112 | + { |
| 113 | + "name": "Tools", |
| 114 | + "children": [ |
| 115 | + {"name": "Jira Board", "url": "https://example.com/jira"}, |
| 116 | + {"name": "Slack", "url": "https://example.com/slack"}, |
| 117 | + {"name": "GitHub PRs", "url": "https://example.com/github"}, |
| 118 | + {"name": "Runbooks", "url": "https://example.com/runbooks"} |
| 119 | + ] |
| 120 | + } |
| 121 | + ] |
| 122 | + } |
| 123 | +) |
| 124 | +``` |
| 125 | +</CodeGroup> |
| 126 | + |
| 127 | +## Example policies |
| 128 | + |
| 129 | +| Policy | Type | Description | |
| 130 | +| --- | --- | --- | |
| 131 | +| `HomepageLocation` | `string` | URL loaded when clicking the home button | |
| 132 | +| `HomepageIsNewTabPage` | `boolean` | When `false`, the home button navigates to `HomepageLocation` instead of the new tab page | |
| 133 | +| `ShowHomeButton` | `boolean` | Shows the home button in the toolbar | |
| 134 | +| `NewTabPageLocation` | `string` | URL shown when opening a new tab | |
| 135 | +| `RestoreOnStartup` | `integer` | Set to `4` to open a specific list of URLs on browser startup | |
| 136 | +| `RestoreOnStartupURLs` | `string[]` | URLs to open when the browser starts. Requires `RestoreOnStartup` set to `4` | |
| 137 | +| `BookmarkBarEnabled` | `boolean` | Shows the bookmark bar | |
| 138 | +| `ManagedBookmarks` | `array` | Pre-configured bookmarks. Supports folders via nested `children` arrays | |
| 139 | +| `DownloadBubbleEnabled` | `boolean` | Controls the download bubble UI. Set to `false` to fall back to the classic download shelf | |
| 140 | + |
| 141 | +## Available policies |
| 142 | + |
| 143 | +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. |
0 commit comments