cef: stop wiring transcoding request handlers
- commit
- b15abc436d2c8dcb3583298034b805621355da1e
- author
- brice · · 2026-04-28 03:44 UTC
- parent
- 91bd671
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
2 files · +4 -29
M internal/infrastructure/cef/factory.go +1 -12
| @@ -121,19 +121,8 @@ func (f *WebViewFactory) newWebView(ctx context.Context) *WebView { | |||
| 121 | 121 | backgroundColor: f.bgColor.Load(), | |
| 122 | 122 | } | |
| 123 | 123 | ||
| 124 | - | var transcodingHandler purecef.ResourceRequestHandler | |
| 125 | - | if f.transcoder != nil { | |
| 126 | - | transcodingHandler = newTranscodingRequestHandler(f.transcoder, f.mediaClassifier, func() context.Context { | |
| 127 | - | if f.engine != nil { | |
| 128 | - | return f.engine.currentContext() | |
| 129 | - | } | |
| 130 | - | return ctx | |
| 131 | - | }) | |
| 132 | - | } | |
| 133 | - | ||
| 134 | 124 | handlers := &handlerSet{ | |
| 135 | - | wv: wv, | |
| 136 | - | transcodingHandler: transcodingHandler, | |
| 125 | + | wv: wv, | |
| 137 | 126 | } | |
| 138 | 127 | wv.handlers = handlers | |
| 139 | 128 | wv.findCtrl = newFindController() | |
| @@ -121,19 +121,8 @@ func (f *WebViewFactory) newWebView(ctx context.Context) *WebView { | |||||
| 121 | backgroundColor: f.bgColor.Load(), | 121 | backgroundColor: f.bgColor.Load(), | ||
| 122 | } | 122 | } | ||
| 123 | 123 | ||||
| 124 | - | var transcodingHandler purecef.ResourceRequestHandler | |||
| 125 | - | if f.transcoder != nil { | |||
| 126 | - | transcodingHandler = newTranscodingRequestHandler(f.transcoder, f.mediaClassifier, func() context.Context { | |||
| 127 | - | if f.engine != nil { | |||
| 128 | - | return f.engine.currentContext() | |||
| 129 | - | } | |||
| 130 | - | return ctx | |||
| 131 | - | }) | |||
| 132 | - | } | |||
| 133 | - | ||||
| 134 | handlers := &handlerSet{ | 124 | handlers := &handlerSet{ | ||
| 135 | - | wv: wv, | 125 | + | wv: wv, |
| 136 | - | transcodingHandler: transcodingHandler, | |||
| 137 | } | 126 | } | ||
| 138 | wv.handlers = handlers | 127 | wv.handlers = handlers | ||
| 139 | wv.findCtrl = newFindController() | 128 | wv.findCtrl = newFindController() | ||
M internal/infrastructure/cef/webview_handlers.go +3 -17
| @@ -8,7 +8,6 @@ import ( | |||
| 8 | 8 | ||
| 9 | 9 | "github.com/bnema/dumber/internal/application/port" | |
| 10 | 10 | downloadutil "github.com/bnema/dumber/internal/domain/download" | |
| 11 | - | "github.com/bnema/dumber/internal/infrastructure/transcoder" | |
| 12 | 11 | "github.com/bnema/dumber/internal/logging" | |
| 13 | 12 | ) | |
| 14 | 13 | ||
| @@ -23,8 +22,7 @@ const ( | |||
| 23 | 22 | // owning WebView. A single struct is used so that the Client's Get*Handler | |
| 24 | 23 | // methods can return the same receiver, avoiding extra allocations. | |
| 25 | 24 | type handlerSet struct { | |
| 26 | - | wv *WebView | |
| 27 | - | transcodingHandler purecef.ResourceRequestHandler | |
| 25 | + | wv *WebView | |
| 28 | 26 | } | |
| 29 | 27 | ||
| 30 | 28 | // Compile-time interface checks. | |
| @@ -993,21 +991,9 @@ func (h *handlerSet) OnOpenUrlfromTab( | |||
| 993 | 991 | } | |
| 994 | 992 | ||
| 995 | 993 | func (h *handlerSet) GetResourceRequestHandler( | |
| 996 | - | _ purecef.Browser, _ purecef.Frame, request purecef.Request, | |
| 997 | - | _, _ int32, _ string, disableDefaultHandling *int32, | |
| 994 | + | _ purecef.Browser, _ purecef.Frame, _ purecef.Request, | |
| 995 | + | _, _ int32, _ string, _ *int32, | |
| 998 | 996 | ) purecef.ResourceRequestHandler { | |
| 999 | - | if h.transcodingHandler != nil && request != nil && disableDefaultHandling != nil && | |
| 1000 | - | transcoder.IsEagerTranscodeURL(request.GetURL()) { | |
| 1001 | - | *disableDefaultHandling = 1 | |
| 1002 | - | if h.wv != nil && h.wv.ctx != nil { | |
| 1003 | - | logging.FromContext(h.wv.ctx).Info(). | |
| 1004 | - | Str("url", logging.TruncateURL(request.GetURL(), maxTranscodingURLLength)). | |
| 1005 | - | Msg("cef: disabled default handling for eager transcode candidate") | |
| 1006 | - | } | |
| 1007 | - | } | |
| 1008 | - | if h.transcodingHandler != nil { | |
| 1009 | - | return h.transcodingHandler | |
| 1010 | - | } | |
| 1011 | 997 | return nil | |
| 1012 | 998 | } | |
| 1013 | 999 | ||
| @@ -8,7 +8,6 @@ import ( | |||||
| 8 | 8 | ||||
| 9 | "github.com/bnema/dumber/internal/application/port" | 9 | "github.com/bnema/dumber/internal/application/port" | ||
| 10 | downloadutil "github.com/bnema/dumber/internal/domain/download" | 10 | downloadutil "github.com/bnema/dumber/internal/domain/download" | ||
| 11 | - | "github.com/bnema/dumber/internal/infrastructure/transcoder" | |||
| 12 | "github.com/bnema/dumber/internal/logging" | 11 | "github.com/bnema/dumber/internal/logging" | ||
| 13 | ) | 12 | ) | ||
| 14 | 13 | ||||
| @@ -23,8 +22,7 @@ const ( | |||||
| 23 | // owning WebView. A single struct is used so that the Client's Get*Handler | 22 | // owning WebView. A single struct is used so that the Client's Get*Handler | ||
| 24 | // methods can return the same receiver, avoiding extra allocations. | 23 | // methods can return the same receiver, avoiding extra allocations. | ||
| 25 | type handlerSet struct { | 24 | type handlerSet struct { | ||
| 26 | - | wv *WebView | 25 | + | wv *WebView |
| 27 | - | transcodingHandler purecef.ResourceRequestHandler | |||
| 28 | } | 26 | } | ||
| 29 | 27 | ||||
| 30 | // Compile-time interface checks. | 28 | // Compile-time interface checks. | ||
| @@ -993,21 +991,9 @@ func (h *handlerSet) OnOpenUrlfromTab( | |||||
| 993 | } | 991 | } | ||
| 994 | 992 | ||||
| 995 | func (h *handlerSet) GetResourceRequestHandler( | 993 | func (h *handlerSet) GetResourceRequestHandler( | ||
| 996 | - | _ purecef.Browser, _ purecef.Frame, request purecef.Request, | 994 | + | _ purecef.Browser, _ purecef.Frame, _ purecef.Request, |
| 997 | - | _, _ int32, _ string, disableDefaultHandling *int32, | 995 | + | _, _ int32, _ string, _ *int32, |
| 998 | ) purecef.ResourceRequestHandler { | 996 | ) purecef.ResourceRequestHandler { | ||
| 999 | - | if h.transcodingHandler != nil && request != nil && disableDefaultHandling != nil && | |||
| 1000 | - | transcoder.IsEagerTranscodeURL(request.GetURL()) { | |||
| 1001 | - | *disableDefaultHandling = 1 | |||
| 1002 | - | if h.wv != nil && h.wv.ctx != nil { | |||
| 1003 | - | logging.FromContext(h.wv.ctx).Info(). | |||
| 1004 | - | Str("url", logging.TruncateURL(request.GetURL(), maxTranscodingURLLength)). | |||
| 1005 | - | Msg("cef: disabled default handling for eager transcode candidate") | |||
| 1006 | - | } | |||
| 1007 | - | } | |||
| 1008 | - | if h.transcodingHandler != nil { | |||
| 1009 | - | return h.transcodingHandler | |||
| 1010 | - | } | |||
| 1011 | return nil | 997 | return nil | ||
| 1012 | } | 998 | } | ||
| 1013 | 999 | ||||