Page 1 of 1

clear browser history

Posted: Wed Oct 30, 2024 12:01 pm
by Fvert
Quick way to clear browser history without going into settings? Thanks in advance.

Re: clear browser history

Posted: Thu Oct 31, 2024 10:04 am
by salvadordf
Try calling TChromiumCore.ExecuteChromeCommand(IDC_CLEAR_BROWSING_DATA, CEF_WOD_CURRENT_TAB) or deleting the history database files before initializing CEF.

Re: clear browser history

Posted: Thu Oct 31, 2024 1:41 pm
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);

Re: clear browser history

Posted: Fri Nov 01, 2024 9:59 am
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.

Re: clear browser history

Posted: Fri Nov 01, 2024 10:13 am
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

Re: clear browser history

Posted: Fri Nov 01, 2024 10:17 am
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.