diff --git a/src/java/net/i2p/i2pfirefox/I2PFirefox.java b/src/java/net/i2p/i2pfirefox/I2PFirefox.java index 7291b0a..f2a7f0d 100644 --- a/src/java/net/i2p/i2pfirefox/I2PFirefox.java +++ b/src/java/net/i2p/i2pfirefox/I2PFirefox.java @@ -332,7 +332,7 @@ public class I2PFirefox extends I2PCommonBrowser { } /** - * * Build a ProcessBuilder for the top Firefox binary and + * Build a ProcessBuilder for the top Firefox binary and * the default profile. Pass the --private-window flag to * open a private window. * @@ -353,6 +353,28 @@ public class I2PFirefox extends I2PCommonBrowser { return processBuilder(argList.toArray(new String[argList.size()])); } + /** + * Build a ProcessBuilder for the top Firefox binary and + * the default profile. Pass the --headless flag to open + * without a window. + * + * @param args the arguments to pass to the Firefox binary + * @return a ProcessBuilder for the top Firefox binary and + * the default profile. + */ + public ProcessBuilder headlessProcessBuilder(String[] args) { + ArrayList argList = new ArrayList(); + argList.add("--headless"); + if (args != null) { + if (args.length > 0) { + for (String arg : args) { + argList.add(arg); + } + } + } + return processBuilder(argList.toArray(new String[argList.size()])); + } + /** * Build a ProcessBuilder for the top Firefox binary and * the default profile, with a specific set of extended @@ -480,8 +502,21 @@ public class I2PFirefox extends I2PCommonBrowser { println("Rebuilt profile directory: " + profileDirectory); } } - if (validateProfileFirstRun(profileDirectory)) - return null; + if (validateProfileFirstRun(profileDirectory)) { + ProcessBuilder hpb = headlessProcessBuilder(url); + try { + Process hp = hpb.start(); + try { + int hev = hp.waitFor(); + println("Headless browser run completed, exit: " + hev); + } catch (InterruptedException e) { + println(e.toString()); + } + } catch (IOException e) { + println(e.toString()); + } + } + ProcessBuilder pb; if (privateWindow) { pb = privateProcessBuilder(url);