# HG changeset patch # User Jaroslav Tulach # Date 1358008501 -3600 # Node ID 742bb3f91603a8f1f5310c8f65dfd2d35a680a81 # Parent 1bdeeb77f5a3f292a0894462f90783f253c27e76 Support execution through browser on Windows diff -r 1bdeeb77f5a3 -r 742bb3f91603 launcher/src/main/java/org/apidesign/bck2brwsr/launcher/Bck2BrwsrLauncher.java --- a/launcher/src/main/java/org/apidesign/bck2brwsr/launcher/Bck2BrwsrLauncher.java Sat Jan 12 16:29:29 2013 +0100 +++ b/launcher/src/main/java/org/apidesign/bck2brwsr/launcher/Bck2BrwsrLauncher.java Sat Jan 12 17:35:01 2013 +0100 @@ -237,20 +237,14 @@ URI uri = new URI("http://localhost:" + port + page); LOG.log(Level.INFO, "Showing {0}", uri); -// try { -// Desktop.getDesktop().browse(uri); -// return null; -// } catch (UnsupportedOperationException ex) - { -// File dir = File.createTempFile("chrome", ".dir"); -// dir.delete(); -// dir.mkdirs(); -// String[] cmd = { -// "google-chrome", "--user-data-dir=" + dir, "--app=" + uri.toString() -// }; -// LOG.log(Level.INFO, "Launching {0}", Arrays.toString(cmd)); -// final Process process = Runtime.getRuntime().exec(cmd); -// return new Object[] { process, dir }; + if (cmd == null) { + try { + java.awt.Desktop.getDesktop().browse(uri); + LOG.log(Level.INFO, "Desktop.browse successfully finished"); + return null; + } catch (UnsupportedOperationException ex) { + LOG.log(Level.INFO, "Desktop.browse not supported", ex); + } } { String cmdName = cmd == null ? "xdg-open" : cmd; @@ -365,8 +359,13 @@ r = r.substring(1); } } - if (r.endsWith(".html") || r.endsWith(".xhtml")) { + if (r.endsWith(".html")) { response.setContentType("text/html"); + LOG.info("Content type text/html"); + } + if (r.endsWith(".xhtml")) { + response.setContentType("application/xhtml+xml"); + LOG.info("Content type application/xhtml+xml"); } OutputStream os = response.getOutputStream(); try (InputStream is = res.get(r)) {