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 browser history

Post Reply
Fvert
Posts: 19
Joined: Fri Oct 22, 2021 10:22 am

clear browser history

Post by Fvert »

Quick way to clear browser history without going into settings? Thanks in advance.
User avatar
salvadordf
Posts: 4563
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: clear browser history

Post by salvadordf »

Try calling TChromiumCore.ExecuteChromeCommand(IDC_CLEAR_BROWSING_DATA, CEF_WOD_CURRENT_TAB) or deleting the history database files before initializing CEF.
Fvert
Posts: 19
Joined: Fri Oct 22, 2021 10:22 am

Re: clear browser history

Post by Fvert »

salvadordf wrote: Thu Oct 31, 2024 10:04 am Try calling TChromiumCore.ExecuteChromeCommand(IDC_CLEAR_BROWSING_DATA, CEF_WOD_CURRENT_TAB) or deleting the history database files before initializing CEF.
calling TChromiumCore.ExecuteChromeCommand(IDC_CLEAR_BROWSING_DATA, CEF_WOD_CURRENT_TAB) chrome://settings/clearBrowserData opens and you need to press Delete data. It is not difficult for me to execute javascript, but is it possible to press it automatically?

Although this script doesn't work for some reason Chromium1.browser.MainFrame.ExecuteJavaScript('document.getElementById("clearButton").click();',Chromium1.browser.MainFrame.GetURL, 0);
User avatar
salvadordf
Posts: 4563
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: clear browser history

Post by salvadordf »

Do you want to clear the browser cache or only the navigation history?

As far as I know there are only a few ways to clear the navigation history :
  • calling TChromiumCore.ExecuteChromeCommand(IDC_CLEAR_BROWSING_DATA, CEF_WOD_CURRENT_TAB) or navigating to chrome://settings/clearBrowserData and then click on the "Delete data" button manually.
  • Executing the Page.resetNavigationHistory DevTools method to reset navigation history for the current page. https://chromedevtools.github.io/devtools-protocol/tot/Page/#method-resetNavigationHistory
  • Deleting the database files related to the navigation history before the CEF initialization.
However, if you want to clear the browser cache you can :
  • Call TChromiumCore.ClearCache
  • Call TChromiumCore.ClearDataForOrigin with custom "aStorageTypes" values.
  • Set GlobalCEFApp.DeleteCache to True before the GlobalCEFApp.StarMainProcess call.
Fvert
Posts: 19
Joined: Fri Oct 22, 2021 10:22 am

Re: clear browser history

Post by Fvert »

salvadordf wrote: Fri Nov 01, 2024 9:59 am Do you want to clear the browser cache or only the navigation history?
Very briefly, I want to clear the History cache file without unloading the browser. None of the methods above will clear it. TChromiumCore.ExecuteChromeCommand(IDC_CLEAR_BROWSING_DATA, CEF_WOD_CURRENT_TAB) - only opens options where you still need to click ‘Delete data’. Thanks for the reply.

The Cef forum answered like this, but I didn't understand anything https://www.magpcss.org/ceforum/viewtopic.php?f=6&t=20028
Last edited by Fvert on Fri Nov 01, 2024 10:18 am, edited 1 time in total.
User avatar
salvadordf
Posts: 4563
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: clear browser history

Post by salvadordf »

I'm sorry but CEF doesn't expose any method to clear the navigation history only.
The previous methods is all we have.
Post Reply