001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.kernel.servlet;
016    
017    import com.liferay.portal.kernel.security.pacl.permission.PortalRuntimePermission;
018    
019    import javax.servlet.http.HttpServletRequest;
020    
021    /**
022     * See http://www.zytrax.com/tech/web/browser_ids.htm for examples.
023     *
024     * @author Brian Wing Shun Chan
025     * @author Eduardo Lundgren
026     */
027    public class BrowserSnifferUtil {
028    
029            public static boolean acceptsGzip(HttpServletRequest request) {
030                    return getBrowserSniffer().acceptsGzip(request);
031            }
032    
033            public static String getBrowserId(HttpServletRequest request) {
034                    return getBrowserSniffer().getBrowserId(request);
035            }
036    
037            public static BrowserSniffer getBrowserSniffer() {
038                    PortalRuntimePermission.checkGetBeanProperty(BrowserSnifferUtil.class);
039    
040                    return _browserSniffer;
041            }
042    
043            public static float getMajorVersion(HttpServletRequest request) {
044                    return getBrowserSniffer().getMajorVersion(request);
045            }
046    
047            public static String getRevision(HttpServletRequest request) {
048                    return getBrowserSniffer().getRevision(request);
049            }
050    
051            public static String getVersion(HttpServletRequest request) {
052                    return getBrowserSniffer().getVersion(request);
053            }
054    
055            public static boolean isAir(HttpServletRequest request) {
056                    return getBrowserSniffer().isAir(request);
057            }
058    
059            public static boolean isAndroid(HttpServletRequest request) {
060                    return getBrowserSniffer().isAndroid(request);
061            }
062    
063            public static boolean isChrome(HttpServletRequest request) {
064                    return getBrowserSniffer().isChrome(request);
065            }
066    
067            public static boolean isFirefox(HttpServletRequest request) {
068                    return getBrowserSniffer().isFirefox(request);
069            }
070    
071            public static boolean isGecko(HttpServletRequest request) {
072                    return getBrowserSniffer().isGecko(request);
073            }
074    
075            public static boolean isIe(HttpServletRequest request) {
076                    return getBrowserSniffer().isIe(request);
077            }
078    
079            public static boolean isIeOnWin32(HttpServletRequest request) {
080                    return getBrowserSniffer().isIeOnWin32(request);
081            }
082    
083            public static boolean isIeOnWin64(HttpServletRequest request) {
084                    return getBrowserSniffer().isIeOnWin64(request);
085            }
086    
087            public static boolean isIphone(HttpServletRequest request) {
088                    return getBrowserSniffer().isIphone(request);
089            }
090    
091            public static boolean isLinux(HttpServletRequest request) {
092                    return getBrowserSniffer().isLinux(request);
093            }
094    
095            public static boolean isMac(HttpServletRequest request) {
096                    return getBrowserSniffer().isMac(request);
097            }
098    
099            public static boolean isMobile(HttpServletRequest request) {
100                    return getBrowserSniffer().isMobile(request);
101            }
102    
103            public static boolean isMozilla(HttpServletRequest request) {
104                    return getBrowserSniffer().isMozilla(request);
105            }
106    
107            public static boolean isOpera(HttpServletRequest request) {
108                    return getBrowserSniffer().isOpera(request);
109            }
110    
111            public static boolean isRtf(HttpServletRequest request) {
112                    return getBrowserSniffer().isRtf(request);
113            }
114    
115            public static boolean isSafari(HttpServletRequest request) {
116                    return getBrowserSniffer().isSafari(request);
117            }
118    
119            public static boolean isSun(HttpServletRequest request) {
120                    return getBrowserSniffer().isSun(request);
121            }
122    
123            public static boolean isWap(HttpServletRequest request) {
124                    return getBrowserSniffer().isWap(request);
125            }
126    
127            public static boolean isWapXhtml(HttpServletRequest request) {
128                    return getBrowserSniffer().isWapXhtml(request);
129            }
130    
131            public static boolean isWebKit(HttpServletRequest request) {
132                    return getBrowserSniffer().isWebKit(request);
133            }
134    
135            public static boolean isWindows(HttpServletRequest request) {
136                    return getBrowserSniffer().isWindows(request);
137            }
138    
139            public static boolean isWml(HttpServletRequest request) {
140                    return getBrowserSniffer().isWml(request);
141            }
142    
143            public void setBrowserSniffer(BrowserSniffer browserSniffer) {
144                    PortalRuntimePermission.checkSetBeanProperty(getClass());
145    
146                    _browserSniffer = browserSniffer;
147            }
148    
149            private static BrowserSniffer _browserSniffer;
150    
151    }