User agent string override for navigator.userAgent should be site specific quirks
[WebKit-https.git] / Source / WebKit / UIProcess / API / Cocoa / _WKWebsitePolicies.mm
index ac960b4..dde107a 100644 (file)
     return _websitePolicies->contentBlockersEnabled();
 }
 
+- (void)setDeviceOrientationEventEnabled:(BOOL)deviceOrientationEventEnabled
+{
+    _websitePolicies->setDeviceOrientationEventEnabled(deviceOrientationEventEnabled);
+}
+
+- (BOOL)deviceOrientationEventEnabled
+{
+    return _websitePolicies->deviceOrientationEventEnabled();
+}
+
 - (void)setAllowedAutoplayQuirks:(_WKWebsiteAutoplayQuirk)allowedQuirks
 {
     OptionSet<WebKit::WebsiteAutoplayQuirk> quirks;
 
     if (allowedQuirks & _WKWebsiteAutoplayQuirkInheritedUserGestures)
-        quirks |= WebKit::WebsiteAutoplayQuirk::InheritedUserGestures;
+        quirks.add(WebKit::WebsiteAutoplayQuirk::InheritedUserGestures);
 
     if (allowedQuirks & _WKWebsiteAutoplayQuirkSynthesizedPauseEvents)
-        quirks |= WebKit::WebsiteAutoplayQuirk::SynthesizedPauseEvents;
+        quirks.add(WebKit::WebsiteAutoplayQuirk::SynthesizedPauseEvents);
 
     if (allowedQuirks & _WKWebsiteAutoplayQuirkArbitraryUserGestures)
-        quirks |= WebKit::WebsiteAutoplayQuirk::ArbitraryUserGestures;
+        quirks.add(WebKit::WebsiteAutoplayQuirk::ArbitraryUserGestures);
+
+    if (allowedQuirks & _WKWebsiteAutoplayQuirkPerDocumentAutoplayBehavior)
+        quirks.add(WebKit::WebsiteAutoplayQuirk::PerDocumentAutoplayBehavior);
 
     _websitePolicies->setAllowedAutoplayQuirks(quirks);
 }
     if (allowedQuirks.contains(WebKit::WebsiteAutoplayQuirk::ArbitraryUserGestures))
         quirks |= _WKWebsiteAutoplayQuirkArbitraryUserGestures;
 
+    if (allowedQuirks.contains(WebKit::WebsiteAutoplayQuirk::PerDocumentAutoplayBehavior))
+        quirks |= _WKWebsiteAutoplayQuirkPerDocumentAutoplayBehavior;
+
     return quirks;
 }
 
     }
 }
 
+- (void)setPopUpPolicy:(_WKWebsitePopUpPolicy)policy
+{
+    switch (policy) {
+    case _WKWebsitePopUpPolicyDefault:
+        _websitePolicies->setPopUpPolicy(WebKit::WebsitePopUpPolicy::Default);
+        break;
+    case _WKWebsitePopUpPolicyAllow:
+        _websitePolicies->setPopUpPolicy(WebKit::WebsitePopUpPolicy::Allow);
+        break;
+    case _WKWebsitePopUpPolicyBlock:
+        _websitePolicies->setPopUpPolicy(WebKit::WebsitePopUpPolicy::Block);
+        break;
+    }
+}
+
+- (_WKWebsitePopUpPolicy)popUpPolicy
+{
+    switch (_websitePolicies->popUpPolicy()) {
+    case WebKit::WebsitePopUpPolicy::Default:
+        return _WKWebsitePopUpPolicyDefault;
+    case WebKit::WebsitePopUpPolicy::Allow:
+        return _WKWebsitePopUpPolicyAllow;
+    case WebKit::WebsitePopUpPolicy::Block:
+        return _WKWebsitePopUpPolicyBlock;
+    }
+}
+
 - (NSDictionary<NSString *, NSString *> *)customHeaderFields
 {
     const auto& fields = _websitePolicies->customHeaderFields();
 
 - (WKWebsiteDataStore *)websiteDataStore
 {
-    auto* store = _websitePolicies->websiteDataStore();
-    return store ? WebKit::wrapper(*store) : nil;
+    return wrapper(_websitePolicies->websiteDataStore());
 }
 
 - (void)setWebsiteDataStore:(WKWebsiteDataStore *)websiteDataStore
     _websitePolicies->setWebsiteDataStore(websiteDataStore->_websiteDataStore.get());
 }
 
+- (void)setCustomUserAgent:(NSString *)customUserAgent
+{
+    _websitePolicies->setCustomUserAgent(customUserAgent);
+}
+
+- (NSString *)customUserAgent
+{
+    return _websitePolicies->customUserAgent();
+}
+
+- (void)setCustomJavaScriptUserAgentAsSiteSpecificQuirks:(NSString *)customUserAgent
+{
+    _websitePolicies->setCustomJavaScriptUserAgentAsSiteSpecificQuirks(customUserAgent);
+}
+
+- (NSString *)customJavaScriptUserAgentAsSiteSpecificQuirks
+{
+    return _websitePolicies->customJavaScriptUserAgentAsSiteSpecificQuirks();
+}
+
+- (void)setCustomNavigatorPlatform:(NSString *)customNavigatorPlatform
+{
+    _websitePolicies->setCustomNavigatorPlatform(customNavigatorPlatform);
+}
+
+- (NSString *)customNavigatorPlatform
+{
+    return _websitePolicies->customNavigatorPlatform();
+}
+
 - (NSString *)description
 {
     return [NSString stringWithFormat:@"<%@: %p; contentBlockersEnabled = %d>", NSStringFromClass(self.class), self, self.contentBlockersEnabled];