gecko清除缓存历史记录和Cookie
救命! 我使用GeckoFx-Windows-10.0-0.6浏览器和xulrunner-10.0.en-US.win32 。 (Visual Studio 2010 c#)一切正常。 但我需要清除所有历史记录,如Firefox:工具>>选项>>隐私
我发现Gecko.CookieManager.RemoveAll();
cookie是多么清晰Gecko.CookieManager.RemoveAll();
如何清除缓存,临时文件和历史记录?!
当我初始化Gecko.Xpcom
我无法清除文件夹"Gecko.Xpcom.ProfileDirectory"
(缓存和cookie),原因很明显。 Gecko.Xpcom.Shutdown()
没有帮助
我找到了一种通过javascript清理cookie的方法:
var cookieManager = Components.classes["@mozilla.org/cookiemanager;1"].getService(Components.interfaces.nsICookieManager); cookieManager.removeAll();
如何在C#中调用这个JS?
要清除cookie,您需要查询以下界面:
if (MessageBox.Show("Do you want to delete cookies?", "About to delete all cookies", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { nsICookieManager CookieMan; CookieMan = Xpcom.GetService("@mozilla.org/cookiemanager;1"); CookieMan = Xpcom.QueryInterface (CookieMan); CookieMan.RemoveAll(); }
在运行时期间拒绝访问缓存可能导致安全性等。 这意味着您需要在程序关闭后找到删除这些文件夹的方法等。创建另一个应用程序来处理它。
为了它的价值和我看了一段时间,在GeckoFX 29上至少历史遵循相同的模式:
nsIBrowserHistory historyMan = Xpcom.GetService(Gecko.Contracts.NavHistoryService); historyMan = Xpcom.QueryInterface (historyMan); historyMan.RemoveAllPages();
对于Cache而不确定是否正确:
// https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/imgICache Gecko.Cache.ImageCache.ClearCache(true); Gecko.Cache.ImageCache.ClearCache(false); // Defaults to all devices(0) - https://bitbucket.org/geckofx/geckofx-9.0/issue/7/idl-translation-bug-for-enums Gecko.Cache.CacheService.Clear(new CacheStoragePolicy());