Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement removeDataOfTypes to WKWebsiteDataStore #13605

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions Source/WebKit/Headers.cmake
Expand Up @@ -112,6 +112,7 @@ set(WebKit_PUBLIC_FRAMEWORK_HEADERS
UIProcess/API/C/WKUserMediaPermissionRequest.h
UIProcess/API/C/WKUserScriptRef.h
UIProcess/API/C/WKViewportAttributes.h
UIProcess/API/C/WKWebsiteDataRecordRef.h
UIProcess/API/C/WKWebsiteDataStoreConfigurationRef.h
UIProcess/API/C/WKWebsiteDataStoreRef.h
UIProcess/API/C/WKWebsitePolicies.h
Expand Down
1 change: 1 addition & 0 deletions Source/WebKit/Shared/API/c/WKBase.h
Expand Up @@ -139,6 +139,7 @@ typedef const struct OpaqueWKUserMediaPermissionCheck* WKUserMediaPermissionChec
typedef const struct OpaqueWKUserMediaPermissionRequest* WKUserMediaPermissionRequestRef;
typedef const struct OpaqueWKUserScript* WKUserScriptRef;
typedef const struct OpaqueWKViewportAttributes* WKViewportAttributesRef;
typedef const struct OpaqueWKWebsiteDataRecord* WKWebsiteDataRecordRef;
typedef const struct OpaqueWKWebsiteDataConfigurationStore* WKWebsiteDataStoreConfigurationRef;
typedef const struct OpaqueWKWebsiteDataStore* WKWebsiteDataStoreRef;
typedef const struct OpaqueWKWebsitePolicies* WKWebsitePoliciesRef;
Expand Down
3 changes: 3 additions & 0 deletions Source/WebKit/Sources.txt
Expand Up @@ -483,9 +483,11 @@ UIProcess/API/APIUserScript.cpp
UIProcess/API/APIUserStyleSheet.cpp
UIProcess/API/APIWebAuthenticationAssertionResponse.cpp
UIProcess/API/APIWebAuthenticationPanel.cpp
UIProcess/API/APIWebsiteDataRecord.cpp
UIProcess/API/APIWebsitePolicies.cpp
UIProcess/API/APIWindowFeatures.cpp

UIProcess/API/C/WKAPICast.cpp
UIProcess/API/C/WKApplicationCacheManager.cpp
UIProcess/API/C/WKAuthenticationChallenge.cpp
UIProcess/API/C/WKAuthenticationDecisionListener.cpp
Expand Down Expand Up @@ -537,6 +539,7 @@ UIProcess/API/C/WKUserContentControllerRef.cpp
UIProcess/API/C/WKUserContentExtensionStoreRef.cpp
UIProcess/API/C/WKUserMediaPermissionCheck.cpp
UIProcess/API/C/WKUserMediaPermissionRequest.cpp
UIProcess/API/C/WKWebsiteDataRecordRef.cpp
UIProcess/API/C/WKWebsiteDataStoreConfigurationRef.cpp
UIProcess/API/C/WKWebsiteDataStoreRef.cpp
UIProcess/API/C/WKWebsitePolicies.cpp
Expand Down
2 changes: 0 additions & 2 deletions Source/WebKit/SourcesCocoa.txt
Expand Up @@ -238,8 +238,6 @@ UIProcess/ViewSnapshotStore.cpp
UIProcess/WebMemoryPressureHandler.cpp
UIProcess/WKImagePreviewViewController.mm

UIProcess/API/APIWebsiteDataRecord.cpp

UIProcess/API/C/WKContextMenuListener.cpp
UIProcess/API/C/WKTestingSupport.cpp
UIProcess/API/C/WKUserScriptRef.cpp
Expand Down
139 changes: 139 additions & 0 deletions Source/WebKit/UIProcess/API/C/WKAPICast.cpp
@@ -0,0 +1,139 @@
/*
* Copyright (C) 2023 Sony Interactive Entertainment Inc.
*
* 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.
*/

#include "config.h"
#include "WKAPICast.h"

namespace WebKit {

OptionSet<WebsiteDataType> toWebsiteDataTypes(WKWebsiteDataTypes websiteDataTypes)
{
OptionSet<WebsiteDataType> result;

if (websiteDataTypes & kWKWebsiteDataTypesCookies)
result.add(WebsiteDataType::Cookies);
if (websiteDataTypes & kWKWebsiteDataTypesDiskCache)
result.add(WebsiteDataType::DiskCache);
if (websiteDataTypes & kWKWebsiteDataTypesMemoryCache)
result.add(WebsiteDataType::MemoryCache);
if (websiteDataTypes & kWKWebsiteDataTypesOfflineWebApplicationCache)
result.add(WebsiteDataType::OfflineWebApplicationCache);
if (websiteDataTypes & kWKWebsiteDataTypesSessionStorage)
result.add(WebsiteDataType::SessionStorage);
if (websiteDataTypes & kWKWebsiteDataTypesLocalStorage)
result.add(WebsiteDataType::LocalStorage);
if (websiteDataTypes & kWKWebsiteDataTypesWebSQLDatabases)
result.add(WebsiteDataType::WebSQLDatabases);
if (websiteDataTypes & kWKWebsiteDataTypesIndexedDBDatabases)
result.add(WebsiteDataType::IndexedDBDatabases);
if (websiteDataTypes & kWKWebsiteDataTypesMediaKeys)
result.add(WebsiteDataType::MediaKeys);
if (websiteDataTypes & kWKWebsiteDataTypesHSTSCache)
result.add(WebsiteDataType::HSTSCache);
if (websiteDataTypes & kWKWebsiteDataTypesSearchFieldRecentSearches)
result.add(WebsiteDataType::SearchFieldRecentSearches);
if (websiteDataTypes & kWKWebsiteDataTypesResourceLoadStatistics)
result.add(WebsiteDataType::ResourceLoadStatistics);
if (websiteDataTypes & kWKWebsiteDataTypesCredentials)
result.add(WebsiteDataType::Credentials);
#if ENABLE(SERVICE_WORKER)
if (websiteDataTypes & kWKWebsiteDataTypesServiceWorkerRegistrations)
result.add(WebsiteDataType::ServiceWorkerRegistrations);
#endif
if (websiteDataTypes & kWKWebsiteDataTypesDOMCache)
result.add(WebsiteDataType::DOMCache);
if (websiteDataTypes & kWKWebsiteDataTypesDeviceIdHashSalt)
result.add(WebsiteDataType::DeviceIdHashSalt);
if (websiteDataTypes & kWKWebsiteDataTypesPrivateClickMeasurements)
result.add(WebsiteDataType::PrivateClickMeasurements);
#if HAVE(ALTERNATIVE_SERVICE)
if (websiteDataTypes & kWKWebsiteDataTypesAlternativeServices)
result.add(WebsiteDataType::AlternativeServices);
#endif
if (websiteDataTypes & kWKWebsiteDataTypesFileSystem)
result.add(WebsiteDataType::FileSystem);
#if ENABLE(SERVICE_WORKER)
if (websiteDataTypes & kWKWebsiteDataTypesBackgroundFetchStorage)
result.add(WebsiteDataType::BackgroundFetchStorage);
#endif

return result;
}

WKWebsiteDataTypes toAPI(const OptionSet<WebsiteDataType>& websiteDataTypes)
{
WKWebsiteDataTypes result = 0;

if (websiteDataTypes.contains(WebsiteDataType::Cookies))
result |= kWKWebsiteDataTypesCookies;
if (websiteDataTypes.contains(WebsiteDataType::DiskCache))
result |= kWKWebsiteDataTypesDiskCache;
if (websiteDataTypes.contains(WebsiteDataType::MemoryCache))
result |= kWKWebsiteDataTypesMemoryCache;
if (websiteDataTypes.contains(WebsiteDataType::OfflineWebApplicationCache))
result |= kWKWebsiteDataTypesOfflineWebApplicationCache;
if (websiteDataTypes.contains(WebsiteDataType::SessionStorage))
result |= kWKWebsiteDataTypesSessionStorage;
if (websiteDataTypes.contains(WebsiteDataType::LocalStorage))
result |= kWKWebsiteDataTypesLocalStorage;
if (websiteDataTypes.contains(WebsiteDataType::WebSQLDatabases))
result |= kWKWebsiteDataTypesWebSQLDatabases;
if (websiteDataTypes.contains(WebsiteDataType::IndexedDBDatabases))
result |= kWKWebsiteDataTypesIndexedDBDatabases;
if (websiteDataTypes.contains(WebsiteDataType::MediaKeys))
result |= kWKWebsiteDataTypesMediaKeys;
if (websiteDataTypes.contains(WebsiteDataType::HSTSCache))
result |= kWKWebsiteDataTypesHSTSCache;
if (websiteDataTypes.contains(WebsiteDataType::SearchFieldRecentSearches))
result |= kWKWebsiteDataTypesSearchFieldRecentSearches;
if (websiteDataTypes.contains(WebsiteDataType::ResourceLoadStatistics))
result |= kWKWebsiteDataTypesResourceLoadStatistics;
if (websiteDataTypes.contains(WebsiteDataType::Credentials))
result |= kWKWebsiteDataTypesCredentials;
#if ENABLE(SERVICE_WORKER)
if (websiteDataTypes.contains(WebsiteDataType::ServiceWorkerRegistrations))
result |= kWKWebsiteDataTypesServiceWorkerRegistrations;
#endif
if (websiteDataTypes.contains(WebsiteDataType::DOMCache))
result |= kWKWebsiteDataTypesDOMCache;
if (websiteDataTypes.contains(WebsiteDataType::DeviceIdHashSalt))
result |= kWKWebsiteDataTypesDeviceIdHashSalt;
if (websiteDataTypes.contains(WebsiteDataType::PrivateClickMeasurements))
result |= kWKWebsiteDataTypesPrivateClickMeasurements;
#if HAVE(ALTERNATIVE_SERVICE)
if (websiteDataTypes.contains(WebsiteDataType::AlternativeServices))
result |= kWKWebsiteDataTypesAlternativeServices;
#endif
if (websiteDataTypes.contains(WebsiteDataType::FileSystem))
result |= kWKWebsiteDataTypesFileSystem;
#if ENABLE(SERVICE_WORKER)
if (websiteDataTypes.contains(WebsiteDataType::BackgroundFetchStorage))
result |= kWKWebsiteDataTypesBackgroundFetchStorage;
#endif

return result;
}

} // namespace WebKit
7 changes: 7 additions & 0 deletions Source/WebKit/UIProcess/API/C/WKAPICast.h
Expand Up @@ -41,6 +41,8 @@
#include "WKProtectionSpaceTypes.h"
#include "WKResourceCacheManager.h"
#include "WKSharedAPICast.h"
#include "WKWebsiteDataRecordRef.h"
#include "WebsiteDataType.h"
#include <WebCore/Credential.h>
#include <WebCore/FrameLoaderTypes.h>
#include <WebCore/HTTPCookieAcceptPolicy.h>
Expand All @@ -66,6 +68,7 @@ class PageConfiguration;
class ProcessPoolConfiguration;
class SessionState;
class UserScript;
class WebsiteDataRecord;
class WebsitePolicies;
class WindowFeatures;
}
Expand Down Expand Up @@ -163,6 +166,7 @@ WK_ADD_API_MAPPING(WKUserMediaPermissionCheckRef, UserMediaPermissionCheckProxy)
WK_ADD_API_MAPPING(WKUserMediaPermissionRequestRef, UserMediaPermissionRequestProxy)
WK_ADD_API_MAPPING(WKUserScriptRef, API::UserScript)
WK_ADD_API_MAPPING(WKViewportAttributesRef, WebViewportAttributes)
WK_ADD_API_MAPPING(WKWebsiteDataRecordRef, API::WebsiteDataRecord)
WK_ADD_API_MAPPING(WKWebsiteDataStoreRef, WebKit::WebsiteDataStore)
WK_ADD_API_MAPPING(WKWebsiteDataStoreConfigurationRef, WebKit::WebsiteDataStoreConfiguration)
WK_ADD_API_MAPPING(WKWebsitePoliciesRef, API::WebsitePolicies)
Expand Down Expand Up @@ -419,6 +423,9 @@ inline WKStorageBlockingPolicy toAPI(WebCore::StorageBlockingPolicy policy)
return kWKAllowAllStorage;
}

OptionSet<WebsiteDataType> toWebsiteDataTypes(WKWebsiteDataTypes websiteDataTypes);
WKWebsiteDataTypes toAPI(const OptionSet<WebsiteDataType>& websiteDataTypes);

} // namespace WebKit

#if defined(BUILDING_GTK__)
Expand Down
45 changes: 45 additions & 0 deletions Source/WebKit/UIProcess/API/C/WKWebsiteDataRecordRef.cpp
@@ -0,0 +1,45 @@
/*
* Copyright (C) 2023 Sony Interactive Entertainment Inc.
*
* 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.
*/

#include "config.h"
#include "WKWebsiteDataRecordRef.h"

#include "APIWebsiteDataRecord.h"
#include "WKAPICast.h"

WKTypeID WKWebsiteDataRecordGetTypeID()
{
return WebKit::toAPI(API::WebsiteDataRecord::APIType);
}

WKStringRef WKWebsiteDataRecordGetDisplayName(WKWebsiteDataRecordRef dataRecordRef)
{
return WebKit::toCopiedAPI(WebKit::toImpl(dataRecordRef)->websiteDataRecord().displayName);
}

WKWebsiteDataTypes WKWebsiteDataRecordGetDataTypes(WKWebsiteDataRecordRef dataRecordRef)
{
return WebKit::toAPI(WebKit::toImpl(dataRecordRef)->websiteDataRecord().types);
}
65 changes: 65 additions & 0 deletions Source/WebKit/UIProcess/API/C/WKWebsiteDataRecordRef.h
@@ -0,0 +1,65 @@
/*
* Copyright (C) 2023 Sony Interactive Entertainment Inc.
*
* 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

#include <WebKit/WKBase.h>

#ifdef __cplusplus
extern "C" {
#endif

enum {
kWKWebsiteDataTypesCookies = 1 << 0,
kWKWebsiteDataTypesDiskCache = 1 << 1,
kWKWebsiteDataTypesMemoryCache = 1 << 2,
kWKWebsiteDataTypesOfflineWebApplicationCache = 1 << 3,
kWKWebsiteDataTypesSessionStorage = 1 << 4,
kWKWebsiteDataTypesLocalStorage = 1 << 5,
kWKWebsiteDataTypesWebSQLDatabases = 1 << 6,
kWKWebsiteDataTypesIndexedDBDatabases = 1 << 7,
kWKWebsiteDataTypesMediaKeys = 1 << 8,
kWKWebsiteDataTypesHSTSCache = 1 << 9,
kWKWebsiteDataTypesSearchFieldRecentSearches = 1 << 10,
kWKWebsiteDataTypesResourceLoadStatistics = 1 << 12,
kWKWebsiteDataTypesCredentials = 1 << 13,
kWKWebsiteDataTypesServiceWorkerRegistrations = 1 << 14,
kWKWebsiteDataTypesDOMCache = 1 << 15,
kWKWebsiteDataTypesDeviceIdHashSalt = 1 << 16,
kWKWebsiteDataTypesPrivateClickMeasurements = 1 << 17,
kWKWebsiteDataTypesAlternativeServices = 1 << 18,
kWKWebsiteDataTypesFileSystem = 1 << 19,
kWKWebsiteDataTypesBackgroundFetchStorage = 1 << 20
};
typedef uint64_t WKWebsiteDataTypes;

WK_EXPORT WKTypeID WKWebsiteDataRecordGetTypeID();

WK_EXPORT WKStringRef WKWebsiteDataRecordGetDisplayName(WKWebsiteDataRecordRef dataRecordRef);
WK_EXPORT WKWebsiteDataTypes WKWebsiteDataRecordGetDataTypes(WKWebsiteDataRecordRef dataRecordRef);

#ifdef __cplusplus
}
#endif