Changeset e2574afbe in vaadin


Ignore:
Timestamp:
12/22/11 13:15:52 (2 years ago)
Author:
Marc Englund <marc@…>
Branches:
716046af83ec05a44314a792648863646398d3b9, 7.0, 7.1, 7.2
Children:
a90834512
Parents:
a614a722e
git-author:
Marc Englund <marc@…> (12/22/11 12:51:46)
git-committer:
Marc Englund <marc@…> (12/22/11 13:15:52)
Message:

External UnsupportedBrowserHandler

Location:
src/com/vaadin/terminal/gwt/server
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java

    r0cc29722 re2574afbe  
    188188        application.addRequestHandler(getBootstrapHandler()); 
    189189        application.addRequestHandler(APP_RESOURCE_HANDLER); 
     190        application.addRequestHandler(UnsupportedBrowserHandler.getInstance()); 
    190191        requireLocale(application.getLocale().toString()); 
    191192    } 
  • src/com/vaadin/terminal/gwt/server/BootstrapHandler.java

    r0cc29722 re2574afbe  
    2727public abstract class BootstrapHandler implements RequestHandler { 
    2828 
    29     /** Cookie used to ignore browser checks */ 
    30     private static final String FORCE_LOAD_COOKIE = "vaadinforceload=1"; 
    31  
    3229    protected class BootstrapContext implements Serializable { 
     30 
    3331        private final WrappedResponse response; 
    3432        private final WrappedRequest request; 
     
    118116            throws IOException { 
    119117 
    120         if (request.getBrowserDetails() != null) { 
    121             // Check if the browser is supported; we'll activate Chrome Frame 
    122             // silently if available. 
    123             WebBrowser b = request.getBrowserDetails().getWebBrowser(); 
    124             if (b.isTooOldToFunctionProperly() && !b.isChromeFrameCapable()) { 
    125                 // bypass if cookie set 
    126                 String c = request.getHeader("Cookie"); 
    127                 if (c == null || !c.contains(FORCE_LOAD_COOKIE)) { 
    128                     writeBrowserTooOldPage(request, response); 
    129                     return true; 
    130                 } 
    131  
    132             } 
    133         } 
    134  
    135118        // TODO Should all urls be handled here? 
    136119        int rootId; 
     
    154137 
    155138        return true; 
    156     } 
    157  
    158     /** 
    159      * Writes a page encouraging the user to upgrade to a more current browser. 
    160      *  
    161      * @param request 
    162      * @param response 
    163      * @throws IOException 
    164      */ 
    165     protected void writeBrowserTooOldPage(WrappedRequest request, 
    166             WrappedResponse response) throws IOException { 
    167         Writer page = response.getWriter(); 
    168         WebBrowser b = request.getBrowserDetails().getWebBrowser(); 
    169  
    170         page.write("<html><body><h1>I'm sorry, but your browser is not supported</h1>" 
    171                 + "<p>The version (" 
    172                 + b.getBrowserMajorVersion() 
    173                 + "." 
    174                 + b.getBrowserMinorVersion() 
    175                 + ") of the browser you are using " 
    176                 + " is outdated and not supported.</p>" 
    177                 + "<p>You should <b>consider upgrading</b> to a more up-to-date browser.</p> " 
    178                 + "<p>The most popular browsers are <b>" 
    179                 + " <a href=\"https://www.google.com/chrome\">Chrome</a>," 
    180                 + " <a href=\"http://www.mozilla.com/firefox\">Firefox</a>," 
    181                 + (b.isWindows() ? " <a href=\"http://windows.microsoft.com/en-US/internet-explorer/downloads/ie\">Internet Explorer</a>," 
    182                         : "") 
    183                 + " <a href=\"http://www.opera.com/browser\">Opera</a>" 
    184                 + " and <a href=\"http://www.apple.com/safari\">Safari</a>.</b><br/>" 
    185                 + "Upgrading to the latest version of one of these <b>will make the web safer, faster and better looking.</b></p>" 
    186                 + (b.isIE() ? "<script type=\"text/javascript\" src=\"http://ajax.googleapis.com/ajax/libs/chrome-frame/1/CFInstall.min.js\"></script>" 
    187                         + "<p>If you can not upgrade your browser, please consider trying <a onclick=\"CFInstall.check({mode:'overlay'});return false;\" href=\"http://www.google.com/chromeframe\">Chrome Frame</a>.</p>" 
    188                         : "") // 
    189                 + "<p><sub><a onclick=\"document.cookie='" 
    190                 + FORCE_LOAD_COOKIE 
    191                 + "';window.location.reload();return false;\" href=\"#\">Continue without updating</a> (not recommended)</sub></p>" 
    192                 + "</body>\n" + "</html>"); 
    193  
    194         page.close(); 
    195139    } 
    196140 
Note: See TracChangeset for help on using the changeset viewer.