Hide hasFlash inside of UserAgent.Flash.isInstalled
Clarify this only means the Flash plugin is installed in the browser. It may be disabled by the user's preferences, or set to "click to run" mode, where an empty gray box is displayed until the user clicks the box to start the Flash content. Change-Id: I1e12c8382ed6fea5dec449fce4b762b84e95e706
This commit is contained in:
@@ -127,7 +127,7 @@ public class CopyableLabel extends Composite implements HasText {
|
||||
}
|
||||
|
||||
private void embedMovie() {
|
||||
if (flashEnabled && UserAgent.hasFlash && text.length() > 0) {
|
||||
if (flashEnabled && !text.isEmpty() && UserAgent.Flash.isInstalled()) {
|
||||
final String flashVars = "text=" + URL.encodeQueryString(getText());
|
||||
final SafeHtmlBuilder h = new SafeHtmlBuilder();
|
||||
|
||||
|
@@ -27,26 +27,42 @@ import com.google.gwt.user.client.Window;
|
||||
* trivial compared to the time developers lose building their application.
|
||||
*/
|
||||
public class UserAgent {
|
||||
/** Does the browser have ShockwaveFlash plugin enabled? */
|
||||
public static final boolean hasFlash = hasFlash();
|
||||
public static class Flash {
|
||||
private static boolean checked;
|
||||
private static boolean installed;
|
||||
|
||||
private static native boolean hasFlash()
|
||||
/*-{
|
||||
if (navigator.plugins && navigator.plugins.length) {
|
||||
if (navigator.plugins['Shockwave Flash']) return true;
|
||||
if (navigator.plugins['Shockwave Flash 2.0']) return true;
|
||||
|
||||
} else if (navigator.mimeTypes && navigator.mimeTypes.length) {
|
||||
var mimeType = navigator.mimeTypes['application/x-shockwave-flash'];
|
||||
if (mimeType && mimeType.enabledPlugin) return true;
|
||||
|
||||
} else {
|
||||
try { new ActiveXObject('ShockwaveFlash.ShockwaveFlash.7'); return true; } catch (e) {}
|
||||
try { new ActiveXObject('ShockwaveFlash.ShockwaveFlash.6'); return true; } catch (e) {}
|
||||
try { new ActiveXObject('ShockwaveFlash.ShockwaveFlash'); return true; } catch (e) {}
|
||||
/**
|
||||
* Does the browser have ShockwaveFlash plugin installed?
|
||||
* <p>
|
||||
* This method may still return true if the user has disabled Flash or set
|
||||
* the plugin to "click to run".
|
||||
*/
|
||||
public static boolean isInstalled() {
|
||||
if (!checked) {
|
||||
installed = hasFlash();
|
||||
checked = true;
|
||||
}
|
||||
return installed;
|
||||
}
|
||||
return false;
|
||||
}-*/;
|
||||
|
||||
private static native boolean hasFlash()
|
||||
/*-{
|
||||
if (navigator.plugins && navigator.plugins.length) {
|
||||
if (navigator.plugins['Shockwave Flash']) return true;
|
||||
if (navigator.plugins['Shockwave Flash 2.0']) return true;
|
||||
|
||||
} else if (navigator.mimeTypes && navigator.mimeTypes.length) {
|
||||
var mimeType = navigator.mimeTypes['application/x-shockwave-flash'];
|
||||
if (mimeType && mimeType.enabledPlugin) return true;
|
||||
|
||||
} else {
|
||||
try { new ActiveXObject('ShockwaveFlash.ShockwaveFlash.7'); return true; } catch (e) {}
|
||||
try { new ActiveXObject('ShockwaveFlash.ShockwaveFlash.6'); return true; } catch (e) {}
|
||||
try { new ActiveXObject('ShockwaveFlash.ShockwaveFlash'); return true; } catch (e) {}
|
||||
}
|
||||
return false;
|
||||
}-*/;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for and disallow running this application in an <iframe>.
|
||||
|
Reference in New Issue
Block a user