List of usage examples for com.liferay.portal.kernel.servlet BrowserSnifferUtil isSafari
public static boolean isSafari(HttpServletRequest httpServletRequest)
From source file:com.liferay.content.targeting.rule.browser.BrowserRule.java
License:Open Source License
@Override public boolean evaluate(HttpServletRequest request, RuleInstance ruleInstance, AnonymousUser anonymousUser) throws Exception { String browser = ruleInstance.getTypeSettings(); if (browser.equals(CHROME) && BrowserSnifferUtil.isChrome(request)) { return true; } else if (browser.equals(FIREFOX) && BrowserSnifferUtil.isFirefox(request)) { return true; } else if (browser.equals(IE) && BrowserSnifferUtil.isIe(request)) { return true; } else if (browser.equals(OPERA) && BrowserSnifferUtil.isOpera(request)) { return true; } else if (browser.equals(SAFARI) && BrowserSnifferUtil.isSafari(request)) { return true; }//w w w . java2 s . c o m return false; }
From source file:com.liferay.content.targeting.rule.browser.BrowserRuleTest.java
License:Open Source License
@Test public void testSafari() throws Exception { when(_ruleInstance.getTypeSettings()).thenReturn(BrowserRule.SAFARI); when(BrowserSnifferUtil.isSafari(_request)).thenReturn(true); Assert.assertTrue(_browserRule.evaluate(_request, _ruleInstance, _anonymousUser)); }
From source file:org.apache.jsp.html.js.editor.editor_jsp.java
License:Open Source License
public void _jspService(HttpServletRequest request, HttpServletResponse response) throws java.io.IOException, ServletException { PageContext pageContext = null;/*from ww w .j a v a2s . co m*/ HttpSession session = null; ServletContext application = null; ServletConfig config = null; JspWriter out = null; Object page = this; JspWriter _jspx_out = null; PageContext _jspx_page_context = null; try { response.setContentType("text/html"); pageContext = _jspxFactory.getPageContext(this, request, response, null, true, 8192, true); _jspx_page_context = pageContext; application = pageContext.getServletContext(); config = pageContext.getServletConfig(); session = pageContext.getSession(); out = pageContext.getOut(); _jspx_out = out; /** * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved. * * This library is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. */ out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); String editorImpl = ParamUtil.getString(request, "editorImpl", PropsValues.EDITOR_WYSIWYG_DEFAULT); if (!BrowserSnifferUtil.isRtf(request)) { if (BrowserSnifferUtil.isSafari(request) && BrowserSnifferUtil.isMobile(request)) { editorImpl = "simple"; } else if (BrowserSnifferUtil.isSafari(request) && (editorImpl.indexOf("simple") == -1)) { editorImpl = "tinymcesimple"; } else { editorImpl = "simple"; } } //editorImpl = "fckeditor"; //editorImpl = "liferay"; //editorImpl = "simple"; //editorImpl = "tinymce"; //editorImpl = "tinymcesimple"; // Resin won't allow dynamic content inside the jsp:include tag RequestDispatcher rd = application .getRequestDispatcher(StrutsUtil.TEXT_HTML_DIR + "/js/editor/" + editorImpl + ".jsp"); rd.include(request, response); out.write('\n'); out.write('\n'); } catch (Throwable t) { if (!(t instanceof SkipPageException)) { out = _jspx_out; if (out != null && out.getBufferSize() != 0) try { out.clearBuffer(); } catch (java.io.IOException e) { } if (_jspx_page_context != null) _jspx_page_context.handlePageException(t); } } finally { _jspxFactory.releasePageContext(_jspx_page_context); } }