Skip to content

Commit

Permalink
517582: iframe in news html opened externally
Browse files Browse the repository at this point in the history
Only begin opening content in external browser once page has
completed loading. And only if we're sure it's external content.

Bug: 517582
Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=517582
  • Loading branch information
creckord committed May 31, 2017
1 parent 8d5d004 commit d365739
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Expand Up @@ -37,7 +37,7 @@
*/
public class NewsUrlHandler extends MarketplaceUrlHandler implements LocationListener, ProgressListener {

private final Set<String> documentLinks = new HashSet<String>();
private Set<String> documentLinks = null;

private final NewsViewer viewer;

Expand Down Expand Up @@ -72,15 +72,16 @@ public void run() {
MarketplaceClientUi.log(IStatus.WARNING,
"Failed to process link targets on news page. Some links might not open in external browser.", //$NON-NLS-1$
ex);
documentLinks.clear();
NewsUrlHandler.this.documentLinks = null;
}
// Remember document links for navigation handling since we
// don't want to deal with URLs from dynamic loading events
if (links != null) {
documentLinks.clear();
Set<String> documentLinks = new HashSet<String>();
for (Object link : links) {
documentLinks.add(link.toString());
}
NewsUrlHandler.this.documentLinks = documentLinks;
}
}

Expand Down Expand Up @@ -109,7 +110,7 @@ private boolean isNavigation(String currentLocation, String newLocation) {
"about:blank".equals(newLocation) || "about:blank".equals(currentLocation)) { //$NON-NLS-1$//$NON-NLS-2$
return false;
}
if (!documentLinks.isEmpty() && !documentLinks.contains(newLocation)) {
if (documentLinks == null || !documentLinks.contains(newLocation)) {
return false;
}
return !isSameLocation(currentLocation, newLocation);
Expand Down
Expand Up @@ -282,6 +282,7 @@ public void run() {
Browser browser = getBrowser();
if (!browser.isDisposed()) {
browser.stop();
browser.removeProgressListener(ProgressRunnable.this);
}
}
}
Expand Down

0 comments on commit d365739

Please sign in to comment.