| <!-- --> | |
| <!-- Copyright 2007 Google Inc. --> | |
| <!-- Licensed under the Apache License, Version 2.0 (the "License"); you --> | |
| <!-- may not use this file except in compliance with the License. You may --> | |
| <!-- may obtain a copy of the License at --> | |
| <!-- --> | |
| <!-- http://www.apache.org/licenses/LICENSE-2.0 --> | |
| <!-- --> | |
| <!-- Unless required by applicable law or agreed to in writing, software --> | |
| <!-- distributed under the License is distributed on an "AS IS" BASIS, --> | |
| <!-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or --> | |
| <!-- implied. License for the specific language governing permissions and --> | |
| <!-- limitations under the License. --> | |
| <!-- Defines the user.agent property and its provider function. --> | |
| <!-- --> | |
| <!-- This module is typically inherited via com.google.gwt.user.User --> | |
| <!-- --> | |
| <module> | |
| <!-- Browser-sensitive code should use the 'user.agent' property --> | |
| <define-property name="user.agent" values="ie6,gecko,gecko1_8,safari,opera"/> | |
| <property-provider name="user.agent"><![CDATA[ | |
| var ua = navigator.userAgent.toLowerCase(); | |
| var makeVersion = function(result) { | |
| return (parseInt(result[1]) * 1000) + parseInt(result[2]); | |
| }; | |
| if (ua.indexOf("opera") != -1) { | |
| return "opera"; | |
| } else if (ua.indexOf("webkit") != -1) { | |
| return "safari"; | |
| } else if (ua.indexOf("msie") != -1) { | |
| var result = /msie ([0-9]+)\.([0-9]+)/.exec(ua); | |
| if (result && result.length == 3) { | |
| if (makeVersion(result) >= 6000) { | |
| return "ie6"; | |
| } | |
| } | |
| } else if (ua.indexOf("gecko") != -1) { | |
| var result = /rv:([0-9]+)\.([0-9]+)/.exec(ua); | |
| if (result && result.length == 3) { | |
| if (makeVersion(result) >= 1008) | |
| return "gecko1_8"; | |
| } | |
| return "gecko"; | |
| } | |
| return "unknown"; | |
| ]]></property-provider> | |
| </module> |