private Locale getClientsLocale() { return Page.getCurrent().getWebBrowser().getLocale(); } }
+ "</head>" + "<body><h1>I'm sorry, but your browser is not supported</h1>" + "<p>The version (" + b.getBrowserMajorVersion() + "." + b.getBrowserMinorVersion() + ") of the browser you are using " + " is outdated and not supported.</p>" + " <a href=\"https://www.google.com/chrome\">Chrome</a>," + " <a href=\"http://www.mozilla.com/firefox\">Firefox</a>," + (b.isWindows() ? " <a href=\"http://windows.microsoft.com/en-US/internet-explorer/downloads/ie\">Internet Explorer</a>," : "") + " and <a href=\"http://www.apple.com/safari\">Safari</a>.</b><br/>" + "Upgrading to the latest version of one of these <b>will make the web safer, faster and better looking.</b></p>" + (b.isIE() ? "<script type=\"text/javascript\" src=\"http://ajax.googleapis.com/ajax/libs/chrome-frame/1/CFInstall.min.js\"></script>" + "<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>"
protected TimeZone detectTimeZone() { WebBrowser webBrowser = getWebBrowserDetails(); int offset = webBrowser.getTimezoneOffset() / 1000 / 60; char sign = offset >= 0 ? '+' : '-'; int absOffset = Math.abs(offset); String hours = StringUtils.leftPad(String.valueOf(absOffset / 60), 2, '0'); String minutes = StringUtils.leftPad(String.valueOf(absOffset % 60), 2, '0'); return TimeZone.getTimeZone("GMT" + sign + hours + minutes); }
protected boolean useWrapper() { Page current = Page.getCurrent(); if (current != null) { WebBrowser browser = current.getWebBrowser(); return browser != null && (browser.isIE() && browser.getBrowserMajorVersion() <= 10 || browser.isSafari()); } else { return false; } }
private static boolean isUnsupportedBrowser() { final WebBrowser webBrowser = Page.getCurrent().getWebBrowser(); return webBrowser.isIE() && webBrowser.getBrowserMajorVersion() < 11; }
di.setAddress(webBrowser.getAddress()); di.setBrowserApplication(webBrowser.getBrowserApplication()); di.setBrowserMajorVersion(webBrowser.getBrowserMajorVersion()); di.setBrowserMinorVersion(webBrowser.getBrowserMinorVersion()); di.setChrome(webBrowser.isChrome()); di.setChromeFrame(webBrowser.isChromeFrame()); di.setChromeFrameCapable(webBrowser.isChromeFrameCapable()); di.setEdge(webBrowser.isEdge()); di.setFirefox(webBrowser.isFirefox()); di.setOpera(webBrowser.isOpera()); di.setIE(webBrowser.isIE()); if (webBrowser.isWindows()) { di.setOperatingSystem(OperatingSystem.WINDOWS); } else if (webBrowser.isAndroid()) { di.setOperatingSystem(OperatingSystem.ANDROID); } else if (webBrowser.isIOS()) { di.setOperatingSystem(OperatingSystem.IOS); } else if (webBrowser.isMacOSX()) { di.setOperatingSystem(OperatingSystem.MACOSX); } else if (webBrowser.isLinux()) { di.setOperatingSystem(OperatingSystem.LINUX); di.setIPad(webBrowser.isIPad()); di.setIPhone(webBrowser.isIPhone()); di.setWindowsPhone(webBrowser.isWindowsPhone()); di.setSecureConnection(webBrowser.isSecureConnection());
@Test public void datesAcrossDstUserDoesNotObserveDstAndKnowsThatSystemDoes() throws Exception { // GIVEN TimeZone oldTimeZone = TimeZone.getDefault(); TimeZone.setDefault(TimeZone.getTimeZone("Europe/London")); // Simulating browser offset prior to the March 2017 DST switch. // User is in Ho Chi Minh City, Vietnam this time, sends browser info accordingly when(browserInfo.getTimezoneOffset()).thenReturn(7 * 60 * 60 * 1000); when(browserInfo.getRawTimezoneOffset()).thenReturn(7 * 60 * 60 * 1000); DateField field = (DateField) factory.createField(); Date expectedDate = Date.from(LocalDateTime.of(2017, MARCH.getValue(), 25, 0, 0).atZone(ZoneId.of("Asia/Ho_Chi_Minh")).toInstant()); Date expectedDateDst = Date.from(LocalDateTime.of(2017, MARCH.getValue(), 27, 0, 0).atZone(ZoneId.of("Asia/Ho_Chi_Minh")).toInstant()); // Before the switch to DST // WHEN–THEN (Vaadin) enterDate(field, 2017, MARCH, 24, 17, 0); // user aligns with midnight in HCMC, does the maths herself assertEquals(expectedDate, nodeAdapter.getItemProperty("startDate").getValue()); // WHEN–THEN (JCR) Node node = nodeAdapter.applyChanges(); assertThat(node, hasProperty("startDate", expectedDate)); // After the switch to DST // WHEN–THEN (Vaadin) enterDate(field, 2017, MARCH, 26, 18, 0); // user aligns with midnight in HCMC, does the maths herself assertEquals(expectedDateDst, nodeAdapter.getItemProperty("startDate").getValue()); // WHEN–THEN (JCR) node = nodeAdapter.applyChanges(); assertThat(node, hasProperty("startDate", expectedDateDst)); TimeZone.setDefault(oldTimeZone); }
+ "<p>The version (" + b.getBrowserMajorVersion() + "." + b.getBrowserMinorVersion() + ") of the browser you are using " + " is outdated and not supported.</p>"
@Override public boolean synchronizedHandleRequest(VaadinSession session, VaadinRequest request, VaadinResponse response) throws IOException { try { assert UI.getCurrent() == null; // Update browser information from the request session.getBrowser().updateRequestDetails(request); UI uI = getBrowserDetailsUI(request, session); session.getCommunicationManager().repaintAll(uI); JsonObject params = Json.createObject(); params.put(UIConstants.UI_ID_PARAMETER, uI.getUIId()); String initialUIDL = getInitialUidl(request, uI); params.put("uidl", initialUIDL); return commitJsonResponse(request, response, JsonUtil.stringify(params)); } catch (JsonException e) { throw new IOException("Error producing initial UIDL", e); } }
@Override public void changeVariables(Object source, Map<String, Object> variables) { if (Page.getCurrent().getWebBrowser().isIE() && variables.containsKey("clickEvent")) { focus(); } super.changeVariables(source, variables); if (shortcutActionManager != null) { shortcutActionManager.handleActions(variables, this); } }
@Override public int getScreenHeight() { WebBrowser browser = (Page.getCurrent() != null) ? Page.getCurrent().getWebBrowser() : null; if (browser != null) { return browser.getScreenHeight(); } return -1; }
@Override public int getScreenWidth() { WebBrowser browser = (Page.getCurrent() != null) ? Page.getCurrent().getWebBrowser() : null; if (browser != null) { return browser.getScreenWidth(); } return -1; }
/** * Get browser time zone. * * @return TimeZone */ public static TimeZone getBrowserTimeZone() { final WebBrowser webBrowser = com.vaadin.server.Page.getCurrent().getWebBrowser(); final String[] timeZones = TimeZone.getAvailableIDs(webBrowser.getRawTimezoneOffset()); TimeZone tz = TimeZone.getDefault(); for (final String string : timeZones) { final TimeZone t = TimeZone.getTimeZone(string); if (t.getRawOffset() == webBrowser.getRawTimezoneOffset()) { tz = t; } } return tz; }
when(browserInfo.getTimezoneOffset()).thenReturn(0); when(browserInfo.getRawTimezoneOffset()).thenReturn(0);
private static boolean isUnsupportedBrowser() { final WebBrowser webBrowser = Page.getCurrent().getWebBrowser(); return webBrowser.isIE() && webBrowser.getBrowserMajorVersion() < 11; }
/** * Creates and registers a new VaadinSession for this service. Assumes * proper locking has been taken care of by the caller. * * * @param request * The request which triggered session creation. * @return A new VaadinSession instance * @throws ServiceException */ private VaadinSession createAndRegisterSession(VaadinRequest request) throws ServiceException { assert ((ReentrantLock) getSessionLock(request.getWrappedSession())) .isHeldByCurrentThread() : "Session has not been locked by this thread"; VaadinSession session = createVaadinSession(request); VaadinSession.setCurrent(session); storeSession(session, request.getWrappedSession()); // Initial WebBrowser data comes from the request session.getBrowser().updateRequestDetails(request); // Initial locale comes from the request Locale locale = request.getLocale(); session.setLocale(locale); session.setConfiguration(getDeploymentConfiguration()); session.setCommunicationManager( new LegacyCommunicationManager(session)); ServletPortletHelper.initDefaultUIProvider(session, this); onVaadinSessionStarted(request, session); return session; }
@Override public void changeVariables(Object source, Map<String, Object> variables) { if (Page.getCurrent().getWebBrowser().isIE() && variables.containsKey("clickEvent")) { focus(); } super.changeVariables(source, variables); if (shortcutActionManager != null) { shortcutActionManager.handleActions(variables, this); } if (variables.containsKey("updateAggregationRow")) { Boolean updateAggregationRow = (Boolean) variables.get("updateAggregationRow"); if (updateAggregationRow) { markAsDirty(); } } }
@Override public int getScreenHeight() { WebBrowser browser = (Page.getCurrent() != null) ? Page.getCurrent().getWebBrowser() : null; if (browser != null) { return browser.getScreenHeight(); } return -1; }