Skip to content

Commit

Permalink
Merge branch 'master' into 'release'
Browse files Browse the repository at this point in the history
Release 2.2.2

See merge request voltstro-studios/uwb/unitywebbrowser!5
  • Loading branch information
Voltstro committed Oct 16, 2024
2 parents c81279a + 7379df0 commit 433bcfe
Show file tree
Hide file tree
Showing 25 changed files with 194 additions and 79 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,24 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [2.2.2] - 2024-10-16

### Added

- Added ignore SSL errors option (#350)

### Changed

- Move some web browser client options to a new section called "Advanced"

### Fixed

- Fixed `LoadHtml` not working correctly (#351)

### Removed

- Removed CEF engine custom error page. It shows the default chrome one now.

## [2.2.1] - 2024-10-06

### Added
Expand Down
4 changes: 2 additions & 2 deletions src/Packages/UnityWebBrowser.Communication.Pipes/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "dev.voltstro.unitywebbrowser.communication.pipes",
"displayName": "Unity Web Browser Pipes Communication",
"description": "Adds support to use pipes in UWB.",
"version": "2.2.0",
"version": "2.2.2",
"unity": "2021.3",
"author": {
"name": "Voltstro",
Expand All @@ -18,7 +18,7 @@
"documentationUrl": "https://projects.voltstro.dev/UnityWebBrowser/latest/",
"licensesUrl": "https://github.com/Voltstro-Studios/UnityWebBrowser/blob/master/LICENSE.md",
"dependencies": {
"dev.voltstro.unitywebbrowser": "2.2.0",
"dev.voltstro.unitywebbrowser": "2.2.2",
"org.nuget.voltrpc.communication.pipes": "3.1.0"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "dev.voltstro.unitywebbrowser.engine.cef.linux.x64",
"displayName": "Unity Web Browser CEF Engine (Linux x64)",
"description": "CEF engine for Unity Web Browser (Linux x64).",
"version": "2.2.1-129.0.11",
"version": "2.2.2-129.0.11",
"unity": "2021.3",
"author": {
"name": "Voltstro",
Expand All @@ -17,6 +17,6 @@
"documentationUrl": "https://projects.voltstro.dev/UnityWebBrowser/latest/articles/user/engines/#cef-engine",
"licensesUrl": "https://github.com/Voltstro-Studios/UnityWebBrowser/blob/master/LICENSE.md",
"dependencies": {
"dev.voltstro.unitywebbrowser.engine.cef": "2.2.1-129.0.11"
"dev.voltstro.unitywebbrowser.engine.cef": "2.2.2-129.0.11"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "dev.voltstro.unitywebbrowser.engine.cef.macos.arm64",
"displayName": "Unity Web Browser CEF Engine (MacOS arm64)",
"description": "CEF engine for Unity Web Browser (MacOS arm64).",
"version": "2.2.1-129.0.11",
"version": "2.2.2-129.0.11",
"unity": "2021.2",
"author": {
"name": "Voltstro",
Expand All @@ -17,6 +17,6 @@
"documentationUrl": "https://projects.voltstro.dev/UnityWebBrowser/latest/articles/user/engines/#cef-engine",
"licensesUrl": "https://github.com/Voltstro-Studios/UnityWebBrowser/blob/master/LICENSE.md",
"dependencies": {
"dev.voltstro.unitywebbrowser.engine.cef": "2.2.1-129.0.11"
"dev.voltstro.unitywebbrowser.engine.cef": "2.2.2-129.0.11"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "dev.voltstro.unitywebbrowser.engine.cef.macos.x64",
"displayName": "Unity Web Browser CEF Engine (MacOS x64)",
"description": "CEF engine for Unity Web Browser (MacOS x64).",
"version": "2.2.1-129.0.11",
"version": "2.2.2-129.0.11",
"unity": "2021.2",
"author": {
"name": "Voltstro",
Expand All @@ -17,6 +17,6 @@
"documentationUrl": "https://projects.voltstro.dev/UnityWebBrowser/latest/articles/user/engines/#cef-engine",
"licensesUrl": "https://github.com/Voltstro-Studios/UnityWebBrowser/blob/master/LICENSE.md",
"dependencies": {
"dev.voltstro.unitywebbrowser.engine.cef": "2.2.1-129.0.11"
"dev.voltstro.unitywebbrowser.engine.cef": "2.2.2-129.0.11"
}
}
4 changes: 2 additions & 2 deletions src/Packages/UnityWebBrowser.Engine.Cef.Win-x64/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "dev.voltstro.unitywebbrowser.engine.cef.win.x64",
"displayName": "Unity Web Browser CEF Engine (Win x64)",
"description": "CEF engine for Unity Web Browser (Win x64).",
"version": "2.2.1-129.0.11",
"version": "2.2.2-129.0.11",
"unity": "2021.2",
"author": {
"name": "Voltstro",
Expand All @@ -17,6 +17,6 @@
"documentationUrl": "https://projects.voltstro.dev/UnityWebBrowser/latest/articles/user/engines/#cef-engine",
"licensesUrl": "https://github.com/Voltstro-Studios/UnityWebBrowser/blob/master/LICENSE.md",
"dependencies": {
"dev.voltstro.unitywebbrowser.engine.cef": "2.2.1-129.0.11"
"dev.voltstro.unitywebbrowser.engine.cef": "2.2.2-129.0.11"
}
}
4 changes: 2 additions & 2 deletions src/Packages/UnityWebBrowser.Engine.Cef/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "dev.voltstro.unitywebbrowser.engine.cef",
"displayName": "Unity Web Browser CEF Engine",
"description": "CEF engine for Unity Web Browser.",
"version": "2.2.1-129.0.11",
"version": "2.2.2-129.0.11",
"unity": "2021.3",
"author": {
"name": "Voltstro",
Expand All @@ -18,6 +18,6 @@
"documentationUrl": "https://projects.voltstro.dev/UnityWebBrowser/latest/articles/user/engines/#cef-engine",
"licensesUrl": "https://github.com/Voltstro-Studios/UnityWebBrowser/blob/master/LICENSE.md",
"dependencies": {
"dev.voltstro.unitywebbrowser": "2.2.1"
"dev.voltstro.unitywebbrowser": "2.2.2"
}
}
4 changes: 2 additions & 2 deletions src/Packages/UnityWebBrowser/Runtime/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.2.1")]
[assembly: AssemblyFileVersion("2.2.1")]
[assembly: AssemblyVersion("2.2.2")]
[assembly: AssemblyFileVersion("2.2.2")]

[assembly: InternalsVisibleTo("VoltstroStudios.UnityWebBrowser.Prj")]
[assembly: InternalsVisibleTo("VoltstroStudios.UnityWebBrowser.Editor")]
Expand Down
30 changes: 25 additions & 5 deletions src/Packages/UnityWebBrowser/Runtime/Core/WebBrowserClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,6 @@ public Resolution Resolution
[Tooltip("Enable or disable incognito/private mode. When true, no profile-specific data is persisted to disk, but cache is still used to persist installation-specific data.")]
public bool incognitoMode;

/// <summary>
/// Enable or disable WebRTC
/// </summary>
[Tooltip("Enable or disable WebRTC")] public bool webRtc;

/// <summary>
/// Enable or disable local storage
/// </summary>
Expand All @@ -134,6 +129,12 @@ public Resolution Resolution
/// Proxy Settings
/// </summary>
[Tooltip("Proxy settings")] public ProxySettings proxySettings;

/// <summary>
/// Enable or disable WebRTC
/// </summary>
[Header("Advanced")]
[Tooltip("Enable or disable WebRTC")] public bool webRtc;

/// <summary>
/// Enable or disable remote debugging
Expand All @@ -159,6 +160,18 @@ public Resolution Resolution
[Tooltip("Manager for JS methods")]
public JsMethodManager jsMethodManager = new();

/// <summary>
/// Will ignore SSL errors on provided domains in <see cref="ignoreSslErrorsDomains"/>
/// </summary>
[Tooltip("Will ignore SSL errors on provided domains in ignoreSSLErrorsDomains")]
public bool ignoreSslErrors = false;

/// <summary>
/// Domains to ignore SSL errors on if <see cref="ignoreSslErrors"/> is enabled
/// </summary>
[Tooltip("Domains to ignore SSL errors on if ignoreSSLErrors is enabled")]
public string[] ignoreSslErrorsDomains;

/// <summary>
/// The <see cref="CommunicationLayer" /> to use
/// </summary>
Expand Down Expand Up @@ -385,6 +398,13 @@ internal void Init()
if (!string.IsNullOrWhiteSpace(proxySettings.Password))
argsBuilder.AppendArgument("proxy-password", proxySettings.Password, true);
}

//Ignore ssl errors
if (ignoreSslErrors)
{
argsBuilder.AppendArgument("ignore-ssl-errors", true);
argsBuilder.AppendArgument("ignore-ssl-errors-domains", string.Join(",", ignoreSslErrorsDomains));
}

//Make sure not to include this, its for testing
#if UWB_ENGINE_PRJ //Define for backup, cause I am dumb as fuck and gonna accidentally include this in a release build one day
Expand Down
2 changes: 1 addition & 1 deletion src/Packages/UnityWebBrowser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "dev.voltstro.unitywebbrowser",
"displayName": "Unity Web Browser",
"description": "Unity Web Browser (UWB) is a Unity package that allows displaying and interacting with the web from within Unity.",
"version": "2.2.1",
"version": "2.2.2",
"unity": "2021.3",
"author": {
"name": "Voltstro",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,8 @@ public void Init(ClientControlsActions clientControlsActions, EnginePopupManager
launchArguments.PopupAction,
popupManager,
new ProxySettings(launchArguments.ProxyUsername, launchArguments.ProxyPassword, launchArguments.ProxyEnabled),
launchArguments.IgnoreSslErrors,
launchArguments.IgnoreSslErrorsDomains,
clientControlsActions,
mainLogger,
browserConsoleLogger);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,20 @@ public class UwbCefEnginePopupInfo : EnginePopupInfo
/// </summary>
/// <param name="proxySettings"></param>
/// <param name="popupManager"></param>
public UwbCefEnginePopupInfo(EnginePopupManager popupManager, ProxySettings proxySettings, ref CefClient client)
/// <param name="client"></param>
/// <param name="ignoreSslErrors"></param>
/// <param name="ignoreSslErrorsDomains"></param>
public UwbCefEnginePopupInfo(
EnginePopupManager popupManager,
ProxySettings proxySettings,
ref CefClient client,
bool ignoreSslErrors,
string[] ignoreSslErrorsDomains)
{
this.popupManager = popupManager;

//Create a new client for it, and properly create the window
popupClient = new UwbCefPopupClient(proxySettings, DisposeNoClose);
popupClient = new UwbCefPopupClient(proxySettings, DisposeNoClose, ignoreSslErrors, ignoreSslErrorsDomains);
client = popupClient;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,15 @@ public class UwbCefPopupClient : CefClient
/// </summary>
/// <param name="proxySettings"></param>
/// <param name="onShutdown"></param>
public UwbCefPopupClient(ProxySettings proxySettings, Action onShutdown)
/// <param name="ignoreSslErrors"></param>
/// <param name="ignoreSslErrorsDomains"></param>
public UwbCefPopupClient(
ProxySettings proxySettings,
Action onShutdown,
bool ignoreSslErrors,
string[] ignoreSslErrorsDomains)
{
requestHandler = new UwbCefRequestHandler(proxySettings);
requestHandler = new UwbCefRequestHandler(proxySettings, ignoreSslErrors, ignoreSslErrorsDomains);
lifeSpanHandler = new UwbCefPopupLifeSpanHandler(onShutdown);
}

Expand Down
7 changes: 4 additions & 3 deletions src/UnityWebBrowser.Engine.Cef/Shared/Browser/UwbCefApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
//
// This project is under the MIT license. See the LICENSE.md file for more details.

#nullable enable
using VoltstroStudios.UnityWebBrowser.Engine.Shared.Core;
using Xilium.CefGlue;

Expand All @@ -16,9 +17,9 @@ public class UwbCefApp : CefApp
private readonly bool mediaStreamingEnabled;
private readonly bool noProxyServer;
private readonly bool remoteDebugging;
private readonly string[] remoteDebuggingOrigins;
private readonly string[]? remoteDebuggingOrigins;

private UwbCefBrowserProcessHandler browserProcessHandler;
private UwbCefBrowserProcessHandler browserProcessHandler = null!;

public UwbCefApp(LaunchArguments launchArguments)
{
Expand All @@ -36,7 +37,7 @@ protected override void OnBeforeCommandLineProcessing(string processType, CefCom
if (mediaStreamingEnabled && !commandLine.HasSwitch("--enable-media-stream"))
commandLine.AppendSwitch("--enable-media-stream");

if (remoteDebugging && !commandLine.HasSwitch("--remote-allow-origins"))
if (remoteDebugging && remoteDebuggingOrigins != null && !commandLine.HasSwitch("--remote-allow-origins"))
commandLine.AppendSwitch("--remote-allow-origins", string.Join(',', remoteDebuggingOrigins));

#if LINUX || MACOS
Expand Down
36 changes: 25 additions & 11 deletions src/UnityWebBrowser.Engine.Cef/Shared/Browser/UwbCefClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Collections.Generic;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Text;
using Microsoft.Extensions.Logging;
using UnityWebBrowser.Engine.Cef.Shared.Browser.Js;
using UnityWebBrowser.Engine.Cef.Shared.Browser.Messages;
Expand Down Expand Up @@ -45,6 +46,8 @@ internal class UwbCefClient : CefClient, IDisposable
private UwbCefPopupClient devToolsClient;

//Dev Tools
private readonly bool ignoreSslErrors;
private readonly string[] ignoreSslErrorsDomains;
private CefWindowInfo devToolsWindowInfo;

//State of mouse click events that needs to be persisted for dragging
Expand All @@ -58,6 +61,8 @@ public UwbCefClient(
PopupAction popupAction,
EnginePopupManager popupManager,
ProxySettings proxySettings,
bool ignoreSslErrors,
string[] ignoreSslErrorsDomains,
ClientControlsActions clientControlsActions,
ILogger mainLogger,
ILogger browserConsoleLogger)
Expand All @@ -71,16 +76,19 @@ public UwbCefClient(
//Setup our handlers
loadHandler = new UwbCefLoadHandler(this);
renderHandler = new UwbCefRenderHandler(this, size);
lifespanHandler = new UwbCefLifespanHandler(popupAction, popupManager, proxySettings);
lifespanHandler = new UwbCefLifespanHandler(popupAction, popupManager, proxySettings, ignoreSslErrors, ignoreSslErrorsDomains);
lifespanHandler.AfterCreated += cefBrowser =>
{
browser = cefBrowser;
browserHost = cefBrowser.GetHost();
};
displayHandler = new UwbCefDisplayHandler(this, mainLogger, browserConsoleLogger);
requestHandler = new UwbCefRequestHandler(proxySettings);
requestHandler = new UwbCefRequestHandler(proxySettings, ignoreSslErrors, ignoreSslErrorsDomains);
contextMenuHandler = new UwbCefContextMenuHandler();

this.ignoreSslErrors = ignoreSslErrors;
this.ignoreSslErrorsDomains = ignoreSslErrorsDomains;

//Create message types
messageTypes = new Dictionary<string, IMessageBase>
{
Expand Down Expand Up @@ -289,7 +297,7 @@ public void ProcessMouseScrollEvent(MouseScrollEvent mouseScrollEvent)
/// <param name="url"></param>
public void LoadUrl(string url)
{
browser.GetMainFrame()?.LoadUrl(url);
browser.GetMainFrame()!.LoadUrl(url);
}

/// <summary>
Expand All @@ -307,7 +315,10 @@ public Vector2 GetMouseScrollPosition()
/// <param name="html"></param>
public void LoadHtml(string html)
{
browser.GetMainFrame()?.LoadUrl($"data:text/html,{html}");
html = CefRuntime.Base64Encode(Encoding.UTF8.GetBytes(html));
html = CefRuntime.UriEncode(html, false);

browser.GetMainFrame()!.LoadUrl($"data:text/html;base64,{html}");
}

/// <summary>
Expand All @@ -316,7 +327,7 @@ public void LoadHtml(string html)
/// <param name="js"></param>
public void ExecuteJs(string js)
{
browser.GetMainFrame()?.ExecuteJavaScript(js, "", 0);
browser.GetMainFrame()!.ExecuteJavaScript(js, "", 0);
}

/// <summary>
Expand Down Expand Up @@ -347,12 +358,15 @@ public void OpenDevTools()
if (devToolsWindowInfo == null)
{
devToolsWindowInfo = CefWindowInfo.Create();
devToolsClient = new UwbCefPopupClient(proxySettings, () =>
{
devToolsWindowInfo = null;
devToolsClient = null;
devToolsBrowserSettings = null;
});
devToolsClient = new UwbCefPopupClient(
proxySettings, () =>
{
devToolsWindowInfo = null;
devToolsClient = null;
devToolsBrowserSettings = null;
},
ignoreSslErrors,
ignoreSslErrorsDomains);
devToolsBrowserSettings = new CefBrowserSettings();
}

Expand Down
Loading

0 comments on commit 433bcfe

Please sign in to comment.