gecko clear cache history & cookies

我们两清 提交于 2019-12-03 08:03:44

To clear cookies you will need to query interface like this:

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

An access to cache is denied during runtime brobably cause of security or such. Meaning you will need to find a way to delete these folders after you program closes etc. create another app for handling it.

For what its worth and since I looked a while for this, on GeckoFX 29 at least history follows the same pattern:

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

For Cache without being sure is the correct way:

// 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());
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!