我想在用户单击链接或提交表单时捕获 mozswing 发出的请求,以便永远不会建立套接字连接,我可以“自己”回答请求。
问问题
344 次
1 回答
2
我发现了该怎么做。我希望这对某人有所帮助。
编辑:收听链接的最佳方式:
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);
于 2011-03-03T14:06:51.417 回答