Scriptable thisObj,
final Object[] args,
Function funObj) {
int len = args.length;
WindowWrapper ww = (WindowWrapper)thisObj;
final Window window = ww.window;
if (len < 3) {
throw Context.reportRuntimeError("invalid argument count");
}
RhinoInterpreter interp =
(RhinoInterpreter)window.getInterpreter();
final String uri = (String)Context.jsToJava(args[0], String.class);
final String content = (String)Context.jsToJava(args[1], String.class);
Window.URLResponseHandler urlHandler = null;
if (args[2] instanceof Function) {
urlHandler = new GetURLFunctionWrapper
(interp, (Function)args[2], ww);
} else {
urlHandler = new GetURLObjectWrapper
(interp, (NativeObject)args[2], ww);
}
final Window.URLResponseHandler fw = urlHandler;
AccessControlContext acc;
acc = interp.getAccessControlContext();
switch (len) {
case 3:
AccessController.doPrivileged(new PrivilegedAction() {
public Object run(){
window.postURL(uri, content, fw);
return null;
}
}, acc);
break;
case 4:
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
window.postURL
(uri, content, fw,
(String)Context.jsToJava(args[3], String.class));
return null;
}
}, acc);
break;
default:
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
window.postURL
(uri, content, fw,
(String)Context.jsToJava(args[3], String.class),
(String)Context.jsToJava(args[4], String.class));
return null;
}