|
37 | 37 | import java.net.URI; |
38 | 38 | import java.net.URISyntaxException; |
39 | 39 | import java.net.URL; |
| 40 | +import java.nio.file.Paths; |
40 | 41 | import java.util.ArrayList; |
41 | 42 | import java.util.Arrays; |
42 | 43 | import java.util.Collection; |
|
74 | 75 | import org.eclipse.core.runtime.ListenerList; |
75 | 76 | import org.eclipse.core.runtime.MultiStatus; |
76 | 77 | import org.eclipse.core.runtime.Platform; |
| 78 | +import org.eclipse.core.runtime.Platform.OS; |
77 | 79 | import org.eclipse.core.runtime.SafeRunner; |
78 | 80 | import org.eclipse.core.runtime.Status; |
79 | 81 | import org.eclipse.core.runtime.SubMonitor; |
|
140 | 142 | import org.eclipse.jface.window.IShellProvider; |
141 | 143 | import org.eclipse.jface.window.Window; |
142 | 144 | import org.eclipse.osgi.internal.location.LocationHelper; |
| 145 | +import org.eclipse.osgi.service.datalocation.Location; |
143 | 146 | import org.eclipse.osgi.service.runnable.StartupMonitor; |
144 | 147 | import org.eclipse.osgi.util.NLS; |
145 | 148 | import org.eclipse.swt.SWT; |
@@ -292,6 +295,8 @@ public final class Workbench extends EventManager implements IWorkbench, org.ecl |
292 | 295 | public static final String PROP_EXIT_CODE = "eclipse.exitcode"; //$NON-NLS-1$ |
293 | 296 | private static final String CMD_DATA = "-data"; //$NON-NLS-1$ |
294 | 297 |
|
| 298 | + private static final String EDGE_USER_DATA_FOLDER = "org.eclipse.swt.internal.win32.Edge.userDataFolder"; //$NON-NLS-1$ |
| 299 | + |
295 | 300 | private static final class StartupProgressBundleListener implements ServiceListener { |
296 | 301 |
|
297 | 302 | private final SubMonitor subMonitor; |
@@ -451,6 +456,10 @@ public void serviceChanged(ServiceEvent event) { |
451 | 456 | private Workbench(Display display, final WorkbenchAdvisor advisor, MApplication app, IEclipseContext appContext) { |
452 | 457 | this.advisor = Objects.requireNonNull(advisor); |
453 | 458 | this.display = Objects.requireNonNull(display); |
| 459 | + if (OS.isWindows()) { |
| 460 | + setEdgeDataDirectory(this.display); |
| 461 | + } |
| 462 | + |
454 | 463 | application = app; |
455 | 464 | e4Context = appContext; |
456 | 465 |
|
@@ -510,6 +519,19 @@ public void eventLoopException(Throwable exception) { |
510 | 519 | new WorkbenchLocationService(IServiceScopes.WORKBENCH_SCOPE, this, null, null, null, null, 0)); |
511 | 520 | } |
512 | 521 |
|
| 522 | + private static void setEdgeDataDirectory(Display display) { |
| 523 | + Location workspaceLocation = Platform.getInstanceLocation(); |
| 524 | + if (workspaceLocation == null) { |
| 525 | + return; |
| 526 | + } |
| 527 | + try { |
| 528 | + URI workspaceLocationURI = workspaceLocation.getURL().toURI(); |
| 529 | + display.setData(EDGE_USER_DATA_FOLDER, Paths.get(workspaceLocationURI).toString()); |
| 530 | + } catch (URISyntaxException e) { |
| 531 | + WorkbenchPlugin.log("Invalid workspace location to be set for Edge browser.", e); //$NON-NLS-1$ |
| 532 | + } |
| 533 | + } |
| 534 | + |
513 | 535 | /** |
514 | 536 | * Returns the one and only instance of the workbench, if there is one. |
515 | 537 | * |
|
0 commit comments