Skip to content

Refactor Interface, DRM Functionality and Web Requests (WIP)#48

Merged
ovsky merged 34 commits into
devfrom
refactor/drm-functionality-plus-requests
Dec 3, 2025
Merged

Refactor Interface, DRM Functionality and Web Requests (WIP)#48
ovsky merged 34 commits into
devfrom
refactor/drm-functionality-plus-requests

Conversation

@ovsky
Copy link
Copy Markdown
Owner

@ovsky ovsky commented Dec 2, 2025

This pull request introduces significant improvements for Windows DRM webview support, Facebook/Messenger compatibility, and user agent customization. The most important changes include integrating the Microsoft WebView2 SDK for DRM-protected content on Windows, updating ad/tracker blocking lists to allow Facebook/Messenger login, adding a customizable user agent setting, and injecting JavaScript polyfills to improve compatibility with sites that rely on modern web APIs.

Windows DRM WebView Integration:

  • Added logic in CMakeLists.txt to automatically download and configure the Microsoft WebView2 SDK for DRM webview support on Windows, including proper header and library setup for the build.
  • Added a new loading page for DRM-protected content (assets/drm_loading.html) with improved UI messaging.

Facebook/Messenger Compatibility:

  • Updated assets/blocklist.txt and assets/filters/trackers.txt to comment out Facebook tracking domains, allowing Facebook/Messenger login to function correctly. Clear notes added to explain the necessity. [1] [2]
  • Expanded assets/drm_sites.json to force DRM mode for Facebook/Messenger/Instagram domains, ensuring protected content and compatibility.

User Agent Customization:

  • Implemented a new setting for custom user agent strings in Settings.cpp, including lenient parsing and escaping for disk persistence. [1] [2] [3]
  • Refactored Tab.cpp and Tab.h to use the custom user agent (or a Chromium-like default) for all tabs, improving site compatibility and user privacy. [1] [2] [3]

Debugging and Logging Enhancements:

  • Added debug logging for all network requests in AdBlocker.cpp and enabled it by default to help diagnose login issues. [1] [2] [3]
  • Improved console message logging in Tab.cpp for easier debugging.

Web API Polyfills for Site Compatibility:

  • Injected JavaScript polyfills for XMLHttpRequest, fetch, and crypto.subtle APIs in Tab.cpp to ensure compatibility with Facebook and other sites that use modern web authentication and cryptography.

ovsky added 25 commits December 2, 2025 18:54
Introduces parsing and saving of a custom user agent string in settings. The Tab constructor now accepts a user agent parameter, and UI passes the active user agent when creating new tabs. The settings payload and equality operator are updated to handle custom user agent fields.
Facebook tracking domains have been commented out in blocklist and filter files to ensure Facebook and Messenger login functionality. Notes were added to clarify the reason for this change.
Introduces a log_all_requests_ flag to AdBlocker, allowing debug logging of every network request. Updates logging to include method, URL, and host, and ensures blocked requests are logged when either log_blocked_ or log_all_requests_ is enabled. Adds setter for the new flag in the header.
Added a call to set_log_all_requests(true) to help diagnose login issues by logging all adblock requests during browser initialization.
Implements OnWindowObjectReady for early script injection, including XHR/fetch credential fixes and a Web Crypto API polyfill for compatibility with sites like Facebook. Also connects a network listener for ad/tracker blocking, matches acceleration/display settings with the main UI view, improves console message logging, and updates the default user agent to Chrome 131.
Reorders the initialization of url_utf8 to occur before binding the JS context and global object. This improves code clarity and ensures url_utf8 is available for subsequent checks.
Introduces SetWebKitEnvironment to set environment variables that attempt to relax WebKit security restrictions. This is called at startup for both Windows and non-Windows entry points to potentially improve compatibility or debugging with Ultralight's WebKit.
Removed unused IUnknown parameters from WebView2 event handler lambdas to match expected signatures. Changed can_go_back_ and can_go_forward_ member variables from bool to BOOL for consistency with Windows API types.
Introduces logic to download and configure the Microsoft WebView2 SDK via FetchContent for Windows builds using MSVC. Sets up include and library directories, and links WebView2LoaderStatic.lib if the SDK is available; otherwise, falls back to a stub implementation.
Introduces the PrewarmWebViewEnvironment() function to pre-initialize the WebView environment, reducing first-load lag. On Windows, this caches the WebView2 environment for faster tab creation; on Linux and macOS, the function is a no-op as prewarming is unnecessary. Also refactors Windows WebView2 initialization to support environment reuse and pending URL navigation.
Adds background pre-warming of the WebView2 environment when DRM is enabled to reduce first-load lag. Also updates the DRM tab title to indicate loading state and sets loading status immediately when opening a DRM tab.
Added facebook.com, messenger.com, fbcdn.net, fbsbx.com, instagram.com, and cdninstagram.com to the list of DRM sites with force enabled.
Introduced a public method network_blocker() to provide access to the AdBlocker instance from the UI class.
Enhanced the logic for opening and managing DRM tabs, including more robust checks and UI updates. Added detailed comments throughout the DRM tab workflow for clarity. Improved handling of tab state transitions, URL updates, and loading indicators for DRM and non-DRM sites.
Added patterns to ignore files and directories starting with 'debug_log' and 'debug_' to prevent accidental commits of debug artifacts.
Adds Blur() methods to DRMWebViewTab implementations for macOS and Windows to allow proper focus management between Ultralight UI and DRM tabs. Updates UI.cpp to blur DRM tab when address bar is focused and focus DRM tab when content area is clicked. Modifies DRMSettings.cpp to always merge all catalog entries, ensuring new sites are picked up. Also sets initial bounds for WebView2 controller on Windows.
Introduces a Blur() method to the DRMWebViewTab interface and implements it for Linux by shifting focus from the WebView to its parent window. This allows programmatic removal of focus from the WebView component.
Introduces a new drm_loading.html asset for displaying a DRM system loading screen. Adds HideAllDrmTabs() to UI.h for managing visibility of all DRM tabs.
Enhances Blur, Resize, Show, and Hide methods for better focus management and visibility control of WebView2. Focus is explicitly released when hiding, bounds are only updated when visible, and bounds are restored when showing. WebView2 is moved off-screen when hidden to prevent input capture.
Adds HideAllDrmTabs to ensure all DRM tabs are hidden when switching tabs, navigating, or creating new tabs. Improves focus management by explicitly blurring and focusing tabs during transitions, and ensures Ultralight loading page is shown while DRM tab initializes. These changes prevent input interference and provide a smoother tab switching experience.
Enhances the Blur, Resize, Show, and Hide methods for DRMWebViewTab on Linux. Focus is now properly managed by clearing and restoring focus on the WebView widget, resize parameters are stored and only applied when visible, and hiding the WebView moves it off-screen to prevent input capture.
Enhanced Blur to also resign first responder from the web view. Resize now stores config and only updates frames if visible. Show restores position and size before displaying, and Hide blurs, hides, and moves the view off-screen to prevent input capture.
Adds a desired_visible_ member to DRMWebViewTabWindows to track the intended visibility state. Ensures the WebView controller respects Hide() and Show() calls even if invoked before the controller is ready, starting hidden until explicitly shown.
DRM WebView2 tabs are now hidden when overlays (downloads, menu, context menu, suggestions) are shown, and restored when overlays are dismissed. This ensures overlays appear above DRM content and the loading page remains visible during initialization.
@ovsky ovsky changed the title Refactor Interface, DRM Functionality and Web Requests Refactor Interface, DRM Functionality and Web Requests (WIP) Dec 2, 2025
ovsky added 4 commits December 3, 2025 00:34
Adds DetachFromParent and ReattachToParent methods to DRMWebViewTab for better input handling and prevents WebView2 from intercepting keyboard events. Refactors UI transitions between DRM and non-DRM tabs for smoother visual experience, preloads solid backgrounds, and ensures proper cleanup and hiding of DRM tabs. Also adds debug logging for address bar navigation.
@ovsky ovsky force-pushed the refactor/drm-functionality-plus-requests branch from 715e4af to e71a9fe Compare December 2, 2025 23:51
ovsky added 5 commits December 3, 2025 01:08
- Set LD_LIBRARY_PATH/DYLD_LIBRARY_PATH in workflow test steps
- Add BUILD_RPATH to UtilsTest for Linux/macOS
- Add test step to macOS-arm64 workflow for consistency
- Remove debug cout statements from UI.cpp
Only run DRMSettingsTest on CI as it's standalone. UtilsTest requires
Ultralight SDK shared libraries at runtime which aren't available on
CI runners.
@ovsky ovsky merged commit 7706bf7 into dev Dec 3, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant