Commit Graph

122 Commits

Author SHA1 Message Date
Alex Maitland 20efc0fee3 Core - Xml Doc fixes for Find/FindHandler
- Update xml doc
2022-12-16 06:17:13 +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
Alex Maitland 787665bcfe Core - WebBrowserExtensions throw explicit ObjectDisposedException if IsDisposed
- Make it clear that the ChromiumWebBrowser instance has been disposed.
  Previously when the browser was disposed BrowserCore would be null.
  An explicit ObjectDisposedException is now thrown.
2022-05-31 10:56:13 +10:00
Alex Maitland 22de75f1be WaitForNavigationAsync - Change timeout handling 2022-05-30 19:14:06 +10:00
Alex Maitland 29c7473b77 Core - WaitForNavigationAsync cleanup events on timeout
Unsubscribe to events when timeout occurs
2022-05-30 14:24:55 +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 d701cee655 Enhancement - Add WaitForSelectorAsync extension method. (#4095)
* Enhancement - Add WaitForSelectorAsync extension method.

string script = "const newDiv = document.createElement('div'); newDiv.id = 'myElement'; document.body.append(newDiv);";
await Task.WhenAll(
     browser.WaitForSelectorAsync("#myElement");,
     chromiumWebBrowser.EvaluateScriptAsync(script));

Resolves #4094
2022-05-30 12:00:18 +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 640672dcf9 Core - Add IChromiumWebBrowserBase.GetRequestContext extension method
Simplifies getting the RequestContext for a ChromiumWebBrowser instance
2022-04-12 14:03:51 +10:00
Alex Maitland 597e54fc11 IBrowserHost.Find remove identifier param
Resolves #4013
2022-02-22 11:17:56 +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 288825d30c Core - IFrame.EvaluateScriptAsPromiseAsync add javascriptBindingApiGlobalObjectName
- Defaults to null, only required if you set JavascriptBindingSettings.JavascriptBindingApiGlobalObjectName
2022-01-10 13:44:29 +10:00
Alex Maitland 2a9826601b Core - Change WebBrowserExtensions replace IWebBrowser with IChromiumWebBrowserBase where possible
- Improve xml doc comments also
2022-01-10 13:44:28 +10:00
Alex Maitland 0ae18addc1 Core - ExecuteScriptAsync(script) incorrectly appends braces and semicolon to script.
Issue #3944
2022-01-10 13:44:28 +10:00
Alex Maitland 51b2c74801 Core - Fix ExecuteScriptAsync infinite recursion
Resolves #3914
2021-12-01 05:47:01 +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 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 c7e477b306 WebBrowserExtensions - Hide RegisterJsObject and RegisterAsyncJsObject from intellisense
They're obsolete and will throw exceptions anyway, only exist to point upgrading users to the correct doco
2021-10-22 16:29:21 +10:00
Alex Maitland 0a1a8855c5 Core - Add IBrowser.IsValid
- Add IBrowser.IsValid
- Update xml doc comments
- Remove ExecuteScriptAsync CanExecuteJavascriptInMainFrame check as CEF should now internally queue commands for ExecuteScript and LoadRequest

https://bitbucket.org/chromiumembedded/cef/issues/2421/add-onframecreated-onframedeleted#comment-60616371

Issue #3588
2021-07-22 13:27:36 +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 bec06b2495 Add Fluent DownloadHandler (#3576)
* Core - Add Fluent DownloadHandler implementation and IFrame.DownloadUrlAsync

Resolves #3550
2021-06-01 13:34:21 +10:00
Alex Maitland 744ff3fb5a Core - WebBrowserExtensions.LoadUrlWithPostData remove Obsolete attribute
No further reports of issues

#2705
2021-05-01 16:57:07 +10:00
Alex Maitland 6d9f214196 Javascript Callback - Add very basic support for executing a Promise
It's a manual process at this stage and requires the end user to deal to:
- Return "CefSharpDefEvalScriptRes" immediately after the promise function has been created
- Call cefSharp.sendEvalScriptResponse when the async/await (promise) processing has completed
2021-02-15 13:43:51 +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
pgodwin b8a36411ce Add async to EvaluateScriptAsPromiseAsync and tests (#3314)
Co-authored-by: Peter Godwin <peter.godwin@health.qld.gov.au>
2020-12-11 13:01:27 +10:00
Alex Maitland e213f37285 Core - EvaluateScriptAsPromiseAsync not working when JavascriptBindingApiGlobalObjectName specified
Resolves #3281
2020-11-14 12:07:38 +10:00
Alex Maitland fd46a4c145 Core - Add EvaluateScriptAsPromiseAsync (#3251)
- Add useImmediatelyInvokedFuncExpression param to EvaluateScriptAsync which wraps the script in an IIFE
  with the cefSharpInternalCallbackId variable defined in scope to allow for deferred completion
- Wrap script in Immediately Invoked Function Expression and call promise.resolve to guarantee a promise.
- Return 'CefSharpDefEvalScriptRes' as the result of the js function to defer execution of the callback
- Call newly added cefSharp.sendEvalScriptResponse method in javascript when promise has been resolved/rejected

This is built up of a few parts and can technically be used by the new user to defer the response until they are ready.
Just return `'CefSharpDefEvalScriptRes'` and manually call cefSharp.sendEvalScriptResponse using the cefSharpInternalCallbackId
variable which is injected into the script execution (wrapped in an IIFE to limit scope)
2020-10-06 15:19:37 +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 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
chacham2 82c1d27815 WebBrowserExtensions fix spelling mistakes (#3176) 2020-07-10 04:54:14 +10:00
amaitland bd4cadd2ed Core - Add ExecuteDevToolsMethodAsync extension method
ExecuteDevToolsMethod has to be called exclusively on the CEF UI thread.
This extension method will invoke into the CEF UI thread if required.
2020-06-30 14:48:35 +10:00
amaitland 49ee24912d Core - Add support for direct DevTools protocol messaging
Add support for direct DevTools protocol messaging (fixes issue #2961).

This change allows the client to directly send and receive DevTools
protocol messages (send method calls, and receive method results and
events) without requiring a DevTools front-end or remote-debugging
session.

https://bitbucket.org/chromiumembedded/cef/commits/fd6631bd181233d36b98e1327da84c44372add76
2020-06-29 11:12:37 +10:00
amaitland 961fc97c9d WebBrowserExtensions - Add missing semi colon 2020-01-31 08:16:34 +10:00
amaitland 499c6a80db WPF - ChromiumWebBrowser.GetBrowser() Throws InvalidOperationException if called on Non UI Thread.
- Extract error message out into a internal const so it's not duplicated
- Manually check InternalIsBrowserInitialized() method instead of using the extension method

Resolves #3032
2020-01-31 07:51:25 +10:00
amaitland 10d52419f3 xml doc improvements 2020-01-29 10:22:18 +10:00
amaitland 39a305cac1 Xml Doc - Improvements and fixes
- Some classes are now excluded
- Many minor fixes should hopefully reduce the number of errors reported by Sandcastle
- Some of the xml doc is generated by Atomineer, usually in cases where CEF lacks documentation
2020-01-29 05:36:54 +10:00
amaitland 44113d77a4 DevTools - now shown as popup (visible in taskbar).
- Pass null for CefWindowInfo.SetAsPopup parent handle
- Add optional params to IWebBrowser/IBrowser.ShowDevTools extension methods.

Anyone wishing to use the old behaviour can do something like

var host = browser.GetBrowserHost();

var windowInfo = new WindowInfo();
windowInfo.SetAsPopup(host.GetWindowHandle(), "DevTools");

browser.ShowDevTools(windowInfo);

Resolves #2997
2020-01-21 09:06:28 +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 c5c9271cb7 Core - WebBrowserExtensions.RegisterJsObject and WebBrowserExtensions.RegisterAsyncJsObject now throw NotImplementedException
Follow up to commit ffaff5d151.

Resolves #2990
2019-12-11 14:12:31 +10:00
amaitland ffaff5d151 Core - Remove WebBrowserExtensions.RegisterJsObject and WebBrowserExtensions.RegisterAsyncJsObject
This is a breaking change, these methods are being removed as they are used for LegacyBinding which is being drastically changed in #2977

Resolves #2990
2019-12-11 10:08:08 +10:00
amaitland db4f5f3822 Core - Fix WebBrowserExtensions xml doc 2019-12-10 07:54:28 +10:00
amaitland 60a1f640cf CEF Upgrade - Breaking Changes
- Remove CefSettings.EnableNetSecurityExpiration
- Remove RequestContextSettings.EnableNetSecurityExpiration
#2954

- Remove IFrame.LoadStringForUrl and IWebBrowser.LoadString
Resolves #2955
2019-11-03 12:33:45 +10:00
amaitland f88708f063 WebBrowserExtensions - Make GetScript public and rename to GetScriptForJavascriptMethodWithArgs 2019-09-06 09:59:31 +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
amaitland ec21d01182 WebBrowserExtensions - Reenable CanExecuteJavascriptInMainFrame checks 2019-07-08 20:14:51 +10:00
amaitland b68d8d7a8f RequestHandler - Change interface implementation to be explicit
- Make members protected virtual (BREAKING CHANGE)
- Remove Default from name of DefaultResourceRequestHandlerFactory/DefaultResourceRequestHandlerFactoryItem
2019-06-25 19:24:57 +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 049f576de3 UrlRequestFlags.AllowCachedCredentials rename to AllowStoredCredentials
Resolves #2755

This is a breaking change
2019-05-04 06:43:56 +10:00
Gilberto Stankiewicz db3839a285 Fix typos (#2750) 2019-04-26 12:19:34 +10:00