Skip to content

Commit 636b5e3

Browse files
amartya4256fedejeanne
authored andcommitted
Allow to configure Edge userdata directory via Display data
With this contribution, a custom userdata directory can provided to Edge browser via its Display for the separation of the usage of userdata directory per application by the webview2Environment. contributes to #1013
1 parent 69d16e9 commit 636b5e3

File tree

1 file changed

+14
-5
lines changed
  • bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser

1 file changed

+14
-5
lines changed

bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/Edge.java

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ class Edge extends WebBrowser {
3939
static final String SDK_TARGET_VERSION = "99.0.1150.38";
4040

4141
// Display.getData() keys
42+
static final String EDGE_USER_DATA_FOLDER = "org.eclipse.swt.internal.win32.edgeUserDataFolder";
4243
static final String APPLOCAL_DIR_KEY = "org.eclipse.swt.internal.win32.appLocalDir";
4344
static final String EDGE_USE_DARK_PREFERED_COLOR_SCHEME = "org.eclipse.swt.internal.win32.Edge.useDarkPreferedColorScheme"; //$NON-NLS-1$
4445

@@ -473,13 +474,9 @@ WebViewEnvironment createEnvironment() {
473474

474475
// Gather customization properties
475476
String browserDir = System.getProperty(BROWSER_DIR_PROP);
476-
String dataDir = System.getProperty(DATA_DIR_PROP);
477477
String browserArgs = System.getProperty(BROWSER_ARGS_PROP);
478478
String language = System.getProperty(LANGUAGE_PROP);
479-
if (dataDir == null) {
480-
// WebView2 will append "\\EBWebView"
481-
dataDir = (String)display.getData(APPLOCAL_DIR_KEY);
482-
}
479+
String dataDir = getDataDir(display);
483480

484481
// Initialize options
485482
long pOpts = COM.CreateSwtWebView2Options();
@@ -529,6 +526,18 @@ WebViewEnvironment createEnvironment() {
529526
return environmentWrapper;
530527
}
531528

529+
private String getDataDir(Display display) {
530+
String dataDir = System.getProperty(DATA_DIR_PROP);
531+
if (dataDir == null) {
532+
dataDir = (String) display.getData(EDGE_USER_DATA_FOLDER);
533+
}
534+
if (dataDir == null) {
535+
// WebView2 will append "\\EBWebView"
536+
dataDir = (String)display.getData(APPLOCAL_DIR_KEY);
537+
}
538+
return dataDir;
539+
}
540+
532541
@Override
533542
public void create(Composite parent, int style) {
534543
containingEnvironment = createEnvironment();

0 commit comments

Comments
 (0)