Changeset 228472 in webkit


Ignore:
Timestamp:
Feb 14, 2018 10:52:15 AM (6 years ago)
Author:
commit-queue@webkit.org
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 <mdaum@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:
Location:
trunk/Source/WebKit
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r228470 r228472  
     12018-02-14  Maureen Daum  <mdaum@apple.com>
     2
     3        Add C SPI for support of Website Data Store in Website Policies
     4        https://bugs.webkit.org/show_bug.cgi?id=182698
     5        <rdar://problem/37412008>
     6
     7        Reviewed by Andy Estes.
     8
     9        Expand the API added for _WKWebsitePolicies.websiteDataStore in r225989 and r226325
     10        to be available in the C API. In the ObjC API, we handle setting the website data
     11        store in NavigationState::NavigationClient::decidePolicyForNavigationAction. There
     12        we throw an exception if setting the website data store isn't supported, and then
     13        change the website data store. The equivalent place to do this work in the C API is
     14        in WKFramePolicyListenerUseWithPolicies. However, instead of throwing exceptions,
     15        release asserts are used.
     16
     17        * UIProcess/API/C/WKFramePolicyListener.cpp:
     18        (WKFramePolicyListenerUseWithPolicies):
     19        If the website policies data contains a website data store, do the same checks that
     20        are done in NavigationState::NavigationClient::decidePolicyForNavigationAction. Namely,
     21        that it is a valid website data store and it is a policy decision for a main frame navigation.
     22        If these checks are met, change the website data store.
     23        * UIProcess/API/C/WKPage.cpp:
     24        (WKPageUpdateWebsitePolicies):
     25        * UIProcess/API/C/WKWebsitePolicies.cpp:
     26        (WKWebsitePoliciesGetDataStore):
     27        (WKWebsitePoliciesSetDataStore):
     28        * UIProcess/API/C/WKWebsitePolicies.h:
     29        * UIProcess/WebFrameListenerProxy.cpp:
     30        (WebKit::WebFrameListenerProxy::changeWebsiteDataStore):
     31        (WebKit::WebFrameListenerProxy::isMainFrame):
     32        Expose whether the frame proxy is for a main frame, which is required to verify that
     33        website policies only specify a website data store for main frame policy decisions.
     34        * UIProcess/WebFrameListenerProxy.h:
     35        * UIProcess/WebFramePolicyListenerProxy.cpp:
     36        * UIProcess/WebFrameProxy.cpp:
     37        (WebKit::WebFrameProxy::changeWebsiteDataStore):
     38        * UIProcess/WebFrameProxy.h:
     39
    1402018-02-14  Ryan Haddad  <ryanhaddad@apple.com>
    241
  • trunk/Source/WebKit/UIProcess/API/C/WKFramePolicyListener.cpp

    r225989 r228472  
    2727#include "WKFramePolicyListener.h"
    2828
     29#include "APIWebsiteDataStore.h"
    2930#include "APIWebsitePolicies.h"
    3031#include "WKAPICast.h"
     
    4849{
    4950    auto data = toImpl(websitePolicies)->data();
    50     RELEASE_ASSERT_WITH_MESSAGE(!data.websiteDataStoreParameters, "Setting WebsitePolicies.WebsiteDataStore is not supported in the C API.");
     51
     52    if (data.websiteDataStoreParameters) {
     53        auto& sessionID = data.websiteDataStoreParameters->networkSessionParameters.sessionID;
     54        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.");
     55        RELEASE_ASSERT_WITH_MESSAGE(toImpl(policyListenerRef)->isMainFrame(), "WebsitePolicies cannot specify a WebsiteDataStore for subframe navigations.");
     56
     57        toImpl(policyListenerRef)->changeWebsiteDataStore(toImpl(websitePolicies)->websiteDataStore()->websiteDataStore());
     58    }
     59
    5160    toImpl(policyListenerRef)->use(WTFMove(data));
    5261}
  • trunk/Source/WebKit/UIProcess/API/C/WKPage.cpp

    r228194 r228472  
    327327{
    328328    auto data = toImpl(websitePoliciesRef)->data();
    329     RELEASE_ASSERT_WITH_MESSAGE(!data.websiteDataStoreParameters, "Setting WebsitePolicies.WebsiteDataStore is not supported in the C API.");
     329    RELEASE_ASSERT_WITH_MESSAGE(!data.websiteDataStoreParameters, "Setting WebsitePolicies.WebsiteDataStore is only supported during WKFramePolicyListenerUseWithPolicies().");
    330330    toImpl(pageRef)->updateWebsitePolicies(WTFMove(data));
    331331}
  • trunk/Source/WebKit/UIProcess/API/C/WKWebsitePolicies.cpp

    r226984 r228472  
    2828
    2929#include "APIDictionary.h"
     30#include "APIWebsiteDataStore.h"
    3031#include "APIWebsitePolicies.h"
    3132#include "WKAPICast.h"
     
    175176    ASSERT_NOT_REACHED();
    176177}
     178
     179WKWebsiteDataStoreRef WKWebsitePoliciesGetDataStore(WKWebsitePoliciesRef websitePolicies)
     180{
     181    return toAPI(toImpl(websitePolicies)->websiteDataStore());
     182}
     183
     184void WKWebsitePoliciesSetDataStore(WKWebsitePoliciesRef websitePolicies, WKWebsiteDataStoreRef websiteDataStore)
     185{
     186    toImpl(websitePolicies)->setWebsiteDataStore(toImpl(websiteDataStore));
     187}
     188
  • trunk/Source/WebKit/UIProcess/API/C/WKWebsitePolicies.h

    r226984 r228472  
    7171WK_EXPORT void WKWebsitePoliciesSetPopUpPolicy(WKWebsitePoliciesRef, WKWebsitePopUpPolicy);
    7272
     73WK_EXPORT WKWebsiteDataStoreRef WKWebsitePoliciesGetDataStore(WKWebsitePoliciesRef);
     74WK_EXPORT void WKWebsitePoliciesSetDataStore(WKWebsitePoliciesRef, WKWebsiteDataStoreRef);
     75
    7376#ifdef __cplusplus
    7477}
  • trunk/Source/WebKit/UIProcess/WebFrameListenerProxy.cpp

    r225954 r228472  
    2828
    2929#include "WebFrameProxy.h"
     30#include "WebsiteDataStore.h"
    3031#include "WebsitePoliciesData.h"
    3132
     
    5657}
    5758
     59void WebFrameListenerProxy::changeWebsiteDataStore(WebsiteDataStore& websiteDataStore)
     60{
     61    if (!m_frame)
     62        return;
     63
     64    m_frame->changeWebsiteDataStore(websiteDataStore);
     65}
     66
     67bool WebFrameListenerProxy::isMainFrame() const
     68{
     69    if (!m_frame)
     70        return false;
     71
     72    return m_frame->isMainFrame();
     73}
     74
    5875} // namespace WebKit
  • trunk/Source/WebKit/UIProcess/WebFrameListenerProxy.h

    r225954 r228472  
    3535
    3636class WebFrameProxy;
     37class WebsiteDataStore;
    3738struct WebsitePoliciesData;
    3839
     
    4546
    4647    void setNavigation(Ref<API::Navigation>&& navigation) { m_navigation = WTFMove(navigation); }
     48
     49    void changeWebsiteDataStore(WebsiteDataStore&);
     50    bool isMainFrame() const;
    4751
    4852protected:
  • trunk/Source/WebKit/UIProcess/WebFramePolicyListenerProxy.cpp

    r225954 r228472  
    2828
    2929#include "WebFrameProxy.h"
     30#include "WebsiteDataStore.h"
    3031#include "WebsitePoliciesData.h"
    3132
  • trunk/Source/WebKit/UIProcess/WebFrameProxy.cpp

    r225954 r228472  
    3333#include "WebPasteboardProxy.h"
    3434#include "WebProcessPool.h"
     35#include "WebsiteDataStore.h"
    3536#include "WebsitePoliciesData.h"
    3637#include <WebCore/Image.h>
     
    193194    m_activeListener = WebFramePolicyListenerProxy::create(this, listenerID);
    194195    return *static_cast<WebFramePolicyListenerProxy*>(m_activeListener.get());
     196}
     197
     198void WebFrameProxy::changeWebsiteDataStore(WebsiteDataStore& websiteDataStore)
     199{
     200    if (!m_page)
     201        return;
     202
     203    m_page->changeWebsiteDataStore(websiteDataStore);
    195204}
    196205
  • trunk/Source/WebKit/UIProcess/WebFrameProxy.h

    r225954 r228472  
    5252class WebFramePolicyListenerProxy;
    5353class WebPageProxy;
     54class WebsiteDataStore;
    5455struct WebsitePoliciesData;
    5556
     
    117118    void receivedPolicyDecision(WebCore::PolicyAction, uint64_t listenerID, API::Navigation*, std::optional<WebsitePoliciesData>&&);
    118119    WebFramePolicyListenerProxy& setUpPolicyListenerProxy(uint64_t listenerID);
     120    void changeWebsiteDataStore(WebsiteDataStore&);
    119121
    120122#if ENABLE(CONTENT_FILTERING)
Note: See TracChangeset for help on using the changeset viewer.