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.
If you find these projects useful please consider becoming a sponsor with Patreon, GitHub or Liberapay.

Clear cache, history and form data while application running

Hitman
Posts: 73
Joined: Sat May 20, 2017 11:08 am

Re: Clear cache, history and form data while application running

Post by Hitman »

Thanks Salvador!
i do very much appreciated.

Google wants to steal our privacy as much as possible, i therefore do not believe they would remove collecting data :cry:
I am filling forms with extremely sensitive data which needs to be cleared immediately the soon the user has left the system.

"Have you tried "Cache-Control: no-cache, no-store" or "Pragma: no-cache"? "
Since "no-cache" does not work, i will try the rest and let you know.

With best regards
User avatar
salvadordf
Posts: 4564
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Clear cache, history and form data while application running

Post by salvadordf »

This is an example of a simple form with an input using the "autocomplete=off" attribute and Chromium doesn't fill any data when you navigate back :
https://www.wufoo.com/html5/autocomplete-attribute/

Even if you show web pages made by third parties and you can't access those servers, you can add the "autocomplete=off" attribute to the form and input elements.

Take a look at the KioskOSRBrowser demo. It uses the GlobalCEFApp.OnFocusedNodeChanged event to check if the focused node needs a keyboard but you can modify that code to call node.SetElementAttribute('autocomplete', 'off');

Try adding that autocomplete attribute to the INPUT and the FORM elements. You can find the parent FORM calling node.getparent until you find a node with node.ElementTagName = 'form'
Hitman
Posts: 73
Joined: Sat May 20, 2017 11:08 am

Re: Clear cache, history and form data while application running

Post by Hitman »

Hi Salvador,
I have tried this ==> "Have you tried "Cache-Control: no-cache, no-store" or "Pragma: no-cache"? "
No success :(

Yes,
i have this "GlobalCEFApp.OnFocusedNodeChanged := GlobalCEFApp_OnFocusedNodeChanged;" in Kiosk demo but not sure how to use it :(

I am very close to give up because i simply see no benefit of using this browser as long as I cannot prevent cache.
User avatar
salvadordf
Posts: 4564
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Clear cache, history and form data while application running

Post by salvadordf »

Hitman wrote: Wed Dec 05, 2018 3:10 pm i have this "GlobalCEFApp.OnFocusedNodeChanged := GlobalCEFApp_OnFocusedNodeChanged;" in Kiosk demo but not sure how to use it :(
That event is executed in the render process and the KioskOSRBrowser demo uses it to detect if the focused DOM node is a form element that edits text.

GlobalCEFApp_OnFocusedNodeChanged sends a message to the browser process to show or hide the virtual keyboard depending on the node type.
Hitman wrote: Wed Dec 05, 2018 3:10 pm I am very close to give up because i simply see no benefit of using this browser as long as I cannot prevent cache.
I'm sorry to hear that.
Hitman
Posts: 73
Joined: Sat May 20, 2017 11:08 am

Re: Clear cache, history and form data while application running

Post by Hitman »

Is it so that there are no options for clearing/preventing cache?

I still do not understand how this is supposed to be used,
"Take a look at the KioskOSRBrowser demo. It uses the GlobalCEFApp.OnFocusedNodeChanged event to check if the focused node needs a keyboard but you can modify that code to call node.SetElementAttribute('autocomplete', 'off')"
How do i use this?
will it prevent the cache and history?
The idea is to prevent showing anything that was typed previously or stored previously.
User avatar
salvadordf
Posts: 4564
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Clear cache, history and form data while application running

Post by salvadordf »

After reading this thread again I think there might be an easier way to reset the form data.

Please, use the TChromium.OnLoadEnd to execute JavaScript code to reset the form data using this method :
https://www.w3schools.com/jsref/met_form_reset.asp

Perhaps you can use TChromium.OnLoadingProgressChange to reset the form even before the document is fully loaded.

If calling "reset()" doesn't work as desired you can also clear the INPUT element values using JavaScript.
Hitman
Posts: 73
Joined: Sat May 20, 2017 11:08 am

Re: Clear cache, history and form data while application running

Post by Hitman »

salvadordf wrote: Fri Dec 07, 2018 4:18 pm After reading this thread again I think there might be an easier way to reset the form data.

Please, use the TChromium.OnLoadEnd to execute JavaScript code to reset the form data using this method :
https://www.w3schools.com/jsref/met_form_reset.asp

Perhaps you can use TChromium.OnLoadingProgressChange to reset the form even before the document is fully loaded.

If calling "reset()" doesn't work as desired you can also clear the INPUT element values using JavaScript.
Yes,
this sounds good but,
first,
it is not possible for me to find out the name of the form which is mentioned as "MyForm" in the link you have provided. I simply have no clue of what are the forms that i need to clear. I am filling up web forms with security sensitive data which means i have to empty the forms before the next user starts using the system.
Second,
How do i exactly run java script TChromium.OnLoadEnd or TChromium.OnLoadingProgressChange without using TWebBrowser?
I might sound completely idiot because i have never done this before and have no clue of how to do it.
In Delphi documentations, they are all talking about TWebBrowser which in this case we do not have.
If you have any ideas of how to run the code without using TWebBrowser, please let me know!

My suggestion would be,
to add a feature to the TChromium component which will do this and could be something like "ClearCache", "ClearHistory" or whatever you may call it.
User avatar
salvadordf
Posts: 4564
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Clear cache, history and form data while application running

Post by salvadordf »

Hitman wrote: Sun Dec 09, 2018 10:28 am it is not possible for me to find out the name of the form which is mentioned as "MyForm" in the link you have provided. I simply have no clue of what are the forms that i need to clear. I am filling up web forms with security sensitive data which means i have to empty the forms before the next user starts using the system.
Use document.getElementsByTagName("form") to get all the elements with the "form" tag name.
https://www.w3schools.com/jsref/met_doc ... agname.asp
Hitman wrote: Sun Dec 09, 2018 10:28 am How do i exactly run java script TChromium.OnLoadEnd or TChromium.OnLoadingProgressChange without using TWebBrowser?
I might sound completely idiot because i have never done this before and have no clue of how to do it.
In Delphi documentations, they are all talking about TWebBrowser which in this case we do not have.
If you have any ideas of how to run the code without using TWebBrowser, please let me know!
You don't need TWebBrowser to execute JavaScript with CEF4Delphi.
The Delphi documentation mentions TWebBrowser because it's one of the components included in Delphi, while CEF4Delphi is not included.

The MiniBrowser demo and several other demos execute JavaScript code. You can call TChromium.ExecuteJavaScript directly or ICefFrame.ExecuteJavaScript if a frame parameter is available.

You would need something like this to show an alert box each time the TChromium.OnLoadEnd is called :

Code: Select all

procedure TMiniBrowserFrm.Chromium1LoadEnd(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; httpStatusCode: Integer);
begin
  frame.ExecuteJavaScript('alert(' + chr(39) + 'Load End' + chr(39) + ');', 'about:blank', 0);
end;
Read this to know more details about the "ExecuteJavaScript" funtion :
https://magpcss.org/ceforum/apidocs3/pr ... ring&,int)
Hitman wrote: Sun Dec 09, 2018 10:28 am My suggestion would be,
to add a feature to the TChromium component which will do this and could be something like "ClearCache", "ClearHistory" or whatever you may call it.
CEF4Delphi is just a CEF3 wrapper and it can only do what CEF3 allows it to do.
If you need that functionality you can create a pull request in the CEF3 project or suggest it as a new CEF3 feature.
Hitman
Posts: 73
Joined: Sat May 20, 2017 11:08 am

Re: Clear cache, history and form data while application running

Post by Hitman »

Salvador,
i have just sent you a private message, could you please check it?

BTW,
if i exit my app and restart it, the history and cache is gone.
The idea is to be able to do it without exiting the application.
Hitman
Posts: 73
Joined: Sat May 20, 2017 11:08 am

Re: Clear cache, history and form data while application running

Post by Hitman »

Just one more thing,
I have regular chrome in my machine,
if i use the same links and fill the forms, after filling them then just clear the chrome history, the content of the forms is no longer shown.

So,
what i need to understand is,
how come Chrome does clear the history but DCEF can't?

And why the history does no longer exist after restarting my app?
I would say the reason is, because there is no history stored in my pc which is of course the purpose.

During the use,
the history is always there, reloading the same page still keeps the history.
How do i clear the history when i reload the page with out terminating my application?

Here is the sample:
I am navigating to page x when my application starts, i fill the form in page x and leave the page for a while to refresh itself because i have a timer which does refresh the page if page is inactive for 3 minutes. After 3 minutes, the page is refreshed but the data i have inserted is still there.

Now,
please help me out to prevent browser loading this history after refreshing it.
Please also keep in mind!!
the page i am inserting text has forms that are not shown with any tag names to search for, it is very complicated system which means it is impossible to find any forms by tag or anything else in order to be able to clear em up.
I need to clear the history of the browser while refreshing just like i do in Chrome. I can clear the history of chrome without closing it and refresh the page, after the refresh, the history isn't there anymore.

I still believe we can clear the history of TChromium while refreshing but the problem is, i do not know how :cry: :cry:

One more thing,
if i just use google in my application, make couple of searches and visit the results of the search, after the refresh, everything is there too :cry: :cry:
It is not just the forms keeping the history data.

How about,
freeing the component and recreating it during the refresh, in order to make sure history is not there?
If this is possible,
can you please tell how do i free the running TChromium and create a new one?
Post Reply