diff options
author | Henri Sara <henri.sara@itmill.com> | 2009-05-11 09:19:03 +0000 |
---|---|---|
committer | Henri Sara <henri.sara@itmill.com> | 2009-05-11 09:19:03 +0000 |
commit | adc8c0ad3573272c236040c3a76005b9e73a5737 (patch) | |
tree | a3860704dbd5b82dc6af38684b80f8ef79a32722 /src/com/vaadin/terminal/gwt/server/WebBrowser.java | |
parent | 5abc870dda584d0c2fc47fd5eec4ae3de3fa240e (diff) | |
download | vaadin-framework-adc8c0ad3573272c236040c3a76005b9e73a5737.tar.gz vaadin-framework-adc8c0ad3573272c236040c3a76005b9e73a5737.zip |
#2904: initial bulk rename "com.itmill.toolkit" -> "com.vaadin"
- com.itmill.toolkit.external not yet fully renamed
svn changeset:7715/svn branch:6.0
Diffstat (limited to 'src/com/vaadin/terminal/gwt/server/WebBrowser.java')
-rw-r--r-- | src/com/vaadin/terminal/gwt/server/WebBrowser.java | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/src/com/vaadin/terminal/gwt/server/WebBrowser.java b/src/com/vaadin/terminal/gwt/server/WebBrowser.java new file mode 100644 index 0000000000..2ec726fc6a --- /dev/null +++ b/src/com/vaadin/terminal/gwt/server/WebBrowser.java @@ -0,0 +1,98 @@ +/* +@ITMillApache2LicenseForJavaFiles@ + */ + +package com.vaadin.terminal.gwt.server; + +import java.util.Locale; + +import javax.servlet.http.HttpServletRequest; + +import com.vaadin.terminal.Terminal; + +@SuppressWarnings("serial") +public class WebBrowser implements Terminal { + + private int screenHeight = 0; + private int screenWidth = 0; + private String browserApplication = null; + private Locale locale; + private String address; + private boolean secureConnection; + + /** + * There is no default-theme for this terminal type. + * + * @return Allways returns null. + */ + public String getDefaultTheme() { + return null; + } + + /** + * Get the height of the users display in pixels. + * + */ + public int getScreenHeight() { + return screenHeight; + } + + /** + * Get the width of the users display in pixels. + * + */ + public int getScreenWidth() { + return screenWidth; + } + + /** + * Get the browser user-agent string. + * + * @return + */ + public String getBrowserApplication() { + return browserApplication; + } + + void updateBrowserProperties(HttpServletRequest request) { + locale = request.getLocale(); + address = request.getRemoteAddr(); + secureConnection = request.isSecure(); + + final String agent = request.getHeader("user-agent"); + if (agent != null) { + browserApplication = agent; + } + + final String sw = request.getParameter("screenWidth"); + final String sh = request.getParameter("screenHeight"); + if (sw != null && sh != null) { + try { + screenHeight = Integer.parseInt(sh); + screenWidth = Integer.parseInt(sw); + } catch (final NumberFormatException e) { + screenHeight = screenWidth = 0; + } + } + } + + /** + * Get the IP-address of the web browser. + * + * @return IP-address in 1.12.123.123 -format + */ + public String getAddress() { + return address; + } + + /** Get the default locate of the browser. */ + public Locale getLocale() { + return locale; + } + + /** Is the connection made using HTTPS? */ + public boolean isSecureConnection() { + return secureConnection; + } + +} |