Customizing chrome:// pages
Rename, restyle and replace Chromium's internal pages such as chrome://settings.
configuration.productName = "Orbit"
configuration.stringOverrides[.companyName] = "Orbit Software"
pageConfiguration.userScripts = [
.styleSheet("#about-menu { display: none !important }", matching: ["chrome://settings/*"]),
]
Gallery: ChromeWindowDemo.
Browser example: Features/ChromiumPages trims chrome://settings and adds its own About page.
Customizing Chromium’s own pages
Chrome-style pages show Chromium’s internal pages, such as
chrome://settings, chrome://history and chrome://downloads. You can
rename, restyle and replace them.
Names. productName replaces “Chromium” in settings, chrome://version,
dialogs and the About page. stringOverrides replaces any other built-in
string by its IDS_* identifier, as a CefRuntime.StringID. The named constants are
.productName, .shortProductName and .companyName; other identifiers are
in the vendored cef_pack_strings.h and can change between CEF versions.
configuration.productName = "Orbit"
configuration.stringOverrides[.companyName] = "Orbit Software"
Scripts and styles. User scripts also run on chrome:// pages; scope
them with a URL pattern:
pageConfiguration.userScripts = [
.styleSheet("#about-menu { display: none !important }", matching: ["chrome://settings/*"]),
]
Internal pages are built from web components whose markup sits in shadow
roots. styleSheet(_:matching:includingShadowRoots:) reaches into them, but
a selector cannot cross a shadow boundary: write #themeRow, not
settings-appearance-page #themeRow, because the row lives in that
component’s shadow root. Matching rows by the preference they edit
(settings-toggle-button[pref-key="browser.show_home_button"]) holds up
across Chromium updates better than matching by position. Scripts run
on chrome:// pages as on any other, before the page’s own scripts.
Replacing a page. Cancel the navigation and load a page of your own, served from a custom scheme:
func page(_ page: CefPage, decidePolicyFor navigation: CefNavigationAction) -> CefNavigationDecision {
guard navigation.url?.absoluteString.hasPrefix("chrome://settings/help") == true else { return .allow }
page.load(URL(string: "orbit://about/")!)
return .cancel
}
The Browser example replaces Chromium’s About page this way and trims
chrome://settings with a style sheet
(Examples/Sources/Browser/Features/ChromiumPages/ChromiumPages.swift).