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() {
|
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 String flashVars = "text=" + URL.encodeQueryString(getText());
|
||||||
final SafeHtmlBuilder h = new SafeHtmlBuilder();
|
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.
|
* trivial compared to the time developers lose building their application.
|
||||||
*/
|
*/
|
||||||
public class UserAgent {
|
public class UserAgent {
|
||||||
/** Does the browser have ShockwaveFlash plugin enabled? */
|
public static class Flash {
|
||||||
public static final boolean hasFlash = hasFlash();
|
private static boolean checked;
|
||||||
|
private static boolean installed;
|
||||||
|
|
||||||
private static native boolean hasFlash()
|
/**
|
||||||
/*-{
|
* Does the browser have ShockwaveFlash plugin installed?
|
||||||
if (navigator.plugins && navigator.plugins.length) {
|
* <p>
|
||||||
if (navigator.plugins['Shockwave Flash']) return true;
|
* This method may still return true if the user has disabled Flash or set
|
||||||
if (navigator.plugins['Shockwave Flash 2.0']) return true;
|
* the plugin to "click to run".
|
||||||
|
*/
|
||||||
} else if (navigator.mimeTypes && navigator.mimeTypes.length) {
|
public static boolean isInstalled() {
|
||||||
var mimeType = navigator.mimeTypes['application/x-shockwave-flash'];
|
if (!checked) {
|
||||||
if (mimeType && mimeType.enabledPlugin) return true;
|
installed = hasFlash();
|
||||||
|
checked = true;
|
||||||
} else {
|
}
|
||||||
try { new ActiveXObject('ShockwaveFlash.ShockwaveFlash.7'); return true; } catch (e) {}
|
return installed;
|
||||||
try { new ActiveXObject('ShockwaveFlash.ShockwaveFlash.6'); return true; } catch (e) {}
|
|
||||||
try { new ActiveXObject('ShockwaveFlash.ShockwaveFlash'); return true; } catch (e) {}
|
|
||||||
}
|
}
|
||||||
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>.
|
* Test for and disallow running this application in an <iframe>.
|
||||||
|
Reference in New Issue
Block a user