content

package
v0.28.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 27, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetBehavior

func GetBehavior(popupType PopupType, cfg *entity.PopupBehaviorConfig) entity.PopupBehavior

GetBehavior returns the appropriate behavior based on popup type and config.

func IsOAuthCallback

func IsOAuthCallback(url string) bool

IsOAuthCallback checks if the URL is an OAuth callback with response parameters. This indicates the OAuth flow has completed (successfully or with error).

func IsOAuthError

func IsOAuthError(url string) bool

IsOAuthError checks if the callback indicates an authentication error.

func IsOAuthSuccess

func IsOAuthSuccess(rawURL string) bool

IsOAuthSuccess checks if the callback indicates successful authentication. It parses query and fragment parameters (like IsOAuthCallback) to avoid false positives from substring matching.

func IsOAuthURL

func IsOAuthURL(url string) bool

IsOAuthURL checks if the URL is related to an OAuth flow. This includes authorization endpoints, login pages, and callback URLs.

The matching is intentionally broad: both oauthFlowPatterns (path-based terms like "login", "authorize", "callback") and oauthRequestPatterns (query parameters like "client_id=" and "scope=") use simple substring matching without anchoring. This maximizes recall — we prefer false positives over missed detections — so that edge-case provider URLs and non-standard redirect paths are still caught. The trade-off is reduced precision: some unrelated URLs that happen to contain these substrings will be classified as OAuth URLs. Callers that need higher confidence should combine this with IsOAuthCallback, which checks for concrete response params.

func ShouldAutoClose

func ShouldAutoClose(url string) bool

ShouldAutoClose determines if a popup at this URL should auto-close. Returns true for OAuth callbacks that indicate flow completion.

This is comprehensive detection that handles: - Success: code=, access_token=, id_token= - Errors: error=, error_description= - Various OAuth providers (Google, GitHub, Auth0, etc.)

Types

type Coordinator

type Coordinator struct {
	// contains filtered or unexported fields
}

Coordinator manages WebView lifecycle, title tracking, and content attachment.

func NewCoordinator

func NewCoordinator(
	ctx context.Context,
	pool port.WebViewPool,
	injector port.ContentInjector,
	widgetFactory layout.WidgetFactory,
	faviconAdapter *adapter.FaviconAdapter,
	getActiveWS func() (*entity.Workspace, *component.WorkspaceView),
	zoomUC *usecase.ManageZoomUseCase,
	permissionUC *usecase.HandlePermissionUseCase,
) *Coordinator

NewCoordinator creates a new Coordinator.

func (*Coordinator) ActivePaneID

func (c *Coordinator) ActivePaneID(ctx context.Context) entity.PaneID

ActivePaneID returns the currently active pane ID used by navigation.

func (*Coordinator) ActiveWebView

func (c *Coordinator) ActiveWebView(ctx context.Context) port.WebView

ActiveWebView returns the WebView for the active pane.

func (*Coordinator) ApplyFiltersToAll

func (c *Coordinator) ApplyFiltersToAll(ctx context.Context)

ApplyFiltersToAll applies content filters to all active webviews. Called when filters become available after webviews were already created.

func (*Coordinator) ApplySettingsToAll

func (c *Coordinator) ApplySettingsToAll(ctx context.Context)

ApplySettingsToAll reapplies engine settings to all active WebViews.

func (*Coordinator) ApplyWebUIThemeToAll

func (c *Coordinator) ApplyWebUIThemeToAll(ctx context.Context, prefersDark bool, cssText string)

ApplyWebUIThemeToAll updates theme CSS for already-loaded dumb:// pages. This is necessary because user scripts only run on navigation.

func (*Coordinator) AttachToWorkspace

func (c *Coordinator) AttachToWorkspace(ctx context.Context, ws *entity.Workspace, wsView *component.WorkspaceView)

AttachToWorkspace ensures each pane in the workspace has a WebView widget attached.

func (*Coordinator) ClearActivePaneOverride

func (c *Coordinator) ClearActivePaneOverride()

ClearActivePaneOverride removes any forced active pane override.

func (*Coordinator) EnsureWebView

func (c *Coordinator) EnsureWebView(ctx context.Context, paneID entity.PaneID) (port.WebView, error)

EnsureWebView acquires or reuses a WebView for the given pane.

func (*Coordinator) FaviconAdapter

func (c *Coordinator) FaviconAdapter() *adapter.FaviconAdapter

FaviconAdapter returns the favicon adapter for external use (e.g., omnibox).

func (*Coordinator) GetTitle

func (c *Coordinator) GetTitle(paneID entity.PaneID) string

GetTitle returns the current title for a pane.

func (*Coordinator) GetWebView

func (c *Coordinator) GetWebView(paneID entity.PaneID) port.WebView

GetWebView returns the WebView for a specific pane.

func (*Coordinator) PreloadCachedFavicon

func (c *Coordinator) PreloadCachedFavicon(ctx context.Context, paneID entity.PaneID, uri string)

PreloadCachedFavicon checks the favicon cache and updates the stacked pane title bar immediately if a cached favicon exists for the URL. This provides instant favicon display without waiting for WebKit.

func (*Coordinator) RefreshInjectedScriptsToAll

func (c *Coordinator) RefreshInjectedScriptsToAll(ctx context.Context)

RefreshInjectedScriptsToAll clears and re-injects user scripts into all active WebViews.

WebKit user scripts are snapshotted when added to a WebKitUserContentManager, so when appearance settings change at runtime (dark mode, palettes, UI scale), we must refresh the scripts so future navigations pick up the latest values. Script refresh is deferred for any WebView that is currently loading to avoid removing scripts mid-navigation.

func (*Coordinator) RegisterPopupWebView

func (c *Coordinator) RegisterPopupWebView(paneID entity.PaneID, wv port.WebView)

RegisterPopupWebView registers a popup WebView that was created externally. This is used when popup tabs are created and the WebView needs to be tracked.

func (*Coordinator) ReleaseWebView

func (c *Coordinator) ReleaseWebView(ctx context.Context, paneID entity.PaneID)

ReleaseWebView returns the WebView for a pane to the pool.

func (*Coordinator) SetActivePaneOverride

func (c *Coordinator) SetActivePaneOverride(paneID entity.PaneID)

SetActivePaneOverride forces ActiveWebView/ActivePaneID to use a specific pane.

func (*Coordinator) SetFilterApplier

func (c *Coordinator) SetFilterApplier(fa port.FilterApplier)

SetFilterApplier sets the content filter applier for late-binding filters.

func (*Coordinator) SetGestureActionHandler

func (c *Coordinator) SetGestureActionHandler(handler input.ActionHandler)

SetGestureActionHandler sets the callback for mouse button navigation gestures.

func (*Coordinator) SetIdleInhibitor

func (c *Coordinator) SetIdleInhibitor(inhibitor port.IdleInhibitor)

SetIdleInhibitor sets the idle inhibitor for fullscreen video playback.

func (*Coordinator) SetNavigationOrigin

func (c *Coordinator) SetNavigationOrigin(paneID entity.PaneID, uri string)

SetNavigationOrigin records the original URL before navigation starts. This allows caching favicons under both original and final domains when cross-domain redirects occur (e.g., google.fr → google.com).

func (*Coordinator) SetOnActiveNavigationCommitted

func (c *Coordinator) SetOnActiveNavigationCommitted(fn func(uri string))

SetOnActiveNavigationCommitted sets a callback fired when the active pane commits a navigation.

func (*Coordinator) SetOnClosePane

func (c *Coordinator) SetOnClosePane(fn func(ctx context.Context, paneID entity.PaneID) error)

SetOnClosePane sets the callback to close a pane when its popup closes.

func (*Coordinator) SetOnFirstLoadStarted

func (c *Coordinator) SetOnFirstLoadStarted(fn func())

SetOnFirstLoadStarted sets the callback for when the first navigation starts. This is used to trigger deferred initialization after the initial load_uri() has been processed by the GTK main loop.

func (*Coordinator) SetOnFullscreenChanged

func (c *Coordinator) SetOnFullscreenChanged(fn func(entering bool))

SetOnFullscreenChanged sets the callback for fullscreen state changes.

func (*Coordinator) SetOnHistoryRecord

func (c *Coordinator) SetOnHistoryRecord(fn func(ctx context.Context, paneID entity.PaneID, url string))

SetOnHistoryRecord sets the callback for recording history on page commit.

func (*Coordinator) SetOnInsertPopup

func (c *Coordinator) SetOnInsertPopup(fn func(ctx context.Context, input InsertPopupInput) error)

SetOnInsertPopup sets the callback to insert popups into the workspace.

func (*Coordinator) SetOnLaunchExternalURL

func (c *Coordinator) SetOnLaunchExternalURL(fn func(uri string))

SetOnLaunchExternalURL sets the callback invoked when an external URL scheme (e.g. vscode://, spotify://) is detected and must be handed off to the system.

func (*Coordinator) SetOnPaneURIUpdated

func (c *Coordinator) SetOnPaneURIUpdated(fn func(paneID entity.PaneID, url string))

SetOnPaneURIUpdated sets the callback for pane URI changes (for session snapshots).

func (*Coordinator) SetOnPermissionActivity

func (c *Coordinator) SetOnPermissionActivity(
	fn func(origin string, permTypes []entity.PermissionType, state PermissionActivityState),
)

SetOnPermissionActivity sets a callback for WebRTC permission activity changes.

func (*Coordinator) SetOnTitleUpdated

func (c *Coordinator) SetOnTitleUpdated(fn func(ctx context.Context, paneID entity.PaneID, url, title string))

SetOnTitleUpdated sets the callback for title changes (for history persistence).

func (*Coordinator) SetOnWebViewFocused

func (c *Coordinator) SetOnWebViewFocused(fn func(paneID entity.PaneID, wv port.WebView))

SetOnWebViewFocused sets the callback for when a WebView gains focus.

func (*Coordinator) SetOnWebViewShown

func (c *Coordinator) SetOnWebViewShown(fn func(paneID entity.PaneID))

SetOnWebViewShown sets a callback that fires when a pane's WebView is shown.

func (*Coordinator) SetOnWindowTitleChanged

func (c *Coordinator) SetOnWindowTitleChanged(fn func(title string))

SetOnWindowTitleChanged sets the callback for active pane title changes (for window title updates).

func (*Coordinator) SetPopupConfig

func (c *Coordinator) SetPopupConfig(
	factory port.WebViewFactory,
	popupConfig *entity.PopupBehaviorConfig,
	generateID func() string,
)

SetPopupConfig configures popup handling.

func (*Coordinator) SetSettingsApplier

func (c *Coordinator) SetSettingsApplier(sa port.SettingsApplier)

SetSettingsApplier sets the engine settings applier for config hot-reload.

func (*Coordinator) WrapWidget

func (c *Coordinator) WrapWidget(ctx context.Context, wv port.WebView) layout.Widget

WrapWidget converts a WebView to a layout.Widget for embedding. It also attaches gesture handlers for mouse button navigation.

type InsertPopupInput

type InsertPopupInput struct {
	// ParentPaneID is the pane that spawned this popup.
	ParentPaneID entity.PaneID

	// PopupPane is the pre-created pane entity for the popup.
	// It should have IsRelated=true and ParentPaneID set.
	PopupPane *entity.Pane

	// WebView is the related WebView for the popup.
	WebView port.WebView

	// Behavior determines how the popup is inserted (split/stacked/tabbed).
	Behavior entity.PopupBehavior

	// Placement specifies direction for split behavior (right/left/top/bottom).
	Placement string

	// PopupType indicates if this is a tab-like or JS popup.
	PopupType PopupType

	// TargetURI is the URL to load in the popup.
	TargetURI string
}

InsertPopupInput contains the data needed to insert a popup into the workspace.

type PendingPopup

type PendingPopup struct {
	// PaneID is the popup pane created during the create phase.
	PaneID entity.PaneID

	// WebView is the related WebView created in the "create" phase.
	// It shares cookies/session with the parent for OAuth support.
	WebView port.WebView

	// ParentPaneID is the pane that spawned this popup.
	ParentPaneID entity.PaneID

	// ParentWebViewID is the WebView ID of the parent (for lookup).
	ParentWebViewID port.WebViewID

	// TargetURI is the initial URL the popup will load.
	TargetURI string

	// FrameName is the target frame name from the navigation action.
	// "_blank" indicates a tab-like popup, other values indicate JS popups.
	FrameName string

	// IsUserGesture indicates if the popup was triggered by user action
	// (click) vs script-initiated (e.g., popup after timeout).
	IsUserGesture bool

	// PopupType categorizes this as a tab-like or JS popup.
	PopupType PopupType

	// CreatedAt is when the popup was created (for timeout handling).
	CreatedAt time.Time
}

PendingPopup tracks a popup WebView that has been created but not yet inserted into the workspace. This is used during the three-phase popup lifecycle: create → ready-to-show → (insert into workspace).

type PermissionActivityState

type PermissionActivityState string

PermissionActivityState represents the visible state for media permission activity.

const (
	PermissionActivityRequesting PermissionActivityState = "requesting"
	PermissionActivityAllowed    PermissionActivityState = "allowed"
	PermissionActivityBlocked    PermissionActivityState = "blocked"
)

type PopupType

type PopupType int

PopupType indicates whether the popup was triggered by a link or JavaScript.

const (
	// PopupTypeTab represents a popup from target="_blank" links.
	// These are typically user-initiated and open like new tabs.
	PopupTypeTab PopupType = iota
	// PopupTypePopup represents a popup from window.open() JavaScript calls.
	// These may have different placement behavior than tab-like popups.
	PopupTypePopup
)

func DetectPopupType

func DetectPopupType(frameName string) PopupType

DetectPopupType determines if this is a tab-like or JS popup based on frame name.

func (PopupType) String

func (t PopupType) String() string

String returns a human-readable name for the popup type.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL