2012-11-22 70 views
5

帮助!我使用GeckoFx-Windows-10.0-0.6浏览器和xulrunner-10.0.en-US.win32。 (Visual Studio 2010 c#)一切正常。但我需要清除所有的历史在Firefox中: 工具>>选项>>隐私壁虎清除缓存历史记录和Cookie

我觉得多么清晰的cookie超过Gecko.CookieManager.RemoveAll();

如何清除缓存,临时文件和历史?!

而当我初始化Gecko.Xpcom我无法清除文件夹"Gecko.Xpcom.ProfileDirectory"(其中缓存和cookie)的原因很明显。 Gecko.Xpcom.Shutdown()不利于


我发现了一种通过JavaScript来清洁饼干:

var cookieManager = Components.classes["@mozilla.org/cookiemanager;1"].getService(Components.interfa‌​ces.nsICookieManager); cookieManager.removeAll();

如何正确调用这个JS在C#中?

回答

4

要清除,您将需要查询的接口这样的饼干:

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<nsICookieManager>("@mozilla.org/cookiemanager;1"); 
     CookieMan = Xpcom.QueryInterface<nsICookieManager>(CookieMan); 
     CookieMan.RemoveAll(); 
    } 

缓存的访问安全或这样的运行brobably原因时被拒绝。 这意味着你需要找到一种方法来在程序关闭后删除这些文件夹等。 创建另一个应用程序来处理它。

1

为了什么它的价值,因为我看了一段时间这一点,GeckoFX 29至少历史遵循相同的模式:

nsIBrowserHistory historyMan = Xpcom.GetService<nsIBrowserHistory>(Gecko.Contracts.NavHistoryService); 
historyMan = Xpcom.QueryInterface<nsIBrowserHistory>(historyMan); 
historyMan.RemoveAllPages(); 

缓存没有被确认是正确的方法:

// 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());