Title: [228472] trunk/Source/WebKit
Revision
228472
Author
commit-qu...@webkit.org
Date
2018-02-14 10:52:15 -0800 (Wed, 14 Feb 2018)

Log Message

Add C SPI for support of Website Data Store in Website Policies
https://bugs.webkit.org/show_bug.cgi?id=182698
<rdar://problem/37412008>

Patch by Maureen Daum <md...@apple.com> on 2018-02-14
Reviewed by Andy Estes.

Expand the API added for _WKWebsitePolicies.websiteDataStore in r225989 and r226325
to be available in the C API. In the ObjC API, we handle setting the website data
store in NavigationState::NavigationClient::decidePolicyForNavigationAction. There
we throw an exception if setting the website data store isn't supported, and then
change the website data store. The equivalent place to do this work in the C API is
in WKFramePolicyListenerUseWithPolicies. However, instead of throwing exceptions,
release asserts are used.

* UIProcess/API/C/WKFramePolicyListener.cpp:
(WKFramePolicyListenerUseWithPolicies):
If the website policies data contains a website data store, do the same checks that
are done in NavigationState::NavigationClient::decidePolicyForNavigationAction. Namely,
that it is a valid website data store and it is a policy decision for a main frame navigation.
If these checks are met, change the website data store.
* UIProcess/API/C/WKPage.cpp:
(WKPageUpdateWebsitePolicies):
* UIProcess/API/C/WKWebsitePolicies.cpp:
(WKWebsitePoliciesGetDataStore):
(WKWebsitePoliciesSetDataStore):
* UIProcess/API/C/WKWebsitePolicies.h:
* UIProcess/WebFrameListenerProxy.cpp:
(WebKit::WebFrameListenerProxy::changeWebsiteDataStore):
(WebKit::WebFrameListenerProxy::isMainFrame):
Expose whether the frame proxy is for a main frame, which is required to verify that
website policies only specify a website data store for main frame policy decisions.
* UIProcess/WebFrameListenerProxy.h:
* UIProcess/WebFramePolicyListenerProxy.cpp:
* UIProcess/WebFrameProxy.cpp:
(WebKit::WebFrameProxy::changeWebsiteDataStore):
* UIProcess/WebFrameProxy.h:

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (228471 => 228472)


--- trunk/Source/WebKit/ChangeLog	2018-02-14 18:46:10 UTC (rev 228471)
+++ trunk/Source/WebKit/ChangeLog	2018-02-14 18:52:15 UTC (rev 228472)
@@ -1,3 +1,42 @@
+2018-02-14  Maureen Daum  <md...@apple.com>
+
+        Add C SPI for support of Website Data Store in Website Policies
+        https://bugs.webkit.org/show_bug.cgi?id=182698
+        <rdar://problem/37412008>
+
+        Reviewed by Andy Estes.
+
+        Expand the API added for _WKWebsitePolicies.websiteDataStore in r225989 and r226325
+        to be available in the C API. In the ObjC API, we handle setting the website data
+        store in NavigationState::NavigationClient::decidePolicyForNavigationAction. There
+        we throw an exception if setting the website data store isn't supported, and then
+        change the website data store. The equivalent place to do this work in the C API is
+        in WKFramePolicyListenerUseWithPolicies. However, instead of throwing exceptions,
+        release asserts are used.
+
+        * UIProcess/API/C/WKFramePolicyListener.cpp:
+        (WKFramePolicyListenerUseWithPolicies):
+        If the website policies data contains a website data store, do the same checks that
+        are done in NavigationState::NavigationClient::decidePolicyForNavigationAction. Namely,
+        that it is a valid website data store and it is a policy decision for a main frame navigation.
+        If these checks are met, change the website data store.
+        * UIProcess/API/C/WKPage.cpp:
+        (WKPageUpdateWebsitePolicies):
+        * UIProcess/API/C/WKWebsitePolicies.cpp:
+        (WKWebsitePoliciesGetDataStore):
+        (WKWebsitePoliciesSetDataStore):
+        * UIProcess/API/C/WKWebsitePolicies.h:
+        * UIProcess/WebFrameListenerProxy.cpp:
+        (WebKit::WebFrameListenerProxy::changeWebsiteDataStore):
+        (WebKit::WebFrameListenerProxy::isMainFrame):
+        Expose whether the frame proxy is for a main frame, which is required to verify that
+        website policies only specify a website data store for main frame policy decisions.
+        * UIProcess/WebFrameListenerProxy.h:
+        * UIProcess/WebFramePolicyListenerProxy.cpp:
+        * UIProcess/WebFrameProxy.cpp:
+        (WebKit::WebFrameProxy::changeWebsiteDataStore):
+        * UIProcess/WebFrameProxy.h:
+
 2018-02-14  Ryan Haddad  <ryanhad...@apple.com>
 
         Unreviewed, rolling out r228444.

Modified: trunk/Source/WebKit/UIProcess/API/C/WKFramePolicyListener.cpp (228471 => 228472)


--- trunk/Source/WebKit/UIProcess/API/C/WKFramePolicyListener.cpp	2018-02-14 18:46:10 UTC (rev 228471)
+++ trunk/Source/WebKit/UIProcess/API/C/WKFramePolicyListener.cpp	2018-02-14 18:52:15 UTC (rev 228472)
@@ -26,6 +26,7 @@
 #include "config.h"
 #include "WKFramePolicyListener.h"
 
+#include "APIWebsiteDataStore.h"
 #include "APIWebsitePolicies.h"
 #include "WKAPICast.h"
 #include "WebFramePolicyListenerProxy.h"
@@ -47,7 +48,15 @@
 void WKFramePolicyListenerUseWithPolicies(WKFramePolicyListenerRef policyListenerRef, WKWebsitePoliciesRef websitePolicies)
 {
     auto data = ""
-    RELEASE_ASSERT_WITH_MESSAGE(!data.websiteDataStoreParameters, "Setting WebsitePolicies.WebsiteDataStore is not supported in the C API.");
+
+    if (data.websiteDataStoreParameters) {
+        auto& sessionID = data.websiteDataStoreParameters->networkSessionParameters.sessionID;
+        RELEASE_ASSERT_WITH_MESSAGE(sessionID.isEphemeral() || sessionID == PAL::SessionID::defaultSessionID(), "If WebsitePolicies specifies a WebsiteDataStore, the data store's session must be default or non-persistent.");
+        RELEASE_ASSERT_WITH_MESSAGE(toImpl(policyListenerRef)->isMainFrame(), "WebsitePolicies cannot specify a WebsiteDataStore for subframe navigations.");
+
+        toImpl(policyListenerRef)->changeWebsiteDataStore(toImpl(websitePolicies)->websiteDataStore()->websiteDataStore());
+    }
+
     toImpl(policyListenerRef)->use(WTFMove(data));
 }
 

Modified: trunk/Source/WebKit/UIProcess/API/C/WKPage.cpp (228471 => 228472)


--- trunk/Source/WebKit/UIProcess/API/C/WKPage.cpp	2018-02-14 18:46:10 UTC (rev 228471)
+++ trunk/Source/WebKit/UIProcess/API/C/WKPage.cpp	2018-02-14 18:52:15 UTC (rev 228472)
@@ -326,7 +326,7 @@
 void WKPageUpdateWebsitePolicies(WKPageRef pageRef, WKWebsitePoliciesRef websitePoliciesRef)
 {
     auto data = ""
-    RELEASE_ASSERT_WITH_MESSAGE(!data.websiteDataStoreParameters, "Setting WebsitePolicies.WebsiteDataStore is not supported in the C API.");
+    RELEASE_ASSERT_WITH_MESSAGE(!data.websiteDataStoreParameters, "Setting WebsitePolicies.WebsiteDataStore is only supported during WKFramePolicyListenerUseWithPolicies().");
     toImpl(pageRef)->updateWebsitePolicies(WTFMove(data));
 }
 

Modified: trunk/Source/WebKit/UIProcess/API/C/WKWebsitePolicies.cpp (228471 => 228472)


--- trunk/Source/WebKit/UIProcess/API/C/WKWebsitePolicies.cpp	2018-02-14 18:46:10 UTC (rev 228471)
+++ trunk/Source/WebKit/UIProcess/API/C/WKWebsitePolicies.cpp	2018-02-14 18:52:15 UTC (rev 228472)
@@ -27,6 +27,7 @@
 #include "WKWebsitePolicies.h"
 
 #include "APIDictionary.h"
+#include "APIWebsiteDataStore.h"
 #include "APIWebsitePolicies.h"
 #include "WKAPICast.h"
 #include "WKArray.h"
@@ -174,3 +175,14 @@
     }
     ASSERT_NOT_REACHED();
 }
+
+WKWebsiteDataStoreRef WKWebsitePoliciesGetDataStore(WKWebsitePoliciesRef websitePolicies)
+{
+    return toAPI(toImpl(websitePolicies)->websiteDataStore());
+}
+
+void WKWebsitePoliciesSetDataStore(WKWebsitePoliciesRef websitePolicies, WKWebsiteDataStoreRef websiteDataStore)
+{
+    toImpl(websitePolicies)->setWebsiteDataStore(toImpl(websiteDataStore));
+}
+

Modified: trunk/Source/WebKit/UIProcess/API/C/WKWebsitePolicies.h (228471 => 228472)


--- trunk/Source/WebKit/UIProcess/API/C/WKWebsitePolicies.h	2018-02-14 18:46:10 UTC (rev 228471)
+++ trunk/Source/WebKit/UIProcess/API/C/WKWebsitePolicies.h	2018-02-14 18:52:15 UTC (rev 228472)
@@ -70,6 +70,9 @@
 WK_EXPORT WKWebsitePopUpPolicy WKWebsitePoliciesGetPopUpPolicy(WKWebsitePoliciesRef);
 WK_EXPORT void WKWebsitePoliciesSetPopUpPolicy(WKWebsitePoliciesRef, WKWebsitePopUpPolicy);
 
+WK_EXPORT WKWebsiteDataStoreRef WKWebsitePoliciesGetDataStore(WKWebsitePoliciesRef);
+WK_EXPORT void WKWebsitePoliciesSetDataStore(WKWebsitePoliciesRef, WKWebsiteDataStoreRef);
+
 #ifdef __cplusplus
 }
 #endif

Modified: trunk/Source/WebKit/UIProcess/WebFrameListenerProxy.cpp (228471 => 228472)


--- trunk/Source/WebKit/UIProcess/WebFrameListenerProxy.cpp	2018-02-14 18:46:10 UTC (rev 228471)
+++ trunk/Source/WebKit/UIProcess/WebFrameListenerProxy.cpp	2018-02-14 18:52:15 UTC (rev 228472)
@@ -27,6 +27,7 @@
 #include "WebFrameListenerProxy.h"
 
 #include "WebFrameProxy.h"
+#include "WebsiteDataStore.h"
 #include "WebsitePoliciesData.h"
 
 namespace WebKit {
@@ -55,4 +56,20 @@
     m_frame = nullptr;
 }
 
+void WebFrameListenerProxy::changeWebsiteDataStore(WebsiteDataStore& websiteDataStore)
+{
+    if (!m_frame)
+        return;
+
+    m_frame->changeWebsiteDataStore(websiteDataStore);
+}
+
+bool WebFrameListenerProxy::isMainFrame() const
+{
+    if (!m_frame)
+        return false;
+
+    return m_frame->isMainFrame();
+}
+
 } // namespace WebKit

Modified: trunk/Source/WebKit/UIProcess/WebFrameListenerProxy.h (228471 => 228472)


--- trunk/Source/WebKit/UIProcess/WebFrameListenerProxy.h	2018-02-14 18:46:10 UTC (rev 228471)
+++ trunk/Source/WebKit/UIProcess/WebFrameListenerProxy.h	2018-02-14 18:52:15 UTC (rev 228472)
@@ -34,6 +34,7 @@
 namespace WebKit {
 
 class WebFrameProxy;
+class WebsiteDataStore;
 struct WebsitePoliciesData;
 
 class WebFrameListenerProxy : public API::Object {
@@ -45,6 +46,9 @@
 
     void setNavigation(Ref<API::Navigation>&& navigation) { m_navigation = WTFMove(navigation); }
 
+    void changeWebsiteDataStore(WebsiteDataStore&);
+    bool isMainFrame() const;
+
 protected:
     WebFrameListenerProxy(WebFrameProxy*, uint64_t listenerID);
 

Modified: trunk/Source/WebKit/UIProcess/WebFramePolicyListenerProxy.cpp (228471 => 228472)


--- trunk/Source/WebKit/UIProcess/WebFramePolicyListenerProxy.cpp	2018-02-14 18:46:10 UTC (rev 228471)
+++ trunk/Source/WebKit/UIProcess/WebFramePolicyListenerProxy.cpp	2018-02-14 18:52:15 UTC (rev 228472)
@@ -27,6 +27,7 @@
 #include "WebFramePolicyListenerProxy.h"
 
 #include "WebFrameProxy.h"
+#include "WebsiteDataStore.h"
 #include "WebsitePoliciesData.h"
 
 namespace WebKit {

Modified: trunk/Source/WebKit/UIProcess/WebFrameProxy.cpp (228471 => 228472)


--- trunk/Source/WebKit/UIProcess/WebFrameProxy.cpp	2018-02-14 18:46:10 UTC (rev 228471)
+++ trunk/Source/WebKit/UIProcess/WebFrameProxy.cpp	2018-02-14 18:52:15 UTC (rev 228472)
@@ -32,6 +32,7 @@
 #include "WebPageProxy.h"
 #include "WebPasteboardProxy.h"
 #include "WebProcessPool.h"
+#include "WebsiteDataStore.h"
 #include "WebsitePoliciesData.h"
 #include <WebCore/Image.h>
 #include <WebCore/MIMETypeRegistry.h>
@@ -194,6 +195,14 @@
     return *static_cast<WebFramePolicyListenerProxy*>(m_activeListener.get());
 }
 
+void WebFrameProxy::changeWebsiteDataStore(WebsiteDataStore& websiteDataStore)
+{
+    if (!m_page)
+        return;
+
+    m_page->changeWebsiteDataStore(websiteDataStore);
+}
+
 void WebFrameProxy::getWebArchive(Function<void (API::Data*, CallbackBase::Error)>&& callbackFunction)
 {
     if (!m_page) {

Modified: trunk/Source/WebKit/UIProcess/WebFrameProxy.h (228471 => 228472)


--- trunk/Source/WebKit/UIProcess/WebFrameProxy.h	2018-02-14 18:46:10 UTC (rev 228471)
+++ trunk/Source/WebKit/UIProcess/WebFrameProxy.h	2018-02-14 18:52:15 UTC (rev 228472)
@@ -51,6 +51,7 @@
 class WebCertificateInfo;
 class WebFramePolicyListenerProxy;
 class WebPageProxy;
+class WebsiteDataStore;
 struct WebsitePoliciesData;
 
 typedef GenericCallback<API::Data*> DataCallback;
@@ -116,6 +117,7 @@
     // Policy operations.
     void receivedPolicyDecision(WebCore::PolicyAction, uint64_t listenerID, API::Navigation*, std::optional<WebsitePoliciesData>&&);
     WebFramePolicyListenerProxy& setUpPolicyListenerProxy(uint64_t listenerID);
+    void changeWebsiteDataStore(WebsiteDataStore&);
 
 #if ENABLE(CONTENT_FILTERING)
     void contentFilterDidBlockLoad(WebCore::ContentFilterUnblockHandler contentFilterUnblockHandler) { m_contentFilterUnblockHandler = WTFMove(contentFilterUnblockHandler); }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to