The standalone cache feature of the FMX version of FMXTabbedBrowser is not working.
chenzhifeng0025 opened this issue · 5 comments
In the FMX version of the FMXTabbedBrowser project, modify the code in the procedure TBrowserFrame.CreateBrowser; in the uBrowserFrame unit to:
var TempCache := GlobalCEFApp.RootCache + '\cache' + inttostr(1);
var TempContext := TCefRequestContextRef.New(TempCache, '', '', False, False, True);
FMXChromium1.CreateBrowser(TempHandle, TempRect, '', TempContext);This is intended to enable the browser to save the account and password information. However, it does not work as expected. Upon restarting the browser, it still requires entering the account and password again. This code works properly in the VCL version.
With the above code, it does create a separate cache directory, but it should remember the username and password. Am I doing something wrong? Is there anything that needs to be corrected?
It should be noted that you need to comment out this line of code: // GlobalCEFApp.cache := 'cache';
Copy the code that creates the child browsers in the MDIBrowser demo and it should work the same.
Assigning a new request context allows you to create independent browsers that store the cache, cookies, etc in a different directory for that browser.
Please, for more questions use our forum :
https://www.briskbard.com/forum/
The code above is from MDIBrowser and has been tested many times without success. Have you tested this feature in FMX? Isn't the code above the same as in MDIBrowser? Could you please check this FMX demo?
I reviewed the code repeatedly, and the final code is as follows:
procedure TBrowserFrame.CreateBrowser;
var
{$IFDEF MSWINDOWS}
TempHandle: HWND;
TempRect: System.Types.TRect;
TempClientRect: TRectF;
TempScale: single;
{$ENDIF}
begin
CreateFMXWindowParent;
if not (FMXChromium1.Initialized) then
begin
{$IFDEF MSWINDOWS}
TempHandle := FmxHandleToHWND(FMXWindowParent.Handle);
TempClientRect := FMXWindowParent.ClientRect;
TempScale := FMXChromium1.ScreenScale;
TempRect.Left := round(TempClientRect.Left);
TempRect.Top := round(TempClientRect.Top);
TempRect.Right := round(TempClientRect.Right * TempScale);
TempRect.Bottom := round(TempClientRect.Bottom * TempScale);
FMXChromium1.DefaultUrl := FHomepage;
var TempCache := GlobalCEFApp.RootCache + '\cache' + inttostr(1);
var TempContext := TCefRequestContextRef.New(TempCache, '', '', False, True, False, FMXChromium1.ReqContextHandler);
FMXChromium1.CreateBrowser(TempHandle, TempRect, '', TempContext);
// FMXChromium1.CreateBrowser(TempHandle, TempRect);
{$ENDIF}
end;
end;This code still doesn't work. I believe there might be a bug in your FMX version. Could you please test it personally?
This is the modified code attachment.
The issue with the non-persistent feature has been resolved. I used the following code:
var TempCache := 'D:\cache2';
var TempContext := TCefRequestContextRef.New(TempCache, '', '', False, False, False, FMXChromium1.ReqContextHandler);
FMXChromium1.CreateBrowser(TempHandle, TempRect, '', TempContext);The problem was that GlobalCEFApp.RootCache was empty, so I needed to set an absolute path. However, a serious issue has now arisen: after setting the directory, the entire page becomes extremely sluggish—so much so that even entering a password is very slow, making it almost impossible to work. The video below demonstrates the entire process (the project works normally when the path is empty, with the rest of the code unchanged).
Attached is the recorded video file.