Scriptable thisObj,
final Object[] args,
Function funObj)
throws JavaScriptException {
int len = args.length;
final Window window = ((RhinoInterpreter.ExtendedContext)cx).getWindow();
final ScriptableObject go = ((RhinoInterpreter.ExtendedContext)cx).getGlobalObject();
if (len < 2) {
throw Context.reportRuntimeError("invalid argument count");
}
RhinoInterpreter interp =
(RhinoInterpreter)window.getInterpreter();
final String uri = (String)Context.toType(args[0], String.class);
Window.GetURLHandler urlHandler = null;
if (args[1] instanceof Function) {
urlHandler = new GetURLFunctionWrapper
(interp, (Function)args[1], go);
} else {
urlHandler = new GetURLObjectWrapper
(interp, (NativeObject)args[1], go);
}
final Window.GetURLHandler fw = urlHandler;
AccessControlContext acc =
((RhinoInterpreter)window.getInterpreter()).getAccessControlContext();
if (len == 2) {
AccessController.doPrivileged(new PrivilegedAction() {
public Object run(){
window.getURL(uri, fw);
return null;
}
}, acc);
} else {
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
window.getURL
(uri, fw,
(String)Context.toType(args[2], String.class));
return null;
}
}, acc);