Changeset 28499 in webkit


Ignore:
Timestamp:
Dec 6, 2007 2:36:10 PM (16 years ago)
Author:
Darin Adler
Message:

Reviewed by Tim Hatcher.

  • fix <rdar://problem/5513394> No way to detect Tiger vs Leopard from Safari's user agent string
  • WebView/WebView.mm: (callGestalt): Added. (createMacOSXVersionString): Added. (-[WebView _userAgentWithApplicationName:andWebKitVersion:]): Added Mac OS X version string, right after the string "Mac OS X", but with underscores instead of dots to avoid the dreaded "4." problem (old libraries that think a "4." anywhere in the user agent means Netscape 4). (-[WebView _userAgentForURL:]): Fixed incorrect bug numbers.
Location:
trunk/WebKit/mac
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKit/mac/ChangeLog

    r28468 r28499  
     12007-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
    1152007-12-04  Geoffrey Garen  <ggaren@apple.com>
    216
  • trunk/WebKit/mac/WebView/WebView.mm

    r28446 r28499  
    40614061}
    40624062
     4063static 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.
     4072static 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
    40634085- (NSString *)_userAgentWithApplicationName:(NSString *)applicationName andWebKitVersion:(NSString *)version
    40644086{
     4087    static NSString *osVersion = createMacOSXVersionString();
    40654088    NSString *language = [NSUserDefaults _webkit_preferredLanguageCode];
    40664089    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];
    40694094}
    40704095
     
    40734098{
    40744099    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.
    40774101        if (url.host().endsWith("yahoo.com")) {
    40784102            static String yahooUserAgent([self _userAgentWithApplicationName:_private->applicationNameForUserAgent andWebKitVersion:@"422"]);
     
    40804104        }
    40814105       
    4082         // FIXME: Remove flickr.com workaround once <rdar://problem/5084872> is fixed
     4106        // FIXME: Remove flickr.com workaround once <rdar://problem/5081617> is fixed
    40834107        if (url.host().endsWith("flickr.com")) {
    40844108            // Safari 2.0.4's user agent string works here
Note: See TracChangeset for help on using the changeset viewer.