litesoft
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
package com.temp.client.foundation.support.useragent;
import com.google.gwt.core.client.GWT;
/**
* This class provides extended support over the built in GWT User Agent code
*
* @author georgs
*/
public class UserAgent {
/**
* Specific User Agents:
*/
public static final String FIREFOX = "Firefox";
public static final String SAFARI = "Safari";
public static final String CHROME = "Chrome";
public static final String OPERA = "Opera";
/**
* Unlike the others above, since IE is so "variable" from version to
* version, the "Specific" is made from the the IE_PREFIX and the specific
* version number (e.g. IE6, IE7, IE8, IE9, ...).
*/
public static final String IE_PREFIX = "IE";
private static UserAgent sInstance = null;
public static UserAgent getInstance() {
if (sInstance == null) {
sInstance = (UserAgent) GWT.create(UserAgent.class);
}
return sInstance;
}
private Platform mPlatform;
private BrowserFamily mFamily;
protected String mSpecific;
protected UserAgent() {
this(BrowserFamily.Other, "");
}
protected UserAgent(BrowserFamily pFamily, String pSpecific) {
mFamily = pFamily;
mSpecific = pSpecific;
String zUserAgent = getBrowserUserAgent().toLowerCase();
if (zUserAgent.contains("win")) {
mPlatform = Platform.Win;
} else if (zUserAgent.contains("mac")) {
mPlatform = Platform.Mac;
} else {
mPlatform = Platform.Other;
}
}
public Platform getPlatform() {
return mPlatform;
}
public BrowserFamily getFamily() {
return mFamily;
}
public String getSpecific() {
return mSpecific;
}
public boolean isLegacyIE() {
return false;
}
public static native String getBrowserUserAgent() /*-{
return navigator.userAgent;
}-*/;
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(mPlatform);
sb.append('-').append(mFamily).append('-').append(mSpecific);
sb.append(" '").append(getBrowserUserAgent()).append("'");
return sb.toString();
}
}
|
Revision |
Author |
Commited |
Message |
626
|
GeorgeS
|
Wed 11 Apr, 2012 19:39:41 +0000 |
|