Commit Graph

484 Commits

Author SHA1 Message Date
Alex Maitland 8a367fbdc4 Refactor CefSharp.Core into CefSharp.Core.Runtime (#3311)
* Net Core - Rename CefSharp.Core.dll to CefSharp.Core.Runtime.dll

Partial rename, only Net Core, folder not renamed

* Net Core - Rename CefSharp.Core.RefAssembly to CefSharp.Core.netcore

Remove GenApi

* Core - Rename CefDragDataWrapper to DragData

Move into CefSharp.Core namespace

* WinForms/WPF/OffScreen - Migrate from GitLink command line to Nuget package

* Net Core - Refactor to have CefSharp.Core.dll contain only public Api

* Net Core - Remove CefSharp.Core.RefAssembly

* Net Core - Change CefSharp.Core.netcore output folder

* Net Core - Restructure nuget packages

* Net Core - Add Cefsharp.Core.Runtime.RefAssembly

* Net Core - Hide CLI/C++ classes from intellisense

Make sure users don't attempt to load them directly

* Rename CefSharp.Core to CefSharp.Core.Runtime

* Core - Restructure Net 4.5.2 packages to use CefSharp.Core.dll anycpu variant

Attempt to load CefSharp.Core.Runtime at runtime rather than having to use msbuild to copy the correct version

* Rename CefSharp.Core.netcore to CefSharp.Core

* WPF/WinForms/OffScreen - Change from x86/64 to AnyCPU

As they are all managed assemblies they can target AnyCPU.
Includes CefSharp.dll

* Convert RequestContextBuilder from C++ to C#

Now part of the CefSharp.Core PublicApi

* Update version number to 87.1.11

* Migrate more of the public Api to C#

* Net Core - Basic restructure complete

* Net Core - ModuleInitializer (Doesn't work yet)

* Remove direct references to BrowserSettings

* Net Core - ModuleInitializer load CefShar.Core.Runtime.dl

* Net Core - Load libcef.dll via CLR Module initializer

If no RID is specified then we can load libcef.dll using the module initializer

* Add version to CefSharp.Core

* Remove dependency on CefSharp.Core.Runtime
Rewrite common targets

* AnyCPU app.config transform

Improve AnyCPU support

* Improve Net Core 3 support
Only delete CefSharp.Core.Runtime.dll when AnyCPU

* Nuget - Add CefSharp.Core.Runtime reference when TargetFramework = NetCore

* Fix Typos

Based on #3306

* Net Core - Rename CefSharp.Core.Runtime RefAssembly source file

* Net Full - Generate CefSharp.Core.Runtime Ref Assembly

For now the powershell build script generates the .cs file based on a x86 release build.ps1
It's not possible to directly install GenApi as it requires a Sdk style project

* Net Core - Old packages copy files to required folders

* Test - Install newer .Net Compiler and set Lang Version to 7.3

* Net Core - Exclude Net 452 Runtime generated reference source

* Core - Add Refactoring TODO

* Ref Assembly - Generate source as part of build

- Move ref assembly source generate into GenerateRefAssemblySource.ps1
- Call before project build

Runs locally, see if Appveyor has a problem with the powershell script execution

* Core - Add more factory methods to create instances of managed wrappers

* Net Core - Make Initialzier properties internal

Not quite sure what the public API should look like as yet, so making internal for now.
2020-12-16 10:47:34 +10:00
GitHubPang 728420ca7f Fix typos (#3305) 2020-12-06 11:24:14 +10:00
Alex Maitland 928bc68ef6 Net Core - Embed PDB and Source
For release builds we embed project source and symbols (at least until https://github.com/dotnet/sdk/issues/1458 is resolved)

Issue #3197
2020-11-06 15:45:36 +10:00
Alex Maitland c0ef404213 Core - VS2019 Invalid option '7.3' for /langversion
When building CefSharp3.sln under VS2019 the Microsoft.Net.Compilers (version 2.4) is passed version 7.3 for c# version
Version 2.4 supports a maximum of version 7.1, the issue doesn't happen on VS2015 or VS2017
Hard code LangVersion in csproj files

CS1617	Invalid option '7.3' for /langversion; must be ISO-1, ISO-2, Default, Latest or a valid version in range 1 to 7.1.

https://stackoverflow.com/questions/46419760/using-c-sharp-7-1-with-msbuild
2020-11-06 13:13:28 +10:00
amaitland 3372ce8a57 Build - Generate Ref Assemblies for .Net 4.5.2 assemblies
Only for Release builds.

This appears to work as expected under VS2017, not sure about VS2015
Roslny .Net compiler upgraded to 2.4 allows for Ref Assembly generation
2020-10-21 18:10:04 +10:00
amaitland 5d4897f4c6 Core - Add Microsoft.Net.Compilers 2.4
This is the last version to support .Net 4.5.2
Set allowedVersions="2.4"  to stop from updating to a newer version which won't compile under VS2015
2020-10-21 17:55:29 +10:00
amaitland 71773424dc Wpf/WinForms/OffScreen - Standardize InternalIsBrowserInitialized
- Add InternalIsBrowserInitialized to partial class
- Move ThrowExceptionIfDisposed/ThrowExceptionIfBrowserNotInitialized to partial class
- Remove checks from DevToolsExtensions.ExecuteDevToolsMethodAsync as the checks were already in GetBrowser

In WPF it's no longer necessary to have a custom implementation, will leave the Dependency property
(won't action #3033 at this point in time)
2020-09-18 13:32:22 +10:00
amaitland 3ccb0f8b10 Core - Reduce ChromiumWebBrowser Code Duplication
- Move events to partial class (where possible)
- Move other explicit interface implementation methods

Issue #3082
2020-09-16 19:44:36 +10:00
amaitland 6d62d188b7 Core - Reduce Code Duplication
Move Handler property decelerations to partial class

Issue #3082
2020-09-16 17:06:57 +10:00
amaitland 8d1afada20 WinForms - OnHandleDestroyed directly references CefSharp.Core crashing Designer
Designer attempts to load CefSharp.Core.dll which in fails, we avoid that when designMode is true

Resolves #3219
2020-08-26 14:55:51 +10:00
amaitland e1ca2f085b Net Core - Produce reference assemblies for c# projects
- Produce ref assembly for Release builds only

#3197
2020-08-07 15:41:09 +10:00
amaitland 0183c429e0 WPF/WinForms/OffScreen - Reduce Code Duplication Initial
- Add ChromiumWebBrowser.Partial.cs and include in all three projects
- Remove InternalsVisibleTo from Cefsharp.dll start moving code into the partial class
  (We don't want to publish our internals as part of our Ref Assembly so this goings together)

#3082
#3197
2020-08-07 14:24:07 +10:00
amaitland e8cf336bf3 Net Core - Support for compiling with .Net Core 3.1
- Make Wpf/WinForms/OffScreen projects target AnyCPU
Only the VC++ projects are platform specific now.
- Remove BrowserSubProcess project reference
Not needed as we now have a standalone exe
- Add OffScreen example
- Add WPF Example project
- Fix some compile errors for main solution
- Add BrowserSubProcess executable
- JavascriptObjectRepository remove isAsync param
Rather than throw exception remove the option
- BrowserSubprocess Exclude the WCF specific code from the netCore project
- Add some ifdef/ifndef to exclude the WCF specific implementation
- Move WCF implementation into separate namespace
2020-07-23 15:23:45 +10:00
Konstantin Preißer 5e89f71a44 Add new projects targeting .NET Core 3.1 (#3181)
* Add .NET Core 3.1 projects for CefSharp, CefSharp.Core, CefSharp.BrowserSubprocess.Core, CefSharp.WinForms, CefSharp.Wpf, CefSharp.OffScreen.

Contributes to CefSharp#2796

* - Remove dependencies to "opengl32.lib" and "glu32.lib" which aren't available for ARM64 and don't seem to be needed.
- Clean up project files.

* Switch project CefSharp.netcore.csproj to AnyCPU as it doesn't require different builds for each platform.

* Remove WindowsTargetPlatformVersion property as that is declared in CefSharp.props.

* Use "bin.netcore" and "obj.netcore" as [intermediate] output path for the .NET Core projects, to allow side-by-side builds with the .NET Framework projects.

* Output documentation files.

* Add CefSharp.Example.netcore and CefSharp.WinForms.Example.netcore.

* Follow-up: Remove properties from the example projects that are also not used in the corresponding .NET Framework projects.
2020-07-23 15:21:14 +10:00
Alex Maitland 8d25b71490 Core - Re-Add IAudioHandler (#3153)
Resolves #3152
2020-07-08 08:06:16 +10:00
amaitland 046db62ad9 WinForms - Possible null reference when Dispose
If you've somehow managed to set BrowserSettings to null then Dispose would throw a NullReferenceException
2020-06-29 10:47:17 +10:00
amaitland 545cbce36d WinForms - Form minimise set browser size to 0,0
When the form is minimized set the browser window size to 0x0 to reduce resource usage.

https://github.com/chromiumembedded/cef/blob/c7701b8a6168f105f2c2d6b239ce3958da3e3f13/tests/cefclient/browser/browser_window_std_win.cc#L89

Issue #2922
2020-05-05 08:30:27 +10:00
amaitland 1824a0334d WPF/WinForms/OffScreen - CanExecuteJavascriptInMainFrame incorrectly false after loading page with different origin
Proof of concept for a workaround. The frameId for the second OnContextReleased that arrives after the OnContextCreated from
the old render process strangely has a frameId greater than the new frameId

TODO: Unit tests

Issue #3021
2020-05-04 12:34:47 +10:00
amaitland 73e7c5de13 Core - Rename AbstractCefSettings to CefSettingsBase
This is a somewhat cosmetic change so the API Doc looks better, the
classes appear next to each other (CefSettings, CefSettingsBase)
when sorted alphabetically.

Resolves #3093
2020-04-06 14:59:33 +10:00
amaitland defc2c3af6 WinForms - Remove WS_EX_NOACTIVATE style on initial page Load
- When LoadingStateChanged occurs we remove the ExStyle WS_EX_NOACTIVATE flag
- Previous change to the FocusHandler was reverted in 917480da3b

Updated to match the cefclient example
https://github.com/chromiumembedded/cef/blob/9df4a54308a88fd80c5774d91c62da35afb5fd1b/tests/cefclient/browser/root_window_win.cc#L1088

Resolves #2776
2020-04-06 10:48:53 +10:00
amaitland 917480da3b Revert "WinForms - DefaultFocusHandler now allows browser to take focus on initial load"
This reverts commit f725ab3907.

Issue #2776
2020-04-06 10:28:54 +10:00
amaitland 4cac03bb93 WinForms - Add ParkControlOnHandleDestroyed property.
When true the browser will always be moved to a parking control when the ChromiumWebBrowser handle is destroyed.
By default it's only moved when RecreatingHandle = true;

Resolves #2840
2020-04-02 11:34:05 +10:00
amaitland 270b5c496e WinForms - Dispose of FrameworkCreated BrowserSettings when Control Disposed
If BrowserSettings is FrameworkCreated we dispose of the BrowserSettings object immediately,
this code was in ManagedCefBrowserAdapter::CreateBrowser, now it's duplicated in WPF/OffScreen

The WinForms version has a slightly different behaviour, we keep the browserSettings reference
until the Control is Disposed incase the Control handle is destroyed then Created again.

Issue #2840
2020-04-01 09:42:56 +10:00
Alex Maitland 81871ff4bb WinForms - RecreatingHandle re-parent browser to parkingControl (#3090)
Use a parkingControl as a temporary parent for the CefBrowser while the handle is recreating.

https://docs.microsoft.com/en-us/archive/blogs/sburke/flashback-windows-forms-parking-window

Issue #2840 should now create a new browser correctly when the MdiParent is changed,
the browser state won't be persisted, I believe this is expected as detailed in the .Net Source
https://referencesource.microsoft.com/#System.Windows.Forms/winforms/Managed/System/WinForms/Form.cs,1925

When toggling ShowInTaskbar when the browser is hosted in a TabControl then the handle isn't
actually recreated yet the browser is effectively parked, perhaps the .Net source has some tricks
we can use to further improve the case when using  MdiParent

Resolves #2042
2020-04-01 07:44:42 +10:00
amaitland 3ba0290676 WPF - Add IWebBrowser.IsBrowserInitialized explicit interface implementation
Can be called from any Thread, the ChromiumWebBrowser.IsBrowserInitialized property remains
as Dependency property.

Issue #3033
2020-03-26 09:10:36 +10:00
Gilberto Stankiewicz 29e6a6d03a Fix a typo in an error message (#3087) 2020-03-26 08:37:02 +10:00
amaitland 82836e0aee WinForms - Update xml doc Dock = DockStyle.Fill is the default
Make it clear we are setting the default to DockStyle.Fill, this may not be expected
by some. It has been that way for 5+ years, so changing the default would be difficult
and unexpected, instead we make it clearer this is the case.

Resolves #3019
2020-02-01 20:48:30 +10:00
amaitland d82caeaceb WinForms - override Control.DefaultSize return 200x100
When ChromiumWebBrowser is hosted in a FlowLayoutPanel the Dock = DockStyle.Fill
ends up with a browser having no width/height depending on the option layout.

As Control.DefaultSize returns Size.Empty, looking at WebBrowserBase it defaults to Size(75, 23)
which seems way too small to be meaningful. We'll default to 200x100 for now.

https://referencesource.microsoft.com/#System.Windows.Forms/winforms/Managed/System/WinForms/Control.cs,17f6db7866977c1a

Related to issue #3019
2020-02-01 20:43:40 +10:00
amaitland 38c7941ab6 xml doc - remove seealso internal interface references 2020-01-29 10:22:17 +10:00
amaitland 79c99878c5 Xml Doc improvements 2020-01-29 05:37:45 +10:00
amaitland 19a70727f2 WinForms/WPF/OffScreen - Improve Dispose/BrowserInitialized error messaging
- Set CanExecuteJavascriptInMainFrame to false when disposing
- Throw exception if Disposed when calling GetBrowser method
- Improve error messaging
2020-01-15 11:16:06 +10:00
amaitland 1e88322b7d WinForms - Rename WinFormsWebBrowserExtensions to WebBrowserExtensions
Let's just keep it simple, we're in the WinForms namesapce, so we already know the context.
2019-12-10 08:09:22 +10:00
amaitland 6793ff2355 Core - Add WinFormsWebBrowserExtensions.DestroyWindow helper function
Used to manually destroy a browser instance (can be used to avoid having CEF send a WM_Close message).
MUST BE CALLED ON THE CEF UI Thread, see xml doc example
2019-12-10 07:54:14 +10:00
amaitland daeb4fb13f WinForms - Improve handling of Load method when called after CreateBrowser and before OnAfterBrowserCreated
Call MainFrame.Load after the browser has been created if the Address property has been set after CreateBrowser and before OnAfterBrowserCreated
2019-12-03 07:08:08 +10:00
amaitland ca2837f928 WinForms - Make ControlExtensions.InvokeOnUiThreadIfRequired internal
- Additional check is control is being Disposed
- Add copy and paste version of ControlExtensions.InvokeOnUiThreadIfRequired to example project

Resolves #2983
2019-12-02 20:37:41 +10:00
amaitland 0c06026371 WinForms - ControlExtensions.InvokeOnUiThreadIfRequired perform no action if control disposed/ishandlecreated false 2019-12-02 19:03:12 +10:00
amaitland 802bb7f43c Remove IAudioHandler
The Chromium implementation has changed so dramatically that CEF has removed support see https://bitbucket.org/chromiumembedded/cef/commits/1f893c76a97eaa88e3ff782b8e2e47dd0f5d27b2

Track https://bitbucket.org/chromiumembedded/cef/issues/2755/reimplement-audio-mirroring-for for details on when it will be reimplemented

Original Issue #2727
2019-10-01 20:06:37 +10:00
amaitland 6f32aa1a0a WinForms - Only use DefaultFocusHandler when !MultiThreadedMessageLoop
If the WinForms UI thread and CEF UI thread are one in the same then we're not using MultiThreadedMessageLoop
2019-07-26 14:13:58 +10:00
amaitland f8972c6c45 WinForms - Add new constructor overload (HtmlString html, RequestContext context = null)
- New HtmlString class can be used to create a DataUri encoded string for use with the WinForms
ChromiumWebBrowser constructor
- Remove duplication in WebBrowserExtensions extensions, use new HtmlString class

Related issue is #2668
2019-07-11 12:44:57 +10:00
Eklavya df680aec3c Add Shift+Tab as inputs to browser when MultiThreadedMessage loop is disabled. (#2814)
When MultiThreaded message loop is disabled, we use the winform message loop. We want to ensure that Shift+Tab (cycle selection back) is recognized as a valid input in this case or it breaks keyboard accessibility.
2019-07-08 08:32:06 +10:00
amaitland 73a156fdc5 Initial version 75 upgrade and NetworkService changes
Compiles, that's about it at this point, there are major CEF breaking changes, and lots to be addressed.

Browser Process (main process)
- Removed IResourceHandlerFactory as it no longer fits with the structure that CEF provides
- New IResourceRequestHandler interface added, not plumbed in yet
- CefSettings - Add RootCachePath and ApplicationClientIdForFileScanning

BrowserSubprocess (render process)
- SendProcessMessage was moved from CefBrowser to CefFrame
- OnBrowserCreated added extraInfo param

The BrowserSubprocess changes for this upgrade should be complete
2019-06-25 19:24:57 +10:00
amaitland f725ab3907 WinForms - DefaultFocusHandler now allows browser to take focus on initial load
Previously on LoadUrl etc we didn't take focus, we now take focus on the initial Load so touch screens work
The behaviour when using ChromiumWebBrowser.ActivateBrowserOnCreation = true is still the same as versions prior to 73 (version 73 is the only different version)

Issue #2776
2019-06-04 20:10:47 +10:00
amaitland 7c3d66817b WinForms - Add ChromiumWebBrowser.ActivateBrowserOnCreation
Set ActivateBrowserOnCreation = true to restore the old behaviour where the browser was activated upon creation.

Issue #2776
2019-06-04 19:50:16 +10:00
Alex Maitland 1a2c8ffcb6 Add CefSharp.PostMessage (#2799)
- JavascriptMessageReceived event added to ChromiumWebBrowser/IWebBrowser
- CefSharp.PostMessage and cefSharp.postMessage added to V8Context on creation for use in Javascript
- Add PostMessageTest.html
2019-06-03 21:08:03 +10:00
amaitland b09b5fd959 WinForms - Replace EditorBrowsable(EditorBrowsableState.Never) with DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)
Was hiding the methods from Intellisense

Resolves #2784
2019-05-28 13:56:24 +10:00
Alex Maitland 76e5a8d5c0 Add IAudioHandler (#2727)
* Feature Request - Add IAudioHandler

- For performance reasons we return NULL if no audiohandler is assigned
- No example is provided currently

Initial implementation for #2714
2019-05-03 12:54:40 +10:00
amaitland 3cff24cf1f DefaultFocusHandler.OnGotFocus - Add browser null check
For the print dialog we appear to be passed a CefRefPtr<CefBrowser> reference which doesn't appear to trigger an OnAfterCreated call
so we have no reference to it. Looking at the `CefBrowser`, there's no real data of value, empty url, no frame information (just an invalid frame id)
so for now we'll just ignore it in DefaultFocusHandler, we don't want to handle for popups anyway

Resolves #2725
2019-04-17 20:34:47 +10:00
Chris e22d1c2fd2 Removed IsBrowserInitializedChangedEventArgs (#2710) 2019-04-10 19:51:34 +10:00
Alex Maitland c3bbd37cce Reorder dispose pattern in ChromiumWebBrowser (#2701)
* WinForms/Wpf/OffScreen - Reorder Dispose methods

- Set browser initialized to false
- Release event handlers
- Dispose managedCefBrowserAdapter
- Set handlers to null

* WinForms/WPF/OffScreen - Set Handlers to null immediately after event handlers cleared

The one exception is LifeSpanHandler which is released after managedCefBrowserAdapter.Dispose
2019-03-26 20:14:13 +10:00
Chris 987f988dac Refactoring - Moved RegisterJsObject and RegisterAsyncJsObject to WebBrowserExtensions (#2703) 2019-03-23 13:31:09 +10:00