Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.
How to navigate using incognito ?
-
- Posts: 513
- Joined: Thu Aug 10, 2017 12:40 pm
How to navigate using incognito ?
Hello,
Let's say my TChromium instance is logged in a website. Is there a way to navigate to this same website, but in incognito mode ? And better yet, when navigate again, return to normal mode and still, logged in the same website ?
Thanks !
Let's say my TChromium instance is logged in a website. Is there a way to navigate to this same website, but in incognito mode ? And better yet, when navigate again, return to normal mode and still, logged in the same website ?
Thanks !
- salvadordf
- Posts: 4565
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: How to navigate using incognito ?
Yes, you can do that.
All you need to navigate in incognito mode is to use a different request context without specifying a cache directory and that's what the MDIBrowser demo does when you check the "Create a new request context for new browsers" checkbox.
Follow these steps :
All you need to navigate in incognito mode is to use a different request context without specifying a cache directory and that's what the MDIBrowser demo does when you check the "Create a new request context for new browsers" checkbox.
Follow these steps :
- Add a valid directory to GlobalCEFApp.cache in the MDIBrowser demo.
- Run the MDIBrowser demo and create a new child form without a check the "Create a new request context for new browsers" checkbox.
- Login into that website.
- Check the "Create a new request context for new browsers" checkbox and create a second child form. This new form will be independent from the first one and you would have to login again if you navigate to that website.
- UnCheck the "Create a new request context for new browsers" checkbox and create a third child form. The 3rd form will share the same request context with the 1st form and it's logged in into that website with the credentials you used in the 1st form.
-
- Posts: 513
- Joined: Thu Aug 10, 2017 12:40 pm
Re: How to navigate using incognito ?
Sounds great , that's just what i'm looking for.
However i'm on Delphi 2007 and can't open the MDIBrowser demo ; so i tried to implement the same code on my app.
For some reason, when i run the code below :
My app starts, but as soon as TChromium is created, Delphi goes to the CPU window and thrown an exception :
Project test.exe faulted with message : 'system exception (code 0xc000001d) at 0x626a55e1'. Process stoped. Use step or run to continue'
Seems like something is missing but i can't see further details. Any hints ?
In my app i'm not putting the new TChromium in a new form, is this needed ? The new TChromium is on the same form of the 'normal' one.
Thank you !
However i'm on Delphi 2007 and can't open the MDIBrowser demo ; so i tried to implement the same code on my app.
For some reason, when i run the code below :
Code: Select all
windowParent := TCEFWindowParent.Create(parent);
TempContext := TCefRequestContextRef.New('', '', False, False, False, False);
CreateBrowser(windowParent,'',TempContext);
// before was
// CreateBrowser(windowParent);
Project test.exe faulted with message : 'system exception (code 0xc000001d) at 0x626a55e1'. Process stoped. Use step or run to continue'
Seems like something is missing but i can't see further details. Any hints ?

In my app i'm not putting the new TChromium in a new form, is this needed ? The new TChromium is on the same form of the 'normal' one.
Thank you !
- salvadordf
- Posts: 4565
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: How to navigate using incognito ?
Some old Delphi versions have issues with the lifetime of interfaces. Add a "try..finally" block like this :
You can have the new TChromium wherever you want.
Code: Select all
procedure TChildForm.FormShow(Sender: TObject);
var
TempContext : ICefRequestContext;
begin
try
if MainForm.NewContextChk.Checked then
TempContext := TCefRequestContextRef.New('', '', False, False, False, False)
else
TempContext := nil;
Chromium1.CreateBrowser(CEFWindowParent1, '', TempContext);
finally
TempContext := nil;
end;
end;
-
- Posts: 513
- Joined: Thu Aug 10, 2017 12:40 pm
Re: How to navigate using incognito ?
Did it, same crash
With TempContext = nil , no error. Otherwise, a crash occurs...


With TempContext = nil , no error. Otherwise, a crash occurs...

- salvadordf
- Posts: 4565
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: How to navigate using incognito ?
I don't have a Delphi 2007 license and I can't test this but in similar cases this is fixed using the interface one last time after the procedure call where it's used. That's why I suggested the "try..finally" block where you set the interface to nil.
In some other cases you also need to remove all the calls to "CefGetData". Please, try replacing the TChromium.CreateBrowserHost function in uCEFChromium.pas with this code :
In some other cases you also need to remove all the calls to "CefGetData". Please, try replacing the TChromium.CreateBrowserHost function in uCEFChromium.pas with this code :
Code: Select all
function TChromium.CreateBrowserHost( aWindowInfo : PCefWindowInfo;
const aURL : ustring;
const aSettings : PCefBrowserSettings;
const aExtraInfo : ICefDictionaryValue;
const aContext : ICefRequestContext): boolean;
var
TempURL : TCefString;
TempContext, TempInfo : Pointer;
begin
TempURL := CefString(aURL);
if (aContext <> nil) then
TempContext := aContext.Wrap
else
TempContext := nil;
if (aExtraInfo <> nil) then
TempInfo := aExtraInfo.Wrap
else
TempInfo := nil;
Result := cef_browser_host_create_browser(aWindowInfo, FHandler.Wrap, @TempURL, aSettings, TempInfo, TempContext) <> 0;
end;
-
- Posts: 513
- Joined: Thu Aug 10, 2017 12:40 pm
Re: How to navigate using incognito ?
It seems the problem is something related with my app... when i create only one instance of TChromium (with or not Tempcontext <>nil), it won't crash. When i create multiple instances, the crash occurs.
I'm trying to debug and find out. So far, thank you !
I'm trying to debug and find out. So far, thank you !
- salvadordf
- Posts: 4565
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: How to navigate using incognito ?
Read this too :
https://www.briskbard.com/forum/viewtop ... 4095#p4095
If you use several cache directories you need to set a common parent directory in GlobalCEFApp.RootCache.
https://www.briskbard.com/forum/viewtop ... 4095#p4095
If you use several cache directories you need to set a common parent directory in GlobalCEFApp.RootCache.