main 5041353

browsing_context_policy.go RawHistoryFolder

1package content
2
3import (
4	"strings"
5
6	"github.com/bnema/dumber/internal/application/dto"
7	"github.com/bnema/dumber/internal/application/port"
8	"github.com/bnema/dumber/internal/application/usecase"
9	"github.com/rs/zerolog"
10)
11
12func logBrowsingContextDecision(logger zerolog.Logger, req dto.NewBrowsingContextRequest, decision dto.HostDecision) {
13	logger.Debug().
14		Str("engine", string(req.Engine)).
15		Str("source_host", string(req.SourceHost)).
16		Str("decision", string(decision.Kind)).
17		Str("target_disposition", string(req.TargetDisposition)).
18		Str("reason_code", string(decision.ReasonCode)).
19		Msg("browsing context host decided")
20}
21
22func logBrowsingContextFailure(
23	logger zerolog.Logger,
24	req dto.NewBrowsingContextRequest,
25	decision dto.HostDecision,
26	code dto.BrowsingContextFailureCode,
27	err error,
28) {
29	logger.Error().Err(err).
30		Str("engine", string(req.Engine)).
31		Str("source_host", string(req.SourceHost)).
32		Str("decision", string(decision.Kind)).
33		Str("target_disposition", string(req.TargetDisposition)).
34		Str("reason_code", string(code)).
35		Msg("browsing context hosting failed")
36}
37
38func buildPopupBrowsingContextRequest(req port.PopupRequest) dto.NewBrowsingContextRequest {
39	return dto.NewBrowsingContextRequest{
40		ParentWebViewID:           uint64(req.ParentViewID),
41		Engine:                    req.Engine,
42		SourceBrowserID:           req.SourceBrowserID,
43		SourceFrameID:             req.SourceFrameID,
44		SourceFrameURL:            req.SourceFrameURL,
45		TargetURI:                 req.TargetURI,
46		TargetFrameName:           req.FrameName,
47		TargetDisposition:         inferPopupWindowDisposition(req),
48		IsUserGesture:             req.IsUserGesture,
49		NoJavaScriptAccess:        req.NoJavaScriptAccess,
50		PopupFeatures:             req.PopupFeatures,
51		TriggerKind:               inferPopupTriggerKind(req),
52		AuthIntent:                IsOAuthURL(req.TargetURI),
53		RequiresNativeOpener:      false,
54		RequestContextDisposition: dto.RequestContextInheritParent,
55	}
56}
57
58func buildLinkBrowsingContextRequest(parentWebViewID port.WebViewID, uri string) dto.NewBrowsingContextRequest {
59	return dto.NewBrowsingContextRequest{
60		ParentWebViewID:           uint64(parentWebViewID),
61		TargetURI:                 uri,
62		TargetFrameName:           "_blank",
63		TargetDisposition:         dto.WindowDispositionNewTab,
64		IsUserGesture:             true,
65		NoJavaScriptAccess:        true,
66		TriggerKind:               dto.TriggerLinkNewPage,
67		AuthIntent:                IsOAuthURL(uri),
68		RequestContextDisposition: dto.RequestContextInheritParent,
69	}
70}
71
72func inferPopupWindowDisposition(req port.PopupRequest) dto.WindowDisposition {
73	if req.TargetDisposition != "" {
74		return req.TargetDisposition
75	}
76	if strings.EqualFold(strings.TrimSpace(req.FrameName), "_blank") {
77		return dto.WindowDispositionNewTab
78	}
79	return dto.WindowDispositionNewPopup
80}
81
82func inferPopupTriggerKind(req port.PopupRequest) dto.TriggerKind {
83	if usecase.ReusableBrowsingContextName(req.FrameName) != "" {
84		return dto.TriggerNamedTargetNavigation
85	}
86	switch inferPopupWindowDisposition(req) {
87	case dto.WindowDispositionCurrentTab, dto.WindowDispositionNewTab:
88		return dto.TriggerLinkNewPage
89	case dto.WindowDispositionNewPopup, dto.WindowDispositionNewWindow:
90		return dto.TriggerScriptWindowOpen
91	default:
92		return dto.TriggerUnknown
93	}
94}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 8

Tags 42

↑↓ moveenter openesc close