From cd2ff30fc70c508664e1bc90fdea0186b75e6646 Mon Sep 17 00:00:00 2001 From: JanEggers Date: Thu, 12 Jun 2014 21:02:20 +0200 Subject: [PATCH 1/8] cleanup usings --- CefSharp.Test/BrowserTest.cs | 5 +---- CefSharp.Test/DispatcherThread.cs | 3 --- CefSharp.Test/Fixture.cs | 1 - CefSharp/IRequestHandler.cs | 4 +--- CefSharp/IWebPluginInfo.cs | 4 +--- 5 files changed, 3 insertions(+), 14 deletions(-) diff --git a/CefSharp.Test/BrowserTest.cs b/CefSharp.Test/BrowserTest.cs index 5cc1f9c8a9..52eb7c8b1b 100644 --- a/CefSharp.Test/BrowserTest.cs +++ b/CefSharp.Test/BrowserTest.cs @@ -1,7 +1,4 @@ -using System; -using System.Threading; -using CefSharp.Wpf; -using Xunit; +using Xunit; using Xunit.Extensions; namespace CefSharp.Test diff --git a/CefSharp.Test/DispatcherThread.cs b/CefSharp.Test/DispatcherThread.cs index 75d9fa1fbe..a6146a68d8 100644 --- a/CefSharp.Test/DispatcherThread.cs +++ b/CefSharp.Test/DispatcherThread.cs @@ -1,7 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; using System.Threading; using System.Threading.Tasks; using System.Windows.Threading; diff --git a/CefSharp.Test/Fixture.cs b/CefSharp.Test/Fixture.cs index 17aba30310..8678cdfc5d 100644 --- a/CefSharp.Test/Fixture.cs +++ b/CefSharp.Test/Fixture.cs @@ -1,7 +1,6 @@ using System; using System.IO; using System.Threading; -//using NUnit.Framework; using System.Threading.Tasks; using System.Windows; using CefSharp.Wpf; diff --git a/CefSharp/IRequestHandler.cs b/CefSharp/IRequestHandler.cs index f1bc4901a4..7c49f0de0a 100644 --- a/CefSharp/IRequestHandler.cs +++ b/CefSharp/IRequestHandler.cs @@ -1,6 +1,4 @@ -using System.Net; - -namespace CefSharp +namespace CefSharp { public interface IRequestHandler { diff --git a/CefSharp/IWebPluginInfo.cs b/CefSharp/IWebPluginInfo.cs index f540d7c11b..78e0f70301 100644 --- a/CefSharp/IWebPluginInfo.cs +++ b/CefSharp/IWebPluginInfo.cs @@ -1,6 +1,4 @@ -using System; - -namespace CefSharp +namespace CefSharp { /// /// Wrapper for the CEF3 CefWebPluginInfo From 22671a0245bdef0c7f9b24ec931c756178838464 Mon Sep 17 00:00:00 2001 From: JanEggers Date: Thu, 12 Jun 2014 21:03:01 +0200 Subject: [PATCH 2/8] remove redundant () --- CefSharp.Test/BrowserTest.cs | 4 ++-- CefSharp.Test/Fixture.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CefSharp.Test/BrowserTest.cs b/CefSharp.Test/BrowserTest.cs index 52eb7c8b1b..b2fffd9f15 100644 --- a/CefSharp.Test/BrowserTest.cs +++ b/CefSharp.Test/BrowserTest.cs @@ -5,7 +5,7 @@ namespace CefSharp.Test { public class BrowserTest { - [Theory()] + [Theory] [InlineData("'2'", "2")] [InlineData("2+2", 4)] public void EvaluateScriptTest(string script, object result) @@ -17,7 +17,7 @@ public void EvaluateScriptTest(string script, object result) } } - [Theory()] + [Theory] [InlineData("!!!")] public void EvaluateScriptExceptionTest(string script) { diff --git a/CefSharp.Test/Fixture.cs b/CefSharp.Test/Fixture.cs index 8678cdfc5d..475cfd3cbe 100644 --- a/CefSharp.Test/Fixture.cs +++ b/CefSharp.Test/Fixture.cs @@ -39,7 +39,7 @@ public Task Initialize() Window.Content = Browser = new ChromiumWebBrowser(); Window.Show(); - }).ContinueWith((t) => + }).ContinueWith(t => { if (t.IsFaulted) { From 048af5e8ad0d68dfbaeb2e5ed15ae1418790e708 Mon Sep 17 00:00:00 2001 From: JanEggers Date: Thu, 12 Jun 2014 21:03:46 +0200 Subject: [PATCH 3/8] use initializers --- CefSharp.Test/Fixture.cs | 12 +++++++----- CefSharp.Wpf/ChromiumWebBrowser.cs | 3 ++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/CefSharp.Test/Fixture.cs b/CefSharp.Test/Fixture.cs index 475cfd3cbe..533d9808e4 100644 --- a/CefSharp.Test/Fixture.cs +++ b/CefSharp.Test/Fixture.cs @@ -25,11 +25,13 @@ public Task Initialize() { Window = new Window(); - var cefsettings = new CefSettings(); - cefsettings.BrowserSubprocessPath = Path.Combine( Environment.CurrentDirectory, "CefSharp.BrowserSubprocess.exe" ); - cefsettings.LogSeverity = LogSeverity.Verbose; - cefsettings.LocalesDirPath = Path.Combine(Environment.CurrentDirectory, "locales"); - cefsettings.PackLoadingDisabled = true; + var cefsettings = new CefSettings + { + BrowserSubprocessPath = Path.Combine(Environment.CurrentDirectory, "CefSharp.BrowserSubprocess.exe"), + LogSeverity = LogSeverity.Verbose, + LocalesDirPath = Path.Combine(Environment.CurrentDirectory, "locales"), + PackLoadingDisabled = true + }; if (!Cef.Initialize(cefsettings)) { diff --git a/CefSharp.Wpf/ChromiumWebBrowser.cs b/CefSharp.Wpf/ChromiumWebBrowser.cs index 4fe8047f13..b2c4ae0d76 100644 --- a/CefSharp.Wpf/ChromiumWebBrowser.cs +++ b/CefSharp.Wpf/ChromiumWebBrowser.cs @@ -20,7 +20,8 @@ namespace CefSharp.Wpf { public class ChromiumWebBrowser : ContentControl, IRenderWebBrowser, IWpfWebBrowser { - private static readonly Key[] KeysToSendtoBrowser = new[] { + private static readonly Key[] KeysToSendtoBrowser = + { Key.Tab, Key.Home, Key.End, Key.Left, Key.Right, From b2a17e965dd674741cc41f38d1edff96e8b26212 Mon Sep 17 00:00:00 2001 From: JanEggers Date: Thu, 12 Jun 2014 21:04:07 +0200 Subject: [PATCH 4/8] matrix is a struct so it cant be null --- CefSharp.Wpf/ChromiumWebBrowser.cs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/CefSharp.Wpf/ChromiumWebBrowser.cs b/CefSharp.Wpf/ChromiumWebBrowser.cs index b2c4ae0d76..cffee2dfa5 100644 --- a/CefSharp.Wpf/ChromiumWebBrowser.cs +++ b/CefSharp.Wpf/ChromiumWebBrowser.cs @@ -558,13 +558,10 @@ private void Transform(FrameworkElement element) private void CheckIsNonStandardDpi() { - if (matrix != null) // make sure it's connected - { - dpiTransform = new ScaleTransform( - 1 / matrix.M11, - 1 / matrix.M22 - ); - } + dpiTransform = new ScaleTransform( + 1 / matrix.M11, + 1 / matrix.M22 + ); } private void AddSourceHookIfNotAlreadyPresent() From d95d706929eb3469c0faef260154eda6867acfc8 Mon Sep 17 00:00:00 2001 From: JanEggers Date: Thu, 12 Jun 2014 21:04:42 +0200 Subject: [PATCH 5/8] make static classes static --- CefSharp/Internals/Kernel32.cs | 2 +- CefSharp/Internals/SubProcessProxySupport.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CefSharp/Internals/Kernel32.cs b/CefSharp/Internals/Kernel32.cs index b9b64644ad..4e09343e2c 100644 --- a/CefSharp/Internals/Kernel32.cs +++ b/CefSharp/Internals/Kernel32.cs @@ -2,7 +2,7 @@ namespace CefSharp.Internals { - public class Kernel32 + public static class Kernel32 { [DllImport("kernel32.dll", CharSet = CharSet.Auto)] public static extern void OutputDebugString(string message); diff --git a/CefSharp/Internals/SubProcessProxySupport.cs b/CefSharp/Internals/SubProcessProxySupport.cs index 4a732fd65a..234ce289f2 100644 --- a/CefSharp/Internals/SubProcessProxySupport.cs +++ b/CefSharp/Internals/SubProcessProxySupport.cs @@ -1,6 +1,6 @@ namespace CefSharp.Internals { - public class SubProcessProxySupport + public static class SubProcessProxySupport { private const string BaseAddress = "net.pipe://localhost"; private const string ServiceName = "CefSharpSubProcessProxy"; From bb9c5c0f7e593d2cedc795e154ff7218707493e0 Mon Sep 17 00:00:00 2001 From: JanEggers Date: Thu, 12 Jun 2014 21:05:09 +0200 Subject: [PATCH 6/8] typo --- CefSharp/Internals/SubProcessServiceHost.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CefSharp/Internals/SubProcessServiceHost.cs b/CefSharp/Internals/SubProcessServiceHost.cs index 2d6a4d4342..032fa14084 100644 --- a/CefSharp/Internals/SubProcessServiceHost.cs +++ b/CefSharp/Internals/SubProcessServiceHost.cs @@ -18,7 +18,7 @@ public static SubProcessServiceHost Create(int parentProcessId, int browserId) var host = new SubProcessServiceHost(); AddDebugBehavior(host); - //use absultadress for hosting + //use absolute address for hosting //http://stackoverflow.com/questions/10362246/two-unique-named-pipes-conflicting-and-invalidcredentialexception var serviceName = SubProcessProxySupport.GetServiceName(parentProcessId, browserId); From 7c8ed553357e13337148582744cb313db3812880 Mon Sep 17 00:00:00 2001 From: JanEggers Date: Thu, 12 Jun 2014 21:05:29 +0200 Subject: [PATCH 7/8] we want to ignore the exception here --- CefSharp/Internals/SubProcessServiceHost.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/CefSharp/Internals/SubProcessServiceHost.cs b/CefSharp/Internals/SubProcessServiceHost.cs index 032fa14084..42f9c6b76d 100644 --- a/CefSharp/Internals/SubProcessServiceHost.cs +++ b/CefSharp/Internals/SubProcessServiceHost.cs @@ -49,6 +49,7 @@ private static void KillExistingServiceIfNeeded(string serviceName) var javascriptProxy = channelFactory.CreateChannel(); javascriptProxy.Terminate(); } + // ReSharper disable once EmptyGeneralCatchClause catch { // We assume errors at this point are caused by things like the endpoint not being present (which will happen in From 0abd868f87bdfd44f83967c97dd383afaef53630 Mon Sep 17 00:00:00 2001 From: JanEggers Date: Thu, 12 Jun 2014 21:06:04 +0200 Subject: [PATCH 8/8] made parent processid private --- CefSharp/Internals/CefSubprocess.cs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/CefSharp/Internals/CefSubprocess.cs b/CefSharp/Internals/CefSubprocess.cs index 63523b3da1..d98b7664d7 100644 --- a/CefSharp/Internals/CefSubprocess.cs +++ b/CefSharp/Internals/CefSubprocess.cs @@ -39,18 +39,17 @@ public void FindParentProcessId(IEnumerable args) return; } - var parentProcessId = channelArgument + var parentProcessIdString = channelArgument .Substring(channelPrefix.Length) .Split('.') .First(); - ParentProcessId = int.Parse(parentProcessId); + parentProcessId = int.Parse(parentProcessIdString); } private SubProcessServiceHost javascriptServiceHost; private CefBrowserBase browser; - - public int? ParentProcessId { get; private set; } + private int? parentProcessId; public CefBrowserBase Browser { @@ -66,12 +65,12 @@ public override void OnBrowserCreated(CefBrowserBase cefBrowserWrapper) { browser = cefBrowserWrapper; - if (ParentProcessId == null) + if (parentProcessId == null) { return; } - Task.Factory.StartNew(() => javascriptServiceHost = SubProcessServiceHost.Create(ParentProcessId.Value, cefBrowserWrapper.BrowserId)); + Task.Factory.StartNew(() => javascriptServiceHost = SubProcessServiceHost.Create(parentProcessId.Value, cefBrowserWrapper.BrowserId)); } } } \ No newline at end of file