Changeset 28499 in webkit
- Timestamp:
- Dec 6, 2007 2:36:10 PM (16 years ago)
- Location:
- trunk/WebKit/mac
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebKit/mac/ChangeLog
r28468 r28499 1 2007-12-06 Darin Adler <darin@apple.com> 2 3 Reviewed by Tim Hatcher. 4 5 - fix <rdar://problem/5513394> No way to detect Tiger vs Leopard from Safari's user agent string 6 7 * WebView/WebView.mm: 8 (callGestalt): Added. 9 (createMacOSXVersionString): Added. 10 (-[WebView _userAgentWithApplicationName:andWebKitVersion:]): Added Mac OS X version string, 11 right after the string "Mac OS X", but with underscores instead of dots to avoid the dreaded 12 "4." problem (old libraries that think a "4." anywhere in the user agent means Netscape 4). 13 (-[WebView _userAgentForURL:]): Fixed incorrect bug numbers. 14 1 15 2007-12-04 Geoffrey Garen <ggaren@apple.com> 2 16 -
trunk/WebKit/mac/WebView/WebView.mm
r28446 r28499 4061 4061 } 4062 4062 4063 static inline int callGestalt(OSType selector) 4064 { 4065 SInt32 value = 0; 4066 Gestalt(selector, &value); 4067 ASSERT(value); 4068 return value; 4069 } 4070 4071 // Uses underscores instead of dots because if "4." ever appears in a user agent string, old DHTML libraries treat it as Netscape 4. 4072 static NSString *createMacOSXVersionString() 4073 { 4074 // Can't use -[NSProcessInfo operatingSystemVersionString] because it has too much stuff we don't want. 4075 int major = callGestalt(gestaltSystemVersionMajor); 4076 int minor = callGestalt(gestaltSystemVersionMinor); 4077 int bugFix = callGestalt(gestaltSystemVersionBugFix); 4078 if (bugFix) 4079 return [[NSString alloc] initWithFormat:@"%d_%d_%d", major, minor, bugFix]; 4080 if (minor) 4081 return [[NSString alloc] initWithFormat:@"%d_%d", major, minor]; 4082 return [[NSString alloc] initWithFormat:@"%d", major]; 4083 } 4084 4063 4085 - (NSString *)_userAgentWithApplicationName:(NSString *)applicationName andWebKitVersion:(NSString *)version 4064 4086 { 4087 static NSString *osVersion = createMacOSXVersionString(); 4065 4088 NSString *language = [NSUserDefaults _webkit_preferredLanguageCode]; 4066 4089 if ([applicationName length]) 4067 return [NSString stringWithFormat:@"Mozilla/5.0 (Macintosh; U; " PROCESSOR " Mac OS X; %@) AppleWebKit/%@ (KHTML, like Gecko) %@", language, version, applicationName]; 4068 return [NSString stringWithFormat:@"Mozilla/5.0 (Macintosh; U; " PROCESSOR " Mac OS X; %@) AppleWebKit/%@ (KHTML, like Gecko)", language, version]; 4090 return [NSString stringWithFormat:@"Mozilla/5.0 (Macintosh; U; " PROCESSOR " Mac OS X %@; %@) AppleWebKit/%@ (KHTML, like Gecko) %@", 4091 osVersion, language, version, applicationName]; 4092 return [NSString stringWithFormat:@"Mozilla/5.0 (Macintosh; U; " PROCESSOR " Mac OS X %@; %@) AppleWebKit/%@ (KHTML, like Gecko)", 4093 osVersion, language, version]; 4069 4094 } 4070 4095 … … 4073 4098 { 4074 4099 if (_private->useSiteSpecificSpoofing) { 4075 // FIXME: Make this a hash table lookup if more domains need spoofing. 4076 // FIXME: Remove yahoo.com once <rdar://problem/5057117> is fixed. 4100 // FIXME: Remove yahoo.com once <rdar://problem/4549681> is fixed. 4077 4101 if (url.host().endsWith("yahoo.com")) { 4078 4102 static String yahooUserAgent([self _userAgentWithApplicationName:_private->applicationNameForUserAgent andWebKitVersion:@"422"]); … … 4080 4104 } 4081 4105 4082 // FIXME: Remove flickr.com workaround once <rdar://problem/508 4872> is fixed4106 // FIXME: Remove flickr.com workaround once <rdar://problem/5081617> is fixed 4083 4107 if (url.host().endsWith("flickr.com")) { 4084 4108 // Safari 2.0.4's user agent string works here
Note: See TracChangeset
for help on using the changeset viewer.