【问题标题】:How can I catch requests in mozswing?如何在 mozswing 中捕获请求?
【发布时间】:2010-05-02 22:56:43
【问题描述】:

我想在用户单击链接或提交表单时捕获 mozswing 发出的请求,以便永远不会建立套接字连接,我可以“自己”回答请求。

【问题讨论】:

  • 您好,您找到解决方案了吗?我也需要...

标签: java mozilla xpcom xulrunner


【解决方案1】:

我知道该怎么做。我希望这对某人有所帮助。

编辑:收听链接的最佳方式:

final ContentAdapter ca = moz.getChromeAdapter().getContentAdapter();

nsIURIContentListener mycl = new nsIURIContentListener() {
    public boolean onStartURIOpen(nsIURI aURI) {
        System.out.println(aURI.getHost() + aURI.getPath());
        return true;
    }
    public boolean doContent(String aContentType, boolean aIsContentPreferred, nsIRequest aRequest, nsIStreamListener[] aContentHandler) { 
        System.out.println("1");
        return ca.doContent(aContentType, aIsContentPreferred, aRequest, aContentHandler); 
    }
    public boolean isPreferred(String aContentType, String[] aDesiredContentType) { 
        System.out.println("2");
        return ca.isPreferred(aContentType, aDesiredContentType); 
    }
    public boolean canHandleContent(String aContentType, boolean aIsContentPreferred, String[] aDesiredContentType) { 
        System.out.println("3");
        return ca.canHandleContent(aContentType, aIsContentPreferred, aDesiredContentType); 
    }
    public nsISupports getLoadCookie() { 
        System.out.println("4");
        return ca.getLoadCookie(); 
    }
    public void setLoadCookie(nsISupports aLoadCookie) { 
        System.out.println("5");
        ca.setLoadCookie(aLoadCookie); 
    }
    public nsIURIContentListener getParentContentListener() { 
        System.out.println("6");
        return ca.getParentContentListener(); 
    }
    public void setParentContentListener(nsIURIContentListener aParentContentListener) { 
        System.out.println("7");
        ca.setParentContentListener(aParentContentListener); 
    }
    public nsISupports queryInterface(String uuid) { 
        System.out.println("8");
        return ca.queryInterface(uuid); 
    }
 };

 moz.getChromeAdapter().getWebBrowser().setParentURIContentListener(mycl);

【讨论】:

  • 这不是我想要的。我想捕获浏览器发出的请求,这样他们就不会碰到套接字,而是直接处理请求并回答它。我不确定这是否可行。这背后的想法是能够通过 webstart 部署基于 Web 的应用程序,而无需向用户请求特殊权限。
猜你喜欢
  • 2013-09-11
  • 2020-04-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多