Commit Graph

32 Commits

Author SHA1 Message Date
John Hodnik f2b87feac3 Core - OnSelectClientCertificate own the copied certificate vector (#5281)
* Fix deferred client certificate selection reading freed memory

CefCertificateCallbackWrapper held the offered certificate list as
`const X509CertificateList&`, bound to a stack local built in
ClientAdapter::OnSelectClientCertificate. Once that handler returned the
list was destroyed, so calling Select() at any later point walked freed
memory and threw inside the thumbprint-matching loop, taking the host
process down with it.

CEF explicitly permits answering later. cef_request_handler.h says to
return true and call Select "either in this method or at a later time",
so a wrapper that outlives the handler has to own the list it selects
from. It now holds a heap-allocated copy, freed in the finalizer. A ref
class cannot contain a std::vector by value, hence the pointer. Copying
the vector copies the reference-counted CefX509Certificate pointers, and
those references are what keep the certificates alive.

This is the remaining half of #2948. The comment above the caller reads
"Create a copy of the vector in an attempt to fix #2948", and the copy is
indeed made - but it is then bound by reference, so it dies at the same
instant the original would have.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* Remove the redundant certificate vector copy in ClientAdapter

The wrapper takes its own copy in its constructor, so the local copy added
by a51cdd37 in ClientAdapter::OnSelectClientCertificate is now pure
redundancy - two copies where one is needed. Pass `certificates` straight
through instead.

Also refreshes the comment on _certificateList, which described the caller's
stack local that this removes.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: John Hodnik <jhodnik@activu.com>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-29 12:54:32 +10:00
campersau 331ee6a305 Core - Cancel pending tasks when browser crashed or v8 context gets released (#5145)
* Core - Cancel pending tasks when browser crashed or v8 context gets released

* Use TrySetCanceled to cancel pending tasks

* Adjust test to use chrome://crash for simulating a crash

* Add tests for javascript callbacks

* Rename tests and add tests for calling Execute multiple times

* Move FramePendingTaskRepository to its own file

* Rename test to ShouldCancelAfterV8ContextChange

* Fix compile error on .NET Framework

* adjust ShouldTimeoutIfNavigationOccurs test which now throws a TaskCanceledException on navigation
2025-08-22 12:14:38 +10:00
Alex Maitland 3a749c0bf2 Javascript Binding - Add Url to JavascriptBindingEventArgs (#5021)
Co-authored-by: amaitland <307872+amaitland@users.noreply.github.com>
2025-02-01 06:47:42 +10:00
amaitland 2ebad4d768 Upgrade to 131.2.3+g023a05b+chromium-131.0.6778.70 / Chromium 131.0.6778.70
- Add popupId to OnBeforePopup (API not mapped yet)
2024-11-18 06:12:35 +10:00
Alex Maitland ed6a98389f Upgrade to 126.1.14+g2be337f+chromium-126.0.6478.57 / Chromium 126.0.6478.57
- IDialogHandler.OnFileDialog add new extensions and descriptions arguments (Breaking Change)

Resolves #4838
2024-06-16 08:32:50 +10:00
Alex Maitland 0ab5d1a08b IDownloadHandler.OnBeforeDownload now returns boolean
Return true and execute callback either
asynchronously or in this method to continue or cancel the download.
Return false to proceed with default handling (cancel with Alloy style,
download shelf with Chrome style).
2024-05-06 10:28:35 +10:00
Alex Maitland 635eedb58f Upgrade to 124.3.1+g6d871a1+chromium-124.0.6367.60 / Chromium 124.0.6367.60 2024-05-03 18:45:50 +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 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 1460dee5a1 Core - ClientAdapter improve HasParent checks (#4443)
* Core - Improve ClientAdapter::GetBrowserWrapper logic

Simplify the logic

- For non popup return immediately (most common scenario)
- Check for IBrowser instance for matching popup
- Check for HasParent and return the browser Instance
- Return nullptr if no matching IBrowser wrapper found

* Core - ClientAdapter::OnFrameCreated called before OnAfterCreated

- The very first call to ClientAdapter::OnFrameCreated happens
  before OnAfterCreated leaving us with a IBrowser instance that's null
  Create an IBrowser instance that's scoped to the method call

* Core - ClientAdapter improve HasParent checks

- HasParent check has now been replaced with IsHostedBrowser
  which has additional check to make sure the internal
  IWebBrowser.Set* methods are only called for a IBrowser
  instance that's directly associated with a ChromiumWebBrowser instance
  This resolves issues with DevTools being opened for a popup hosted
  in a ChromiumWebBrowser instance.

Related discussion https://github.com/cefsharp/CefSharp/discussions/4438
2023-04-01 18:58:27 +10:00
Alex Maitland 3ce76eb191 CEF Issue Tracker moved to GitHub
- Update some of the internal links

Issue #4430
2023-03-24 10:52:58 +10:00
Alex Maitland a51cdd3723 Core - OnSelectClientCertificate copy certificate vector
- Attempt to fix AccessViolationException by making a copy of
  the vector

Issue #2948
2023-01-17 10:22:59 +10:00
Alex Maitland c2edd111eb Core - Remove IRequestHandler.OnQuotaRequest
persistent quota is no longer supported (see https://crbug.com/1208141)

Resolves #4357
2023-01-08 11:53:54 +10:00
Alex Maitland 1ae9e01b41 Core - PermissionHandler followup
- Rename enums (remove cef prefix)
- Fix typos
- Slightly improve docs
2022-08-08 14:18:54 +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 15cb6d4754 Core - BrowserRefCount add some basic logging
Logs some basic information so we can see what type of ChromiumWebBrowser hasn't been closed
within as part of the xUnit tests.

* Meant for internal use and might be subject to change.
2022-05-31 15:43:34 +10:00
Alex Maitland 6c18e0e863 Update IDialogHandler.OnFileDialog method declaration
CEF is now using Chrome file dialogs on all platforms and runtimes, this brings a number of fixes and also some API changes.

- The selectedAcceptFilter filter arg has now been removed
- The CefFileDialogFlags enum has been removed as CEF no longer supports these options

This is a breaking change.

Issue #4110
2022-05-17 19:51:08 +10:00
Alex Maitland b4c4913b35 Core - Add IDownloadHandler.CanDownload
- Add IDownloadHandler.CanDownload
- Add to Fluent implementation
- Update examples

https://bitbucket.org/chromiumembedded/cef/commits/6d7a6801871cd4fcceb174dfa99a5b46da6253c1

Resolves #4090
2022-05-05 12:40:33 +10:00
Alex Maitland 0ac43cf69f Core - Remove Remaining Plugin APIs
- Remove plugin references
- Update xml doc comments
- Update ref assembly (netcore)
- Update examples

Issue #4045
2022-03-21 10:01:26 +10:00
Alex Maitland 8b247a6a37 Javascript Binding - IJavascriptCallbackProxy.ExecuteAsync correctly creates pending task using callback Id
- Previously a new PendingTask(TaskCompletionSource) was created using a new Id which worked when the Ids matched
  between the browser and render process. If you skipped executing a callback then the Ids would get out of sync.

Issue #3979
2022-01-27 16:03:22 +10:00
Alex Maitland 0e242a8706 Upgrade to CEF 95.7.10+g00d4ad5+chromium-95.0.4638.54 / Chromium 95.0.4638.54
Remove CefBrowserSettings.universal_access_from_file_urls and CefBrowserSettings.file_access_from_file_urls.
https://bitbucket.org/chromiumembedded/cef/commits/ff33d7f72144

Remove CefBrowserSettings.application_cache
https://bitbucket.org/chromiumembedded/cef/commits/370a7749e950ef6784c29a666d07a0b67148dd5f

Remove ignore_certificate_errors setting
https://bitbucket.org/chromiumembedded/cef/commits/aabe4ce466766f8bd9907e7fa30546a3afada214

RequestContextSettings.IgnoreCertificateErrors was removed, the CefSettings.IgnoreCertificateErrors property
now set the command line arg

Use CefRect for CefWindowInfo bounds
https://bitbucket.org/chromiumembedded/cef/commits/8587cc4e4bbc187aa989152e521318818b3f41d3

Additional overload has been added to pass in a Rect directly to SetAsChild

Rename SendFocusEvent to SetFocus
https://bitbucket.org/chromiumembedded/cef/commits/49a4611e28d7bbc221cff816d7c4a96c55ba2721

SendFocusEvent will now call SetFocus internally, the project internally has been updated to use SetFocus for WPF

Replace CefRequestCallback with CefCallback
https://bitbucket.org/chromiumembedded/cef/commits/3e7f1bb529442a6c7674262d9219df57964e9524

No changes to the API for this, I've kept the same interface and just mapped internally

Resolves #3857, #3667, #3668
2021-10-22 14:45:12 +10:00
Alex Maitland db877d73ec Core - IFrameHandler.OnFrameAttached add reattached param
Resolves #3816
2021-09-20 11:51:10 +10:00
Alex Maitland 9567d14ab2 Core - FrameHandler update object lifespan (again)
- Only OnFrameCreated provides a heap managed IFrame reference
  this should be sufficient to keep track of frames using a
  Dictionary in FrameHandler
- Xml doc updates
- Reorder IFrameHandler methods

Issue #3588
2021-09-03 20:41:48 +10:00
Alex Maitland 7937f78b6f Core - OnFrameCreated/OnFrameAttached/OnFrameDetached allocate IFrame on managed heap
- Previously they were stack allocated and disposed when out of scope, they're now managed heap allocated
  to allow for users to keep a long lived reference.

FrameHandler still needs to be updated to deal with Disposing of the references.

Follow up to #3757

Issue #3588
2021-09-03 20:21:22 +10:00
campersau 8d98043000 Core - Add IFrameHandler (#3757)
* Core - Add IFrameHandler/FrameHandler
* Update comments
2021-09-03 20:13:42 +10:00
Alex Maitland a18637facd C++/CLI - Replace NULL with nullptr
Issue #3636
2021-07-31 15:52:56 +10:00
Alex Maitland d5702be495 Core - ClientAdapter::OnProcessMessageReceived add nullptr checks
Follow up to https://github.com/cefsharp/CefSharp/discussions/3573
2021-05-20 10:07:53 +10:00
Alex Maitland 1850f3e0af Core - IJavascriptCallback need additional null check in ClientAdapter::GetBrowserWrapper
IJavascriptCallbacks that are finalized after the browser has been Disposed
but before the IBrowserAdapter.IsDisposed is set might end up calling ClientAdapter::GetBrowserWrapper
which attempts to access _popupBrowsers which has been set to null already.
2021-05-10 15:34:11 +10:00
Alex Maitland 6601a66b75 Javascript Binding - ClientAdapter.MethodInvocationComplete NRE
Resolves #3443
2021-03-12 11:59:04 +10:00
Alex Maitland b72f36c648 Core - ClientAdapter.OnProcessMessageReceived additional null checks
I don't have a full stack trace or a means to reproduce the actual problem, to date there have been only two reported cases.
This is a speculative fix, adds some extra null checks and a dispose check. Basically being a little more defensive.

Some of the code is duplicated in the hopes of one day refactoring out so each message has a different method/class

Issue #3322
2021-01-04 15:03:59 +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