ICefBrowser is available in TChromium.Browser and many TChromium events have a "browser" parameter. TChromium.Browser is valid if TChromium.Initialized is True which means that you can use that property until you destroy the TChromium component.
ICefFrame has a much shorter lifespan because it depends on the loaded document. Many TChromium events have a "frame" parameter that can be used in the scope of that event but if you assign it to a variable and the document changes or you try to close your app, it may be the cause of problems because that frame is not destroyed until you set that variable to nil.
Many CEF3 classes are reference counted and Henri Gourvest adapted those classes to Delphi interfaces in DCEF3. CEF4Delphi inherited that code and you should use those interfaces the same way you use regular Delphi interfaces.
The most important tip I would give is : Don't increment the reference count unless you really have to.
That means :
- Use the event parameters.
- Always pass them as "const" or "var" to other procedures.
- If possible, use local variables to store those interfaces.
- If you use class fields to store those interfaces, always set them to NIL when you no longer use them or before you destroy that object.
Read the comments about the Host interface (cef_browser_host_t) here :
https://bitbucket.org/chromiumembedded/ ... ew-default
Code: Select all
///
// Structure used to represent the browser process aspects of a browser window.
// The functions of this structure can only be called in the browser process.
// They may be called on any thread in that process unless otherwise indicated
// in the comments.
///
Code: Select all
///
// Send a key event to the browser.
///