`
ljl_xyf
  • 浏览: 617888 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

在XULRunner中获得Cookie

阅读更多

最近在看browser嵌入,找到XULRunner,
http://developer.mozilla.org/cn/docs/%E5%88%9B%E5%BB%BA_XPCOM_%E7%BB%84%E4%BB%B6:%E4%BD%BF%E7%94%A8_XPCOM_%E7%BB%84%E4%BB%B6
创建 XPCOM 组件:使用 XPCOM 组件

http://developer.mozilla.org/en/docs/nsICookieManager
nsICookieManager

如何获得Cookie?
http://dev.eclipse.org/newslists/news.eclipse.platform.swt/msg37871.html


Well I got it working, I think I was passing in the wrong ID. Here is the code if anyone else has this problem.

nsIServiceManager serviceManager = Mozilla.getInstance().getServiceManager();
nsICookieManager cookieManager = (nsICookieManager) serviceManager.getServiceByContractID("@mozilla.org/cookiemanager;1", nsICookieManager.NS_ICOOKIEMANAGER_IID);

nsISimpleEnumerator cookieEnumerator = cookieManager.getEnumerator();

while (cookieEnumerator.hasMoreElements()) {
// Not sure how to get the nsICookie Object. 400
nsICookie cookie = (nsICookie)cookieEnumerator.getNext().queryInterface(nsICookie.NS_ICOOKIE_IID);
System.out.println(cookie.getName());
System.out.println(cookie.getHost());
}

If anyone has a place to gather more information for using the JavaXPCOM other than the XUL Planet site I would love to know.

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics