⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 243525 in webkit


Ignore:
Timestamp:
Mar 26, 2019, 4:41:42 PM (7 years ago)
Author:
Wenson Hsieh
Message:

[Cocoa] Refactor some helper functions for building UserAgent strings
https://bugs.webkit.org/show_bug.cgi?id=195990

Reviewed by Brent Fulgham.

Add an optional argument to standardUserAgentWithApplicationName to request the desktop version of the user
agent in Cocoa platforms. Work towards refactoring some codepaths to make the implementation of the "Request
Desktop Site" feature in Safari a bit more straightforward.

No change in behavior.

  • platform/UserAgent.h:
  • platform/ios/UserAgentIOS.mm:

(WebCore::standardUserAgentWithApplicationName):

The corresponding macOS version is currently hard-coded — the followup bug webkit.org/b/196275 tracks making
this dynamically fetch the paired macOS version when building for iOS.

  • platform/mac/UserAgentMac.mm:

(WebCore::standardUserAgentWithApplicationName):

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r243515 r243525  
     12019-03-26  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        [Cocoa] Refactor some helper functions for building UserAgent strings
     4        https://bugs.webkit.org/show_bug.cgi?id=195990
     5
     6        Reviewed by Brent Fulgham.
     7
     8        Add an optional argument to standardUserAgentWithApplicationName to request the desktop version of the user
     9        agent in Cocoa platforms. Work towards refactoring some codepaths to make the implementation of the "Request
     10        Desktop Site" feature in Safari a bit more straightforward.
     11
     12        No change in behavior.
     13
     14        * platform/UserAgent.h:
     15        * platform/ios/UserAgentIOS.mm:
     16        (WebCore::standardUserAgentWithApplicationName):
     17
     18        The corresponding macOS version is currently hard-coded — the followup bug webkit.org/b/196275 tracks making
     19        this dynamically fetch the paired macOS version when building for iOS.
     20
     21        * platform/mac/UserAgentMac.mm:
     22        (WebCore::standardUserAgentWithApplicationName):
     23
    1242019-03-26  Said Abou-Hallawa  <said@apple.com>
    225
  • trunk/Source/WebCore/platform/UserAgent.h

    r243187 r243525  
    3232
    3333#if PLATFORM(COCOA)
    34 WEBCORE_EXPORT String standardUserAgentWithApplicationName(const String& applicationName);
     34enum class UserAgentType { Default, Desktop };
     35WEBCORE_EXPORT String standardUserAgentWithApplicationName(const String& applicationName, UserAgentType = UserAgentType::Default);
    3536
    3637String systemMarketingVersionForUserAgentString();
  • trunk/Source/WebCore/platform/ios/UserAgentIOS.mm

    r243187 r243525  
    7777}
    7878
    79 String standardUserAgentWithApplicationName(const String& applicationName)
     79String standardUserAgentWithApplicationName(const String& applicationName, UserAgentType type)
    8080{
     81    if (type == UserAgentType::Desktop) {
     82        String appNameSuffix = applicationName.isEmpty() ? "" : makeString(" ", applicationName);
     83        return makeString("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14) AppleWebKit/605.1.15 (KHTML, like Gecko)", appNameSuffix);
     84    }
     85
    8186    // FIXME: Is this needed any more? Mac doesn't have this check,
    8287    // Check to see if there is a user agent override for all WebKit clients.
  • trunk/Source/WebCore/platform/mac/UserAgentMac.mm

    r243187 r243525  
    3333namespace WebCore {
    3434
    35 String standardUserAgentWithApplicationName(const String& applicationName)
     35String standardUserAgentWithApplicationName(const String& applicationName, UserAgentType)
    3636{
    3737    String osVersion = systemMarketingVersionForUserAgentString();
Note: See TracChangeset for help on using the changeset viewer.