Let WebKit clients supply an application name for user agent in modern compatibility...
authorwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 10 May 2019 19:58:37 +0000 (19:58 +0000)
committerwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 10 May 2019 19:58:37 +0000 (19:58 +0000)
https://bugs.webkit.org/show_bug.cgi?id=197782
<rdar://problem/50646747>

Reviewed by Beth Dakin.

Add plumbing for a new private property on WKWebpagePreferences.

* UIProcess/API/APIWebsitePolicies.cpp:
(API::WebsitePolicies::copy const):
* UIProcess/API/APIWebsitePolicies.h:
* UIProcess/API/Cocoa/WKWebpagePreferences.mm:
(-[WKWebpagePreferences _applicationNameForUserAgentWithModernCompatibility]):
(-[WKWebpagePreferences _setApplicationNameForUserAgentWithModernCompatibility:]):
* UIProcess/API/Cocoa/WKWebpagePreferencesPrivate.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245189 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit/ChangeLog
Source/WebKit/UIProcess/API/APIWebsitePolicies.cpp
Source/WebKit/UIProcess/API/APIWebsitePolicies.h
Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferences.mm
Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferencesPrivate.h

index 1497a3e..0bf2ac4 100644 (file)
@@ -1,3 +1,21 @@
+2019-05-10  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        Let WebKit clients supply an application name for user agent in modern compatibility mode
+        https://bugs.webkit.org/show_bug.cgi?id=197782
+        <rdar://problem/50646747>
+
+        Reviewed by Beth Dakin.
+
+        Add plumbing for a new private property on WKWebpagePreferences.
+
+        * UIProcess/API/APIWebsitePolicies.cpp:
+        (API::WebsitePolicies::copy const):
+        * UIProcess/API/APIWebsitePolicies.h:
+        * UIProcess/API/Cocoa/WKWebpagePreferences.mm:
+        (-[WKWebpagePreferences _applicationNameForUserAgentWithModernCompatibility]):
+        (-[WKWebpagePreferences _setApplicationNameForUserAgentWithModernCompatibility:]):
+        * UIProcess/API/Cocoa/WKWebpagePreferencesPrivate.h:
+
 2019-05-10  Chris Dumez  <cdumez@apple.com>
 
         The active tab sometimes app naps even though it should not
index 7e44338..99e830c 100644 (file)
@@ -66,6 +66,7 @@ Ref<WebsitePolicies> WebsitePolicies::copy() const
         customHeaderFields.append(WebCore::HTTPHeaderField(field));
     policies->setCustomHeaderFields(WTFMove(customHeaderFields));
     policies->setAllowSiteSpecificQuirksToOverrideCompatibilityMode(m_allowSiteSpecificQuirksToOverrideCompatibilityMode);
+    policies->setApplicationNameForUserAgentWithModernCompatibility(m_applicationNameForUserAgentWithModernCompatibility);
     return policies;
 }
 
index f290b69..4d49269 100644 (file)
@@ -104,6 +104,9 @@ public:
     bool allowSiteSpecificQuirksToOverrideCompatibilityMode() const { return m_allowSiteSpecificQuirksToOverrideCompatibilityMode; }
     void setAllowSiteSpecificQuirksToOverrideCompatibilityMode(bool value) { m_allowSiteSpecificQuirksToOverrideCompatibilityMode = value; }
 
+    WTF::String applicationNameForUserAgentWithModernCompatibility() const { return m_applicationNameForUserAgentWithModernCompatibility; }
+    void setApplicationNameForUserAgentWithModernCompatibility(const WTF::String& applicationName) { m_applicationNameForUserAgentWithModernCompatibility = applicationName; }
+
 private:
     WebsitePolicies(bool contentBlockersEnabled, OptionSet<WebKit::WebsiteAutoplayQuirk>, WebKit::WebsiteAutoplayPolicy, Vector<WebCore::HTTPHeaderField>&&, WebKit::WebsitePopUpPolicy, RefPtr<WebsiteDataStore>&&);
 
@@ -124,6 +127,7 @@ private:
     WebKit::WebsiteMediaSourcePolicy m_mediaSourcePolicy { WebKit::WebsiteMediaSourcePolicy::Default };
     WebKit::WebsiteSimulatedMouseEventsDispatchPolicy m_simulatedMouseEventsDispatchPolicy { WebKit::WebsiteSimulatedMouseEventsDispatchPolicy::Default };
     bool m_allowSiteSpecificQuirksToOverrideCompatibilityMode { false };
+    WTF::String m_applicationNameForUserAgentWithModernCompatibility;
 };
 
 } // namespace API
index 3922f1c..6a36b1b 100644 (file)
@@ -286,6 +286,16 @@ static _WKWebsiteDeviceOrientationAndMotionAccessPolicy toWKWebsiteDeviceOrienta
     _websitePolicies->setAllowSiteSpecificQuirksToOverrideCompatibilityMode(value);
 }
 
+- (NSString *)_applicationNameForUserAgentWithModernCompatibility
+{
+    return _websitePolicies->applicationNameForUserAgentWithModernCompatibility();
+}
+
+- (void)_setApplicationNameForUserAgentWithModernCompatibility:(NSString *)applicationName
+{
+    _websitePolicies->setApplicationNameForUserAgentWithModernCompatibility(applicationName);
+}
+
 - (API::Object&)_apiObject
 {
     return *_websitePolicies;
index 692f329..0bd0fac 100644 (file)
@@ -69,4 +69,6 @@ typedef NS_OPTIONS(NSUInteger, _WKWebsiteDeviceOrientationAndMotionAccessPolicy)
 @property (nonatomic, setter=_setDeviceOrientationAndMotionAccessPolicy:) _WKWebsiteDeviceOrientationAndMotionAccessPolicy _deviceOrientationAndMotionAccessPolicy;
 @property (nonatomic, setter=_setAllowSiteSpecificQuirksToOverrideCompatibilityMode:) BOOL _allowSiteSpecificQuirksToOverrideCompatibilityMode;
 
+@property (nonatomic, copy, setter=_setApplicationNameForUserAgentWithModernCompatibility:) NSString *_applicationNameForUserAgentWithModernCompatibility;
+
 @end