use of com.vaadin.server.WebBrowser in project cuba by cuba-platform.
the class WebDeviceInfoProvider method getDeviceInfo.
@Nullable
@Override
public DeviceInfo getDeviceInfo() {
// per request cache
HttpServletRequest currentServletRequest = VaadinServletService.getCurrentServletRequest();
if (currentServletRequest == null) {
return null;
}
DeviceInfo deviceInfo = (DeviceInfo) currentServletRequest.getAttribute(DeviceInfoProvider.NAME);
if (deviceInfo != null) {
return deviceInfo;
}
Page page = Page.getCurrent();
if (page == null) {
return null;
}
WebBrowser webBrowser = page.getWebBrowser();
DeviceInfo di = new DeviceInfo();
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());
di.setLocale(webBrowser.getLocale());
di.setScreenHeight(webBrowser.getScreenHeight());
di.setScreenWidth(webBrowser.getScreenWidth());
currentServletRequest.setAttribute(DeviceInfoProvider.NAME, di);
return di;
}
use of com.vaadin.server.WebBrowser in project cia by Hack23.
the class CitizenIntelligenceAgencyUI method init.
@Override
protected void init(final VaadinRequest request) {
VaadinSession.getCurrent().setErrorHandler(new UiInstanceErrorHandler(this));
setSizeFull();
springNavigator.addView(CRLF_REPLACEMENT, mainView);
setNavigator(springNavigator);
final Page currentPage = Page.getCurrent();
final String requestUrl = currentPage.getLocation().toString();
final String language = request.getLocale().getLanguage();
final UserConfiguration userConfiguration = configurationManager.getUserConfiguration(requestUrl, language);
currentPage.setTitle(userConfiguration.getAgency().getAgencyName() + ":" + userConfiguration.getPortal().getPortalName() + ":" + userConfiguration.getLanguage().getLanguageName());
if (getSession().getUIs().isEmpty()) {
final WebBrowser webBrowser = currentPage.getWebBrowser();
final CreateApplicationSessionRequest serviceRequest = new CreateApplicationSessionRequest();
serviceRequest.setSessionId(RequestContextHolder.currentRequestAttributes().getSessionId());
final String ipInformation = WebBrowserUtil.getIpInformation(webBrowser);
serviceRequest.setIpInformation(ipInformation);
serviceRequest.setTimeZone(webBrowser.getTimeZoneId());
serviceRequest.setScreenSize(webBrowser.getScreenWidth() + "x" + webBrowser.getScreenHeight());
serviceRequest.setUserAgentInformation(webBrowser.getBrowserApplication());
serviceRequest.setLocale(webBrowser.getLocale().toString());
serviceRequest.setOperatingSystem(WebBrowserUtil.getOperatingSystem(webBrowser));
serviceRequest.setSessionType(ApplicationSessionType.ANONYMOUS);
final ServiceResponse serviceResponse = applicationManager.service(serviceRequest);
LOGGER.info(LOG_INFO_BROWSER_ADDRESS_APPLICATION_SESSION_ID_RESULT, requestUrl.replaceAll(CRLF, CRLF_REPLACEMENT), language.replaceAll(CRLF, CRLF_REPLACEMENT), ipInformation.replaceAll(CRLF, CRLF_REPLACEMENT), webBrowser.getBrowserApplication().replaceAll(CRLF, CRLF_REPLACEMENT), serviceRequest.getSessionId().replaceAll(CRLF, CRLF_REPLACEMENT), serviceResponse.getResult().toString().replaceAll(CRLF, CRLF_REPLACEMENT));
}
}
Aggregations