Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,18 @@ charset = utf-8-bom
tab_width = 4
indent_size = 4
indent_style = space
insert_final_newline = true

csharp_new_line_before_open_brace = all
csharp_new_line_before_else = true
csharp_new_line_before_catch = true
csharp_new_line_before_finally = true
csharp_new_line_before_members_in_object_initializers = true
csharp_new_line_before_members_in_anonymous_types = true
csharp_new_line_between_query_expression_clauses = true
csharp_new_line_between_query_expression_clauses = true

dotnet_style_allow_trailing_comma = true
csharp_wrap_parameters_style = chop_if_long
csharp_wrap_ternary_expr_style = chop_if_long
csharp_wrap_object_and_collection_initializer_style = chop_if_long
csharp_wrap_arguments_style = chop_if_long
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ private void OnDetachedFromVisualTree(object sender, VisualTreeAttachmentEventAr
_previousCursor = null;
_currentDragCursor = null;
_windowStateChangedObservable?.Dispose();
VisibilityChanged(false);
VisibilityChanged?.Invoke(false);
}

private void OnAttachedToVisualTree(object sender, VisualTreeAttachmentEventArgs e)
Expand Down
1 change: 1 addition & 0 deletions CefGlue.BrowserProcess/CefGlue.BrowserProcess.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<RuntimeIdentifiers>osx-x64;osx-arm64;win-x64;win-arm64;linux-x64;linux-arm64</RuntimeIdentifiers>
<RunPostBuildEvent>OnOutputUpdated</RunPostBuildEvent>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<ApplicationManifest>app.manifest</ApplicationManifest>
<PublishCommonConfig>Configuration=$(Configuration);Platform=$(Platform);TargetFramework=$(TargetFramework);IsPublishing=True;PublishTrimmed=True;SelfContained=True;RuntimeIdentifier=</PublishCommonConfig>
<IsEditbinEnabled>True</IsEditbinEnabled>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ private static void HandleJavascriptEvaluation(MessageReceivedEventArgs args)
}
}
}
}
}
43 changes: 43 additions & 0 deletions CefGlue.BrowserProcess/app.manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly
manifestVersion="1.0"
xmlns="urn:schemas-microsoft-com:asm.v1"
xmlns:asmv1="urn:schemas-microsoft-com:asm.v1"
xmlns:asmv2="urn:schemas-microsoft-com:asm.v2"
xmlns:asmv3="urn:schemas-microsoft-com:asm.v3"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<!-- UAC Manifest Options
If you want to change the Windows User Account Control level replace the
requestedExecutionLevel node with one of the following.
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />

Specifying requestedExecutionLevel node will disable file and registry virtualization.
If you want to utilize File and Registry Virtualization for backward
compatibility then delete the requestedExecutionLevel node.-->
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>

<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- A list of all Windows versions that this application is designed to work with.
Windows will automatically select the most compatible environment.-->

<!-- Windows 7 -->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />
<!-- Windows 8 -->
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />
<!-- Windows 8.1 -->
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />
<!-- Windows 10 -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
</application>
</compatibility>
</asmv1:assembly>
2 changes: 1 addition & 1 deletion CefGlue.Common.Shared/Serialization/Deserializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -227,4 +227,4 @@ private static IDeserializerState CreateNewDeserializerState(Utf8JsonReader read
};
}
}
}
}
18 changes: 12 additions & 6 deletions CefGlue.Common/BrowserCefApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,24 @@ protected override void OnBeforeCommandLineProcessing(string processType, CefCom
{
if (string.IsNullOrEmpty(processType))
{
if (CefRuntime.Platform == CefRuntimePlatform.Linux)
if (CefRuntime.Platform == CefRuntimePlatform.Linux)
{
commandLine.AppendSwitch("no-zygote");
}

if (CefRuntimeLoader.IsOSREnabled)
{
commandLine.AppendSwitch("disable-gpu", "1");
commandLine.AppendSwitch("disable-gpu-compositing", "1");
commandLine.AppendSwitch("enable-begin-frame-scheduling", "1");
commandLine.AppendSwitch("disable-smooth-scrolling", "1");
commandLine.AppendSwitch("disable-gpu");
commandLine.AppendSwitch("disable-gpu-compositing");
commandLine.AppendSwitch("enable-begin-frame-scheduling");
commandLine.AppendSwitch("disable-smooth-scrolling");
}


// Telemetry to debug
//commandLine.AppendSwitch("disable-features", "NetworkServiceSandbox");
commandLine.AppendSwitch("log-severity", "verbose");
commandLine.AppendSwitch("log-file", "C:\\git\\CefGlue\\cef_main_log.txt");

if (_flags != null)
{
foreach (var flag in _flags)
Expand Down
20 changes: 3 additions & 17 deletions CefGlue.Common/CefRuntimeLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ private static void InternalInitialize(CefSettings settings = null, KeyValuePair
switch (CefRuntime.Platform)
{
case CefRuntimePlatform.Windows:
case CefRuntimePlatform.Linux:
settings.NoSandbox = true;
settings.MultiThreadedMessageLoop = true;
break;

Expand All @@ -59,11 +61,6 @@ private static void InternalInitialize(CefSettings settings = null, KeyValuePair
settings.FrameworkDirPath = basePath;
settings.ResourcesDirPath = resourcesPath;
break;

case CefRuntimePlatform.Linux:
settings.NoSandbox = true;
settings.MultiThreadedMessageLoop = true;
break;
}

AppDomain.CurrentDomain.ProcessExit += delegate { CefRuntime.Shutdown(); };
Expand All @@ -77,18 +74,7 @@ private static void InternalInitialize(CefSettings settings = null, KeyValuePair
{
exeFileName = "CefGlue";
}

// Fix crash with youtube https://github.com/chromiumembedded/cef/issues/3643
{
#if DEBUG
if (CefRuntime.ChromeVersion.Split(".").First() != "120")
{
throw new Exception("Remove this fix block after CEF upgrade");
}
#endif
flags = (flags ?? []).Append(KeyValuePair.Create("disable-features", "FirstPartySets")).ToArray();
}


CefRuntime.Initialize(new CefMainArgs(new[] { exeFileName }), settings, new BrowserCefApp(customSchemes, flags, browserProcessHandler), IntPtr.Zero);

if (customSchemes != null)
Expand Down
3 changes: 2 additions & 1 deletion CefGlue.Common/CommonBrowserAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ public void ExecuteJavaScript(string code, string url, int line)

public Task<T> EvaluateJavaScript<T>(string code, string url, int line, string frameName = null, TimeSpan? timeout = null)
{
var frame = frameName != null ? _browser?.GetFrame(frameName) : _browser?.GetMainFrame();
var frame = frameName != null ? _browser?.GetFrameByName(frameName) : _browser?.GetMainFrame();
if (frame != null)
{
return EvaluateJavaScript<T>(code, url, line, frame, timeout);
Expand All @@ -254,6 +254,7 @@ public Task<T> EvaluateJavaScript<T>(string code, string url, int line, CefFrame
public void ShowDeveloperTools()
{
var windowInfo = CefWindowInfo.Create();
windowInfo.RuntimeStyle = CefRuntimeStyle.Chrome;

if (CefRuntime.Platform == CefRuntimePlatform.Windows)
{
Expand Down
4 changes: 2 additions & 2 deletions CefGlue.Common/Handlers/Handlers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ internal void HandleBeforeClose(CefBrowser browser)
OnBeforeClose(browser);
}

internal bool HandleBeforePopup(CefBrowser browser, CefFrame frame, string targetUrl, string targetFrameName, CefWindowOpenDisposition targetDisposition, bool userGesture, CefPopupFeatures popupFeatures, CefWindowInfo windowInfo, ref CefClient client, CefBrowserSettings settings, ref CefDictionaryValue extraInfo, ref bool noJavascriptAccess)
internal bool HandleBeforePopup(CefBrowser browser, CefFrame frame, int popupId, string targetUrl, string targetFrameName, CefWindowOpenDisposition targetDisposition, bool userGesture, CefPopupFeatures popupFeatures, CefWindowInfo windowInfo, ref CefClient client, CefBrowserSettings settings, ref CefDictionaryValue extraInfo, ref bool noJavascriptAccess)
{
return OnBeforePopup(browser, frame, targetUrl, targetFrameName, targetDisposition, userGesture, popupFeatures, windowInfo, ref client, settings, ref extraInfo, ref noJavascriptAccess);
return OnBeforePopup(browser, frame, popupId, targetUrl, targetFrameName, targetDisposition, userGesture, popupFeatures, windowInfo, ref client, settings, ref extraInfo, ref noJavascriptAccess);
}

internal void HandleAfterCreated(CefBrowser browser)
Expand Down
6 changes: 3 additions & 3 deletions CefGlue.Common/InternalHandlers/CommonCefLifeSpanHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ protected override void OnBeforeClose(CefBrowser browser)
}


protected override bool OnBeforePopup(CefBrowser browser, CefFrame frame, string targetUrl, string targetFrameName, CefWindowOpenDisposition targetDisposition, bool userGesture, CefPopupFeatures popupFeatures, CefWindowInfo windowInfo, ref CefClient client, CefBrowserSettings settings, ref CefDictionaryValue extraInfo, ref bool noJavascriptAccess)
protected override bool OnBeforePopup(CefBrowser browser, CefFrame frame, int popupId, string targetUrl, string targetFrameName, CefWindowOpenDisposition targetDisposition, bool userGesture, CefPopupFeatures popupFeatures, CefWindowInfo windowInfo, ref CefClient client, CefBrowserSettings settings, ref CefDictionaryValue extraInfo, ref bool noJavascriptAccess)
{
return (_owner.LifeSpanHandler?.HandleBeforePopup(browser, frame, targetUrl, targetFrameName, targetDisposition, userGesture, popupFeatures, windowInfo, ref client, settings, ref extraInfo, ref noJavascriptAccess) ?? false) ||
base.OnBeforePopup(browser, frame, targetUrl, targetFrameName, targetDisposition, userGesture, popupFeatures, windowInfo, ref client, settings, ref extraInfo, ref noJavascriptAccess);
return (_owner.LifeSpanHandler?.HandleBeforePopup(browser, frame, popupId, targetUrl, targetFrameName, targetDisposition, userGesture, popupFeatures, windowInfo, ref client, settings, ref extraInfo, ref noJavascriptAccess) ?? false) ||
base.OnBeforePopup(browser, frame, popupId, targetUrl, targetFrameName, targetDisposition, userGesture, popupFeatures, windowInfo, ref client, settings, ref extraInfo, ref noJavascriptAccess);
}

protected override void OnBeforeDevToolsPopup(CefBrowser browser, CefWindowInfo windowInfo, ref CefClient client, CefBrowserSettings settings, ref CefDictionaryValue extraInfo, ref bool useDefaultWindow)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ protected override void OnPopupSize(CefBrowser browser, CefRectangle rect)
_owner.HandlePopupSizeChange(rect);
}

protected override void OnAcceleratedPaint(CefBrowser browser, CefPaintElementType type, CefRectangle[] dirtyRects, IntPtr sharedHandle)
protected override void OnAcceleratedPaint(CefBrowser browser, CefPaintElementType type, CefRectangle[] dirtyRects, CefAcceleratedPaintInfo info)
{
}

Expand Down
4 changes: 3 additions & 1 deletion CefGlue.Demo.Avalonia/BrowserView.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ public BrowserView()
var browserWrapper = this.FindControl<Decorator>("browserWrapper");

browser = new AvaloniaCefBrowser();
browser.Address = "https://www.google.com";
browser.Address = "https://get.webgl.org/";
//browser.Address = "https://webglsamples.org/aquarium/aquarium.html";
browser.RegisterJavascriptObject(new BindingTestClass(), "boundBeforeLoadObject");
browser.LoadStart += OnBrowserLoadStart;
browser.TitleChanged += OnBrowserTitleChanged;
Expand Down Expand Up @@ -142,6 +143,7 @@ private class BrowserLifeSpanHandler : LifeSpanHandler
protected override bool OnBeforePopup(
CefBrowser browser,
CefFrame frame,
int popupId,
string targetUrl,
string targetFrameName,
CefWindowOpenDisposition targetDisposition,
Expand Down
3 changes: 2 additions & 1 deletion CefGlue.Demo.Avalonia/CefGlue.Demo.Avalonia.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@
<Import Project="$(ProjectDir)..\CefGlue.CopyLocal.props" />

<ItemGroup>
<PackageReference Include="Avalonia.Desktop" />
<PackageReference Include="Dotnet.Bundle" />
<PackageReference Include="Avalonia.Desktop" />
<PackageReference Include="Avalonia.ReactiveUI" />
<PackageReference Include="Avalonia.Diagnostics" />
</ItemGroup>

Expand Down
4 changes: 0 additions & 4 deletions CefGlue.Demo.Avalonia/MainWindow.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ public partial class MainWindow : Window
public MainWindow()
{
InitializeComponent();

#if WINDOWLESS
Title += " - OSR mode";
#endif
}

private void InitializeComponent()
Expand Down
25 changes: 9 additions & 16 deletions CefGlue.Demo.Avalonia/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,20 @@ static int Main(string[] args)
var cachePath = Path.Combine(Path.GetTempPath(), "CefGlue_" + Guid.NewGuid().ToString().Replace("-", null));

AppDomain.CurrentDomain.ProcessExit += delegate { Cleanup(cachePath); };

AppBuilder.Configure<App>()
.UsePlatformDetect()
.With(new Win32PlatformOptions())
.AfterSetup(_ => CefRuntimeLoader.Initialize(new CefSettings() {
RootCachePath = cachePath,
#if WINDOWLESS
// its recommended to leave this off (false), since its less performant and can cause more issues
WindowlessRenderingEnabled = true
#else
WindowlessRenderingEnabled = false
#endif
},
customSchemes: new[] {
new CustomScheme()
.UsePlatformDetect()
.With(new Win32PlatformOptions())
.AfterSetup(_ => CefRuntimeLoader.Initialize(new CefSettings {
RootCachePath = cachePath,
},
customSchemes: [
new CustomScheme
{
SchemeName = "test",
SchemeHandlerFactory = new CustomSchemeHandler()
}
}))
.StartWithClassicDesktopLifetime(args);
]))
.StartWithClassicDesktopLifetime(args);

return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion CefGlue.Demo.WPF/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ private static int Main(string[] args)
};
CefRuntimeLoader.Initialize(settings);

var app = new Xilium.CefGlue.Demo.WPF.App();
var app = new App();
app.InitializeComponent();
app.Run();

Expand Down
2 changes: 1 addition & 1 deletion CefGlue.Interop.Gen/cef_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def get_capi_name(cppname, isclassname, prefix=None):
# and the last character was a lower case letter
if len(result) > 0 and not chr.isdigit() \
and chr.upper() == chr \
and not lastchr.upper() == lastchr:
and (lastchr.lower() == lastchr or lastchr.isdigit()):
result += '_'
result += chr.lower()
lastchr = chr
Expand Down
Empty file modified CefGlue.Interop.Gen/gen-cef3.sh
100644 → 100755
Empty file.
Loading
Loading