Commit Graph

261 Commits

Author SHA1 Message Date
Alex Maitland 4f8bdc5f2c OffScreen - ChromeRuntime doesn't work with LoadURL
- After switching to the Chrome bootstrap, the browser wouldn't load if you passed in an empty
  string to the constructor, we can defer loading until after another LoadUrl call is made.

Resolves #4832
2024-06-21 19:55:53 +10:00
Alex Maitland 5b29591b22 WinForms/WPF/OffScreen - Set disable-chrome-login-prompt command line arg by default
- GetAuthCredentials won't be called otherwise, those wishing to use the Chrome password
  prompt can remove the command line arg at runtime.

Resolves #4830
2024-06-21 19:31:19 +10:00
Alex Maitland 43321f74e6 WinForms/WPF/OffScreen - Change to using Chrome bootstrap by default
Issue #4835
2024-06-16 08:37:16 +10:00
Alex Maitland 635eedb58f Upgrade to 124.3.1+g6d871a1+chromium-124.0.6367.60 / Chromium 124.0.6367.60 2024-05-03 18:45:50 +10:00
campersau ae272a9b68 OffScreen - Check if browser is not null in GetScreenInfo/GetViewRect (#4661) 2024-01-01 08:03:31 +10:00
Alex Maitland e45890a0f9 WPF/OffScreen - WaitForRenderIdleAsync possible ObjectDisposedException
- Potentially the call to the Stop/Start the Timer in the Paint event handler
  may result in an ObjectDisposedException as the Timer was disposed on a different thread.

Resolves #4597
2023-11-11 10:39:50 +10:00
developersthinksmartbox f75b991898 NetCore - Generate Reference Assemblies building with VS2022 (#4559)
* Ensure reference assemblies are copied to output folders

The .NET 6.0 SDK introduced a breaking change meaning that reference
assemblies are no longer automatically copied from the intermediate
build directory to the output directory. An additional MsBuild property
is now required.

* Specify VS2022 for reference assembly copy condition

---------

Co-authored-by: Bernard Mason <bernard.mason@thinksmartbox.com>
2023-08-04 06:24:59 +10:00
Alex Maitland 1def8a7937 Upgrade to .Net 4.6.2 (#4482)
* Upgrade minimum .Net version to 4.6.2

#4433

* Use TaskCreationOptions.RunContinuationsAsynchronously

- Now that min version is .Net 4.6.2 we can use RunContinuationsAsynchronously
- Remove some unused code
2023-06-10 07:33:20 +10:00
Alex Maitland 3ce76eb191 CEF Issue Tracker moved to GitHub
- Update some of the internal links

Issue #4430
2023-03-24 10:52:58 +10:00
Alex Maitland a51da76ad9 OffScreen - Add useLegacyRenderHandler optional param to constructor
- Defaults to true
- For those using CaptureScreenshotAsync set to false to avoid
  creating DefaultRenderHandler
2023-01-15 11:33:08 +10:00
Alex Maitland 0d790cdf8f Revert "OffScreen - Lazy Initialize RenderHandler"
This reverts commit 664406869a.
2023-01-15 11:05:27 +10:00
Alex Maitland 664406869a OffScreen - Lazy Initialize RenderHandler
- Instead of assigning RenderHandler directly in the constructor, only assign when
  the new instance in ScreenshotOrNull. Avoid allocating the buffer for those
  using the new CaptureScreenshotAsync method.
2023-01-15 10:23:10 +10:00
Alex Maitland 10f90f267c OffScreen - Support Size and DeviceScaleFactor when RenderHandler is null 2022-06-06 10:57:04 +10:00
Alex Maitland 93dcfacef2 OffScreen - Explicitly dispose of RenderHandler 2022-06-06 10:53:29 +10:00
Alex Maitland b8b27f6885 WPF/OffScreen - Add WaitForRenderIdleAsync (#4080)
* WPF/OffScreen - Add WaitForRenderIdleAsync

- Task resolves when render has been idle for the specified time
- Make TaskTimeoutExtensions public (they're not extension methods as this was expected)
2022-05-30 19:11:17 +10:00
Alex Maitland 7eb6d6f3b7 OffScreen - CaptureScreenshotAsync change to Scale default
- Previously when no Scale was specified, then the previous ChromiumWebBrowser scale was used.
- Now Viewport defaults to a scale of 1, so the behaviour has been changed so the scale passed as
  the param is always used.
- Test updated

This is a minor breaking change.

Resolves #4091
2022-05-05 19:27:29 +10:00
Alex Maitland f201c694c6 WinForms - Add CaptureScreenshotAsync
- Simplification of calling the DevTools method
- Moved GetContentSizeAsync from OffScreen into partial class (now accessible from WinForms/WPF/OffScreen).
- Added menu option

Resolves #4081
2022-05-03 11:29:11 +10:00
campersau 5e16914d9a OffScreen - Fix ResizeAsync with deviceScalingFactor (#3964)
* OffScreen - Fix ResizeAsync with deviceScalingFactor

* OffScreen - Fix CaptureScreenshotAsync Width / Height calculation to include X and Y

Always apply Scale changes
2022-01-18 11:03:44 +10:00
Alex Maitland 4dba51955b OffScreen - CaptureScreenshotAsync only resize if larger and support clip 2022-01-15 11:20:06 +10:00
Alex Maitland b72d41353e WinForms - Improve hosting of popups using ChromiumHostControl
- Add IChromiumWebBrowserBase which is can be used for ChromiumWebBrowser instances and ChromiumHostControl
- Reduce code duplication for extensions methods
- Update WinForms Example
2021-11-30 13:47:42 +10:00
Alex Maitland d8674fd076 OffScreen - Add CaptureScreenshotAsync, GetContentSizeAsync and ResizeAsync
- Simply taking full page screenshots
- Added new methods
- CaptureScreenshotAsync uses Devtools protocol and allows for specifying image format and quality (if jpg)

Cannot use clip param as https://bitbucket.org/chromiumembedded/cef/issues/3103/offscreen-capture-screenshot-with-devtools
2021-11-16 13:41:26 +10:00
Alex Maitland 4a07af26e9 Core - Rename WaitForBrowserInitialLoadAsync to WaitForInitialLoadAsync and simplify
- Initial intention was to have a reusable method that could be used CefSharp.Wpf.HwndHost,
  upon further deliberation I've decided to build the functionality into the ChromiumWebBrowser.Partial.cs
  and will need to duplicate the functionality in CefSharp.Wpf.HwndHost. This guarantees that the
  Task will be resolved in all cases. The previous implementation there was a theoretical change we'd
  miss subscribing to the relevant events
- Remove CancellationToken as it's not possible to cancel

Issue #3842
2021-10-28 10:31:03 +10:00
Alex Maitland 9993aa78e0 OffScreen - Create Browser when Global CefRequestContext initialized.
- GlobalContextInitialized wraps a TaskCompletionSource which is resolved
  when the Global CefRequestContext has been created
- Reduce code duplication

If successful we can apply the same changes to WinForms/WPF though they're less likely to have
issues than the OffScreen implementation as the CreateBrowser doesn't happen until much later

Issue #3850 #3634
2021-10-26 14:31:10 +10:00
Alex Maitland b82fa05291 WinForms/WPF/OffScreen - Update Load(string url) behaviour
- All three implementations updated to include an IsDisposed check which
  will simply return immediately
- OffScreen updated to match the WinForms behaviour
- WPF is more complex because of the initialAddress and Address properties
  initialAddress will be set if the browser hasn't been created, if the browserCreated
  has been created and OnAfterBrowserCreated hasn't been called then we'll set the Address
  dependency property.

NOTE: For WinForms/OffScreen there's a small window
here between CreateBrowser and OnAfterBrowserCreated
where the Address prop will be updated, though LoadUrl
won't be called.
2021-10-08 12:40:54 +10:00
Alex Maitland c226d344b1 WinForms/WPF/OffScreen - Add LoadUrl method (Same as Load(string)).
A more meaningful name for the method, matches the LoadUrlAsync method
that was added recently.
2021-10-08 10:21:31 +10:00
Alex Maitland 65534275b7 Core - Upgrade to newer SDK Style project
- Upgrade CefSharp.Core.csproj
- Upgrade CefSharp.csproj
- Ensure pdbs are generated for release builds with same settings as before

Issue #3791
2021-09-20 11:32:14 +10:00
Alex Maitland 172ee5afe8 Migrate from GitLink to Source link
Resolves #3036
2021-09-07 12:08:56 +10:00
Alex Maitland e4e0f22ca7 WinForms/WPF/OffScreen - Upgrade to SDK style projects and multi-target net452 and net462
Haven't tested the output nuget packages yet, we might still need to change the nuspec files to add a
dependency group.

Issue #3791
2021-09-05 15:09:35 +10:00
Alex Maitland d350cad52a Update to M93 (#3781)
* Upgrade to CEF 93.1.7+g9117d6a+chromium-93.0.4577.42 / Chromium 93.0.4577.42

- Core - Add basic ref counting implementation

IMPLEMENT_REFCOUNTING implementation uses atomic which
forces the VC++ compiler to compile as native which doesn't work for our managed ref classes.

    - Use InterlockedCompareExchange for custom ref count reads
    - Use InterlockedIncrement/InterlockedDecrement directly
    - There's no memory barrier for HasOneRef/HasAtLeastOneRef as the read of a LONG should happen in one operation
on 32/64 bit architectures (at least that's my understanding at this point in time).

    References:
    https://github.com/chromiumembedded/cef/blob/4472/include/base/internal/cef_atomicops_x86_msvc.h#L125
    https://github.com/chromiumembedded/cef/blob/4472/include/base/internal/cef_atomicops_arm64_msvc.h#L107
    https://github.com/chromiumembedded/cef/blob/4472/include/base/cef_atomic_ref_count.h#L114
    https://github.com/chromiumembedded/cef/blob/4472/include/cef_base.h#L91

-  Remove Microsoft.Net.Compilers package from projects
Now that we require a min of VS2019 to build there's no need for a custom compiler package
- Start removing VS2015/VC++2015 references
- Remove RegisterWidevineCdm
This is a breaking change. CEF will now automatically download the Widevine CDM component
Resolves #3767

- RequestContext.LoadExtension now uses managed to code spawn on CEF UI Thread
Avoid having to use cef_callback.h which was causing problems for x86 builds
2021-09-03 10:51:18 +10:00
Alex Maitland e5f2381351 WinForms/WPF/OffScreen - Use custom FocusHandler when disposing to block taking focus
This was added as a workaround for Issue #3715 which is specific to WinForms
and will hopefully be fixed upstream.

I've added the logic to all three implementations as I think the behaviour should be
consistent across all implementations.
2021-07-27 13:13:17 +10:00
Alex Maitland a6ff42ee6f Core - IAudioHandler now implements IDisposable
IAudioHandler.Dispose is called when the ChromiumWebBrowser instance is being Disposed.

This is a breaking change.

Resolves #3598
2021-06-04 15:49:52 +10:00
Alex Maitland 96117f9a47 OffScreen - Add CreateBrowserAsync
Issue #3594
2021-06-02 19:42:04 +10:00
Alex Maitland 4ebe7de1bc OffScreen - Add ChromiumWebBrowser constructor overload with onAfterBrowserCreated delegate
Use the constructor overload as an alternative to the BrowserInitialized event

Follow up to #3552
2021-05-22 13:45:42 +10:00
Alex Maitland 2568236ac1 OffScreen - Clarify BrowserInitialized may not be called if Browser created automatically
Resolves #3552
2021-05-22 13:18:52 +10:00
Alex Maitland 047f8b838c WPF/WinForms/OffScreen - Reduce code duplication
Issue #3082
2021-04-01 16:28:20 +10:00
Alex Maitland 5780aefda3 Net Source - Add SourceLink support
- The Debug PDBs will now use SourceLink
- The C++/CLI projects will use SourceLink
- CefSharp.Core.dll now generates/uses a ref assembly
- The managed (c#) projects still embed sources/symbols for Release builds

At some point we should investigate generating a snupkg to reduce the dll size
2021-03-12 13:15:31 +10:00
Alex Maitland bcc2c91e0a Core - ManagedCefBrowserAdapter::InitializeBrowserProcessServiceHost improve Dispose handling
As the browser is Disposed on a different Thread to OnAfterBrowserCreated is called there's possibility of an ObjectDisposedException.
Instead of locking just catch and ignore the error as it's extremely rare

Resolves #3437
2021-03-11 15:22:30 +10:00
Alex Maitland 30860d66d6 WinForms/WPF/OffScreen - Improve Cef.Initialize failed error message.
Direct user to check log file as the underlying CefInitialize call doesn't return an error message.
Errors are only available through the logs.
2021-02-26 12:16:49 +10:00
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
GitHubPang facecb1bab Fix typo. (#3282) 2020-11-15 05:13:47 +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 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