* Javascript Binding - Add Ability to limit origins
* Move JS binding settings to CefBrowserWrapper and optimize origin validation
* Initialize origins to null
* Normalize allowed origins
* Optimize origin validation
* Add null check for origin compare
* Fix JavaScript Binding API settings for popups
Move the JS binding API configuration block out of the !browser->IsPopup() scope
in OnBrowserCreated. This ensures that IsJavascriptBindingApiAllowed() enforces
configured restrictions for popups as well.
* Fix possible null deref for JavascriptBindingApiAllowOrigins
In IsJavascriptBindingApiAllowed, added a null check for JavascriptBindingApiAllowOrigins
to prevent a potential null dereference if JavascriptBindingApiHasAllowOrigins is true
but the allowOrigins list itself was null.
* Simplify origin normalization and add null check
* Add more test cases
* Refactor IsJavascriptBindingApiAllowed signature
Refactored IsJavascriptBindingApiAllowed to accept a CefBrowserWrapper^ parameter directly, eliminating redundant lookups and improving clarity. Updated all call sites to pass the browser wrapper explicitly.
* Clarify summary for HasJavascriptBindingApiAllowOrigins
Clarify documentation for HasJavascriptBindingApiAllowOrigins method to specify zero or more origins
* Simplify origin comparison logic in CefAppUnmanagedWrapper
Refactored code to directly compare wide string origins using
_wcsicmp, removing unnecessary pointer casts and null checks.
This streamlines the logic and improves readability.
* Add tests for JavaScript binding API behavior across cross-origin navigation
---------
Co-authored-by: amaitland <307872+amaitland@users.noreply.github.com>
Co-authored-by: Luca Sonntag <luca.sonntag@cgm.com>
- JavascriptCallbackRegistry - Get BrowserId From V8Context
- Render Process - Rewrite to store root object wrapper by frame instead of per browser
- Don't store JavascriptRootObjectWrapper in the browserWrapper as CEF is calling destroyed more than it should.
- Revert "Tests - Simplify ShouldFailWhenIsObjectCachedCalledWithInvalidObjectName"
This reverts commit f8a81acf7a.
---------
Co-authored-by: amaitland <307872+amaitland@users.noreply.github.com>
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
- 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.
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
* 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.
- 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)
Two new properties have been added (both have the same value)
- CefSharp.RenderProcessId
- cefSharp.renderProcessId
Use which ever suites your naming style
Resolves#2984
- 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
- 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
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
- 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
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
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
- JavascriptMessageReceived event added to ChromiumWebBrowser/IWebBrowser
- CefSharp.PostMessage and cefSharp.postMessage added to V8Context on creation for use in Javascript
- Add PostMessageTest.html
* 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
* Applied formatting
* Fixed file encoding + Updated copyright year
* Updated License
* Fixed more file encoding
* Copyright notice now shows the year the file was created
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)
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
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
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
* 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