WebKit Bugzilla
Attachment 368533 Details for
Bug 197402
: Add a way to override the device name when building a user agent string
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-197402-20190429200619.patch (text/plain), 4.71 KB, created by
Wenson Hsieh
on 2019-04-29 20:06:20 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Wenson Hsieh
Created:
2019-04-29 20:06:20 PDT
Size:
4.71 KB
patch
obsolete
>Subversion Revision: 244716 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index bf870456c01df9e8ab4f3ae8c027d7d3661de635..ef314e25250d159d6a4de57bb32fd05feff744b0 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,20 @@ >+2019-04-29 Wenson Hsieh <wenson_hsieh@apple.com> >+ >+ Add a way to override the device name when building a user agent string >+ https://bugs.webkit.org/show_bug.cgi?id=197402 >+ <rdar://problem/50141531> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Adds an optional device name argument that, if specified, takes precedence over the real device name. >+ >+ * platform/UserAgent.h: >+ (WebCore::standardUserAgentWithApplicationName): >+ * platform/ios/UserAgentIOS.mm: >+ (WebCore::standardUserAgentWithApplicationName): >+ * platform/mac/UserAgentMac.mm: >+ (WebCore::standardUserAgentWithApplicationName): >+ > 2019-04-28 Wenson Hsieh <wenson_hsieh@apple.com> > > [iOS] Add a version of viewport shrink-to-fit heuristics that preserves page layout >diff --git a/Source/WebCore/platform/UserAgent.h b/Source/WebCore/platform/UserAgent.h >index 3c6ea2930747ff49dab7d4a3a3c2ee4769e25d78..436fce381d929f7fb1c0e08398265035ee175bb1 100644 >--- a/Source/WebCore/platform/UserAgent.h >+++ b/Source/WebCore/platform/UserAgent.h >@@ -32,7 +32,7 @@ namespace WebCore { > > #if PLATFORM(COCOA) > enum class UserAgentType { Default, Desktop }; >-WEBCORE_EXPORT String standardUserAgentWithApplicationName(const String& applicationName, UserAgentType = UserAgentType::Default); >+WEBCORE_EXPORT String standardUserAgentWithApplicationName(const String& applicationName, UserAgentType = UserAgentType::Default, const String& overrideDeviceName = { }); > > String systemMarketingVersionForUserAgentString(); > #else >diff --git a/Source/WebCore/platform/ios/UserAgentIOS.mm b/Source/WebCore/platform/ios/UserAgentIOS.mm >index 1a9a1a9e6bf25a08ef6e0778d7caae90885b5f92..98e36c6d5f24775a6023e2009c96a60b6ad7e69c 100644 >--- a/Source/WebCore/platform/ios/UserAgentIOS.mm >+++ b/Source/WebCore/platform/ios/UserAgentIOS.mm >@@ -76,11 +76,11 @@ static inline String deviceNameForUserAgent() > return name; > } > >-String standardUserAgentWithApplicationName(const String& applicationName, UserAgentType type) >+String standardUserAgentWithApplicationName(const String& applicationName, UserAgentType type, const String& overrideDeviceName) > { > if (type == UserAgentType::Desktop) { > String appNameSuffix = applicationName.isEmpty() ? "" : makeString(" ", applicationName); >- return makeString("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14) AppleWebKit/605.1.15 (KHTML, like Gecko)", appNameSuffix); >+ return makeString("Mozilla/5.0 (", overrideDeviceName.isEmpty() ? String("Macintosh") : overrideDeviceName, "; Intel Mac OS X 10_14) AppleWebKit/605.1.15 (KHTML, like Gecko)", appNameSuffix); > } > > // FIXME: Is this needed any more? Mac doesn't have this check, >@@ -95,7 +95,7 @@ String standardUserAgentWithApplicationName(const String& applicationName, UserA > String osVersion = systemMarketingVersionForUserAgentString(); > String appNameSuffix = applicationName.isEmpty() ? "" : makeString(" ", applicationName); > >- return makeString("Mozilla/5.0 (", deviceNameForUserAgent(), "; CPU ", osNameForUserAgent(), " ", osVersion, " like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko)", appNameSuffix); >+ return makeString("Mozilla/5.0 (", overrideDeviceName.isEmpty() ? deviceNameForUserAgent() : overrideDeviceName, "; CPU ", osNameForUserAgent(), " ", osVersion, " like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko)", appNameSuffix); > } > > } // namespace WebCore. >diff --git a/Source/WebCore/platform/mac/UserAgentMac.mm b/Source/WebCore/platform/mac/UserAgentMac.mm >index 320cadad6535343c117ab73a68b9e0e59197bec0..94a6ae827e13d21c91283f19b5b336b0a76ee8ed 100644 >--- a/Source/WebCore/platform/mac/UserAgentMac.mm >+++ b/Source/WebCore/platform/mac/UserAgentMac.mm >@@ -32,12 +32,12 @@ > > namespace WebCore { > >-String standardUserAgentWithApplicationName(const String& applicationName, UserAgentType) >+String standardUserAgentWithApplicationName(const String& applicationName, UserAgentType, const String& overrideDeviceName) > { > String osVersion = systemMarketingVersionForUserAgentString(); > String appNameSuffix = applicationName.isEmpty() ? "" : makeString(" ", applicationName); > >- return makeString("Mozilla/5.0 (Macintosh; Intel Mac OS X ", osVersion, ") AppleWebKit/605.1.15 (KHTML, like Gecko)", appNameSuffix); >+ return makeString("Mozilla/5.0 (", overrideDeviceName.isEmpty() ? String("Macintosh") : overrideDeviceName, "; Intel Mac OS X ", osVersion, ") AppleWebKit/605.1.15 (KHTML, like Gecko)", appNameSuffix); > } > > } // namespace WebCore
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
thorton
:
review+
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 197402
: 368533