Changeset 170734 in webkit


Ignore:
Timestamp:
Jul 2, 2014, 4:02:43 PM (12 years ago)
Author:
mrowe@apple.com
Message:

<https://webkit.org/b/134522> Remove duplication in code that prepares the user agent string on Mac and iOS

Reviewed by Simon Fraser.

Source/WebCore:

  • page/cocoa/UserAgent.h:
  • page/cocoa/UserAgent.mm:

(WebCore::userVisibleWebKitBundleVersionFromFullVersion): Moved from WebKit2.

  • page/ios/UserAgentIOS.mm:

(WebCore::standardUserAgentWithApplicationName): Pass the WebKit bundle version through userVisibleWebKitBundleVersionFromFullVersion
before including it in the user agent string.

  • page/mac/UserAgentMac.mm:

(WebCore::standardUserAgentWithApplicationName): Ditto.

Source/WebKit/mac:

  • WebView/WebView.mm:

(webKitBundleVersionString): Return the entire CFBundleVersion now that WebCore handles formatting it.
(+[WebView _standardUserAgentWithApplicationName:]):

Source/WebKit2:

  • UIProcess/ios/WebPageProxyIOS.mm:

(WebKit::webKitBundleVersionString): Return the entire CFBundleVersion now that WebCore handles formatting it.
(WebKit::WebPageProxy::standardUserAgent):

  • UIProcess/mac/WebPageProxyMac.mm:

(WebKit::webKitBundleVersionString): Ditto.
(WebKit::WebPageProxy::standardUserAgent):

Location:
trunk/Source
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r170730 r170734  
     12014-07-01  Mark Rowe  <mrowe@apple.com>
     2
     3        <https://webkit.org/b/134522> Remove duplication in code that prepares the user agent string on Mac and iOS
     4
     5        Reviewed by Simon Fraser.
     6
     7        * page/cocoa/UserAgent.h:
     8        * page/cocoa/UserAgent.mm:
     9        (WebCore::userVisibleWebKitBundleVersionFromFullVersion): Moved from WebKit2.
     10        * page/ios/UserAgentIOS.mm:
     11        (WebCore::standardUserAgentWithApplicationName): Pass the WebKit bundle version through userVisibleWebKitBundleVersionFromFullVersion
     12        before including it in the user agent string.
     13        * page/mac/UserAgentMac.mm:
     14        (WebCore::standardUserAgentWithApplicationName): Ditto.
     15
    1162014-07-02  Mark Rowe  <mrowe@apple.com>
    217
  • trunk/Source/WebCore/page/cocoa/UserAgent.h

    r170730 r170734  
    3030
    3131namespace WebCore {
     32
    3233String standardUserAgentWithApplicationName(const String& applicationName, const String& webkitVersionString);
     34
    3335String systemMarketingVersionForUserAgentString();
     36String userVisibleWebKitBundleVersionFromFullVersion(const String&);
     37
    3438}
    3539
  • trunk/Source/WebCore/page/cocoa/UserAgent.mm

    r170730 r170734  
    3939}
    4040
     41String userVisibleWebKitBundleVersionFromFullVersion(const String& fullWebKitVersionString)
     42{
     43    NSString *fullWebKitVersion = fullWebKitVersionString;
     44
     45    // If the version is longer than 3 digits then the leading digits represent the version of the OS. Our user agent
     46    // string should not include the leading digits, so strip them off and report the rest as the version. <rdar://problem/4997547>
     47    NSRange nonDigitRange = [fullWebKitVersion rangeOfCharacterFromSet:[[NSCharacterSet decimalDigitCharacterSet] invertedSet]];
     48    if (nonDigitRange.location == NSNotFound && fullWebKitVersion.length > 3)
     49        return [fullWebKitVersion substringFromIndex:fullWebKitVersion.length - 3];
     50    if (nonDigitRange.location != NSNotFound && nonDigitRange.location > 3)
     51        return [fullWebKitVersion substringFromIndex:nonDigitRange.location - 3];
     52    return fullWebKitVersion;
     53}
     54
    4155} // namespace WebCore
  • trunk/Source/WebCore/page/ios/UserAgentIOS.mm

    r170730 r170734  
    3232namespace WebCore {
    3333
    34 String standardUserAgentWithApplicationName(const String& applicationName, const String& webkitVersionString)
     34String standardUserAgentWithApplicationName(const String& applicationName, const String& fullWebKitVersionString)
    3535{
    3636    if (CFStringRef overrideUserAgent = wkGetUserAgent())
     
    4545    }
    4646
    47     NSString *webKitVersion = webkitVersionString;
     47    NSString *webKitVersion = userVisibleWebKitBundleVersionFromFullVersion(fullWebKitVersionString);
    4848    CFStringRef deviceName = wkGetDeviceName();
    4949    CFStringRef osNameForUserAgent = wkGetOSNameForUserAgent();
  • trunk/Source/WebCore/page/mac/UserAgentMac.mm

    r170730 r170734  
    3939#endif
    4040
    41 String standardUserAgentWithApplicationName(const String& applicationName, const String& webKitVersionString)
     41String standardUserAgentWithApplicationName(const String& applicationName, const String& fullWebKitVersionString)
    4242{
    4343    String osVersion = systemMarketingVersionForUserAgentString();
     44    String webKitVersionString = userVisibleWebKitBundleVersionFromFullVersion(fullWebKitVersionString);
    4445
    4546    if (applicationName.isEmpty())
  • trunk/Source/WebKit/mac/ChangeLog

    r170710 r170734  
     12014-07-01  Mark Rowe  <mrowe@apple.com>
     2
     3        <https://webkit.org/b/134522> Remove duplication in code that prepares the user agent string on Mac and iOS
     4
     5        Reviewed by Simon Fraser.
     6
     7        * WebView/WebView.mm:
     8        (webKitBundleVersionString): Return the entire CFBundleVersion now that WebCore handles formatting it.
     9        (+[WebView _standardUserAgentWithApplicationName:]):
     10
    1112014-07-02  Dan Bernstein  <mitz@apple.com>
    212
  • trunk/Source/WebKit/mac/WebView/WebView.mm

    r170710 r170734  
    678678@implementation WebView (WebPrivate)
    679679
    680 static String userVisibleWebKitVersionString()
    681 {
    682     // If the version is longer than 3 digits then the leading digits represent the version of the OS. Our user agent
    683     // string should not include the leading digits, so strip them off and report the rest as the version. <rdar://problem/4997547>
    684     NSString *fullVersion = [[NSBundle bundleForClass:[WebView class]] objectForInfoDictionaryKey:(NSString *)kCFBundleVersionKey];
    685     NSRange nonDigitRange = [fullVersion rangeOfCharacterFromSet:[[NSCharacterSet decimalDigitCharacterSet] invertedSet]];
    686     if (nonDigitRange.location == NSNotFound && fullVersion.length > 3)
    687         return [fullVersion substringFromIndex:fullVersion.length - 3];
    688     if (nonDigitRange.location != NSNotFound && nonDigitRange.location > 3)
    689         return [fullVersion substringFromIndex:nonDigitRange.location - 3];
    690     return fullVersion;
     680static String webKitBundleVersionString()
     681{
     682    return [[NSBundle bundleForClass:[WebView class]] objectForInfoDictionaryKey:(NSString *)kCFBundleVersionKey];
    691683}
    692684
    693685+ (NSString *)_standardUserAgentWithApplicationName:(NSString *)applicationName
    694686{
    695     return standardUserAgentWithApplicationName(applicationName, userVisibleWebKitVersionString());
     687    return standardUserAgentWithApplicationName(applicationName, webKitBundleVersionString());
    696688}
    697689
  • trunk/Source/WebKit2/ChangeLog

    r170733 r170734  
     12014-07-01  Mark Rowe  <mrowe@apple.com>
     2
     3        <https://webkit.org/b/134522> Remove duplication in code that prepares the user agent string on Mac and iOS
     4
     5        Reviewed by Simon Fraser.
     6
     7        * UIProcess/ios/WebPageProxyIOS.mm:
     8        (WebKit::webKitBundleVersionString): Return the entire CFBundleVersion now that WebCore handles formatting it.
     9        (WebKit::WebPageProxy::standardUserAgent):
     10        * UIProcess/mac/WebPageProxyMac.mm:
     11        (WebKit::webKitBundleVersionString): Ditto.
     12        (WebKit::WebPageProxy::standardUserAgent):
     13
    1142014-06-28  Oliver Hunt  <oliver@apple.com>
    215
  • trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm

    r170491 r170734  
    6262}
    6363
    64 static String userVisibleWebKitVersionString()
    65 {
    66     // If the version is longer than 3 digits then the leading digits represent the version of the OS. Our user agent
    67     // string should not include the leading digits, so strip them off and report the rest as the version. <rdar://problem/4997547>
    68     NSString *fullVersion = [[NSBundle bundleForClass:NSClassFromString(@"WKView")] objectForInfoDictionaryKey:(NSString *)kCFBundleVersionKey];
    69     NSRange nonDigitRange = [fullVersion rangeOfCharacterFromSet:[[NSCharacterSet decimalDigitCharacterSet] invertedSet]];
    70     if (nonDigitRange.location == NSNotFound && fullVersion.length > 3)
    71         return [fullVersion substringFromIndex:fullVersion.length - 3];
    72     if (nonDigitRange.location != NSNotFound && nonDigitRange.location > 3)
    73         return [fullVersion substringFromIndex:nonDigitRange.location - 3];
    74     return fullVersion;
    75 }
    76 
    77 String WebPageProxy::standardUserAgent(const String& applicationName)
    78 {
    79     return standardUserAgentWithApplicationName(applicationName, userVisibleWebKitVersionString());
     64static String webKitBundleVersionString()
     65{
     66    return [[NSBundle bundleForClass:NSClassFromString(@"WKWebView")] objectForInfoDictionaryKey:(NSString *)kCFBundleVersionKey];
     67}
     68
     69String WebPageProxy::standardUserAgent(const String& applicationNameForUserAgent)
     70{
     71    return standardUserAgentWithApplicationName(applicationNameForUserAgent, webKitBundleVersionString());
    8072}
    8173
  • trunk/Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm

    r170569 r170734  
    9898}
    9999
    100 static String userVisibleWebKitVersionString()
    101 {
    102     // If the version is longer than 3 digits then the leading digits represent the version of the OS. Our user agent
    103     // string should not include the leading digits, so strip them off and report the rest as the version. <rdar://problem/4997547>
    104     NSString *fullVersion = [[NSBundle bundleForClass:NSClassFromString(@"WKView")] objectForInfoDictionaryKey:(NSString *)kCFBundleVersionKey];
    105     NSRange nonDigitRange = [fullVersion rangeOfCharacterFromSet:[[NSCharacterSet decimalDigitCharacterSet] invertedSet]];
    106     if (nonDigitRange.location == NSNotFound && fullVersion.length > 3)
    107         return [fullVersion substringFromIndex:fullVersion.length - 3];
    108     if (nonDigitRange.location != NSNotFound && nonDigitRange.location > 3)
    109         return [fullVersion substringFromIndex:nonDigitRange.location - 3];
    110     return fullVersion;
     100static String webKitBundleVersionString()
     101{
     102    return [[NSBundle bundleForClass:NSClassFromString(@"WKView")] objectForInfoDictionaryKey:(NSString *)kCFBundleVersionKey];
    111103}
    112104
    113105String WebPageProxy::standardUserAgent(const String& applicationNameForUserAgent)
    114106{
    115     return standardUserAgentWithApplicationName(applicationNameForUserAgent, userVisibleWebKitVersionString());
     107    return standardUserAgentWithApplicationName(applicationNameForUserAgent, webKitBundleVersionString());
    116108}
    117109
Note: See TracChangeset for help on using the changeset viewer.