Title: [243726] trunk/Source/WebKit
Revision
243726
Author
wenson_hs...@apple.com
Date
2019-04-01 17:01:05 -0700 (Mon, 01 Apr 2019)

Log Message

[WebKit2] Introduce a public version of WKWebsitePolicies
https://bugs.webkit.org/show_bug.cgi?id=195989
<rdar://problem/47228232>

Reviewed by Tim Horton.

Expose the existing _WKWebsitePolicies object as WKWebpagePreferences, in what will eventually become a public
header in the WebKit SDK (WKWebpagePreferences.h). Following a similar transitioning strategy as
_WKWebsiteDataStore and WKWebsiteDataStore, we move existing logic from _WKWebsitePolicies to WKWebpagePreferences
and make _WKWebsitePolicies a wrapper around WKWebpagePreferences.

No change in behavior.

* Shared/Cocoa/APIObject.mm:
(API::Object::newObject):

Wrap API::WebsitePolicies with WKWebpagePreferences.

* SourcesCocoa.txt:
* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _updateWebsitePolicies:]):
* UIProcess/API/Cocoa/WKWebpagePreferences.h: Copied from Source/WebKit/UIProcess/API/Cocoa/_WKWebsitePoliciesInternal.h.
* UIProcess/API/Cocoa/WKWebpagePreferences.mm: Copied from Source/WebKit/UIProcess/API/Cocoa/_WKWebsitePolicies.mm.

Introduce WKWebpagePreferences.

(+[WKWebpagePreferences defaultPreferences]):
(-[WKWebpagePreferences dealloc]):
(-[WKWebpagePreferences init]):
(-[WKWebpagePreferences _setContentBlockersEnabled:]):
(-[WKWebpagePreferences _contentBlockersEnabled]):
(-[WKWebpagePreferences _setAllowedAutoplayQuirks:]):
(-[WKWebpagePreferences _allowedAutoplayQuirks]):
(-[WKWebpagePreferences _setAutoplayPolicy:]):
(-[WKWebpagePreferences _autoplayPolicy]):
(-[WKWebpagePreferences _setDeviceOrientationAndMotionAccessPolicy:]):
(-[WKWebpagePreferences _deviceOrientationAndMotionAccessPolicy]):
(-[WKWebpagePreferences _setPopUpPolicy:]):
(-[WKWebpagePreferences _popUpPolicy]):
(-[WKWebpagePreferences _customHeaderFields]):
(-[WKWebpagePreferences _setCustomHeaderFields:]):
(-[WKWebpagePreferences _websiteDataStore]):
(-[WKWebpagePreferences _setWebsiteDataStore:]):
(-[WKWebpagePreferences _setCustomUserAgent:]):
(-[WKWebpagePreferences _customUserAgent]):
(-[WKWebpagePreferences _setCustomJavaScriptUserAgentAsSiteSpecificQuirks:]):
(-[WKWebpagePreferences _customJavaScriptUserAgentAsSiteSpecificQuirks]):
(-[WKWebpagePreferences _setCustomNavigatorPlatform:]):
(-[WKWebpagePreferences _customNavigatorPlatform]):
(-[WKWebpagePreferences _apiObject]):
* UIProcess/API/Cocoa/WKWebpagePreferencesInternal.h: Copied from Source/WebKit/UIProcess/API/Cocoa/_WKWebsitePoliciesInternal.h.
* UIProcess/API/Cocoa/WKWebpagePreferencesPrivate.h: Copied from Source/WebKit/UIProcess/API/Cocoa/_WKWebsitePolicies.h.

Reintroduce all the interfaces currently available on _WKWebsitePolicies as underscore-prefixed SPI on
WKWebpagePreferences.

* UIProcess/API/Cocoa/_WKWebsitePolicies.h:
* UIProcess/API/Cocoa/_WKWebsitePolicies.mm:

Make _WKWebsitePolicies wrap WKWebpagePreferences, and plumb all existing SPI on WKWebsitePolicies through to
WKWebpagePreferences.

(-[_WKWebsitePolicies init]):
(-[_WKWebsitePolicies webpagePreferences]):
(-[_WKWebsitePolicies setContentBlockersEnabled:]):
(-[_WKWebsitePolicies contentBlockersEnabled]):
(-[_WKWebsitePolicies setAllowedAutoplayQuirks:]):
(-[_WKWebsitePolicies allowedAutoplayQuirks]):
(-[_WKWebsitePolicies setAutoplayPolicy:]):
(-[_WKWebsitePolicies autoplayPolicy]):
(-[_WKWebsitePolicies setDeviceOrientationAndMotionAccessPolicy:]):
(-[_WKWebsitePolicies deviceOrientationAndMotionAccessPolicy]):
(-[_WKWebsitePolicies setPopUpPolicy:]):
(-[_WKWebsitePolicies popUpPolicy]):
(-[_WKWebsitePolicies customHeaderFields]):
(-[_WKWebsitePolicies setCustomHeaderFields:]):
(-[_WKWebsitePolicies websiteDataStore]):
(-[_WKWebsitePolicies setWebsiteDataStore:]):
(-[_WKWebsitePolicies setCustomUserAgent:]):
(-[_WKWebsitePolicies customUserAgent]):
(-[_WKWebsitePolicies setCustomJavaScriptUserAgentAsSiteSpecificQuirks:]):
(-[_WKWebsitePolicies customJavaScriptUserAgentAsSiteSpecificQuirks]):
(-[_WKWebsitePolicies setCustomNavigatorPlatform:]):
(-[_WKWebsitePolicies customNavigatorPlatform]):
(-[_WKWebsitePolicies description]):
(-[_WKWebsitePolicies _apiObject]):
(-[_WKWebsitePolicies dealloc]): Deleted.
* UIProcess/API/Cocoa/_WKWebsitePoliciesInternal.h:
* UIProcess/Cocoa/NavigationState.mm:
(WebKit::NavigationState::NavigationClient::decidePolicyForNavigationAction):
* WebKit.xcodeproj/project.pbxproj:

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (243725 => 243726)


--- trunk/Source/WebKit/ChangeLog	2019-04-02 00:00:50 UTC (rev 243725)
+++ trunk/Source/WebKit/ChangeLog	2019-04-02 00:01:05 UTC (rev 243726)
@@ -1,5 +1,99 @@
 2019-04-01  Wenson Hsieh  <wenson_hs...@apple.com>
 
+        [WebKit2] Introduce a public version of WKWebsitePolicies
+        https://bugs.webkit.org/show_bug.cgi?id=195989
+        <rdar://problem/47228232>
+
+        Reviewed by Tim Horton.
+
+        Expose the existing _WKWebsitePolicies object as WKWebpagePreferences, in what will eventually become a public
+        header in the WebKit SDK (WKWebpagePreferences.h). Following a similar transitioning strategy as
+        _WKWebsiteDataStore and WKWebsiteDataStore, we move existing logic from _WKWebsitePolicies to WKWebpagePreferences
+        and make _WKWebsitePolicies a wrapper around WKWebpagePreferences.
+
+        No change in behavior.
+
+        * Shared/Cocoa/APIObject.mm:
+        (API::Object::newObject):
+
+        Wrap API::WebsitePolicies with WKWebpagePreferences.
+
+        * SourcesCocoa.txt:
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView _updateWebsitePolicies:]):
+        * UIProcess/API/Cocoa/WKWebpagePreferences.h: Copied from Source/WebKit/UIProcess/API/Cocoa/_WKWebsitePoliciesInternal.h.
+        * UIProcess/API/Cocoa/WKWebpagePreferences.mm: Copied from Source/WebKit/UIProcess/API/Cocoa/_WKWebsitePolicies.mm.
+
+        Introduce WKWebpagePreferences.
+
+        (+[WKWebpagePreferences defaultPreferences]):
+        (-[WKWebpagePreferences dealloc]):
+        (-[WKWebpagePreferences init]):
+        (-[WKWebpagePreferences _setContentBlockersEnabled:]):
+        (-[WKWebpagePreferences _contentBlockersEnabled]):
+        (-[WKWebpagePreferences _setAllowedAutoplayQuirks:]):
+        (-[WKWebpagePreferences _allowedAutoplayQuirks]):
+        (-[WKWebpagePreferences _setAutoplayPolicy:]):
+        (-[WKWebpagePreferences _autoplayPolicy]):
+        (-[WKWebpagePreferences _setDeviceOrientationAndMotionAccessPolicy:]):
+        (-[WKWebpagePreferences _deviceOrientationAndMotionAccessPolicy]):
+        (-[WKWebpagePreferences _setPopUpPolicy:]):
+        (-[WKWebpagePreferences _popUpPolicy]):
+        (-[WKWebpagePreferences _customHeaderFields]):
+        (-[WKWebpagePreferences _setCustomHeaderFields:]):
+        (-[WKWebpagePreferences _websiteDataStore]):
+        (-[WKWebpagePreferences _setWebsiteDataStore:]):
+        (-[WKWebpagePreferences _setCustomUserAgent:]):
+        (-[WKWebpagePreferences _customUserAgent]):
+        (-[WKWebpagePreferences _setCustomJavaScriptUserAgentAsSiteSpecificQuirks:]):
+        (-[WKWebpagePreferences _customJavaScriptUserAgentAsSiteSpecificQuirks]):
+        (-[WKWebpagePreferences _setCustomNavigatorPlatform:]):
+        (-[WKWebpagePreferences _customNavigatorPlatform]):
+        (-[WKWebpagePreferences _apiObject]):
+        * UIProcess/API/Cocoa/WKWebpagePreferencesInternal.h: Copied from Source/WebKit/UIProcess/API/Cocoa/_WKWebsitePoliciesInternal.h.
+        * UIProcess/API/Cocoa/WKWebpagePreferencesPrivate.h: Copied from Source/WebKit/UIProcess/API/Cocoa/_WKWebsitePolicies.h.
+
+        Reintroduce all the interfaces currently available on _WKWebsitePolicies as underscore-prefixed SPI on
+        WKWebpagePreferences.
+
+        * UIProcess/API/Cocoa/_WKWebsitePolicies.h:
+        * UIProcess/API/Cocoa/_WKWebsitePolicies.mm:
+
+        Make _WKWebsitePolicies wrap WKWebpagePreferences, and plumb all existing SPI on WKWebsitePolicies through to
+        WKWebpagePreferences.
+
+        (-[_WKWebsitePolicies init]):
+        (-[_WKWebsitePolicies webpagePreferences]):
+        (-[_WKWebsitePolicies setContentBlockersEnabled:]):
+        (-[_WKWebsitePolicies contentBlockersEnabled]):
+        (-[_WKWebsitePolicies setAllowedAutoplayQuirks:]):
+        (-[_WKWebsitePolicies allowedAutoplayQuirks]):
+        (-[_WKWebsitePolicies setAutoplayPolicy:]):
+        (-[_WKWebsitePolicies autoplayPolicy]):
+        (-[_WKWebsitePolicies setDeviceOrientationAndMotionAccessPolicy:]):
+        (-[_WKWebsitePolicies deviceOrientationAndMotionAccessPolicy]):
+        (-[_WKWebsitePolicies setPopUpPolicy:]):
+        (-[_WKWebsitePolicies popUpPolicy]):
+        (-[_WKWebsitePolicies customHeaderFields]):
+        (-[_WKWebsitePolicies setCustomHeaderFields:]):
+        (-[_WKWebsitePolicies websiteDataStore]):
+        (-[_WKWebsitePolicies setWebsiteDataStore:]):
+        (-[_WKWebsitePolicies setCustomUserAgent:]):
+        (-[_WKWebsitePolicies customUserAgent]):
+        (-[_WKWebsitePolicies setCustomJavaScriptUserAgentAsSiteSpecificQuirks:]):
+        (-[_WKWebsitePolicies customJavaScriptUserAgentAsSiteSpecificQuirks]):
+        (-[_WKWebsitePolicies setCustomNavigatorPlatform:]):
+        (-[_WKWebsitePolicies customNavigatorPlatform]):
+        (-[_WKWebsitePolicies description]):
+        (-[_WKWebsitePolicies _apiObject]):
+        (-[_WKWebsitePolicies dealloc]): Deleted.
+        * UIProcess/API/Cocoa/_WKWebsitePoliciesInternal.h:
+        * UIProcess/Cocoa/NavigationState.mm:
+        (WebKit::NavigationState::NavigationClient::decidePolicyForNavigationAction):
+        * WebKit.xcodeproj/project.pbxproj:
+
+2019-04-01  Wenson Hsieh  <wenson_hs...@apple.com>
+
         Unable to copy and paste a PDF from Notes into Mail compose body
         https://bugs.webkit.org/show_bug.cgi?id=196442
         <rdar://problem/48573098>

Modified: trunk/Source/WebKit/Shared/Cocoa/APIObject.mm (243725 => 243726)


--- trunk/Source/WebKit/Shared/Cocoa/APIObject.mm	2019-04-02 00:00:50 UTC (rev 243725)
+++ trunk/Source/WebKit/Shared/Cocoa/APIObject.mm	2019-04-02 00:01:05 UTC (rev 243726)
@@ -63,6 +63,7 @@
 #import "WKWebProcessPlugInPageGroupInternal.h"
 #import "WKWebProcessPlugInRangeHandleInternal.h"
 #import "WKWebProcessPlugInScriptWorldInternal.h"
+#import "WKWebpagePreferencesInternal.h"
 #import "WKWebsiteDataRecordInternal.h"
 #import "WKWebsiteDataStoreInternal.h"
 #import "WKWindowFeaturesInternal.h"
@@ -82,7 +83,6 @@
 #import "_WKUserStyleSheetInternal.h"
 #import "_WKVisitedLinkStoreInternal.h"
 #import "_WKWebsiteDataStoreConfigurationInternal.h"
-#import "_WKWebsitePoliciesInternal.h"
 
 #if ENABLE(APPLICATION_MANIFEST)
 #import "_WKApplicationManifestInternal.h"
@@ -346,7 +346,7 @@
         break;
 
     case Type::WebsitePolicies:
-        wrapper = [_WKWebsitePolicies alloc];
+        wrapper = [WKWebpagePreferences alloc];
         break;
 
     case Type::WindowFeatures:

Modified: trunk/Source/WebKit/SourcesCocoa.txt (243725 => 243726)


--- trunk/Source/WebKit/SourcesCocoa.txt	2019-04-02 00:00:50 UTC (rev 243725)
+++ trunk/Source/WebKit/SourcesCocoa.txt	2019-04-02 00:01:05 UTC (rev 243726)
@@ -306,6 +306,7 @@
 UIProcess/API/Cocoa/WKWebsiteDataStore.mm
 UIProcess/API/Cocoa/WKWebView.mm
 UIProcess/API/Cocoa/WKWebViewConfiguration.mm
+UIProcess/API/Cocoa/WKWebpagePreferences.mm
 UIProcess/API/Cocoa/WKWindowFeatures.mm
 
 UIProcess/API/mac/WKView.mm

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (243725 => 243726)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2019-04-02 00:00:50 UTC (rev 243725)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2019-04-02 00:01:05 UTC (rev 243726)
@@ -77,6 +77,7 @@
 #import "WKUserContentControllerInternal.h"
 #import "WKWebViewConfigurationInternal.h"
 #import "WKWebViewContentProvider.h"
+#import "WKWebpagePreferencesInternal.h"
 #import "WKWebsiteDataStoreInternal.h"
 #import "WebBackForwardList.h"
 #import "WebCertificateInfo.h"
@@ -5128,7 +5129,7 @@
 
 - (void)_updateWebsitePolicies:(_WKWebsitePolicies *)websitePolicies
 {
-    auto data = ""
+    auto data = ""
     if (data.websiteDataStoreParameters)
         [NSException raise:NSInvalidArgumentException format:@"Updating WKWebsiteDataStore is only supported during decidePolicyForNavigationAction."];
     _page->updateWebsitePolicies(WTFMove(data));

Copied: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferences.h (from rev 243722, trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebsitePoliciesInternal.h) (0 => 243726)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferences.h	                        (rev 0)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferences.h	2019-04-02 00:01:05 UTC (rev 243726)
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import <WebKit/WKFoundation.h>
+
+/*! A WKWebpagePreferences object is a collection of properties that
+ determine the preferences to use when loading and rendering a page.
+ @discussion Contains properties used to determine webpage preferences.
+ */
+WK_CLASS_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA))
+@interface WKWebpagePreferences : NSObject
+
+@end

Copied: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferences.mm (from rev 243722, trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebsitePolicies.mm) (0 => 243726)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferences.mm	                        (rev 0)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferences.mm	2019-04-02 00:01:05 UTC (rev 243726)
@@ -0,0 +1,255 @@
+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "WKWebpagePreferences.h"
+
+#import "WKWebpagePreferencesInternal.h"
+#import "WKWebsiteDataStoreInternal.h"
+#import "_WKWebsitePoliciesInternal.h"
+#import <wtf/RetainPtr.h>
+
+@implementation WKWebpagePreferences
+
++ (instancetype)defaultPreferences
+{
+    return [[[self alloc] init] autorelease];
+}
+
+- (void)dealloc
+{
+    _websitePolicies->API::WebsitePolicies::~WebsitePolicies();
+
+    [super dealloc];
+}
+
+- (instancetype)init
+{
+    if (!(self = [super init]))
+        return nil;
+
+    API::Object::constructInWrapper<API::WebsitePolicies>(self);
+
+    return self;
+}
+
+- (void)_setContentBlockersEnabled:(BOOL)contentBlockersEnabled
+{
+    _websitePolicies->setContentBlockersEnabled(contentBlockersEnabled);
+}
+
+- (BOOL)_contentBlockersEnabled
+{
+    return _websitePolicies->contentBlockersEnabled();
+}
+
+- (void)_setAllowedAutoplayQuirks:(_WKWebsiteAutoplayQuirk)allowedQuirks
+{
+    OptionSet<WebKit::WebsiteAutoplayQuirk> quirks;
+
+    if (allowedQuirks & _WKWebsiteAutoplayQuirkInheritedUserGestures)
+        quirks.add(WebKit::WebsiteAutoplayQuirk::InheritedUserGestures);
+
+    if (allowedQuirks & _WKWebsiteAutoplayQuirkSynthesizedPauseEvents)
+        quirks.add(WebKit::WebsiteAutoplayQuirk::SynthesizedPauseEvents);
+
+    if (allowedQuirks & _WKWebsiteAutoplayQuirkArbitraryUserGestures)
+        quirks.add(WebKit::WebsiteAutoplayQuirk::ArbitraryUserGestures);
+
+    if (allowedQuirks & _WKWebsiteAutoplayQuirkPerDocumentAutoplayBehavior)
+        quirks.add(WebKit::WebsiteAutoplayQuirk::PerDocumentAutoplayBehavior);
+
+    _websitePolicies->setAllowedAutoplayQuirks(quirks);
+}
+
+- (_WKWebsiteAutoplayQuirk)_allowedAutoplayQuirks
+{
+    _WKWebsiteAutoplayQuirk quirks = 0;
+    auto allowedQuirks = _websitePolicies->allowedAutoplayQuirks();
+
+    if (allowedQuirks.contains(WebKit::WebsiteAutoplayQuirk::InheritedUserGestures))
+        quirks |= _WKWebsiteAutoplayQuirkInheritedUserGestures;
+
+    if (allowedQuirks.contains(WebKit::WebsiteAutoplayQuirk::SynthesizedPauseEvents))
+        quirks |= _WKWebsiteAutoplayQuirkSynthesizedPauseEvents;
+
+    if (allowedQuirks.contains(WebKit::WebsiteAutoplayQuirk::ArbitraryUserGestures))
+        quirks |= _WKWebsiteAutoplayQuirkArbitraryUserGestures;
+
+    if (allowedQuirks.contains(WebKit::WebsiteAutoplayQuirk::PerDocumentAutoplayBehavior))
+        quirks |= _WKWebsiteAutoplayQuirkPerDocumentAutoplayBehavior;
+
+    return quirks;
+}
+
+- (void)_setAutoplayPolicy:(_WKWebsiteAutoplayPolicy)policy
+{
+    switch (policy) {
+    case _WKWebsiteAutoplayPolicyDefault:
+        _websitePolicies->setAutoplayPolicy(WebKit::WebsiteAutoplayPolicy::Default);
+        break;
+    case _WKWebsiteAutoplayPolicyAllow:
+        _websitePolicies->setAutoplayPolicy(WebKit::WebsiteAutoplayPolicy::Allow);
+        break;
+    case _WKWebsiteAutoplayPolicyAllowWithoutSound:
+        _websitePolicies->setAutoplayPolicy(WebKit::WebsiteAutoplayPolicy::AllowWithoutSound);
+        break;
+    case _WKWebsiteAutoplayPolicyDeny:
+        _websitePolicies->setAutoplayPolicy(WebKit::WebsiteAutoplayPolicy::Deny);
+        break;
+    }
+}
+
+- (_WKWebsiteAutoplayPolicy)_autoplayPolicy
+{
+    switch (_websitePolicies->autoplayPolicy()) {
+    case WebKit::WebsiteAutoplayPolicy::Default:
+        return _WKWebsiteAutoplayPolicyDefault;
+    case WebKit::WebsiteAutoplayPolicy::Allow:
+        return _WKWebsiteAutoplayPolicyAllow;
+    case WebKit::WebsiteAutoplayPolicy::AllowWithoutSound:
+        return _WKWebsiteAutoplayPolicyAllowWithoutSound;
+    case WebKit::WebsiteAutoplayPolicy::Deny:
+        return _WKWebsiteAutoplayPolicyDeny;
+    }
+}
+
+- (void)_setDeviceOrientationAndMotionAccessPolicy:(_WKWebsiteDeviceOrientationAndMotionAccessPolicy)policy
+{
+    switch (policy) {
+    case _WKWebsiteDeviceOrientationAndMotionAccessPolicyAsk:
+        _websitePolicies->setDeviceOrientationAndMotionAccessState(WTF::nullopt);
+        break;
+    case _WKWebsiteDeviceOrientationAndMotionAccessPolicyGrant:
+        _websitePolicies->setDeviceOrientationAndMotionAccessState(true);
+        break;
+    case _WKWebsiteDeviceOrientationAndMotionAccessPolicyDeny:
+        _websitePolicies->setDeviceOrientationAndMotionAccessState(false);
+        break;
+    }
+}
+
+- (_WKWebsiteDeviceOrientationAndMotionAccessPolicy)_deviceOrientationAndMotionAccessPolicy
+{
+    if (!_websitePolicies->deviceOrientationAndMotionAccessState())
+        return _WKWebsiteDeviceOrientationAndMotionAccessPolicyAsk;
+    return *_websitePolicies->deviceOrientationAndMotionAccessState() ? _WKWebsiteDeviceOrientationAndMotionAccessPolicyGrant : _WKWebsiteDeviceOrientationAndMotionAccessPolicyDeny;
+}
+
+- (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();
+    auto dictionary = adoptNS([[NSMutableDictionary alloc] initWithCapacity:fields.size()]);
+    for (const auto& field : fields)
+        [dictionary setObject:field.value() forKey:field.name()];
+    return dictionary.autorelease();
+}
+
+- (void)_setCustomHeaderFields:(NSDictionary<NSString *, NSString *> *)fields
+{
+    Vector<WebCore::HTTPHeaderField> parsedFields;
+    parsedFields.reserveInitialCapacity(fields.count);
+
+    for (NSString *name in fields) {
+        auto field = WebCore::HTTPHeaderField::create(name, [fields objectForKey:name]);
+        if (field && startsWithLettersIgnoringASCIICase(field->name(), "x-"))
+            parsedFields.uncheckedAppend(WTFMove(*field));
+    }
+    _websitePolicies->setCustomHeaderFields(WTFMove(parsedFields));
+}
+
+- (WKWebsiteDataStore *)_websiteDataStore
+{
+    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();
+}
+
+- (API::Object&)_apiObject
+{
+    return *_websitePolicies;
+}
+
+@end

Copied: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferencesInternal.h (from rev 243722, trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebsitePoliciesInternal.h) (0 => 243726)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferencesInternal.h	                        (rev 0)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferencesInternal.h	2019-04-02 00:01:05 UTC (rev 243726)
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#import "APIWebsitePolicies.h"
+#import "WKObject.h"
+#import "WKWebpagePreferencesPrivate.h"
+#import "_WKWebsitePolicies.h"
+
+namespace WebKit {
+
+template<> struct WrapperTraits<API::WebsitePolicies> {
+    using WrapperClass = WKWebpagePreferences;
+};
+
+}
+
+@interface WKWebpagePreferences () <WKObject> {
+@package
+    API::ObjectStorage<API::WebsitePolicies> _websitePolicies;
+}
+
+@property (class, nonatomic, readonly) WKWebpagePreferences *defaultPreferences;
+@end

Copied: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferencesPrivate.h (from rev 243722, trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebsitePolicies.h) (0 => 243726)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferencesPrivate.h	                        (rev 0)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferencesPrivate.h	2019-04-02 00:01:05 UTC (rev 243726)
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#import <WebKit/WKFoundation.h>
+#import <WebKit/WKWebpagePreferences.h>
+#import <WebKit/WKWebsiteDataStore.h>
+
+typedef NS_ENUM(NSInteger, _WKWebsiteAutoplayPolicy) {
+    _WKWebsiteAutoplayPolicyDefault,
+    _WKWebsiteAutoplayPolicyAllow,
+    _WKWebsiteAutoplayPolicyAllowWithoutSound,
+    _WKWebsiteAutoplayPolicyDeny
+} WK_API_AVAILABLE(macos(10.13), ios(11.0));
+
+typedef NS_OPTIONS(NSUInteger, _WKWebsiteAutoplayQuirk) {
+    _WKWebsiteAutoplayQuirkSynthesizedPauseEvents = 1 << 0,
+    _WKWebsiteAutoplayQuirkInheritedUserGestures = 1 << 1,
+    _WKWebsiteAutoplayQuirkArbitraryUserGestures = 1 << 2,
+    _WKWebsiteAutoplayQuirkPerDocumentAutoplayBehavior = 1 << 3,
+} WK_API_AVAILABLE(macos(10.13), ios(11.0));
+
+typedef NS_OPTIONS(NSUInteger, _WKWebsitePopUpPolicy) {
+    _WKWebsitePopUpPolicyDefault,
+    _WKWebsitePopUpPolicyAllow,
+    _WKWebsitePopUpPolicyBlock,
+} WK_API_AVAILABLE(macos(10.14), ios(12.0));
+
+typedef NS_OPTIONS(NSUInteger, _WKWebsiteDeviceOrientationAndMotionAccessPolicy) {
+    _WKWebsiteDeviceOrientationAndMotionAccessPolicyAsk,
+    _WKWebsiteDeviceOrientationAndMotionAccessPolicyGrant,
+    _WKWebsiteDeviceOrientationAndMotionAccessPolicyDeny,
+} WK_API_AVAILABLE(macos(10.14), ios(12.0));
+
+@interface WKWebpagePreferences (WKPrivate)
+
+@property (nonatomic, setter=_setContentBlockersEnabled:) BOOL _contentBlockersEnabled;
+@property (nonatomic, setter=_setAllowedAutoplayQuirks:) _WKWebsiteAutoplayQuirk _allowedAutoplayQuirks;
+@property (nonatomic, setter=_setAutoplayPolicy:) _WKWebsiteAutoplayPolicy _autoplayPolicy;
+@property (nonatomic, copy, setter=_setCustomHeaderFields:) NSDictionary<NSString *, NSString *> *_customHeaderFields;
+@property (nonatomic, setter=_setPopUpPolicy:) _WKWebsitePopUpPolicy _popUpPolicy;
+@property (nonatomic, strong, setter=_setWebsiteDataStore:) WKWebsiteDataStore *_websiteDataStore;
+@property (nonatomic, copy, setter=_setCustomUserAgent:) NSString *_customUserAgent;
+@property (nonatomic, copy, setter=_setCustomJavaScriptUserAgentAsSiteSpecificQuirks:) NSString *_customJavaScriptUserAgentAsSiteSpecificQuirks;
+@property (nonatomic, copy, setter=_setCustomNavigatorPlatform:) NSString *_customNavigatorPlatform;
+@property (nonatomic, setter=_setDeviceOrientationAndMotionAccessPolicy:) _WKWebsiteDeviceOrientationAndMotionAccessPolicy _deviceOrientationAndMotionAccessPolicy;
+
+@end

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebsitePolicies.h (243725 => 243726)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebsitePolicies.h	2019-04-02 00:00:50 UTC (rev 243725)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebsitePolicies.h	2019-04-02 00:01:05 UTC (rev 243726)
@@ -24,33 +24,8 @@
  */
 
 #import <WebKit/WKFoundation.h>
+#import <WebKit/WKWebpagePreferencesPrivate.h>
 
-typedef NS_ENUM(NSInteger, _WKWebsiteAutoplayPolicy) {
-    _WKWebsiteAutoplayPolicyDefault,
-    _WKWebsiteAutoplayPolicyAllow,
-    _WKWebsiteAutoplayPolicyAllowWithoutSound,
-    _WKWebsiteAutoplayPolicyDeny
-} WK_API_AVAILABLE(macos(10.13), ios(11.0));
-
-typedef NS_OPTIONS(NSUInteger, _WKWebsiteAutoplayQuirk) {
-    _WKWebsiteAutoplayQuirkSynthesizedPauseEvents = 1 << 0,
-    _WKWebsiteAutoplayQuirkInheritedUserGestures = 1 << 1,
-    _WKWebsiteAutoplayQuirkArbitraryUserGestures = 1 << 2,
-    _WKWebsiteAutoplayQuirkPerDocumentAutoplayBehavior = 1 << 3,
-} WK_API_AVAILABLE(macos(10.13), ios(11.0));
-
-typedef NS_OPTIONS(NSUInteger, _WKWebsitePopUpPolicy) {
-    _WKWebsitePopUpPolicyDefault,
-    _WKWebsitePopUpPolicyAllow,
-    _WKWebsitePopUpPolicyBlock,
-} WK_API_AVAILABLE(macos(10.14), ios(12.0));
-
-typedef NS_OPTIONS(NSUInteger, _WKWebsiteDeviceOrientationAndMotionAccessPolicy) {
-    _WKWebsiteDeviceOrientationAndMotionAccessPolicyAsk,
-    _WKWebsiteDeviceOrientationAndMotionAccessPolicyGrant,
-    _WKWebsiteDeviceOrientationAndMotionAccessPolicyDeny,
-} WK_API_AVAILABLE(macos(10.14), ios(12.0));
-
 @class WKWebsiteDataStore;
 
 WK_CLASS_AVAILABLE(macos(10.12.3), ios(10.3))

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebsitePolicies.mm (243725 => 243726)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebsitePolicies.mm	2019-04-02 00:00:50 UTC (rev 243725)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebsitePolicies.mm	2019-04-02 00:01:05 UTC (rev 243726)
@@ -24,229 +24,135 @@
  */
 
 #import "config.h"
-#import "_WKWebsitePoliciesInternal.h"
 
+#import "WKWebpagePreferencesInternal.h"
 #import "WKWebsiteDataStoreInternal.h"
+#import "_WKWebsitePoliciesInternal.h"
 
 @implementation _WKWebsitePolicies
 
-- (void)dealloc
-{
-    _websitePolicies->API::WebsitePolicies::~WebsitePolicies();
-    
-    [super dealloc];
-}
-
 - (instancetype)init
 {
     if (!(self = [super init]))
         return nil;
-    
-    API::Object::constructInWrapper<API::WebsitePolicies>(self);
-    
+
+    _webpagePreferences = adoptNS([[WKWebpagePreferences alloc] init]);
     return self;
 }
 
+- (WKWebpagePreferences *)webpagePreferences
+{
+    return _webpagePreferences.get();
+}
+
 - (void)setContentBlockersEnabled:(BOOL)contentBlockersEnabled
 {
-    _websitePolicies->setContentBlockersEnabled(contentBlockersEnabled);
+    [_webpagePreferences _setContentBlockersEnabled:contentBlockersEnabled];
 }
 
 - (BOOL)contentBlockersEnabled
 {
-    return _websitePolicies->contentBlockersEnabled();
+    return [_webpagePreferences _contentBlockersEnabled];
 }
 
 - (void)setAllowedAutoplayQuirks:(_WKWebsiteAutoplayQuirk)allowedQuirks
 {
-    OptionSet<WebKit::WebsiteAutoplayQuirk> quirks;
-
-    if (allowedQuirks & _WKWebsiteAutoplayQuirkInheritedUserGestures)
-        quirks.add(WebKit::WebsiteAutoplayQuirk::InheritedUserGestures);
-
-    if (allowedQuirks & _WKWebsiteAutoplayQuirkSynthesizedPauseEvents)
-        quirks.add(WebKit::WebsiteAutoplayQuirk::SynthesizedPauseEvents);
-
-    if (allowedQuirks & _WKWebsiteAutoplayQuirkArbitraryUserGestures)
-        quirks.add(WebKit::WebsiteAutoplayQuirk::ArbitraryUserGestures);
-
-    if (allowedQuirks & _WKWebsiteAutoplayQuirkPerDocumentAutoplayBehavior)
-        quirks.add(WebKit::WebsiteAutoplayQuirk::PerDocumentAutoplayBehavior);
-
-    _websitePolicies->setAllowedAutoplayQuirks(quirks);
+    [_webpagePreferences _setAllowedAutoplayQuirks:allowedQuirks];
 }
 
 - (_WKWebsiteAutoplayQuirk)allowedAutoplayQuirks
 {
-    _WKWebsiteAutoplayQuirk quirks = 0;
-    auto allowedQuirks = _websitePolicies->allowedAutoplayQuirks();
-
-    if (allowedQuirks.contains(WebKit::WebsiteAutoplayQuirk::InheritedUserGestures))
-        quirks |= _WKWebsiteAutoplayQuirkInheritedUserGestures;
-
-    if (allowedQuirks.contains(WebKit::WebsiteAutoplayQuirk::SynthesizedPauseEvents))
-        quirks |= _WKWebsiteAutoplayQuirkSynthesizedPauseEvents;
-
-    if (allowedQuirks.contains(WebKit::WebsiteAutoplayQuirk::ArbitraryUserGestures))
-        quirks |= _WKWebsiteAutoplayQuirkArbitraryUserGestures;
-
-    if (allowedQuirks.contains(WebKit::WebsiteAutoplayQuirk::PerDocumentAutoplayBehavior))
-        quirks |= _WKWebsiteAutoplayQuirkPerDocumentAutoplayBehavior;
-
-    return quirks;
+    return [_webpagePreferences _allowedAutoplayQuirks];
 }
 
 - (void)setAutoplayPolicy:(_WKWebsiteAutoplayPolicy)policy
 {
-    switch (policy) {
-    case _WKWebsiteAutoplayPolicyDefault:
-        _websitePolicies->setAutoplayPolicy(WebKit::WebsiteAutoplayPolicy::Default);
-        break;
-    case _WKWebsiteAutoplayPolicyAllow:
-        _websitePolicies->setAutoplayPolicy(WebKit::WebsiteAutoplayPolicy::Allow);
-        break;
-    case _WKWebsiteAutoplayPolicyAllowWithoutSound:
-        _websitePolicies->setAutoplayPolicy(WebKit::WebsiteAutoplayPolicy::AllowWithoutSound);
-        break;
-    case _WKWebsiteAutoplayPolicyDeny:
-        _websitePolicies->setAutoplayPolicy(WebKit::WebsiteAutoplayPolicy::Deny);
-        break;
-    }
+    [_webpagePreferences _setAutoplayPolicy:policy];
 }
 
 - (_WKWebsiteAutoplayPolicy)autoplayPolicy
 {
-    switch (_websitePolicies->autoplayPolicy()) {
-    case WebKit::WebsiteAutoplayPolicy::Default:
-        return _WKWebsiteAutoplayPolicyDefault;
-    case WebKit::WebsiteAutoplayPolicy::Allow:
-        return _WKWebsiteAutoplayPolicyAllow;
-    case WebKit::WebsiteAutoplayPolicy::AllowWithoutSound:
-        return _WKWebsiteAutoplayPolicyAllowWithoutSound;
-    case WebKit::WebsiteAutoplayPolicy::Deny:
-        return _WKWebsiteAutoplayPolicyDeny;
-    }
+    return [_webpagePreferences _autoplayPolicy];
 }
 
 - (void)setDeviceOrientationAndMotionAccessPolicy:(_WKWebsiteDeviceOrientationAndMotionAccessPolicy)policy
 {
-    switch (policy) {
-    case _WKWebsiteDeviceOrientationAndMotionAccessPolicyAsk:
-        _websitePolicies->setDeviceOrientationAndMotionAccessState(WTF::nullopt);
-        break;
-    case _WKWebsiteDeviceOrientationAndMotionAccessPolicyGrant:
-        _websitePolicies->setDeviceOrientationAndMotionAccessState(true);
-        break;
-    case _WKWebsiteDeviceOrientationAndMotionAccessPolicyDeny:
-        _websitePolicies->setDeviceOrientationAndMotionAccessState(false);
-        break;
-    }
+    [_webpagePreferences _setDeviceOrientationAndMotionAccessPolicy:policy];
 }
 
 - (_WKWebsiteDeviceOrientationAndMotionAccessPolicy)deviceOrientationAndMotionAccessPolicy
 {
-    if (!_websitePolicies->deviceOrientationAndMotionAccessState())
-        return _WKWebsiteDeviceOrientationAndMotionAccessPolicyAsk;
-    return *_websitePolicies->deviceOrientationAndMotionAccessState() ? _WKWebsiteDeviceOrientationAndMotionAccessPolicyGrant : _WKWebsiteDeviceOrientationAndMotionAccessPolicyDeny;
+    return [_webpagePreferences _deviceOrientationAndMotionAccessPolicy];
 }
 
 - (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;
-    }
+    [_webpagePreferences _setPopUpPolicy:policy];
 }
 
 - (_WKWebsitePopUpPolicy)popUpPolicy
 {
-    switch (_websitePolicies->popUpPolicy()) {
-    case WebKit::WebsitePopUpPolicy::Default:
-        return _WKWebsitePopUpPolicyDefault;
-    case WebKit::WebsitePopUpPolicy::Allow:
-        return _WKWebsitePopUpPolicyAllow;
-    case WebKit::WebsitePopUpPolicy::Block:
-        return _WKWebsitePopUpPolicyBlock;
-    }
+    return [_webpagePreferences _popUpPolicy];
 }
 
 - (NSDictionary<NSString *, NSString *> *)customHeaderFields
 {
-    const auto& fields = _websitePolicies->customHeaderFields();
-    NSMutableDictionary *dictionary = [[[NSMutableDictionary alloc] initWithCapacity:fields.size()] autorelease];
-    for (const auto& field : fields)
-        [dictionary setObject:field.value() forKey:field.name()];
-    return dictionary;
+    return [_webpagePreferences _customHeaderFields];
 }
 
 - (void)setCustomHeaderFields:(NSDictionary<NSString *, NSString *> *)fields
 {
-    Vector<WebCore::HTTPHeaderField> parsedFields;
-    parsedFields.reserveInitialCapacity(fields.count);
-    
-    for (NSString* name in fields) {
-        auto field = WebCore::HTTPHeaderField::create(name, [fields objectForKey:name]);
-        if (field && startsWithLettersIgnoringASCIICase(field->name(), "x-"))
-            parsedFields.uncheckedAppend(WTFMove(*field));
-    }
-    _websitePolicies->setCustomHeaderFields(WTFMove(parsedFields));
+    [_webpagePreferences _setCustomHeaderFields:fields];
 }
 
 - (WKWebsiteDataStore *)websiteDataStore
 {
-    return wrapper(_websitePolicies->websiteDataStore());
+    return [_webpagePreferences _websiteDataStore];
 }
 
 - (void)setWebsiteDataStore:(WKWebsiteDataStore *)websiteDataStore
 {
-    _websitePolicies->setWebsiteDataStore(websiteDataStore->_websiteDataStore.get());
+    [_webpagePreferences _setWebsiteDataStore:websiteDataStore];
 }
 
 - (void)setCustomUserAgent:(NSString *)customUserAgent
 {
-    _websitePolicies->setCustomUserAgent(customUserAgent);
+    [_webpagePreferences _setCustomUserAgent:customUserAgent];
 }
 
 - (NSString *)customUserAgent
 {
-    return _websitePolicies->customUserAgent();
+    return [_webpagePreferences _customUserAgent];
 }
 
 - (void)setCustomJavaScriptUserAgentAsSiteSpecificQuirks:(NSString *)customUserAgent
 {
-    _websitePolicies->setCustomJavaScriptUserAgentAsSiteSpecificQuirks(customUserAgent);
+    [_webpagePreferences _setCustomJavaScriptUserAgentAsSiteSpecificQuirks:customUserAgent];
 }
 
 - (NSString *)customJavaScriptUserAgentAsSiteSpecificQuirks
 {
-    return _websitePolicies->customJavaScriptUserAgentAsSiteSpecificQuirks();
+    return [_webpagePreferences _customJavaScriptUserAgentAsSiteSpecificQuirks];
 }
 
 - (void)setCustomNavigatorPlatform:(NSString *)customNavigatorPlatform
 {
-    _websitePolicies->setCustomNavigatorPlatform(customNavigatorPlatform);
+    [_webpagePreferences _setCustomNavigatorPlatform:customNavigatorPlatform];
 }
 
 - (NSString *)customNavigatorPlatform
 {
-    return _websitePolicies->customNavigatorPlatform();
+    return [_webpagePreferences _customNavigatorPlatform];
 }
 
 - (NSString *)description
 {
-    return [NSString stringWithFormat:@"<%@: %p; contentBlockersEnabled = %d>", NSStringFromClass(self.class), self, self.contentBlockersEnabled];
+    return [NSString stringWithFormat:@"<%@ %@>", self.class, [_webpagePreferences description]];
 }
 
 - (API::Object&)_apiObject
 {
-    return *_websitePolicies;
+    return [_webpagePreferences _apiObject];
 }
 
 @end

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebsitePoliciesInternal.h (243725 => 243726)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebsitePoliciesInternal.h	2019-04-02 00:00:50 UTC (rev 243725)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebsitePoliciesInternal.h	2019-04-02 00:01:05 UTC (rev 243726)
@@ -24,20 +24,16 @@
  */
 
 #import "_WKWebsitePolicies.h"
+#import <wtf/RetainPtr.h>
 
-#import "APIWebsitePolicies.h"
-#import "WKObject.h"
+@class WKWebpagePreferences;
 
-namespace WebKit {
+@interface _WKWebsitePolicies ()
+{
+@package
+    RetainPtr<WKWebpagePreferences> _webpagePreferences;
+}
 
-template<> struct WrapperTraits<API::WebsitePolicies> {
-    using WrapperClass = _WKWebsitePolicies;
-};
+@property (nonatomic, readonly) WKWebpagePreferences *webpagePreferences;
 
-}
-
-@interface _WKWebsitePolicies () <WKObject> {
-@package
-    API::ObjectStorage<API::WebsitePolicies> _websitePolicies;
-}
 @end

Modified: trunk/Source/WebKit/UIProcess/Cocoa/NavigationState.mm (243725 => 243726)


--- trunk/Source/WebKit/UIProcess/Cocoa/NavigationState.mm	2019-04-02 00:00:50 UTC (rev 243725)
+++ trunk/Source/WebKit/UIProcess/Cocoa/NavigationState.mm	2019-04-02 00:01:05 UTC (rev 243726)
@@ -54,6 +54,7 @@
 #import "WKNavigationResponseInternal.h"
 #import "WKReloadFrameErrorRecoveryAttempter.h"
 #import "WKWebViewInternal.h"
+#import "WKWebpagePreferencesInternal.h"
 #import "WebCredential.h"
 #import "WebFrameProxy.h"
 #import "WebNavigationState.h"
@@ -556,7 +557,7 @@
             return;
         checker->didCallCompletionHandler();
 
-        RefPtr<API::WebsitePolicies> apiWebsitePolicies = websitePolicies ? websitePolicies->_websitePolicies.get() : nullptr;
+        RefPtr<API::WebsitePolicies> apiWebsitePolicies = [websitePolicies webpagePreferences] ? [websitePolicies webpagePreferences]->_websitePolicies.get() : nullptr;
         if (apiWebsitePolicies) {
             if (auto* websiteDataStore = apiWebsitePolicies->websiteDataStore()) {
                 auto sessionID = websiteDataStore->websiteDataStore().sessionID();

Modified: trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj (243725 => 243726)


--- trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2019-04-02 00:00:50 UTC (rev 243725)
+++ trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2019-04-02 00:01:05 UTC (rev 243726)
@@ -1634,6 +1634,9 @@
 		ECA680D81E690E2500731D20 /* WebProcessCocoa.h in Headers */ = {isa = PBXBuildFile; fileRef = ECA680D71E690DF800731D20 /* WebProcessCocoa.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		ED82A7F2128C6FAF004477B3 /* WKBundlePageOverlay.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A22F0FF1289FCD90085E74F /* WKBundlePageOverlay.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		F409BA181E6E64BC009DA28E /* WKDragDestinationAction.h in Headers */ = {isa = PBXBuildFile; fileRef = F409BA171E6E64B3009DA28E /* WKDragDestinationAction.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		F438CD1C2241421400DE6DDA /* WKWebpagePreferences.h in Headers */ = {isa = PBXBuildFile; fileRef = F438CD1B224140A600DE6DDA /* WKWebpagePreferences.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		F438CD1F22414D4000DE6DDA /* WKWebpagePreferencesInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = F438CD1E22414D4000DE6DDA /* WKWebpagePreferencesInternal.h */; };
+		F438CD212241F69500DE6DDA /* WKWebpagePreferencesPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = F438CD202241F69500DE6DDA /* WKWebpagePreferencesPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		F44291921FA591C9002CC93E /* _WKAttachment.h in Headers */ = {isa = PBXBuildFile; fileRef = F44291911FA59107002CC93E /* _WKAttachment.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		F44291961FA5942A002CC93E /* _WKAttachmentInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = F44291951FA5942A002CC93E /* _WKAttachmentInternal.h */; };
 		F44DFEB21E9E752F0038D196 /* WebIconUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = F44DFEB01E9E752F0038D196 /* WebIconUtilities.h */; };
@@ -4564,6 +4567,10 @@
 		F409BA171E6E64B3009DA28E /* WKDragDestinationAction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKDragDestinationAction.h; sourceTree = "<group>"; };
 		F40D1B68220BDC0F00B49A01 /* WebAutocorrectionContext.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = WebAutocorrectionContext.h; path = ios/WebAutocorrectionContext.h; sourceTree = "<group>"; };
 		F41056612130699A0092281D /* APIAttachmentCocoa.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = APIAttachmentCocoa.mm; sourceTree = "<group>"; };
+		F438CD1B224140A600DE6DDA /* WKWebpagePreferences.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WKWebpagePreferences.h; sourceTree = "<group>"; };
+		F438CD1D22414AD600DE6DDA /* WKWebpagePreferences.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WKWebpagePreferences.mm; sourceTree = "<group>"; };
+		F438CD1E22414D4000DE6DDA /* WKWebpagePreferencesInternal.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WKWebpagePreferencesInternal.h; sourceTree = "<group>"; };
+		F438CD202241F69500DE6DDA /* WKWebpagePreferencesPrivate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WKWebpagePreferencesPrivate.h; sourceTree = "<group>"; };
 		F44291911FA59107002CC93E /* _WKAttachment.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = _WKAttachment.h; sourceTree = "<group>"; };
 		F44291931FA59311002CC93E /* _WKAttachment.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = _WKAttachment.mm; sourceTree = "<group>"; };
 		F44291951FA5942A002CC93E /* _WKAttachmentInternal.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = _WKAttachmentInternal.h; sourceTree = "<group>"; };
@@ -6252,6 +6259,10 @@
 				1AAF089819267EE500B6390C /* WKUserScript.mm */,
 				1AAF089C19267FC800B6390C /* WKUserScriptInternal.h */,
 				7C882DF61C7E995E006BF731 /* WKUserScriptPrivate.h */,
+				F438CD1B224140A600DE6DDA /* WKWebpagePreferences.h */,
+				F438CD1D22414AD600DE6DDA /* WKWebpagePreferences.mm */,
+				F438CD1E22414D4000DE6DDA /* WKWebpagePreferencesInternal.h */,
+				F438CD202241F69500DE6DDA /* WKWebpagePreferencesPrivate.h */,
 				1A4832CA1A9BC465008B4DFE /* WKWebsiteDataRecord.h */,
 				1A4832C91A9BC465008B4DFE /* WKWebsiteDataRecord.mm */,
 				1A4832CD1A9BC484008B4DFE /* WKWebsiteDataRecordInternal.h */,
@@ -10037,6 +10048,9 @@
 				C5E1AFE916B20B75006CC1F2 /* WKWebArchive.h in Headers */,
 				C5E1AFEB16B20B7E006CC1F2 /* WKWebArchiveResource.h in Headers */,
 				2D1E8223216FFF5100A15265 /* WKWebEvent.h in Headers */,
+				F438CD1C2241421400DE6DDA /* WKWebpagePreferences.h in Headers */,
+				F438CD1F22414D4000DE6DDA /* WKWebpagePreferencesInternal.h in Headers */,
+				F438CD212241F69500DE6DDA /* WKWebpagePreferencesPrivate.h in Headers */,
 				5CADDE05215046BD0067D309 /* WKWebProcess.h in Headers */,
 				1AA2E56718D77508003814BD /* WKWebProcessBundleParameters.h in Headers */,
 				BC989D82161A7E5D000D46D3 /* WKWebProcessPlugIn.h in Headers */,
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to