Skip to content

feat(browser): install Chrome extensions from the Web Store into Orca's browser - #30940

Merged
AmoabaKelvin merged 14 commits into
mainfrom
feat/browser-extensions
Oct 27, 2026
Merged

AmoabaKelvin merged 14 commits into
mainfrom
feat/browser-extensions

Conversation

@AmoabaKelvin

@AmoabaKelvin AmoabaKelvin commented Oct 20, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 107 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​15568 $\color{#cf222e}{\Huge{\mathbf{−}}}$​22 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​15546
Prod 275 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​28328 $\color{#cf222e}{\Huge{\mathbf{−}}}$​167 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​28161

ELI5

Orca's browser can now run Chrome extensions. You add them from the Chrome Web Store with an "Add to Orca" button, and password managers like Bitwarden and 1Password fill logins and passkeys inside Orca's browser. It is off by default behind the experimental "Browser extensions" setting.

What Changed

Before, Orca's browser had no extensions, so no password manager, no dark mode, no dev tools. Now:

  • The store page shows "Add to Orca" / "Remove from Orca" (and hides its "Switch to Chrome" banner). Settings › Browser › Extensions can also install from a store link, turn extensions on per browser profile, remove them, show load errors and review updates that ask for more access.
  • Installing opens Orca's own dialog listing what the extension can do in plain words. The download's CRX3 signature is checked and the package must ask for exactly what the dialog showed.
  • Extensions get toolbar buttons, popups sized to their content, right-click menu items and keyboard shortcuts.
  • Electron 43 ships only part of Chrome's extension API, so Orca fills in the rest itself: tabs (including tabs not loaded yet after a restart), windows, page-navigation events, toolbar actions, context menus, commands, notifications, permissions, cookies, downloads, management, tab screenshots, storage.sync (Electron disables it; Orca keeps it on this machine, like Chrome when signed out), runtime.onInstalled/onStartup, and native messaging so extensions can talk to desktop apps such as Bitwarden and KeePassXC.
  • It also works around Electron bugs found along the way: extension service workers never receive storage.onChanged, so Bitwarden's popup hung after sign-in; use_dynamic_url resources can't load, so Bitwarden's in-field menu stayed invisible; content scripts and extension iframes were missing APIs Chrome gives them.

Extensions run in local browser profiles only. Remote, SSH and streamed pages are unchanged.

Why

  • The Chrome APIs are our own MIT code, not electron-chrome-extensions (GPL-3, Orca is MIT). electron-chrome-web-store (MIT) only downloads and updates packages. Its own store-page bridge isn't used, because it checks the store origin with a prefix match that a look-alike host passes.
  • Workers get Orca's APIs from a small script Orca puts in front of the extension's background script in its own copy of the package, talking to main over a private scheme. A service-worker preload was the first design, but a 30-minute soak with five extensions crashed the extension renderer twice, symbolicated to electron#52310 (a GC check in V8MetricsRecorder while preload code runs), with no fix in Electron.
  • Each worker proves who it is with a per-run token file. Orca rewrites web-accessible wildcards in its package copy so no website can read that file.

This rebuilds what community PR #23826 set out to do.

Known gaps: declarativeNetRequest rules aren't enforced, so ad blockers install but don't block; no userScripts (Tampermonkey), side panel, new-tab override (Momentum) or tab/screen capture (Loom); activeTab doesn't grant script access because Electron 43 checks only manifest host permissions; native messaging isn't tested on Windows yet.

Linked Issue

Fixes #20558
Fixes #30200
Fixes #20088
Fixes #17709

Visual Proof

Store page Install dialog
Store page with Remove from Orca Orca install dialog
Extensions menu Bitwarden in-field menu Dark Reader popup
Toolbar extensions menu Bitwarden inline autofill menu Dark Reader popup

Testing

Turn on Settings › Experimental › Browser extensions, restart, open https://chromewebstore.google.com in an Orca browser tab and click "Add to Orca" on Bitwarden.

Live-checked on macOS: Bitwarden sign-in, autofill, in-field menu, passkey register and sign-in on webauthn.io; 1Password; Dark Reader; Refined GitHub; native messaging against a test host. A one-off run over 31 popular extensions ended with 17 working, 11 partly working and 3 broken (Tampermonkey, Loom, Momentum, for the gaps above).

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

AI Disclosure

Review

Worth a close look: main-window-webview-security.ts (extension pages admitted at attach, nodeIntegrationInSubFrames for extension-enabled profiles), the store bridge host (exact origin, top frame, approval tied to the frame), and native host launching (spawnProcess, Chrome's manifest rules, process cleanup).

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Ensure no issues in: Security, Cross-platoform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

@AmoabaKelvin
AmoabaKelvin force-pushed the feat/browser-extensions branch from a8c38a9 to 46a007b Compare October 20, 2026 23:37
@AmoabaKelvin

Copy link
Copy Markdown
Collaborator Author

Ad blockers now block (46a007b)

uBlock Origin Lite, AdGuard and Ghostery used to install and show their popups, but nothing got blocked. Chrome-store ad blockers hand the browser a list of rules (declarativeNetRequest) and let the browser apply them. Electron accepts those rules and never applies them; its request path (shell/browser/net/proxying_url_loader_factory.cc) never reads a ruleset. Orca now applies them itself.

How it works

  • The rule matcher lives in src/main/browser/extensions/declarative-net-request/. It's our own code, written to Chromium's behaviour: rule priorities, URL filter syntax, domain and first/third-party conditions, allow-all-requests for frames, redirects to an extension's own files, and header changes. Like Chromium, it indexes rules by pieces of the URL, so each request checks a handful of candidates instead of every rule.
  • It runs inside the request handlers Orca already has on every browser session (browser-session-request-decisions.ts), not beside them. Electron allows one listener per request stage per session, and a second one silently replaces the first.
  • Orca has its own copy of chrome.declarativeNetRequest: static, dynamic and session rules, turning rule sets on and off, test match, matched rules, the blocked-count badge, and Chrome's limits and error messages. Rule changes are saved per browser profile and removed on uninstall.
  • Rules load in small slices so the main thread never stalls for long. Requests made before a blocker's rules are ready wait for them, up to 5 seconds, as Chrome does, so restored tabs don't leak ads at startup.
  • When an extension blocks a whole page, Orca shows a plain "blocked" page instead of Electron's blank one:

blocked-page.png

Checked against Chromium itself. Electron still contains Chromium's own matcher behind testMatchOutcome, which extensions can call but which never blocks anything. Using it as the reference:

  • Real rule lists: uBlock Lite's defaults, AdGuard's base and tracking lists, and Ghostery's four lists, each against 20,000 requests. Zero differences in what gets blocked.
  • Loading: all 526,626 rules across uBlock Lite, AdGuard, Ghostery and Privacy Badger load.

Regex rules (under 1% of rules) are translated to JS regexes rather than run through a copy of Chrome's regex engine, so isRegexSupported can disagree with Chrome on patterns near its size limit.

Live check (hidden dev build):

Blocker adblock-tester.com CNN requests blocked Off for one site
None 40 0 –
uBlock Origin Lite 91 25 works
AdGuard 73 28 works
Ghostery 96 25 works
All three 99 – –

Pages render normally, each blocker's popup works, Bitwarden and Dark Reader keep working alongside, and with the blockers switched off nothing is blocked.

Not done yet

  • Files a tab already holds in memory aren't re-checked after rules change until the page reloads. Chrome clears that cache; Electron has no cheap way to.
  • Blocked images and frames are blocked but not collapsed, so a page can show empty boxes where Chrome shows nothing.
  • Requests blocked while a restored tab loads at launch don't count toward the badge.
  • onRuleMatchedDebug (unpacked extensions only) is still unsupported.

@AmoabaKelvin

Copy link
Copy Markdown
Collaborator Author

Performance: one slowdown fixed, and no regression from blocking

I measured Orca's browser before and after this work, on a hidden production build, running the old and new builds back to back on the same machine. Real-site numbers only mean something that way; on a different day the server response time alone doubled.

A slowdown in this PR, now fixed. Passing requests on to extensions (chrome.webRequest) fetched the full extension list, copying every manifest out of Electron, on every request event, even when no extension was listening. With Bitwarden, Dark Reader and uBlock Lite installed, that cost about 300µs of main-process time per request. Now Orca checks for a listener first and only looks up the extensions that listen.

300-resource local test page, first load (production build):

Before After
Extensions off 115 ms 120 ms (within noise)
uBlock Lite + Dark Reader + Bitwarden 204 ms 129 ms

Main-process time per request (development build):

  • Extensions off: 11µs before, 8µs now.
  • Extensions on, none installed: 22µs before, 9µs now.
  • Three extensions installed: 309µs before, 47µs now, even though uBlock's rules are now checked on every request.

Extensions off, real sites, alternating old/new/old/new (median load): Wikipedia 2132 / 2100 / 2131 / 2128 ms, YouTube 3168 / 3209 / 3005 / 3262 ms, GitHub 7554 / 3451 / 5009 / 3310 ms. No difference beyond noise.

Matching cost per request:

  • uBlock Lite's defaults (18.8k rules): about 3µs typical, 15–20µs for the slowest 1%.
  • Profiles without a blocker: pay one map lookup.

Memory and startup: with uBlock Lite installed, main-process memory goes up about 23MB for its rule index (measured with macOS footprint); renderers are unchanged. Startup is about 50ms slower with the three extensions, within noise.

Unrelated find, left for a separate change: the camera/microphone permission check costs 28–40ms of main-process time per CNN load, on main as well.

@AmoabaKelvin
AmoabaKelvin force-pushed the feat/browser-extensions branch from 46a007b to 2ea59d2 Compare October 21, 2026 19:20
@AmoabaKelvin

Copy link
Copy Markdown
Collaborator Author

Extensions switch on and off without a restart (eb5b41a, 2ea59d2)

The experimental "Browser extensions" setting used to apply only after restarting Orca. It now applies right away:

  • On: every open browser profile gets the same setup as at launch. Its extensions load, ad blockers start blocking, and tabs that were already open get extension features.
  • Off: every extension is unloaded and Orca's extension hooks leave the request path, so there's no leftover cost. Extension data (settings, logins, blocker rules) is kept for next time.
  • Shared code paths: off reuses the unload that deleting a browser profile already used, minus the data wipe. Switches run one at a time, so a quick off-then-on can't overlap.
  • Iframes: local-profile tabs now always run Orca's preload in iframes, so a tab opened while extensions were off still gets in-page features like Bitwarden's in-field menu. With extensions off that preload does nothing in iframes.

Two bugs found along the way:

  • Listeners stacking: each switch-on added another set of the extension API host's listeners. They're now installed once per profile and read the current state when they fire.
  • Workers started too early: removing an extension also unregisters its background worker in Chromium. On the next load Orca started the worker before it was registered again ("Failed to start service worker"). Orca now waits for the worker to register again. This also covers turning a single extension off and on in Settings.

Checked in a hidden dev build with Dark Reader and uBlock Origin Lite:

  • Cycles: a fresh launch, 3 off/on cycles of the setting, 3 off/on cycles of a single extension, and a restart.
  • Each time: Dark Reader darkened pages and its worker answered, uBlock blocked, nothing logged a warning, listener counts stayed flat, and extension data survived.

The extensions menu (puzzle button) also gets Visit Chrome Web Store, which opens the store in a new tab in the same browser profile.

@AmoabaKelvin
AmoabaKelvin force-pushed the feat/browser-extensions branch 2 times, most recently from 0da0251 to 3ac9fba Compare October 21, 2026 23:25
@AmoabaKelvin
AmoabaKelvin marked this pull request as ready for review October 21, 2026 23:26
@AmoabaKelvin
AmoabaKelvin force-pushed the feat/browser-extensions branch 4 times, most recently from cf98f3b to 587f35a Compare October 23, 2026 00:32
@lokize

lokize commented Oct 23, 2026

Copy link
Copy Markdown

+1 for this its a necessary update

@AmoabaKelvin
AmoabaKelvin force-pushed the feat/browser-extensions branch 5 times, most recently from c024240 to eda0092 Compare October 27, 2026 16:13
…e Chrome Web Store

Behind the experimental "Browser extensions" setting. Extensions install from the
store page ("Add to Orca") or Settings, run per browser profile, and get the Chrome
APIs Electron leaves out (tabs, windows, action/popups, context menus, storage.sync,
native messaging and more) through Orca's own MIT implementation.
Electron accepts declarativeNetRequest rules but never applies them, so Orca
now matches them itself inside its existing request handlers.
Removing an extension also unregisters its worker in Chromium, so a reload now waits for the
worker to register again before firing lifecycle events.
Extensions could see or act on other browser profiles' tabs and windows, read data from
another Orca profile, load more access than the install prompt showed, or keep running
after being turned off during startup. Content-blocking regex rules could also stall the
main process.
…the second review

Loads that finished after extensions were turned off could still land, a case-variant
backup manifest could carry unapproved permissions, and turning extensions on after a
launch with them off left tab and window APIs without a main window.
…saveAs

Extensions that call chrome.downloads.download({ saveAs: true }) now get the system save
dialog first and download to the chosen path, instead of an error.
…ew-three gaps

A website could stall main before the worker API authenticated it, and a case variant of a
listed file could expose the worker token. activeTab, webRequest and stale menu clicks now
grant only what Chrome grants.
A sandboxed extension page keeps its chrome-extension:// URL but runs with an opaque origin and,
in Chrome, no extension APIs. Orca trusted the URL and handed it the full bridge.
@AmoabaKelvin
AmoabaKelvin force-pushed the feat/browser-extensions branch from c5b9a03 to f18659d Compare October 27, 2026 21:32
@AmoabaKelvin
AmoabaKelvin merged commit 917ef9c into main Oct 27, 2026
84 checks passed
@AmoabaKelvin
AmoabaKelvin deleted the feat/browser-extensions branch October 27, 2026 22:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants