Commit Graph

141 Commits

Author SHA1 Message Date
amaitland c44f56f5af Subprocess - OnBrowserCreated handle extraInfo being null
- Looks like when Chromium creates it's own windows we don't get a reference to the object

Issue #4963
2024-10-26 10:41:31 +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 2a9b50640f Core - Change from cef type defs to C++11 defs
https://bitbucket.org/chromiumembedded/cef/commits/5042d7140822cd13b80990f61ce2d3865864a3d8
2023-07-16 09:31:55 +10:00
Alex Maitland 4ff673e76a Enhancement - Improve Promise support (#4326)
* Enhancement - Improved promise support

Resolves #4276
2022-12-06 14:54:19 +10:00
Alex Maitland a18637facd C++/CLI - Replace NULL with nullptr
Issue #3636
2021-07-31 15:52:56 +10:00
Alex Maitland 20dad8aced Core - Crash opening popup window
Upstream changes mean that extraInfo can now be null (https://bitbucket.org/chromiumembedded/cef/issues/3123/convert-legacy-ipc-messages-to-mojo)
We currently only send extra Info for the main browser and not for popups.
Assign the _jsBindingPropertyName/_jsBindingPropertyNameCamelCase properties
by default and only update when the user has specified their own name.

It's not currently possible to have different naming in the same render process (was previously the case).

Issue #3670
2021-07-06 11:56:35 +10:00
Alex Maitland 0386220e06 JavascriptBinding - Add JavascriptBindingSettings.JavascriptBindingApiEnabled property (#3571)
- The Javascript methods that CefSharp provides in relation to JavaScript Binding are
  created using a Global (window) Object. Settings this property allows you to disable
  the creation of this object. Features like EvaluateScriptAsPromiseAsync that rely on
  the creation of this object will no longer function.
2021-06-04 13:26:00 +10:00
Alex Maitland e3e4c3fe35 BrowserSubprocess - Namespace cleanup
Possibly a few cases that were missed, this should be the bulk of the rename

Resolves #3253
2021-02-27 14:40:16 +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
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 4f74f60787 Core - Add CefSharp.RenderProcessId javascript property
Two new properties have been added (both have the same value)
- CefSharp.RenderProcessId
- cefSharp.renderProcessId

Use which ever suites your naming style

Resolves #2984
2020-09-18 13:56:07 +10:00
amaitland 53f15f22eb Upgrade to CEF 85.3.6+gacfac2f+chromium-85.0.4183.102 / Chromium 85.0.4183.102
- Remove CefSettings.RegisterExtension (#3184)
- Add IRenderProcessHandler.OnWebKitInitialized
- Add Cef.RegisterExtension (Browser SubProcess specific implementation)

Resolves #3184
2020-09-16 13:49:37 +10:00
amaitland e8cf336bf3 Net Core - Support for compiling with .Net Core 3.1
- Make Wpf/WinForms/OffScreen projects target AnyCPU
Only the VC++ projects are platform specific now.
- Remove BrowserSubProcess project reference
Not needed as we now have a standalone exe
- Add OffScreen example
- Add WPF Example project
- Fix some compile errors for main solution
- Add BrowserSubProcess executable
- JavascriptObjectRepository remove isAsync param
Rather than throw exception remove the option
- BrowserSubprocess Exclude the WCF specific code from the netCore project
- Add some ifdef/ifndef to exclude the WCF specific implementation
- Move WCF implementation into separate namespace
2020-07-23 15:23:45 +10:00
amaitland ae41e10d71 Core - Javascript Binding Configure Property Name
- Rename settings object to JavascriptBindingSettings
- Validate JavascriptBindingSettings.JsBindingGlobalObjectName in setter to provide immediate
  feedback
- Add FreezableBase which throws exception when frozen (we can reuse this for some other settings classes)
- Add some basic Unit Tests (More would be better)

Follow on from #3126
2020-05-30 19:28:50 +10:00
Geevo 66691105b4 Core - Added ability to configure/customize javascript binding property name. 2020-05-30 18:53:13 +10:00
Gilberto Stankiewicz e011086883 Fix all C6246 warnings: Local declaration hides declaration of the same name in outer scope. (#3027)
* Fix all C6246 warnings: Local declaration hides declaration of the same name in outer scope.

* Removing outter scope `global`
2020-01-29 16:17:14 +10:00
amaitland c724e3da65 LegacyJavascriptBinding - Enabled field was overwritten when a popup was opened
Popups don't transmit their own bound object information, _legacyBindingEnabled was being set to false
2019-08-11 18:29:40 +10:00
amaitland 85a01973af CefAppUnmanagedWrapper - Minor refactor in kJavascriptRootObjectResponse and kJavascriptAsyncMethodCallResponse
kJavascriptRootObjectResponse - delete the callback when not used
kJavascriptAsyncMethodCallResponse - Only execute if we have a valid frame
2019-07-20 18:28:36 +10:00
amaitland f6edbd5ad8 CefSharp.BindObjectAsync - Split out into it's own Handler
- Add BindObjectAsyncHandler
- Remove unneeded params from RegisterBoundObjectHandler
2019-07-08 20:14:52 +10:00
amaitland e0268a3e2a Network Service - Register custom scheme in all process types
The network services requires that custom schemes be registered, previously we only registered them in render processes.

Add SubProcessApp to handle scheme registration
CefAppUnmanagedWrapper inherits SubProcessApp now

#2743
2019-07-04 20:47:42 +10:00
amaitland 088c3d02f4 ISchemeRegistrar - Change AddCustomScheme to use SchemeOptions enum
- Add new SchemeOptions enum
- Change AddCustomScheme to use new enum (replaces all the bool params)
- Simplify command line arg processing, now sends scheme name and int (options)
- Add CefCustomScheme.IsFetchEnabled

Resolves #2690

Breaking Change
2019-07-02 20:50:09 +10:00
amaitland ff87529a49 Javascript Legacy Binding - Pass objects on CefBrowserHost::CreateBrowser
Previously objects were sent in OnRenderViewReady, which is only called once for a browser instance, not for process switches
Now objects are passed when the browser is created, still need to check for popup handling
2019-06-25 19:24:57 +10:00
amaitland 0542c5138b SendProcessMessage - Remove frame/browserid from messages
Not complete or tested yet
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
Alex Maitland 1a2c8ffcb6 Add CefSharp.PostMessage (#2799)
- JavascriptMessageReceived event added to ChromiumWebBrowser/IWebBrowser
- CefSharp.PostMessage and cefSharp.postMessage added to V8Context on creation for use in Javascript
- Add PostMessageTest.html
2019-06-03 21:08:03 +10:00
amaitland 78fe342988 Javascript CallbackRegistry FindWrapper - Improve error message when no wrapper found 2019-04-26 12:03:32 +10:00
Alex Maitland 70de3a6d9c Add Initial IRenderProcessHandler.OnContextCreated/Released implementation (#2697)
* WinForms/WPF - Dispose of IFrame after calling LoadUrl

* BrowserProcess - Add initial implementation of IRenderProcessHandler.OnContextCreated/OnContextReleased

- IV8Context.Execute is the only method to be implemented so far (execute script without returning a result)
- Wrappers for CefFrame and CefBrowser have yet to be imported yet, still need to determine if they should be included individually or reference to CefSharp.Core added

* BrowserProcess - Add wrappers for Browser and Frame

Ultimately we should probably remove the CefSharp.BrowserSubprocess.Core project and move all the code into a folder/namespace within CefSharp.Core
This would allow us to share the a lot of existing code, major refactor required

* CefSharp.Common.props - Add CefSharpBrowserProcessCore32/64 properties

Make creating your own custom browser process easier

* BrowserProcess - Remove example and add comments about creating your own custom version
2019-03-20 20:33:10 +10:00
amaitland 111439c98e CefSchemeRegistrar->AddCustomScheme - signature changed
https://bitbucket.org/chromiumembedded/cef/commits/cbcbd02638e5b4ccc26bab4a4b45b527c687068b?at=3683

Temp workaround until #2690 is implemented
2019-03-15 21:13:21 +10:00
amaitland 11a8371e19 Rename CefExtension to V8Extension
Resolves #2612
2018-12-27 15:47:29 +10:00
amaitland 19a56bd7f9 CefAppUnmanagedWrapper::OnContextCreated - Fixed up merge mistake
IPC message was only sent for main frame

Follow up #2373
2018-10-28 16:52:21 +10:00
Alex Sukhovy 304a300b0c Call OnContextCreated and OnContextReleased for each frame (#2373)
* ContextEvents for each frame

* set CanExecuteJavascriptOnMainFrame

* example and comments

* whitespace fix

* comments

* whitespace

* update comments
2018-10-28 16:48:50 +10: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 7450d0d51b JSB - Remove use of CefRegisterExtension and change Promise creator to an anon function
Use CefV8Context::Eval to create the promise using an anonymous function

Attempt to resolve #2432 (though it actually seems upgrading to a newer version resolves the underlying problem)
2018-08-27 13:12:55 +10:00
amaitland 38bc2d8365 CefAppUnmanagedWrapper::OnContextCreated - Send OnContextCreated message after Objects created
Message is now sent once the CefSharp.BindObjectAsync and helper functions are created and Legacy objects
are bound.

It should now be reliable to call CefSharp.BindObjectAsync in OnContextCreated
2018-08-05 19:56:41 +10:00
amaitland ddb2fdcbbc CefAppUnmanagedWrapper - Add comment about mapping layer so code isn't duplicated to handle camel casing of object names 2018-05-15 15:52:31 +10:00
amaitland 8f7692ae6e JSB - Add JavascriptBindingCompleteEventArgs and config options to CefSharp.BindObjectAsync
CefSharp.BindObjectAsync can now take an optional config object as first param
Include additional information when binding complete
Add option for cefSharp.bindObjectAsync (starting with lowercase latters)
Add new syntax options - not entirely complete, no variant for the options object
Add ignore cache option
2018-04-27 16:40:39 +10:00
amaitland f6e58283a6 LegacyBinding - Remove objects from cache if key already exists
Temp fix for #2301 Will be resolved properly in #2306
2018-04-20 10:45:52 +10:00
João Neves 5a713fdf7d Support uncaught exception handling (#2244)
* Added support for uncaught javascript exception in Render Process Message Handler
* Fixed typo
* Added stack frame column numbers
* Code review
* Code review
* Update JavascriptException.cs
2018-03-07 10:21:31 +10:00
amaitland 1b00c277b8 JSB Add Caching
Bound object meta data is cached within a render process
CefSharp.IsObjectCached - JS method to test if object cached
CefSharp.RemoveObjectFromCache - JS method to remove object from cache

If a request is made for multiple objects with not all of them being cached then a IPC message is sent.
When all objects already bound return response object for consistency
FindBrowserWrapper signature change - it's really not safe to throw a managed exception in the middle of unmanaged code, changed to logging and null checking
JavascriptObjectRepository - Add All Constant - Used when All objects are requested for binding (objects can also be requested by name)

TODO: Add a JS library to improve user experience when dealing with cached objects
2018-01-30 10:16:28 +10:00
amaitland 934cd70ed6 JSB BindObjectAsync return response object
Can now return additional properties, still need better error handling
2018-01-29 09:45:24 +10:00
amaitland fd64b079a2 IJavascriptObjectRepository.ObjectBoundInJavascript - Fix bug and add example 2018-01-22 12:19:51 +10:00
amaitland 7c699e3ec6 IJavascriptObjectRepositry - Add ObjectBoundInJavascript event
Executed on the thread pool when objects are bound in JS
2018-01-22 12:19:43 +10:00
Alex Maitland 9b01b69d2f Implement Javascript Binding v2 (#2247)
* JSB Rewrite - Add CefSharp.RegisterBoundObject javascript method

To get around the problem of IPC timing, I've reversed the communication, now it's the render process requesting
the bound objects, the implementation is incomplete at this stage, more just a basic proof of concept

Rewrite BindingTest.html using QUnit
One of the tests doesn't map correctly as it requires def user interaction

TODO:

- Get objects by name
- Rename Messages.h values that relate to this change so they are more descriptive
- Better error handling
- Caching of objects within a render process
- Investigate global context options, don't think it's possible to call an async method directly in the global context

# Conflicts:
#	CefSharp.Example/Resources/BindingTest.html

* JSB Improve Request/Response message names

* BindingTest.html - Output stress test results

* Remove JavascriptRootObject was leftover from time we used WCF to transmit objects

* JavascriptObjectRepository - Objects are now sent in the same list with an IsAsync flag

Separation when sending over IPC with two unique lists isn't necessary

* JavascriptObjectRepository - Return objects by name or return all by default

Untabify CefAppUnmanagedWrapper.cpp
Add minor comment to CefBrowserWrapper for a reminder that we use Frame Identifier as dictionary key

* Add //TODO: JSB comments for work that's left to be done

Ideally within a render process we cache bound objects once they've been communicated,
It would also be nice to make multiple binding requests so objects can later be added dynamically

* JSB Allow multiple calls to CefSharp.RegisterBoundObject

Update BindingTest.html to name two distinct calls to different bound objects

* JSB - Add some notes about caching, no working implementation yet

* JSB - Dynamically Register object on Request

* JSB Add ability to unbind an object and rename RegisterBoundObject to BindObjectAsync

# Conflicts:
#	CefSharp.Example/Resources/BindingTest.html

* JSB BindObjectAsync - if objects already bound then return false

* JSB - Ignore Indexer properties

Were previously throwing an exception

* JSB - Add LegacyJavascriptBindingEnabled option so preserve existing behaviour

This is only useful for SPA application and those that only navigate to pages
hosting within a single domain. Any sort of cross-site navigation and a new
render process will be spawned and objects won't be bound automatically
(You can use the new methods to request they're bound yourself, at least in theory,
more testing required on this)

* Add LegacyBindingTest.html

Current disabled by default. To enable uncomment CefSharpSettings.LegacyJavascriptBindingEnabled = true;
in CefExample.cs

* RegisterJsObject and RegisterAsyncJsObject can now only be used when CefSharpSettings.LegacyJavascriptBindingEnabled = true

See https://github.com/cefsharp/CefSharp/issues/2246 for details
2018-01-22 10:24:25 +10:00
Chris 7e2594d2e3 Added CefCustomScheme.IsCspBypassing
Resolves #2038
2017-08-29 18:00:36 +02:00
amaitland 5b472f7258 Upgrade version numbers to 58 - this is for development purposes only, there is no planned 58 version, next version is 59
Upgrade to CEF 3.3029.1611.g44e39a8 / Chromium 58.0.3029.81
2017-05-05 10:46:54 +10:00
João Neves bc83d6c247 Allow calling managed methods from objects bound with RegisterAsyncJsObject that return arrays of structs (#1981)
* Fixed problem when calling CefV8Value::CreateArray. Needs prior call to V8 context enter
* Call callback dispose in case of failure
* Support serialization of struct arrays to JS side
* Fixed formatting
2017-03-13 21:37:55 +10:00
amaitland e5ecfde20f Upgrade version number to 57.0.0
Upgrade to cef.redist.x86.3.2987.1591
CefSchemeRegistrar::AddCustomScheme has new params - IsSecure and IsCorsEnabled
Also new CefRawPtr type is used for Scheme registra
2017-03-13 10:58:03 +10:00
amaitland 5d459a5d32 Add IRenderProcessMessageHandler.OnContextReleased - native IPC message sent from render process 2017-03-07 09:23:10 +10:00
Chris cd934267c6 Updated copyright year and made sure it used same format everywhere (#1966) 2017-03-06 08:44:37 +10:00