Adding Google Chrome Framework for IE<9

This commit is contained in:
Pablo Luna
2011-03-13 16:24:26 +00:00
parent 331652ad74
commit 1b04d1effc
6 changed files with 60 additions and 3 deletions

View File

@@ -18,6 +18,7 @@
package com.wisemapping.controller;
import com.wisemapping.filter.UserAgent;
import com.wisemapping.model.MindMap;
import com.wisemapping.security.Utils;
import org.springframework.web.servlet.ModelAndView;
@@ -38,19 +39,26 @@ public class MindmapEditorController extends BaseMultiActionController {
public ModelAndView open(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception {
ModelAndView view;
UserAgent userAgent = UserAgent.create(httpServletRequest);
if(userAgent.needsGCF()){
view = new ModelAndView("installCFG");
}
else{
final String mindmapId = httpServletRequest.getParameter(MINDMAP_ID_PARAMETER);
final int mapId = Integer.parseInt(mindmapId);
final MindMap mindmap = getMindmapService().getMindmapById(mapId);
// Mark as try mode...
final ModelAndView view = new ModelAndView("mindmapEditor", "mindmap", mindmap);
view = new ModelAndView("mindmapEditor", "mindmap", mindmap);
view.addObject("editorTryMode", false);
final boolean showHelp = isWelcomeMap(mindmap);
view.addObject("showHelp", showHelp);
final String xmlMap = mindmap.getNativeXmlAsJsLiteral();
view.addObject(MAP_XML_PARAM, xmlMap);
view.addObject("user", Utils.getUser());
}
return view;
}

View File

@@ -30,6 +30,7 @@ public class UserAgent implements Serializable {
private Product product;
private OS os;
private final org.apache.commons.logging.Log logger = LogFactory.getLog(UserAgent.class.getName());
private boolean hasGCFInstalled = false;
public static void main(final String argv[]) {
UserAgent explorer = UserAgent.create("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)");
@@ -65,6 +66,10 @@ public class UserAgent implements Serializable {
return this.versionMajor > mayor || (mayor == this.versionMajor && this.versionVariation >= variation);
}
public boolean isVersionLessThan(final int mayor) {
return this.versionMajor < mayor;
}
public int getVersionMajor() {
return versionMajor;
}
@@ -127,6 +132,7 @@ public class UserAgent implements Serializable {
// Explorer Parse ...
this.product = Product.EXPLORER;
this.hasGCFInstalled = productDetails.indexOf("chromeframe")!=-1;
} else if (userAgentHeader.indexOf("iCab") != -1 || userAgentHeader.indexOf("Safari") != -1) {
// Safari:
//Formats: Mozilla/5.0 (Windows; U; Windows NT 5.1; en) AppleWebKit/522.13.1 (KHTML, like Gecko) Version/3.0.2 Safari/522.13.1
@@ -334,4 +340,9 @@ public class UserAgent implements Serializable {
return result;
}
public boolean needsGCF(){
final UserAgent.Product product = this.getProduct();
return product == UserAgent.Product.EXPLORER && this.isVersionLessThan(9) && this.getOs() == UserAgent.OS.WINDOWS && !this.hasGCFInstalled;
}
}