Skip to content

Commit

Permalink
empty
Browse files Browse the repository at this point in the history
  • Loading branch information
rjolly committed Apr 14, 2018
1 parent 885ab12 commit c7f3a17
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -325,27 +325,6 @@ private App getApplication(final String scheme) {
return app;
}

public void open(final URI uri, final MimeType type) {
final App app = getApplication(type, uri.getScheme());
if (app != null) {
app.open(uri, getDesktopPane());
}
}

private App getApplication(final MimeType type, final String scheme) {
final List<App> apps = new ArrayList<>(getApplications(type));
apps.retainAll(getApplications(scheme));
final App app = getPreferredApplication(type);
if (apps.contains(app)) {
return app;
} else {
if (apps.size() > 0) {
return apps.get(0);
}
}
return null;
}

public boolean populate(final URI uri, JPopupMenu... menus) {
final String scheme = uri.getScheme();
final MimeType type = getMimeType(uri);
Expand Down
34 changes: 1 addition & 33 deletions html/src/linoleum/html/Browser.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,12 @@
import java.net.URISyntaxException;
import java.net.URI;
import java.net.URL;
import java.net.URLConnection;
import java.net.HttpURLConnection;
import java.util.List;
import java.util.ArrayList;
import java.util.concurrent.ExecutionException;
import java.util.prefs.PreferenceChangeEvent;
import java.util.prefs.PreferenceChangeListener;
import java.util.prefs.Preferences;
import javax.activation.MimeType;
import javax.activation.MimeTypeParseException;
import javax.swing.Action;
import javax.swing.AbstractAction;
import javax.swing.DefaultComboBoxModel;
Expand All @@ -33,7 +29,6 @@
import javax.swing.event.DocumentListener;
import javax.swing.event.HyperlinkEvent;
import javax.swing.text.Document;
import linoleum.application.App;
import linoleum.application.Frame;

public class Browser extends Frame {
Expand Down Expand Up @@ -200,12 +195,8 @@ public void open() {
}
final URI uri = getURI();
if (uri != null) {
final String scheme = uri.getScheme();
final MimeType type = getMimeType(uri);
if (type == null?canOpen(scheme):canOpen(type)) {
if (canOpen(uri)) {
doOpen();
} else if (canOpen(scheme)) {
getApplicationManager().open(uri, type);
} else {
getApplicationManager().open(uri);
}
Expand All @@ -223,29 +214,6 @@ private void linkActivated(final HyperlinkEvent evt) {
open();
}

@Override
public MimeType getMimeType(final URI uri) {
if (canOpen(uri.getScheme())) try {
final URLConnection conn = uri.toURL().openConnection();
if (conn instanceof HttpURLConnection) {
final HttpURLConnection hconn = (HttpURLConnection) conn;
hconn.setInstanceFollowRedirects(false);
final int response = hconn.getResponseCode();
if (response >= 300 && response <= 399) {
final String loc = conn.getHeaderField("Location");
return getMimeType(uri.resolve(loc));
}
}
final String str = conn.getContentType();
if (str != null) {
return new MimeType(str);
}
} catch (final MimeTypeParseException | IOException ex) {
ex.printStackTrace();
}
return super.getMimeType(uri);
}

private boolean reuseFor(final URL that) {
if (current != null) {
return that == null?false:current.getURL().sameFile(that);
Expand Down

0 comments on commit c7f3a17

Please sign in to comment.