summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Alhroos <john.ahlroos@itmill.com>2011-03-08 07:45:14 +0000
committerJohn Alhroos <john.ahlroos@itmill.com>2011-03-08 07:45:14 +0000
commitff5f72cba9b3428d310466c5bf23378457a05737 (patch)
treecb8f2155bbb6f463472fb19eaa877422ec823715
parent10ebd4b2ede2034aec747dff02d85cbc6835a9f8 (diff)
downloadvaadin-framework-ff5f72cba9b3428d310466c5bf23378457a05737.tar.gz
vaadin-framework-ff5f72cba9b3428d310466c5bf23378457a05737.zip
Fixed flash issues and cleans up the Flash related code. #6501
svn changeset:17651/svn branch:6.5
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VEmbedded.java118
1 files changed, 89 insertions, 29 deletions
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VEmbedded.java b/src/com/vaadin/terminal/gwt/client/ui/VEmbedded.java
index f1d61029d4..8b18439b52 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VEmbedded.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VEmbedded.java
@@ -1,4 +1,4 @@
-/*
+/*
@ITMillApache2LicenseForJavaFiles@
*/
@@ -137,35 +137,9 @@ public class VEmbedded extends HTML implements Paintable {
} else if (uidl.hasAttribute("mimetype")) {
final String mime = uidl.getStringAttribute("mimetype");
if (mime.equals("application/x-shockwave-flash")) {
- addStyleName(CLASSNAME + "-flash");
- String html = "<object "
- + "type=\"application/x-shockwave-flash\" "
- + "width=\"" + width + "\" height=\"" + height + "\">";
+ // Handle embedding of Flash
+ setHTML(createFlashEmbed(uidl));
- Map<String, String> parameters = getParameters(uidl);
- if (parameters.get("movie") == null) {
- parameters.put("movie", getSrc(uidl, client));
- }
-
- // Add the parameters to the Object
- for (String name : parameters.keySet()) {
- html += "<param name=\"" + escapeAttribute(name)
- + "\" value=\""
- + escapeAttribute(parameters.get(name)) + "\"/>";
- }
-
- html += "<embed src=\"" + getSrc(uidl, client) + "\" width=\""
- + width + "\" height=\"" + height + "\" "
- + "type=\"application/x-shockwave-flash\" ";
-
- // Add the parameters to the Embed
- for (String name : parameters.keySet()) {
- html += escapeAttribute(name) + "=\""
- + escapeAttribute(parameters.get(name)) + "\" ";
- }
-
- html += "></embed></object>";
- setHTML(html);
} else if (mime.equals("image/svg+xml")) {
addStyleName(CLASSNAME + "-svg");
String data;
@@ -201,6 +175,92 @@ public class VEmbedded extends HTML implements Paintable {
}
/**
+ * Creates the Object and Embed tags for the Flash plugin so it works
+ * cross-browser
+ *
+ * @param uidl
+ * The UIDL
+ * @return Tags concatenated into a string
+ */
+ private String createFlashEmbed(UIDL uidl) {
+ addStyleName(CLASSNAME + "-flash");
+
+ /*
+ * To ensure cross-browser compatibility we are using the twice-cooked
+ * method to embed flash i.e. we add a OBJECT tag for IE ActiveX and
+ * inside it a EMBED for all other browsers.
+ */
+
+ StringBuilder html = new StringBuilder();
+
+ // Start the object tag
+ html.append("<object ");
+
+ /*
+ * Add classid required for ActiveX to recognize the flash. This is a
+ * predefined value which ActiveX recognizes and must be the given
+ * value. More info can be found on
+ * http://kb2.adobe.com/cps/415/tn_4150.html.
+ */
+ html.append("classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" ");
+
+ /*
+ * Add codebase required for ActiveX and must be exactly this according
+ * to http://kb2.adobe.com/cps/415/tn_4150.html to work with the above
+ * given classid. Again, see more info on
+ * http://kb2.adobe.com/cps/415/tn_4150.html. Limiting Flash version to
+ * 9.0.0.0 and above.
+ */
+ html.append("codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0\" ");
+
+ // Add width and height
+ html.append("width=\"" + width + "\" ");
+ html.append("height=\"" + height + "\" ");
+
+ html.append("type=\"application/x-shockwave-flash\" ");
+
+ // End object tag
+ html.append(">");
+
+ // Ensure we have an movie parameter
+ Map<String, String> parameters = getParameters(uidl);
+ if (parameters.get("movie") == null) {
+ parameters.put("movie", getSrc(uidl, client));
+ }
+
+ // Add parameters to OBJECT
+ for (String name : parameters.keySet()) {
+ html.append("<param ");
+ html.append("name=\"" + escapeAttribute(name) + "\" ");
+ html.append("value=\"" + escapeAttribute(parameters.get(name))
+ + "\" ");
+ html.append("/>");
+ }
+
+ // Build inner EMBED tag
+ html.append("<embed ");
+ html.append("src=\"" + getSrc(uidl, client) + "\" ");
+ html.append("width=\"" + width + "\" ");
+ html.append("height=\"" + height + "\" ");
+ html.append("type=\"application/x-shockwave-flash\" ");
+
+ // Add the parameters to the Embed
+ for (String name : parameters.keySet()) {
+ html.append(escapeAttribute(name));
+ html.append("=");
+ html.append("\"" + escapeAttribute(parameters.get(name)) + "\"");
+ }
+
+ // End embed tag
+ html.append("</embed>");
+
+ // End object tag
+ html.append("</object>");
+
+ return html.toString();
+ }
+
+ /**
* Escapes the string so it is safe to write inside an HTML attribute.
*
* @param attribute