Commit Graph

32 Commits

Author SHA1 Message Date
campersau 4757ee6f6c Avoid ObjectDisposedException when host got disposed (#5003) 2024-12-22 13:28:18 +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 8d7a169590 Change Frame identifier from Int64 to String (#4740)
* Change Frame identifier from Int64 to String

Issue https://github.com/cefsharp/CefSharp/issues/4737

* Fix SetCanExecuteJavascriptOnMainFrame frameId parsing

* Add tests

* NetCore Tests - Install missing packages
2024-03-09 06:55:27 +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 fb779a5b46 Core - Move DevTools Client from CefSharp.dll to CefSharp.Core.dll
- Moves the Dependency of System.Text.Json from CefSharp.dll
  BrowserSubProcess as a result no longer has a reference
  where wasn't required for it's operation.

Resolves #4428 #4427
2023-03-14 14:05:48 +10:00
Alex Maitland b150993d67 CefSharp.Dom - Don't Dispose DevToolsContext
Disposing of the DevToolsContext is causing problems currently as sending the DevTools protocol messages
to the browser is happening after the CefBrowserHost instance has been Disposed.

A separate method of disposing of the DevToolsContext will need to be added that does a cleanup
without sending the commands.

Issue https://github.com/cefsharp/CefSharp.Dom/issues/41
2022-09-12 11:03:09 +10:00
Алексей f92687b7cc Core - Add support PermissonHandler
https://bitbucket.org/chromiumembedded/cef/issues/3352/add-cefpermissionhandler-callback-for-the
2022-08-08 13:59:32 +10:00
Alex Maitland cbbd57e435 Core - Fix some exception messages 2022-05-31 11:05:03 +10:00
Alex Maitland 83c8e009d9 DevTools - Add IWebBrowserInternal.DevToolsContext
- For use with next version of CefSharp.Puppeteer
2022-05-30 14:20:22 +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 d0c9adcf9d Core - Add TryGetBrowserCoreById
- Can be used to obtain an IBrowser reference by Browser Identifier (Id).
- Added a couple of basic unit tests.
2022-01-05 10:47:48 +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 a7aea1821e Core - WaitForInitialLoadAsync set to Cancelled if control is Disposed 2021-11-01 13:27:09 +10:00
Alex Maitland 4112340e48 Core - LoadUrlAsync require url and remove SyncContext param
- Remove url optional null, a Url is now required and an exception will be
  thrown if null or empty. If the browser wasn't loading an null was passed
  in then the task would have never resolved. This provides a predictable behaviour.
  A new WaitForInitialLoadAsync method was added to simplify waiting for initial
  browser load.
- Remove SynchronizationContext param, best to let the framework handle

Issue #3842
2021-10-28 10:51:18 +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 91b7514a1c WinForms/WPF/OffScreen - Add WaitForBrowserInitialLoadAsync
Second attempt at WaitForBrowserInitialLoadAsync, includes optional
CancellationToken param.

Issue #3842
2021-10-27 13:58:57 +10:00
Alex Maitland 544abc68d1 Revert "WinForms/WPF/OffScreen - Add WaitForBrowserInitialLoadAsync"
Tests started failing so will revisit later.

This reverts commit 08e5140060.
2021-10-11 10:14:31 +10:00
Alex Maitland 08e5140060 WinForms/WPF/OffScreen - Add WaitForBrowserInitialLoadAsync
Change all the tests to use WaitForBrowserInitialLoadAsync instead of LoadUrlAsync
as LoadUrlAsync will require a Url as part of #3842
2021-10-10 14:41:04 +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
campersau 8d98043000 Core - Add IFrameHandler (#3757)
* Core - Add IFrameHandler/FrameHandler
* Update comments
2021-09-03 20:13:42 +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 4e16f3b16d Enhancement - Add LoadUrlAsync (#3596)
Core - Add LoadUrlAsync

- Add IWebBrowser.LoadUrlAsync
- Add LoadUrlAsyncResponse
- Update unit tests to use new method
-  Add static method to allow for CefSharp.Wpf.HwndHost to share the same code.
2021-06-04 13:29:40 +10:00
Alex Maitland 047f8b838c WPF/WinForms/OffScreen - Reduce code duplication
Issue #3082
2021-04-01 16:28:20 +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 1299f56c3f Core - Trigger JavascriptMessageReceived event on ThreadPool
Instead of calling on the CEF Thread we are current on in OnProcessMessageReceived
use Task.Run to execute the event on the ThreadPool.
Instances of users calling MessageBox.Show and also problems with with uncaught exceptions
on the CEF thread.
2020-12-16 15:37:17 +10:00
GitHubPang facecb1bab Fix typo. (#3282) 2020-11-15 05:13:47 +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 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