35
35
class Edge extends WebBrowser {
36
36
static {
37
37
Library .loadLibrary ("WebView2Loader" );
38
+ setupLocationForCustomTextPage ();
38
39
}
39
40
40
41
// WebView2Loader.dll compatible version. This is NOT the minimal required version.
@@ -57,7 +58,7 @@ class Edge extends WebBrowser {
57
58
* by Edge browser to navigate to for setting html content in the
58
59
* DOM of the browser to enable it to load local resources.
59
60
*/
60
- private static final URI URI_FOR_CUSTOM_TEXT_PAGE = setupAndGetLocationForCustomTextPage () ;
61
+ static URI URI_FOR_CUSTOM_TEXT_PAGE ;
61
62
private static final String ABOUT_BLANK = "about:blank" ;
62
63
63
64
private static final int MAXIMUM_CREATION_RETRIES = 5 ;
@@ -195,16 +196,14 @@ private static record CursorPosition(Point location, boolean isInsideBrowser) {}
195
196
};
196
197
}
197
198
198
- private static URI setupAndGetLocationForCustomTextPage () {
199
- URI absolutePath ;
199
+ static void setupLocationForCustomTextPage () {
200
200
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 () );
203
203
tempFile .toFile ().deleteOnExit ();
204
204
} catch (IOException e ) {
205
- absolutePath = URI .create (ABOUT_BLANK );
205
+ URI_FOR_CUSTOM_TEXT_PAGE = URI .create (ABOUT_BLANK );
206
206
}
207
- return absolutePath ;
208
207
}
209
208
210
209
static String wstrToString (long psz , boolean free ) {
@@ -1487,7 +1486,7 @@ public void stop() {
1487
1486
webViewProvider .scheduleWebViewTask (() -> webViewProvider .getWebView (false ).Stop ());
1488
1487
}
1489
1488
1490
- private boolean isLocationForCustomText (String location ) {
1489
+ static boolean isLocationForCustomText (String location ) {
1491
1490
try {
1492
1491
return URI_FOR_CUSTOM_TEXT_PAGE .equals (new URI (location ));
1493
1492
} catch (URISyntaxException e ) {
@@ -1497,7 +1496,7 @@ private boolean isLocationForCustomText(String location) {
1497
1496
1498
1497
@ Override
1499
1498
public 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 );
1501
1500
}
1502
1501
1503
1502
private boolean setWebpageData (String url , String postData , String [] headers , String html ) {
0 commit comments