Example usage for com.vaadin.server WebBrowser isChrome

List of usage examples for com.vaadin.server WebBrowser isChrome

Introduction

In this page you can find the example usage for com.vaadin.server WebBrowser isChrome.

Prototype

public boolean isChrome() 

Source Link

Document

Tests whether the user is using Chrome.

Usage

From source file:com.haulmont.cuba.web.config.WebDeviceInfoProvider.java

License:Apache License

@Nullable
@Override//from  w  ww  .  j a v  a2s.c om
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;
}

From source file:edu.nps.moves.mmowgli.MmowgliSessionGlobals.java

License:Open Source License

private String returnBrowserType(WebBrowser webBr) {
    if (webBr.isFirefox()) {
        return "Firefox";
    }/* w w  w .  j  a v  a 2  s.  c om*/
    if (webBr.isSafari()) {
        return "Safari";
    }
    if (webBr.isIE()) {
        return "IE";
    }
    if (webBr.isChrome()) {
        return "Chrome";
    }
    if (webBr.isOpera()) {
        return "Opera";
    }
    if (webBr.isLinux()) {
        return "Linux";
    }
    if (webBr.isAndroid()) {
        return "Android";
    }
    if (webBr.isIPhone()) {
        return "IPhone";
    }
    if (webBr.isIPad()) {
        return "IPad";
    }
    if (webBr.isIOS()) {
        return "IOS";
    }
    return "";
}

From source file:fr.amapj.service.services.session.SessionManager.java

License:Open Source License

/**
 * Permet d'obtenir le nom du navigateur en clair
 *//*from   ww w. ja va 2 s  .c  om*/
public static String getAgentName(UI ui) {
    if (ui.getSession() == null) {
        return "Session null";
    }

    WebBrowser browser = ui.getPage().getWebBrowser();
    if (browser.isChrome()) {
        return "Chrome " + browser.getBrowserMajorVersion();
    } else if (browser.isFirefox()) {
        return "Firefox " + browser.getBrowserMajorVersion();
    } else if (browser.isIE()) {
        return "IE " + browser.getBrowserMajorVersion();
    } else if (browser.isOpera()) {
        return "Opera " + browser.getBrowserMajorVersion();
    } else if (browser.isSafari()) {
        return "Safari " + browser.getBrowserMajorVersion();
    } else if (browser.isEdge()) {
        return "Edge " + browser.getBrowserMajorVersion();
    } else {
        return "XX";
    }
}

From source file:org.vaadin.tori.component.BBCodeWysiwygEditor.java

License:Apache License

private void configurePlugins(final CKEditorConfig config, final boolean autoGrow, final boolean bbcode) {
    if (bbcode) {
        config.addToExtraPlugins("custombbcode");
    }/*w ww  .  ja  v  a2s.  c om*/
    config.addToExtraPlugins("codebutton");
    config.addToRemovePlugins("magicline");

    WebBrowser browser = Page.getCurrent().getWebBrowser();
    boolean disableResizer = true;
    if (autoGrow) {
        if (browser.isChrome() || browser.isSafari() || browser.isOpera()) {
            config.addToExtraPlugins("autogrow");
        } else {
            disableResizer = false;
        }
    }

    if (disableResizer) {
        config.disableResizeEditor();
    }
}