3535class Edge extends WebBrowser {
3636 static {
3737 Library .loadLibrary ("WebView2Loader" );
38+ setupLocationForCustomTextPage ();
3839 }
3940
4041 // WebView2Loader.dll compatible version. This is NOT the minimal required version.
@@ -57,7 +58,7 @@ class Edge extends WebBrowser {
5758 * by Edge browser to navigate to for setting html content in the
5859 * DOM of the browser to enable it to load local resources.
5960 */
60- private static final URI URI_FOR_CUSTOM_TEXT_PAGE = setupAndGetLocationForCustomTextPage () ;
61+ static URI URI_FOR_CUSTOM_TEXT_PAGE ;
6162 private static final String ABOUT_BLANK = "about:blank" ;
6263
6364 private static final int MAXIMUM_CREATION_RETRIES = 5 ;
@@ -195,16 +196,14 @@ private static record CursorPosition(Point location, boolean isInsideBrowser) {}
195196 };
196197 }
197198
198- private static URI setupAndGetLocationForCustomTextPage () {
199- URI absolutePath ;
199+ static void setupLocationForCustomTextPage () {
200200 try {
201- Path tempFile = Files .createTempFile ("base" , ".html" );
202- absolutePath = tempFile .toUri ();
201+ Path tempFile = Files .createTempFile (Path . of ( System . getProperty ( "java.io.tmpdir" )), "base" , ".html" );
202+ URI_FOR_CUSTOM_TEXT_PAGE = URI . create ( tempFile .toUri (). toASCIIString () );
203203 tempFile .toFile ().deleteOnExit ();
204204 } catch (IOException e ) {
205- absolutePath = URI .create (ABOUT_BLANK );
205+ URI_FOR_CUSTOM_TEXT_PAGE = URI .create (ABOUT_BLANK );
206206 }
207- return absolutePath ;
208207}
209208
210209static String wstrToString (long psz , boolean free ) {
@@ -1487,7 +1486,7 @@ public void stop() {
14871486 webViewProvider .scheduleWebViewTask (() -> webViewProvider .getWebView (false ).Stop ());
14881487}
14891488
1490- private boolean isLocationForCustomText (String location ) {
1489+ static boolean isLocationForCustomText (String location ) {
14911490 try {
14921491 return URI_FOR_CUSTOM_TEXT_PAGE .equals (new URI (location ));
14931492 } catch (URISyntaxException e ) {
@@ -1497,7 +1496,7 @@ private boolean isLocationForCustomText(String location) {
14971496
14981497@ Override
14991498public boolean setText (String html , boolean trusted ) {
1500- return setWebpageData (URI_FOR_CUSTOM_TEXT_PAGE .toASCIIString (), null , null , html );
1499+ return setWebpageData (URI_FOR_CUSTOM_TEXT_PAGE .toString (), null , null , html );
15011500}
15021501
15031502private boolean setWebpageData (String url , String postData , String [] headers , String html ) {
0 commit comments