Documentation
¶
Index ¶
- Constants
- func ApplyExtensionSettings(ctx context.Context, options ApplyOptions) error
- func Configure(ctx context.Context, options ConfigureOptions) error
- func EnsureAcceleratorAdded(customAccelerators map[string]any, commandID, accelerator string)
- func LinuxDesktopEntry(text, executable, sourceExec, startupWMClass string) (string, error)
- func NestedObject(root map[string]any, dottedPath string) (map[string]any, error)
- func ReadLocalState(profileDir string) (map[string]any, error)
- func ReadPreferences(profileDir string) (map[string]any, error)
- func ReadVariations(profileDir string) (map[string]any, error)
- func RunLauncher(invocation string, arguments []string) (bool, error)
- func SetCookieAllowlist(preferences map[string]any, patterns []string) error
- func SetCookiePolicy(preferences map[string]any, policy CookiePreferenceConfig) error
- func SetNestedValue(root map[string]any, dottedPath string, value any) error
- func ValidateExtensionSettingsFiles(paths []string) error
- func WriteLocalState(profileDir string, localState map[string]any) error
- func WritePreferences(profileDir string, preferences map[string]any) error
- func WriteVariations(profileDir string, variations map[string]any) error
- type ApplyInput
- type ApplyOptions
- type BraveConfig
- type BraveShieldsConfig
- type BraveSidebarConfig
- type BraveSidebarShowMode
- type BraveTabHoverMode
- type BraveTabMinWidthMode
- type BraveTabsConfig
- type Browser
- func (browser Browser) ApplyBrowserLocalStateSettings(profileDir string) error
- func (browser Browser) ApplyBrowserPreferenceSettings(profileDir string) error
- func (browser Browser) ApplyBrowserVariationSettings(profileDir string) error
- func (browser Browser) ApplyExtensionSettings(ctx context.Context, options ApplyOptions) error
- func (browser Browser) ApplyProfileSettings(ctx context.Context, options ApplyOptions) error
- func (browser Browser) Install(ctx context.Context, options InstallOptions) error
- type BrowserConfig
- type Config
- type ConfigureOptions
- type CookiePreferenceConfig
- type CookieSetting
- type ExtensionSettingsConfig
- type ExtensionStorageArea
- type ExtensionStorageEncoding
- type ExtensionStorageEntry
- type ExtensionStorageInput
- type ExtensionStorageOperation
- type ExtensionStorageOperationKind
- type ExtensionStorageSettings
- type HeliumConfig
- type HeliumCrashReportingMode
- type HeliumServicesConfig
- type HeliumToolbarConfig
- type InstallOptions
- type LinuxConfig
- type MacOSConfig
- type Mode
- type ModePaths
- type PreferenceAcceleratorConfig
- type PreferenceDefaultsConfig
- func (config PreferenceDefaultsConfig) HasPreferences() bool
- func (config PreferenceDefaultsConfig) PatchLocalState(localState map[string]any) error
- func (config PreferenceDefaultsConfig) PatchPreferences(preferences map[string]any) error
- func (config PreferenceDefaultsConfig) PatchVariations(variations map[string]any) error
- type PreferencePatch
- type PreferenceValueConfig
- type SettingsSource
- type ThirdPartyCookiePolicy
Constants ¶
const ( PreferencesFilename = "Preferences" LocalStateFilename = "Local State" VariationsFilename = "Variations" )
Variables ¶
This section is empty.
Functions ¶
func ApplyExtensionSettings ¶
func ApplyExtensionSettings(ctx context.Context, options ApplyOptions) error
func EnsureAcceleratorAdded ¶
func LinuxDesktopEntry ¶
func NestedObject ¶
func RunLauncher ¶
RunLauncher detects whether invocation names an installed browser launcher. If it does, RunLauncher replaces the current process with the configured browser and returns only when preparing or executing the browser fails.
func SetCookieAllowlist ¶
func SetCookiePolicy ¶
func SetCookiePolicy(preferences map[string]any, policy CookiePreferenceConfig) error
SetCookiePolicy updates Chromium's default cookie setting, third-party cookie mode, and per-pattern exceptions. A nil exception list is unmanaged. A non-nil list owns exceptions with that setting, including when the list is empty and therefore removes existing exceptions of that setting.
Types ¶
type ApplyInput ¶
type ApplyInput struct {
CookieAllowlist []string `json:"cookie_allowlist"`
ExtensionValues map[string]any `json:"extension_values"`
}
func DecodeApplyInput ¶
func DecodeApplyInput(reader io.Reader) (ApplyInput, error)
DecodeApplyInput reads exactly one input document and rejects unknown fields.
type ApplyOptions ¶
type ApplyOptions struct {
ProfileDir string
Settings []string
SettingsSource []SettingsSource
ExtensionIDAliases map[string]string
Input ApplyInput
}
type BraveConfig ¶
type BraveConfig struct {
Tabs BraveTabsConfig `toml:"tabs"`
Sidebar BraveSidebarConfig `toml:"sidebar"`
Shields BraveShieldsConfig `toml:"shields"`
}
BraveConfig exposes preferences implemented by Brave rather than upstream Chromium. Every field is opt-in; an omitted value leaves the profile alone.
func (BraveConfig) HasLocalStatePreferences ¶
func (config BraveConfig) HasLocalStatePreferences() bool
func (BraveConfig) HasProfilePreferences ¶
func (config BraveConfig) HasProfilePreferences() bool
func (BraveConfig) PatchLocalState ¶
func (config BraveConfig) PatchLocalState(localState map[string]any) error
func (BraveConfig) PatchPreferences ¶
func (config BraveConfig) PatchPreferences(preferences map[string]any) error
type BraveShieldsConfig ¶
type BraveSidebarConfig ¶
type BraveSidebarConfig struct {
Show BraveSidebarShowMode `toml:"show"`
}
type BraveSidebarShowMode ¶
type BraveSidebarShowMode string
const ( BraveSidebarShowAlways BraveSidebarShowMode = "always" BraveSidebarShowMouseover BraveSidebarShowMode = "mouseover" BraveSidebarShowNever BraveSidebarShowMode = "never" )
type BraveTabHoverMode ¶
type BraveTabHoverMode string
const ( BraveTabHoverTooltip BraveTabHoverMode = "tooltip" BraveTabHoverCard BraveTabHoverMode = "card" BraveTabHoverCardWithPreview BraveTabHoverMode = "card_with_preview" )
type BraveTabMinWidthMode ¶
type BraveTabMinWidthMode string
const ( BraveTabMinWidthDefault BraveTabMinWidthMode = "default" BraveTabMinWidthMinimum BraveTabMinWidthMode = "minimum" BraveTabMinWidthMedium BraveTabMinWidthMode = "medium" BraveTabMinWidthLarge BraveTabMinWidthMode = "large" BraveTabMinWidthFull BraveTabMinWidthMode = "full" )
type BraveTabsConfig ¶
type BraveTabsConfig struct {
HoverMode BraveTabHoverMode `toml:"hover_mode"`
Vertical *bool `toml:"vertical"`
Collapsed *bool `toml:"collapsed"`
ExpandedStatePerWindow *bool `toml:"expanded_state_per_window"`
ShowWindowTitle *bool `toml:"show_window_title"`
HideCompletelyWhenCollapsed *bool `toml:"hide_completely_when_collapsed"`
Floating *bool `toml:"floating"`
ShowToggleButton *bool `toml:"show_toggle_button"`
ExpandedWidth *int `toml:"expanded_width"`
OnRight *bool `toml:"on_right"`
ShowScrollbar *bool `toml:"show_scrollbar"`
Tree *bool `toml:"tree"`
AlwaysHideCloseButton *bool `toml:"always_hide_close_button"`
MiddleClickClose *bool `toml:"middle_click_close"`
MinWidth BraveTabMinWidthMode `toml:"min_width"`
ScrollableHorizontal *bool `toml:"scrollable_horizontal"`
ShowHorizontalScrollButtons *bool `toml:"show_horizontal_scroll_buttons"`
CompactHorizontal *bool `toml:"compact_horizontal"`
}
type Browser ¶
type Browser struct {
Config BrowserConfig
Extensions extensions.Catalog
ExtensionSettings []string
PreferencePatches []PreferencePatch
LocalStatePatches []PreferencePatch
VariationPatches []PreferencePatch
}
func (Browser) ApplyBrowserLocalStateSettings ¶
func (Browser) ApplyBrowserPreferenceSettings ¶
func (Browser) ApplyBrowserVariationSettings ¶
func (Browser) ApplyExtensionSettings ¶
func (browser Browser) ApplyExtensionSettings(ctx context.Context, options ApplyOptions) error
func (Browser) ApplyProfileSettings ¶
func (browser Browser) ApplyProfileSettings(ctx context.Context, options ApplyOptions) error
type BrowserConfig ¶
type BrowserConfig struct {
Name string `toml:"name"`
LogPrefix string `toml:"log_prefix"`
ExecutableName string `toml:"executable_name"`
AliasName string `toml:"alias_name"`
FlagsFile string `toml:"flags_file"`
Flags []string `toml:"flags"`
UserAgent string `toml:"user_agent"`
Linux LinuxConfig `toml:"linux"`
MacOS MacOSConfig `toml:"macos"`
Paths map[string]ModePaths `toml:"paths"`
Preferences PreferenceDefaultsConfig `toml:"preferences"`
ExtensionIDAliases map[string]string `toml:"extension_id_aliases"`
Helium HeliumConfig `toml:"helium"`
Brave BraveConfig `toml:"brave"`
}
func (BrowserConfig) DefaultProfileDir ¶
func (config BrowserConfig) DefaultProfileDir(mode Mode) string
func (BrowserConfig) ExternalExtensionDirs ¶
func (config BrowserConfig) ExternalExtensionDirs(mode Mode) []string
type Config ¶
type Config struct {
Browser BrowserConfig `toml:"browser"`
Extensions extensions.Catalog `toml:"extensions"`
ExtensionSettings ExtensionSettingsConfig `toml:"extension_settings"`
}
func LoadConfig ¶
type ConfigureOptions ¶
type CookiePreferenceConfig ¶
type CookiePreferenceConfig struct {
Default CookieSetting `toml:"default"`
ThirdParty ThirdPartyCookiePolicy `toml:"third_party"`
Allow []string `toml:"allow"`
Block []string `toml:"block"`
SessionOnly []string `toml:"session_only"`
}
func (CookiePreferenceConfig) HasPolicy ¶
func (config CookiePreferenceConfig) HasPolicy() bool
type CookieSetting ¶
type CookieSetting string
const ( CookieSettingAllow CookieSetting = "allow" CookieSettingBlock CookieSetting = "block" CookieSettingSessionOnly CookieSetting = "session_only" )
type ExtensionSettingsConfig ¶
type ExtensionSettingsConfig struct {
Files []string `toml:"files"`
}
ExtensionSettingsConfig names JSON documents that configure chrome.storage for installed extensions. Relative paths are resolved from the TOML configuration file that declares them.
type ExtensionStorageArea ¶
type ExtensionStorageArea string
const ( ExtensionStorageAreaLocal ExtensionStorageArea = "local" ExtensionStorageAreaSync ExtensionStorageArea = "sync" )
type ExtensionStorageEncoding ¶
type ExtensionStorageEncoding string
const ( ExtensionStorageEncodingJSON ExtensionStorageEncoding = "json" ExtensionStorageEncodingLZStringURI ExtensionStorageEncoding = "json-lz-string-uri" )
type ExtensionStorageEntry ¶
type ExtensionStorageInput ¶
type ExtensionStorageInput struct {
Name string `json:"name"`
Area ExtensionStorageArea `json:"area"`
ID string `json:"id"`
Key string `json:"key"`
Path string `json:"path,omitempty"`
Encoding ExtensionStorageEncoding `json:"encoding,omitempty"`
Operation ExtensionStorageOperationKind `json:"operation,omitempty"`
}
type ExtensionStorageOperation ¶
type ExtensionStorageOperation struct {
ID string `json:"id"`
Area ExtensionStorageArea `json:"area"`
Key string `json:"key,omitempty"`
Operation ExtensionStorageOperationKind `json:"operation,omitempty"`
Path string `json:"path,omitempty"`
Encoding ExtensionStorageEncoding `json:"encoding,omitempty"`
Value json.RawMessage `json:"value,omitempty"`
}
type ExtensionStorageOperationKind ¶
type ExtensionStorageOperationKind string
const ( ExtensionStorageOperationSet ExtensionStorageOperationKind = "set" ExtensionStorageOperationMerge ExtensionStorageOperationKind = "merge" ExtensionStorageOperationAppend ExtensionStorageOperationKind = "append" ExtensionStorageOperationRemove ExtensionStorageOperationKind = "remove" ExtensionStorageOperationClear ExtensionStorageOperationKind = "clear" )
type ExtensionStorageSettings ¶
type ExtensionStorageSettings struct {
Schema string `json:"$schema,omitempty"`
SchemaVersion int `json:"schema_version,omitempty"`
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
Local []ExtensionStorageEntry `json:"local,omitempty"`
Sync []ExtensionStorageEntry `json:"sync,omitempty"`
LocalAppend []ExtensionStorageEntry `json:"local_append,omitempty"`
SyncAppend []ExtensionStorageEntry `json:"sync_append,omitempty"`
Operations []ExtensionStorageOperation `json:"operations,omitempty"`
Inputs []ExtensionStorageInput `json:"inputs,omitempty"`
}
ExtensionStorageSettings is the public JSON document accepted by extension_settings.files and --settings. The legacy local/sync fields remain useful for bulk top-level writes, while Operations supports precise mutation of JSON documents stored beneath individual chrome.storage keys.
type HeliumConfig ¶
type HeliumConfig struct {
CompletedOnboarding *bool `toml:"completed_onboarding"`
Services HeliumServicesConfig `toml:"services"`
Toolbar HeliumToolbarConfig `toml:"toolbar"`
CrashReporting HeliumCrashReportingMode `toml:"crash_reporting"`
}
HeliumConfig exposes preferences implemented by Helium rather than upstream Chromium. Every field is opt-in; an omitted value leaves the profile alone.
func (HeliumConfig) HasLocalStatePreferences ¶
func (config HeliumConfig) HasLocalStatePreferences() bool
func (HeliumConfig) HasProfilePreferences ¶
func (config HeliumConfig) HasProfilePreferences() bool
func (HeliumConfig) PatchLocalState ¶
func (config HeliumConfig) PatchLocalState(localState map[string]any) error
func (HeliumConfig) PatchPreferences ¶
func (config HeliumConfig) PatchPreferences(preferences map[string]any) error
type HeliumCrashReportingMode ¶
type HeliumCrashReportingMode string
const ( HeliumCrashReportingDisabled HeliumCrashReportingMode = "disabled" HeliumCrashReportingAsk HeliumCrashReportingMode = "ask" HeliumCrashReportingAutomatic HeliumCrashReportingMode = "automatic" )
type HeliumServicesConfig ¶
type HeliumServicesConfig struct {
Enabled *bool `toml:"enabled"`
UserConsented *bool `toml:"user_consented"`
OriginOverride *string `toml:"origin_override"`
ExtensionProxy *bool `toml:"extension_proxy"`
Bangs *bool `toml:"bangs"`
SpellcheckFiles *bool `toml:"spellcheck_files"`
BrowserUpdates *bool `toml:"browser_updates"`
UBlockAssets *bool `toml:"ublock_assets"`
}
type HeliumToolbarConfig ¶
type HeliumToolbarConfig struct {
ShowBackButton *bool `toml:"show_back_button"`
ShowReloadButton *bool `toml:"show_reload_button"`
ShowAvatarButton *bool `toml:"show_avatar_button"`
ShowExtensionsButton *bool `toml:"show_extensions_button"`
ShowMenuButton *bool `toml:"show_menu_button"`
ShowMediaButton *bool `toml:"show_media_button"`
}
type InstallOptions ¶
type InstallOptions struct {
Mode Mode
Root string
AppDir string
BinDir string
Flags []string
Settings []string
SettingsSource []SettingsSource
Input ApplyInput
ApplySettings bool
LauncherExecutable string
// contains filtered or unexported fields
}
type LinuxConfig ¶
type LinuxConfig struct {
AppDir string `toml:"app_dir"`
DesktopID string `toml:"desktop_id"`
PortalAppID string `toml:"portal_app_id"`
WrapperFlags []string `toml:"wrapper_flags"`
LauncherName string `toml:"launcher_name"`
DesktopName string `toml:"desktop_name"`
DesktopExec string `toml:"desktop_exec"`
IconName string `toml:"icon_name"`
IconSource string `toml:"icon_source"`
}
type MacOSConfig ¶
type PreferenceDefaultsConfig ¶
type PreferenceDefaultsConfig struct {
Values []PreferenceValueConfig `toml:"values"`
LocalStateValues []PreferenceValueConfig `toml:"local_state_values"`
VariationValues []PreferenceValueConfig `toml:"variation_values"`
Accelerators []PreferenceAcceleratorConfig `toml:"accelerators"`
Cookies CookiePreferenceConfig `toml:"cookies"`
}
func (PreferenceDefaultsConfig) HasPreferences ¶
func (config PreferenceDefaultsConfig) HasPreferences() bool
func (PreferenceDefaultsConfig) PatchLocalState ¶
func (config PreferenceDefaultsConfig) PatchLocalState(localState map[string]any) error
func (PreferenceDefaultsConfig) PatchPreferences ¶
func (config PreferenceDefaultsConfig) PatchPreferences(preferences map[string]any) error
func (PreferenceDefaultsConfig) PatchVariations ¶
func (config PreferenceDefaultsConfig) PatchVariations(variations map[string]any) error
type PreferencePatch ¶
type PreferenceValueConfig ¶
type SettingsSource ¶
type ThirdPartyCookiePolicy ¶
type ThirdPartyCookiePolicy string
const ( ThirdPartyCookiePolicyOff ThirdPartyCookiePolicy = "off" ThirdPartyCookiePolicyBlock ThirdPartyCookiePolicy = "block" ThirdPartyCookiePolicyIncognitoOnly ThirdPartyCookiePolicy = "incognito_only" )