You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by ma...@apache.org on 2019/12/24 08:46:26 UTC

[netbeans] branch master updated: [NETBEANS-3249] Chrome connector connection with NetBeans

This is an automated email from the ASF dual-hosted git repository.

matthiasblaesing pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/netbeans.git


The following commit(s) were added to refs/heads/master by this push:
     new e695da2  [NETBEANS-3249] Chrome connector connection with NetBeans
     new e7bc45a  Merge pull request #1803 from matthiasblaesing/NETBEANS-3249
e695da2 is described below

commit e695da29c7030e07ffe5ce8872ed104e303b67df
Author: Matthias Bläsing <mb...@doppel-helix.eu>
AuthorDate: Sat Dec 21 18:26:52 2019 +0100

    [NETBEANS-3249] Chrome connector connection with NetBeans
    
    The call to toRealPath ensures, that symlinks are resolved. It was
    observed, that chrome on macOS reports the file url with symlinks
    resolved, so align with that.
---
 .../extbrowser/chrome/ChromeBrowserImpl.java       | 29 +++++++++++++++-------
 1 file changed, 20 insertions(+), 9 deletions(-)

diff --git a/webcommon/extbrowser.chrome/src/org/netbeans/modules/extbrowser/chrome/ChromeBrowserImpl.java b/webcommon/extbrowser.chrome/src/org/netbeans/modules/extbrowser/chrome/ChromeBrowserImpl.java
index c35af38..952bd9c 100644
--- a/webcommon/extbrowser.chrome/src/org/netbeans/modules/extbrowser/chrome/ChromeBrowserImpl.java
+++ b/webcommon/extbrowser.chrome/src/org/netbeans/modules/extbrowser/chrome/ChromeBrowserImpl.java
@@ -21,13 +21,18 @@ package org.netbeans.modules.extbrowser.chrome;
 
 import java.beans.PropertyChangeListener;
 import java.beans.PropertyChangeSupport;
-import java.io.File;
-import java.io.FileWriter;
 import java.io.IOException;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
 import java.net.MalformedURLException;
 import java.net.URL;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 import org.netbeans.modules.extbrowser.ExtBrowserImpl;
 import org.netbeans.modules.extbrowser.PrivateBrowserFamilyId;
 import org.netbeans.modules.extbrowser.plugins.*;
@@ -54,6 +59,8 @@ import org.openide.util.lookup.ProxyLookup;
  */
 public class ChromeBrowserImpl extends HtmlBrowser.Impl implements EnhancedBrowser {
 
+    private static final Logger LOG = Logger.getLogger(ChromeBrowserImpl.class.getName());
+
     /** Lookup of this {@code HtmlBrowser.Impl}.  */
     private Lookup lookup;
 
@@ -295,16 +302,20 @@ public class ChromeBrowserImpl extends HtmlBrowser.Impl implements EnhancedBrows
         }
         this.url = url;
     }
-    
+
     private URL createBlankHTMLPage() {
         try {
-            File f = File.createTempFile("blank", ".html");
-            FileWriter fw = new FileWriter(f);
-            fw.write("<html :netbeans_temporary=\"true\"></html>");
-            fw.close();
-            return f.toURI().toURL();
+            Path tempPath = Files.createTempFile("blank", ".html");
+            try(OutputStream os = Files.newOutputStream(tempPath);
+                OutputStreamWriter osw = new OutputStreamWriter(os, StandardCharsets.UTF_8)) {
+                osw.write("<html :netbeans_temporary=\"true\"></html>");
+            }
+            // The call to toRealPath ensures, that symlinks are resolved. It
+            // was observed, that chrome on macOS reports the file url with
+            // symlinks resolved, so align with that.
+            return tempPath.toRealPath().toUri().toURL();
         } catch (IOException ex) {
-            Exceptions.printStackTrace(ex);
+            LOG.log(Level.INFO, "Failed to create blank page for chrome", ex);
         }
         return null;
     }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@netbeans.apache.org
For additional commands, e-mail: commits-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists