Refactor Interface, DRM Functionality and Web Requests (WIP)#48
Merged
Conversation
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.
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.
715e4af to
e71a9fe
Compare
- 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
CMakeLists.txtto automatically download and configure the Microsoft WebView2 SDK for DRM webview support on Windows, including proper header and library setup for the build.assets/drm_loading.html) with improved UI messaging.Facebook/Messenger Compatibility:
assets/blocklist.txtandassets/filters/trackers.txtto comment out Facebook tracking domains, allowing Facebook/Messenger login to function correctly. Clear notes added to explain the necessity. [1] [2]assets/drm_sites.jsonto force DRM mode for Facebook/Messenger/Instagram domains, ensuring protected content and compatibility.User Agent Customization:
Settings.cpp, including lenient parsing and escaping for disk persistence. [1] [2] [3]Tab.cppandTab.hto 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:
AdBlocker.cppand enabled it by default to help diagnose login issues. [1] [2] [3]Tab.cppfor easier debugging.Web API Polyfills for Site Compatibility:
XMLHttpRequest,fetch, andcrypto.subtleAPIs inTab.cppto ensure compatibility with Facebook and other sites that use modern web authentication and cryptography.