Skip to content

Commit 435fe7e

Browse files
amartya4256HeikoKlare
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 6a2d73f commit 435fe7e

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
@@ -40,6 +40,7 @@ class Edge extends WebBrowser {
4040

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

4546
// System.getProperty() keys
@@ -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)