517582: iframe in news html opened externally

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
diff --git a/org.eclipse.epp.mpc.ui/src/org/eclipse/epp/internal/mpc/ui/wizards/NewsUrlHandler.java b/org.eclipse.epp.mpc.ui/src/org/eclipse/epp/internal/mpc/ui/wizards/NewsUrlHandler.java
index a3358a0..1a05872 100644
--- a/org.eclipse.epp.mpc.ui/src/org/eclipse/epp/internal/mpc/ui/wizards/NewsUrlHandler.java
+++ b/org.eclipse.epp.mpc.ui/src/org/eclipse/epp/internal/mpc/ui/wizards/NewsUrlHandler.java
@@ -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;
 
@@ -72,15 +72,16 @@
 					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;
 				}
 			}
 
@@ -109,7 +110,7 @@
 				"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);
diff --git a/org.eclipse.epp.mpc.ui/src/org/eclipse/epp/internal/mpc/ui/wizards/NewsViewer.java b/org.eclipse.epp.mpc.ui/src/org/eclipse/epp/internal/mpc/ui/wizards/NewsViewer.java
index e3f7c1f..0427ec0 100644
--- a/org.eclipse.epp.mpc.ui/src/org/eclipse/epp/internal/mpc/ui/wizards/NewsViewer.java
+++ b/org.eclipse.epp.mpc.ui/src/org/eclipse/epp/internal/mpc/ui/wizards/NewsViewer.java
@@ -282,6 +282,7 @@
 							Browser browser = getBrowser();
 							if (!browser.isDisposed()) {
 								browser.stop();
+								browser.removeProgressListener(ProgressRunnable.this);
 							}
 						}
 					}