Commit Graph

504 Commits

Author SHA1 Message Date
amaitland 2f96ee9bb1 WinForms/WPF/OffScreen - Disable back forward cache to improve javascript integration reliability
- Workaround for common cause of "Error while fulfilling of JS: Request BrowserId : 1 not found it's likely the browser is already closed"

Issue #4621
2025-08-16 09:22:05 +10:00
Alex Maitland c38d5010a9 NetCore - Upgrade minimum version to 6.0 (#5127)
* NetCore - Upgrade minimum version to 5.0

* Update platform target
* Change to windows 10 specific TFM for top level packages
* Upgrade to .Net 6
* Nuget - Update packages
* Net Core - Fix dotnet test path
* Add Test Sdk and update Runner

---------

Co-authored-by: amaitland <307872+amaitland@users.noreply.github.com>
2025-07-05 13:59:17 +10:00
amaitland d5d0cb9945 WinForms Example - Focus browser after loading URL from address bar
- Extend IWinFormsChromiumWebBrowser to make it easier to access CanSelect/Select methods
- Update example to call Select() after LoadUrl call

Resolves #4965
2025-04-18 07:14:10 +10:00
amaitland 17269dc648 Core - Add Microsoft.CodeAnalysis.NetAnalyzers 8.0 to all csproj files
- Make sure appveyor builds
- Will look at enabling some of the compiler warnings as errors to improve the sour
2024-09-28 12:14:32 +10:00
amaitland 19739abd9c Remove Alloy Bootstrap (M128)
- Remove ChromeRuntime option
- Remove Extension Handling and related methods (no longer supported)
- Remove PackLoadingDisabled (no longer supported)
- Remove PersistUserPreferences (always on)

Resolves #4795
2024-09-18 17:53:17 +10:00
Alex Maitland 57f8cd344f Core - Change Cef.IsInitialized from bool to bool? (#4869)
Resolves #4867
2024-08-14 17:19:34 +10:00
Alex Maitland 45f257359e Set --hide-crash-restore-bubble by default to prevent Chromium window from opening after unsuccessful shutdown.
Resolves https://github.com/cefsharp/CefSharp/issues/4903
2024-08-14 14:54:33 +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 6b682d60ee WinForms/Wpf.HwndHost - Add CefSharpSettings.RuntimeStyle
- Allow for configuring of the CEF RuntimeStyle globally.

Issue #4835
2024-06-21 19:21:17 +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 7af16b9571 Add IWindowInfo.RuntimeStyle
- CEF will remove the alloy bootstrap (likely in M127)
- Change examples to use the `Chrome Runtime`
-

Issue https://github.com/chromiumembedded/cef/issues/3685
2024-05-06 11:03:04 +10:00
Alex Maitland 525e9be8c1 Upgrade to 122.1.9+gd14e051+chromium-122.0.6261.94 / Chromium 122.0.6261.94 2024-03-02 12:24:44 +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 75fd3acf66 WinForms - LifeSpanHandler.DoClose add ObjectDisposedException try/catch
- If the popup is being hosted on a Form that is being Closed/Disposed
  as we attempt to call Control.Invoke we can end up with an ObjectDisposedException
2023-03-14 13:19:38 +10:00
Alex Maitland 0c7bc3f9b6 WinForms - Refactor ChromiumHostControlBase to use P/Invoke
- Avoid using using NativeMethodWrapper, hopefully this keeps the designer
  happy, no need to load CefSharp.Core.Runtime.dll

Issue #4019
2023-03-13 19:34:10 +10:00
Alex Maitland 8f03007cee WinForms - ChromiumHostControl change designer image 2023-03-12 19:31:41 +10:00
Alex Maitland 1dc71ee486 WinForms - OOP Designer migrate to Microsoft.WinForms.Designer.SDK
Only for Net Core (.Net 5/6/7)
2023-03-12 18:58:07 +10:00
Alex Maitland a4db645e5b Core - Xml Doc fixes 2023-03-12 11:09:48 +10:00
Alex Maitland b8dbb0c0c5 WinForms - Throw InvalidOperationException if Load() called on invalid IBrowser
- When IBrowser.IsValid == false throw an InvalidOperationException when an attempt to
  call Load() is made.

Resolves #4368
2023-01-24 10:55:03 +10:00
Alex Maitland ec282d4c4f WinForms - Set Initial Focus on UI Thread
- Call CefBrowserHost.SetFocus(true) on the WinForms UI Thread to
  workaround upstream issue, see code comment for more detail.
- Add OnSetInitialFocus to allow for providing custom behaviour
- MultiThreadedMessageLoop = false gets focus correctly from parent, no need
  to call SetFocus(true)

https://bitbucket.org/chromiumembedded/cef/issues/3436/chromium-based-browser-loses-focus-when
2023-01-11 06:51:09 +10:00
Alex Maitland 5feb8c0d74 WinForms - LifeSpanHandler default delegate to null as optional 2022-11-03 18:31:54 +10:00
Alex Maitland aa582e83e1 WinForms/WPF - Add ChromiumWebBrowser.UnregisterShutdownHandler
Resolves #4096
2022-10-25 13:12:20 +10:00
Alex Maitland f84f3986cf Test - Tweaks to browser ref count logging 2022-10-04 14:17:36 +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
Alex Maitland 59e0b1afdc Enhancement - Add WaitForNavigationAsync
- Add new WaitForNavigationAsync method
- Change LoadUrlAsync to return CefErrorCode.Failed for HttpStatusCode = -1 (better represents there was an error)

Example:
var navigationTask = browser.WaitForNavigationAsync();
var evaluateTask = browser.EvaluateScriptAsync($"window.location.href = '{expected}';");
await Task.WhenAll(navigationTask, evaluateTask);
var navigationResponse = navigationTask.Result;

Resolves #4073
2022-04-27 11:02:45 +10:00
Alex Maitland c20bc9b87f WinForms - Improve designer support for UserControl
Current DesignMode property is only true when the control is directly interacting with the designer.
This checks if an ancestor is in design mode to allow support for UserControls

Issue #4057
2022-04-05 15:52:59 +10:00
Alex Maitland b9447740c8 WinForms - Hide ChromiumHostControlBase.BrowserHwnd property from designer 2022-03-18 09:28:24 +10:00
Alex Maitland 71d07dfd41 WinForms - Remove obsolete from Paramater less constructor
- Causes a warning in the build log when used via the designer
- Instead update the comment and set EditorBrowsableState.Never
2022-03-18 09:28:24 +10:00
Alex Maitland 8b9a5e21c1 WinForms - Designer avoid calling Cef.Shutdown on Application.Exit 2022-02-23 11:06:00 +10:00
Alex Maitland 3b1c46aab9 Code Cleanup - Minor code cleanup
- Add Microsoft.CodeAnalysis.NetAnalyzers package
- Make some classes sealed
- Fix/Add xml doc
2022-02-01 14:07:01 +10:00
Alex Maitland 12d28b6c02 WinForms - Add new IWinFormsChromiumWebBrowser interface
- Common interface of ChromiumHostControl and ChromiumWebBrowser
- WinForms Example Fix removing of Tab
2022-01-31 12:54:18 +10:00
Alex Maitland 746925b1f7 WinForms - Make ChromiumHostControlBase.FromBrowser public
- Can be used to get the ChromiumHostControlBase instances from the IBrowser instance
2022-01-31 11:35:46 +10:00
Alex Maitland 409c8a85f4 WinForms - Add ChromiumWebBrowser.FromBrowser static method
- Can be used to get ChromiumWebBrowser instance from IBrowser instance
- Added generic base implementation to reduce code duplication
2022-01-10 14:10:26 +10:00
Alex Maitland 01b7a4330e WinForms - Add LifeSpanHandler.OnBeforePopupCreated
- Allow for cancelling of popup creation

browser.LifeSpanHandler = CefSharp.WinForms.Handler.LifeSpanHandler
	.Create()
	.OnBeforePopupCreated((chromiumWebBrowser, b, frame, targetUrl, targetFrameName, targetDisposition, userGesture, browserSettings) =>
	{
		//Can cancel opening popup based on Url if required.
		if(targetUrl?.StartsWith(CefExample.BaseUrl + "/cancelme.html") == true)
		{
			return PopupCreation.Cancel;
		}

		return PopupCreation.Continue;
	})
2022-01-10 13:44:30 +10:00
Alex Maitland 0efd241eb3 WinForms - Allow creation of custom ChromiumHostControl instance
- Add new CreatePopupChromiumHostControl delegate which can be passed to
  LifeSpanHandler.Create to create a new ChromiumHostControl instance.
  You can create a class that inherits from ChromiumHostControl and add
  additional functionality.

LifeSpanHandler
  .Create(() =>
  {
     return new ChromiumHostControl
     {
       Dock = DockStyle.Fill
     };
})
2022-01-10 13:44:29 +10:00
Alex Maitland 571a1db548 Core - Further migration of extensions methods from IWebBrowser to IChromiumWebBrowserBase
- EvaluateScriptAsync can now be used from IChromiumWebBrowserBase, if also IWebBrowser then
main frame check will occur as previous.

Related to #3944
2022-01-10 13:44:29 +10:00
Alex Maitland 604e9570f7 WinForms - Improve xml doc 2022-01-05 13:20:33 +10:00
Alex Maitland 27816d54b8 Core - Change from using GetBrowser() method to BrowserHost
- BrowserHost will return null if not set where GetBrowser() will throw an exception
2022-01-05 10:14:24 +10:00
Alex Maitland d833c5e761 WinForms - ChromiumHostControl close CefBrowser on Dispose
- If you were to remove the ChromiumHostControl from it's parent Control and manually call Dispose()
  then the underlying CefBrowser wouldn't have been closed until the parent ChromiumWebBrowser is
  Disposed (all popups are disposed)
2022-01-04 10:31:36 +10:00
Alex Maitland cbe0e855c6 WinForms - check if MainFrame.IsValid before calling LoadUrl
- Rewrite to directly use BrowserCore checking for null and IsDisposed to
avoid exceptions if at all possible.
- Check MainFrame.IsValid

As yet I've not seen a way to reproduce the actual problem, single reported case
so far at https://github.com/TV-Rename/tvrename/issues/862
2021-12-15 09:27:18 +10:00
Alex Maitland ba7c855353 WinForms - NullReferenceException in ChromiumWebBrowser.OnHandleDestroyed
- Check browserHost is not null

Resolves #3931
2021-12-15 09:11:18 +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 165a05071d WinForms - ChromiumHostControl now has basic events
- Create ChromiumHostControlBase as common base class for ChromiumHostControl and ChromiumWebBrowser
- ChromiumHostControl is now the specific implementation for hosting popups
  Has AddressChanged, LoadingStateChanged, etc events
2021-11-30 13:47:41 +10:00
Alex Maitland 6e9e4a90a2 WinForms - ChromiumHostControl add BrowserCore and IsBrowserInitialized event
- Can now access the IBrowser property via ChromiumHostControl.BrowserCore
- The ChromiumHostControl.IsBrowserInitialized event will be raised when
the underlying CEF browser has been created.
2021-11-25 10:55:31 +10:00
Alex Maitland 129879cd20 WinForms - Add LifeSpanHandler.OnPopupBrowserCreated
- Add new fluent method to the WinForms specific LifeSpanHandler
- Allows simply access to the IBrowser
2021-11-25 10:00:37 +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 0e242a8706 Upgrade to CEF 95.7.10+g00d4ad5+chromium-95.0.4638.54 / Chromium 95.0.4638.54
Remove CefBrowserSettings.universal_access_from_file_urls and CefBrowserSettings.file_access_from_file_urls.
https://bitbucket.org/chromiumembedded/cef/commits/ff33d7f72144

Remove CefBrowserSettings.application_cache
https://bitbucket.org/chromiumembedded/cef/commits/370a7749e950ef6784c29a666d07a0b67148dd5f

Remove ignore_certificate_errors setting
https://bitbucket.org/chromiumembedded/cef/commits/aabe4ce466766f8bd9907e7fa30546a3afada214

RequestContextSettings.IgnoreCertificateErrors was removed, the CefSettings.IgnoreCertificateErrors property
now set the command line arg

Use CefRect for CefWindowInfo bounds
https://bitbucket.org/chromiumembedded/cef/commits/8587cc4e4bbc187aa989152e521318818b3f41d3

Additional overload has been added to pass in a Rect directly to SetAsChild

Rename SendFocusEvent to SetFocus
https://bitbucket.org/chromiumembedded/cef/commits/49a4611e28d7bbc221cff816d7c4a96c55ba2721

SendFocusEvent will now call SetFocus internally, the project internally has been updated to use SetFocus for WPF

Replace CefRequestCallback with CefCallback
https://bitbucket.org/chromiumembedded/cef/commits/3e7f1bb529442a6c7674262d9219df57964e9524

No changes to the API for this, I've kept the same interface and just mapped internally

Resolves #3857, #3667, #3668
2021-10-22 14:45:12 +10:00