99 Commits

Author SHA1 Message Date
Alex Maitland 1ea6c46163 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-25 20:36:24 +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
amaitland ad7cbccbf8 WebBrowserExtensions.LoadUrlWithPostData - Set UrlRequestFlags.AllowCachedCredentials
Possible workaround for sending cookies

Issue #2705
2019-04-11 08:03:11 +10:00
amaitland ba008eed35 WebBrowserExtensions.LoadUrlWithPostData - Mark as Obsolete
Issue #2705
2019-03-26 18:18:40 +10:00
Chris 987f988dac Refactoring - Moved RegisterJsObject and RegisterAsyncJsObject to WebBrowserExtensions (#2703) 2019-03-23 13:31:09 +10:00
amaitland 6f6ca94ea9 WPF Example - Change to using DataUri (LoadHtml extension method) for showing errors instead of LoadString
- Add new IFrame.LoadHtml extension method.

Related `upstream` issue is https://bitbucket.org/chromiumembedded/cef/issues/2586/loadstring-results-in-terminating-renderer
2019-02-08 10:42:15 +10:00
campersau b31069633e add spaces in exception messages (#2620) 2019-01-11 08:57:28 +10:00
amaitland 5396f70232 WebBrowserExtensions.LoadUrlWithPostData - Update xml doc comment
Follow up to #2451
2018-10-17 07:07:52 +10:00
Chris cde90a34b9 WebBrowserExtensions::GetScript - Added support for all numerical types (#2526)
* WebBrowserExtensions::GetScript - Added support for all numerical types

* Removed leftover using
2018-09-29 16:11:38 +10:00
amaitland 63a569c807 WebBrowserExtensions - Add ExecuteScriptAsyncWhenPageLoaded
Extensions method that attempts to execute javascript immediately if the page is loaded or wire up the LoadingStateChanged
event handler.
2018-09-28 14:15:43 +10:00
amaitland 246dad90a1 WebBrowserExtensions - Fix naming private static variable naming
.editorconfig consistency
2018-09-27 17:24:21 +10:00
Chris 30ee538ce0 Added EditorConfig (#2514) 2018-09-17 00:46:21 +02:00
Chris bef5dd37c4 Maintenance - Fixed formatting, file encoding, and copyright year (#2504)
* Applied formatting

* Fixed file encoding + Updated copyright year

* Updated License

* Fixed more file encoding

* Copyright notice now shows the year the file was created
2018-09-10 10:41:13 +10:00
amaitland 8ed2681619 Xml Doc - Add some more xml doc
Some of it's just placeholder doc to keep sandcastle happy
2018-09-05 13:01:41 +10:00
amaitland f6088f33d2 DefaultResourceHandlerFactory - Rewrite so it stores byte[] instead of storing IResourceHandler
It's not actually a factory and will handle multiple requests to the same url

Only API change is for DefaultResourceHandlerFactory directly, the LoadHtml and RegisterResourceHandler extension methods
stay unchanged
2018-08-13 12:39:04 +10:00
amaitland 7275d2c611 WebBrowserExtensions - Add GetCookieManager extension method to simplify getting the
cookie manager associated with the IWebBrowser instance
2018-07-21 21:08:21 +10:00
amaitland 5adff7014b ResourceHandler - Expose AutoDisposeStream for ResourceHandler.FromStream and ResourceHandler.FromFilePath
Also add OneTime param to WebBrowserExtensions.RegisterResourceHandler which translates to AutoDisposeStream
2018-05-17 16:43:14 +10:00
amaitland 2fbc0bb5a1 WebBrowserExtensions - Rename ExecuteScriptAsyncEncodeString to EncodeScriptParam
Method is used by both eval and execute so make name more generic. Improve xmldoc slightly
2018-04-03 14:22:32 +10:00
amaitland 431fe76a39 WebBrowserExtensions - Add ExecuteScriptAsyncEncodeString to allow for custom encoding of string params used with ExecuteScriptAsync overload
Also rename test case and add comment

Follow up to #2340
2018-04-03 14:12:10 +10:00
Garr Godfrey 7e30861bc2 Encode string parameters to pass unchanged.
enter the commit message for your changes. Lines starting
2018-03-28 22:28:01 -07:00
amaitland 68c9a6418c Disable CanExecuteJavascriptInMainFrame checks for ExecuteScriptAsync/EvaluateScriptAsync
See #2250 for details (appears to be bug in `CEF`)
2018-01-24 10:16:01 +10:00
amaitland 9f874807d5 WebBrowserExtensions.GetHost renamed to GetBrowserHost
Add missing this keyboard to make it an extensions method
2018-01-18 10:25:53 +10:00
amaitland fe026a8f9e Add IWebBrowser.GetHost() extension method - make it easier to directly get the IBrowserHost reference 2017-05-29 13:49:23 +10:00
amaitland b2143f60d1 Add IWebBrowser.LoadUrlWithPostData extension method (in WebBrowserExtensions) - simplifies calling LoadRequest
Add IPostData.AddData extension method (in PostDataExtensions)
WPF Example change from calling LoadRequest to using new LoadUrlWithPostData extension method
2017-05-26 11:24:45 +10:00
amaitland 16dbb10c61 Add ThrowExceptionIfCanExecuteJavascriptInMainFrameFalse method to reduce duplication.
Improve error message, add info about V8Context not being created for pages with no javascript
2017-05-08 13:16:24 +10:00