summaryrefslogtreecommitdiff
path: root/platform/platform-api/src/com/intellij/ide
diff options
context:
space:
mode:
Diffstat (limited to 'platform/platform-api/src/com/intellij/ide')
-rw-r--r--platform/platform-api/src/com/intellij/ide/BrowserUtil.java8
-rw-r--r--platform/platform-api/src/com/intellij/ide/browsers/BrowserFamily.java6
-rw-r--r--platform/platform-api/src/com/intellij/ide/browsers/BrowserLauncherAppless.java36
-rw-r--r--platform/platform-api/src/com/intellij/ide/browsers/BrowserSpecificSettings.java6
-rw-r--r--platform/platform-api/src/com/intellij/ide/browsers/chrome/ChromeSettings.java25
-rw-r--r--platform/platform-api/src/com/intellij/ide/browsers/firefox/FirefoxSettingsConfigurable.java16
6 files changed, 73 insertions, 24 deletions
diff --git a/platform/platform-api/src/com/intellij/ide/BrowserUtil.java b/platform/platform-api/src/com/intellij/ide/BrowserUtil.java
index 90308f5dbfda..cd1d1b0dba49 100644
--- a/platform/platform-api/src/com/intellij/ide/BrowserUtil.java
+++ b/platform/platform-api/src/com/intellij/ide/BrowserUtil.java
@@ -20,6 +20,7 @@ import com.intellij.execution.util.ExecUtil;
import com.intellij.ide.browsers.BrowserLauncher;
import com.intellij.ide.browsers.BrowserLauncherAppless;
import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VirtualFile;
@@ -106,6 +107,10 @@ public class BrowserUtil {
getBrowserLauncher().browse(uri);
}
+ public static void browse(@NotNull String url, @Nullable Project project) {
+ getBrowserLauncher().browse(url, null, project);
+ }
+
@SuppressWarnings("UnusedDeclaration")
@NotNull
@Deprecated
@@ -145,6 +150,9 @@ public class BrowserUtil {
else if (SystemInfo.isMac) {
return "open";
}
+ else if (SystemInfo.isUnix) {
+ return "/usr/bin/firefox";
+ }
else {
return "";
}
diff --git a/platform/platform-api/src/com/intellij/ide/browsers/BrowserFamily.java b/platform/platform-api/src/com/intellij/ide/browsers/BrowserFamily.java
index f6826b528427..f767ec90d49f 100644
--- a/platform/platform-api/src/com/intellij/ide/browsers/BrowserFamily.java
+++ b/platform/platform-api/src/com/intellij/ide/browsers/BrowserFamily.java
@@ -35,9 +35,9 @@ public enum BrowserFamily implements Iconable {
private final Icon myIcon;
BrowserFamily(@NotNull String name,
- @NotNull final String windowsPath,
- @Nullable final String unixPath,
- @Nullable final String macPath,
+ @NotNull String windowsPath,
+ @Nullable String unixPath,
+ @Nullable String macPath,
@NotNull Icon icon) {
myName = name;
myWindowsPath = windowsPath;
diff --git a/platform/platform-api/src/com/intellij/ide/browsers/BrowserLauncherAppless.java b/platform/platform-api/src/com/intellij/ide/browsers/BrowserLauncherAppless.java
index 0c34152861d1..736dcd8afe22 100644
--- a/platform/platform-api/src/com/intellij/ide/browsers/BrowserLauncherAppless.java
+++ b/platform/platform-api/src/com/intellij/ide/browsers/BrowserLauncherAppless.java
@@ -74,10 +74,10 @@ public class BrowserLauncherAppless extends BrowserLauncher {
Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(action);
}
- public static boolean canStartDefaultBrowser() {
+ public static boolean canUseSystemDefaultBrowserPolicy() {
return isDesktopActionSupported(Desktop.Action.BROWSE) ||
SystemInfo.isMac || SystemInfo.isWindows ||
- SystemInfo.isUnix && SystemInfo.hasXdgOpen();
+ (SystemInfo.isUnix && SystemInfo.hasXdgOpen());
}
private static GeneralSettings getGeneralSettingsInstance() {
@@ -109,7 +109,7 @@ public class BrowserLauncherAppless extends BrowserLauncher {
@Override
public void open(@NotNull String url) {
- openOrBrowse(url, false);
+ openOrBrowse(url, false, null);
}
@Override
@@ -119,6 +119,10 @@ public class BrowserLauncherAppless extends BrowserLauncher {
@Override
public void browse(@NotNull URI uri) {
+ browse(uri, null);
+ }
+
+ public void browse(@NotNull URI uri, @Nullable Project project) {
LOG.debug("Launch browser: [" + uri + "]");
GeneralSettings settings = getGeneralSettingsInstance();
@@ -136,15 +140,19 @@ public class BrowserLauncherAppless extends BrowserLauncher {
List<String> command = getDefaultBrowserCommand();
if (command != null) {
- doLaunch(uri.toString(), command, null, null, ArrayUtil.EMPTY_STRING_ARRAY, null);
+ doLaunch(uri.toString(), command, null, project, ArrayUtil.EMPTY_STRING_ARRAY, null);
return;
}
}
- browseUsingPath(uri.toString(), settings.getBrowserPath(), null, null, ArrayUtil.EMPTY_STRING_ARRAY);
+ browseUsingNotSystemDefaultBrowserPolicy(uri, settings, project);
}
- private void openOrBrowse(@NotNull String url, boolean browse) {
+ protected void browseUsingNotSystemDefaultBrowserPolicy(@NotNull URI uri, @NotNull GeneralSettings settings, @Nullable Project project) {
+ browseUsingPath(uri.toString(), settings.getBrowserPath(), null, project, ArrayUtil.EMPTY_STRING_ARRAY);
+ }
+
+ private void openOrBrowse(@NotNull String url, boolean browse, @Nullable Project project) {
url = url.trim();
if (url.startsWith("jar:")) {
@@ -181,7 +189,7 @@ public class BrowserLauncherAppless extends BrowserLauncher {
}
if (uri == null) {
- doShowError(IdeBundle.message("error.malformed.url", url), null, null, null, null);
+ doShowError(IdeBundle.message("error.malformed.url", url), null, project, null, null);
}
else {
browse(uri);
@@ -380,7 +388,7 @@ public class BrowserLauncherAppless extends BrowserLauncher {
@Override
public void browse(@NotNull String url, @Nullable WebBrowser browser, @Nullable Project project) {
if (browser == null) {
- openOrBrowse(url, true);
+ openOrBrowse(url, true, project);
}
else {
for (UrlOpener urlOpener : UrlOpener.EP_NAME.getExtensions()) {
@@ -436,8 +444,8 @@ public class BrowserLauncherAppless extends BrowserLauncher {
private boolean doLaunch(@Nullable String url,
@NotNull List<String> command,
- @Nullable final WebBrowser browser,
- @Nullable final Project project,
+ @Nullable WebBrowser browser,
+ @Nullable Project project,
@NotNull String[] additionalParameters,
@Nullable Runnable launchTask) {
GeneralCommandLine commandLine = new GeneralCommandLine(command);
@@ -454,7 +462,13 @@ public class BrowserLauncherAppless extends BrowserLauncher {
commandLine.addParameter(url);
}
- addArgs(commandLine, browser == null ? null : browser.getSpecificSettings(), additionalParameters);
+ final BrowserSpecificSettings browserSpecificSettings = browser == null ? null : browser.getSpecificSettings();
+ if (browserSpecificSettings != null) {
+ commandLine.getEnvironment().putAll(browserSpecificSettings.getEnvironmentVariables());
+ }
+
+ addArgs(commandLine, browserSpecificSettings, additionalParameters);
+
try {
Process process = commandLine.createProcess();
checkCreatedProcess(browser, project, commandLine, process, launchTask);
diff --git a/platform/platform-api/src/com/intellij/ide/browsers/BrowserSpecificSettings.java b/platform/platform-api/src/com/intellij/ide/browsers/BrowserSpecificSettings.java
index 826ca80cd21a..b7fd90ef3ade 100644
--- a/platform/platform-api/src/com/intellij/ide/browsers/BrowserSpecificSettings.java
+++ b/platform/platform-api/src/com/intellij/ide/browsers/BrowserSpecificSettings.java
@@ -20,6 +20,7 @@ import org.jetbrains.annotations.NotNull;
import java.util.Collections;
import java.util.List;
+import java.util.Map;
public abstract class BrowserSpecificSettings implements Cloneable {
@NotNull
@@ -30,6 +31,11 @@ public abstract class BrowserSpecificSettings implements Cloneable {
return Collections.emptyList();
}
+ @NotNull
+ public Map<String, String> getEnvironmentVariables() {
+ return Collections.emptyMap();
+ }
+
@Override
public BrowserSpecificSettings clone() {
try {
diff --git a/platform/platform-api/src/com/intellij/ide/browsers/chrome/ChromeSettings.java b/platform/platform-api/src/com/intellij/ide/browsers/chrome/ChromeSettings.java
index b6ca3e7ac44f..555097bb546c 100644
--- a/platform/platform-api/src/com/intellij/ide/browsers/chrome/ChromeSettings.java
+++ b/platform/platform-api/src/com/intellij/ide/browsers/chrome/ChromeSettings.java
@@ -21,7 +21,9 @@ import com.intellij.openapi.util.io.FileUtilRt;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.PathUtil;
import com.intellij.util.execution.ParametersListUtil;
+import com.intellij.util.xmlb.annotations.MapAnnotation;
import com.intellij.util.xmlb.annotations.Tag;
+import gnu.trove.THashMap;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -33,6 +35,7 @@ public final class ChromeSettings extends BrowserSpecificSettings {
private @Nullable String myCommandLineOptions;
private @Nullable String myUserDataDirectoryPath;
private boolean myUseCustomProfile;
+ private @NotNull THashMap<String, String> myEnvironmentVariables = new THashMap<String, String>();
public ChromeSettings() {
}
@@ -85,6 +88,18 @@ public final class ChromeSettings extends BrowserSpecificSettings {
return cliOptions;
}
+ @Override
+ @NotNull
+ @Tag("environment-variables")
+ @MapAnnotation(surroundWithTag = false, surroundKeyWithTag = false, surroundValueWithTag = false)
+ public THashMap<String, String> getEnvironmentVariables() {
+ return myEnvironmentVariables;
+ }
+
+ public void setEnvironmentVariables(@NotNull final THashMap<String, String> environmentVariables) {
+ myEnvironmentVariables = environmentVariables;
+ }
+
@NotNull
@Override
public ChromeSettingsConfigurable createConfigurable() {
@@ -92,6 +107,13 @@ public final class ChromeSettings extends BrowserSpecificSettings {
}
@Override
+ public ChromeSettings clone() {
+ ChromeSettings clone = (ChromeSettings)super.clone();
+ clone.myEnvironmentVariables = myEnvironmentVariables.clone();
+ return clone;
+ }
+
+ @Override
public boolean equals(Object o) {
if (this == o) {
return true;
@@ -103,6 +125,7 @@ public final class ChromeSettings extends BrowserSpecificSettings {
ChromeSettings settings = (ChromeSettings)o;
return myUseCustomProfile == settings.myUseCustomProfile &&
Comparing.equal(myCommandLineOptions, settings.myCommandLineOptions) &&
- (!myUseCustomProfile || Comparing.equal(myUserDataDirectoryPath, settings.myUserDataDirectoryPath));
+ (!myUseCustomProfile || Comparing.equal(myUserDataDirectoryPath, settings.myUserDataDirectoryPath)) &&
+ myEnvironmentVariables.equals(settings.myEnvironmentVariables);
}
}
diff --git a/platform/platform-api/src/com/intellij/ide/browsers/firefox/FirefoxSettingsConfigurable.java b/platform/platform-api/src/com/intellij/ide/browsers/firefox/FirefoxSettingsConfigurable.java
index ef95f7cb872e..c28b7e495b41 100644
--- a/platform/platform-api/src/com/intellij/ide/browsers/firefox/FirefoxSettingsConfigurable.java
+++ b/platform/platform-api/src/com/intellij/ide/browsers/firefox/FirefoxSettingsConfigurable.java
@@ -26,7 +26,6 @@ import com.intellij.openapi.util.io.FileUtilRt;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.ui.DocumentAdapter;
-import com.intellij.util.ObjectUtils;
import com.intellij.util.PathUtil;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.Nullable;
@@ -48,7 +47,7 @@ public class FirefoxSettingsConfigurable implements Configurable {
private final FirefoxSettings mySettings;
private String myLastProfilesIniPath;
private String myDefaultProfilesIniPath;
- private String myDefaultProfile;
+ private String defaultProfile;
public FirefoxSettingsConfigurable(FirefoxSettings settings) {
mySettings = settings;
@@ -89,11 +88,8 @@ public class FirefoxSettingsConfigurable implements Configurable {
@Nullable
private String getConfiguredProfileName() {
- final String selected = (String)myProfileCombobox.getSelectedItem();
- if (Comparing.equal(myDefaultProfile, selected)) {
- return null;
- }
- return selected;
+ String selected = (String)myProfileCombobox.getSelectedItem();
+ return Comparing.equal(defaultProfile, selected) ? null : selected;
}
@Override
@@ -110,7 +106,9 @@ public class FirefoxSettingsConfigurable implements Configurable {
String path = mySettings.getProfilesIniPath();
myProfilesIniPathField.setText(path != null ? FileUtilRt.toSystemDependentName(path) : myDefaultProfilesIniPath);
updateProfilesList();
- myProfileCombobox.setSelectedItem(ObjectUtils.notNull(mySettings.getProfile(), myDefaultProfile));
+
+ String profile = mySettings.getProfile();
+ myProfileCombobox.setSelectedItem(profile == null ? defaultProfile : profile);
}
private void updateProfilesList() {
@@ -122,7 +120,7 @@ public class FirefoxSettingsConfigurable implements Configurable {
myProfileCombobox.removeAllItems();
final List<FirefoxProfile> profiles = FirefoxUtil.computeProfiles(new File(profilesIniPath));
final FirefoxProfile defaultProfile = FirefoxUtil.getDefaultProfile(profiles);
- myDefaultProfile = defaultProfile != null ? defaultProfile.getName() : null;
+ this.defaultProfile = defaultProfile != null ? defaultProfile.getName() : null;
for (FirefoxProfile profile : profiles) {
//noinspection unchecked
myProfileCombobox.addItem(profile.getName());