Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Temporarily re-add _WKUserContentFilter and _WKUserContentExtensionStore
https://bugs.webkit.org/show_bug.cgi?id=246050 <rdar://100785329> Reviewed by Tim Horton. * Source/WebKit/SourcesCocoa.txt: * Source/WebKit/UIProcess/API/Cocoa/WKUserContentController.mm: (-[WKUserContentController _addUserContentFilter:]): * Source/WebKit/UIProcess/API/Cocoa/WKUserContentControllerPrivate.h: * Source/WebKit/UIProcess/API/Cocoa/_WKUserContentExtensionStore.h: Added. * Source/WebKit/UIProcess/API/Cocoa/_WKUserContentExtensionStore.mm: Added. (toUserContentRuleListStoreError): (+[_WKUserContentExtensionStore defaultStore]): (+[_WKUserContentExtensionStore storeWithURL:]): (-[_WKUserContentExtensionStore compileContentExtensionForIdentifier:encodedContentExtension:completionHandler:]): (-[_WKUserContentExtensionStore lookupContentExtensionForIdentifier:completionHandler:]): (-[_WKUserContentExtensionStore removeContentExtensionForIdentifier:completionHandler:]): (-[_WKUserContentExtensionStore _apiObject]): (-[_WKUserContentExtensionStore _removeAllContentExtensions]): (-[_WKUserContentExtensionStore _invalidateContentExtensionVersionForIdentifier:]): (-[_WKUserContentExtensionStore _initWithWKContentRuleListStore:]): (-[_WKUserContentExtensionStore _contentRuleListStore]): * Source/WebKit/UIProcess/API/Cocoa/_WKUserContentExtensionStoreInternal.h: Added. * Source/WebKit/UIProcess/API/Cocoa/_WKUserContentExtensionStorePrivate.h: Added. * Source/WebKit/UIProcess/API/Cocoa/_WKUserContentFilter.h: Added. * Source/WebKit/UIProcess/API/Cocoa/_WKUserContentFilter.mm: Added. (-[_WKUserContentFilter _apiObject]): (-[_WKUserContentFilter _initWithWKContentRuleList:]): * Source/WebKit/UIProcess/API/Cocoa/_WKUserContentFilterInternal.h: Added. * Source/WebKit/UIProcess/API/Cocoa/_WKUserContentFilterPrivate.h: Added. * Source/WebKit/WebKit.xcodeproj/project.pbxproj: Canonical link: https://commits.webkit.org/255149@main
- Loading branch information
1 parent
49a7efc
commit a80b289
Showing
12 changed files
with
478 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
Source/WebKit/UIProcess/API/Cocoa/_WKUserContentExtensionStore.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright (C) 2015 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> | ||
|
||
@class _WKUserContentFilter; | ||
|
||
// FIXME: Remove this once rdar://100785999 is unblocked. | ||
WK_CLASS_DEPRECATED_WITH_REPLACEMENT("WKContentRuleListStore", macos(10.11, WK_MAC_TBA), ios(9.0, WK_IOS_TBA)) | ||
@interface _WKUserContentExtensionStore : NSObject | ||
|
||
+ (instancetype)defaultStore; | ||
+ (instancetype)storeWithURL:(NSURL *)url; | ||
|
||
- (void)compileContentExtensionForIdentifier:(NSString *)identifier encodedContentExtension:(NSString *) NS_RELEASES_ARGUMENT encodedContentExtension completionHandler:(void (^)(_WKUserContentFilter *, NSError *))completionHandler; | ||
- (void)lookupContentExtensionForIdentifier:(NSString *)identifier completionHandler:(void (^)(_WKUserContentFilter *, NSError *))completionHandler; | ||
- (void)removeContentExtensionForIdentifier:(NSString *)identifier completionHandler:(void (^)(NSError *))completionHandler; | ||
|
||
@end | ||
|
||
WK_EXTERN NSString * const _WKUserContentExtensionsDomain WK_API_AVAILABLE(macos(10.12), ios(10.0)); | ||
|
||
typedef NS_ENUM(NSInteger, _WKUserContentExtensionStoreErrorCode) { | ||
_WKUserContentExtensionStoreErrorLookupFailed, | ||
_WKUserContentExtensionStoreErrorVersionMismatch, | ||
_WKUserContentExtensionStoreErrorCompileFailed, | ||
_WKUserContentExtensionStoreErrorRemoveFailed, | ||
} WK_API_AVAILABLE(macos(10.12), ios(10.0)); |
139 changes: 139 additions & 0 deletions
139
Source/WebKit/UIProcess/API/Cocoa/_WKUserContentExtensionStore.mm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
/* | ||
* Copyright (C) 2015 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 "_WKUserContentExtensionStoreInternal.h" | ||
|
||
#import "WKContentRuleListStoreInternal.h" | ||
#import "WKContentRuleListStorePrivate.h" | ||
#import "WKErrorInternal.h" | ||
#import "_WKUserContentExtensionStorePrivate.h" | ||
#import "_WKUserContentFilterInternal.h" | ||
#import "_WKUserContentFilterPrivate.h" | ||
#import <string> | ||
|
||
NSString * const _WKUserContentExtensionsDomain = @"WKErrorDomain"; | ||
|
||
static NSError *toUserContentRuleListStoreError(const NSError *error) | ||
{ | ||
if (!error) | ||
return nil; | ||
|
||
ASSERT(error.domain == WKErrorDomain); | ||
switch (error.code) { | ||
case WKErrorContentRuleListStoreLookUpFailed: | ||
return [NSError errorWithDomain:_WKUserContentExtensionsDomain code:_WKUserContentExtensionStoreErrorLookupFailed userInfo:error.userInfo]; | ||
case WKErrorContentRuleListStoreVersionMismatch: | ||
return [NSError errorWithDomain:_WKUserContentExtensionsDomain code:_WKUserContentExtensionStoreErrorVersionMismatch userInfo:error.userInfo]; | ||
case WKErrorContentRuleListStoreCompileFailed: | ||
return [NSError errorWithDomain:_WKUserContentExtensionsDomain code:_WKUserContentExtensionStoreErrorCompileFailed userInfo:error.userInfo]; | ||
case WKErrorContentRuleListStoreRemoveFailed: | ||
return [NSError errorWithDomain:_WKUserContentExtensionsDomain code:_WKUserContentExtensionStoreErrorRemoveFailed userInfo:error.userInfo]; | ||
default: | ||
RELEASE_ASSERT_NOT_REACHED(); | ||
} | ||
} | ||
|
||
#pragma clang diagnostic push | ||
#pragma clang diagnostic ignored "-Wdeprecated-implementations" | ||
@implementation _WKUserContentExtensionStore | ||
#pragma clang diagnostic pop | ||
|
||
+ (instancetype)defaultStore | ||
{ | ||
return adoptNS([[_WKUserContentExtensionStore alloc] _initWithWKContentRuleListStore:[WKContentRuleListStore defaultStoreWithLegacyFilename]]).autorelease(); | ||
} | ||
|
||
+ (instancetype)storeWithURL:(NSURL *)url | ||
{ | ||
return adoptNS([[_WKUserContentExtensionStore alloc] _initWithWKContentRuleListStore:[WKContentRuleListStore storeWithURLAndLegacyFilename:url]]).autorelease(); | ||
} | ||
|
||
- (void)compileContentExtensionForIdentifier:(NSString *)identifier encodedContentExtension:(NSString *)encodedContentRuleList completionHandler:(void (^)(_WKUserContentFilter *, NSError *))completionHandler | ||
{ | ||
[_contentRuleListStore compileContentRuleListForIdentifier:identifier encodedContentRuleList:encodedContentRuleList completionHandler:^(WKContentRuleList *contentRuleList, NSError *error) { | ||
auto contentFilter = contentRuleList ? adoptNS([[_WKUserContentFilter alloc] _initWithWKContentRuleList:contentRuleList]) : nil; | ||
completionHandler(contentFilter.get(), toUserContentRuleListStoreError(error)); | ||
}]; | ||
} | ||
|
||
- (void)lookupContentExtensionForIdentifier:(NSString *)identifier completionHandler:(void (^)(_WKUserContentFilter *, NSError *))completionHandler | ||
{ | ||
[_contentRuleListStore lookUpContentRuleListForIdentifier:identifier completionHandler:^(WKContentRuleList *contentRuleList, NSError *error) { | ||
auto contentFilter = contentRuleList ? adoptNS([[_WKUserContentFilter alloc] _initWithWKContentRuleList:contentRuleList]) : nil; | ||
completionHandler(contentFilter.get(), toUserContentRuleListStoreError(error)); | ||
}]; | ||
} | ||
|
||
- (void)removeContentExtensionForIdentifier:(NSString *)identifier completionHandler:(void (^)(NSError *))completionHandler | ||
{ | ||
[_contentRuleListStore removeContentRuleListForIdentifier:identifier completionHandler:^(NSError *error) { | ||
completionHandler(toUserContentRuleListStoreError(error)); | ||
}]; | ||
} | ||
|
||
#pragma mark WKObject protocol implementation | ||
|
||
- (API::Object&)_apiObject | ||
{ | ||
return [_contentRuleListStore _apiObject]; | ||
} | ||
|
||
@end | ||
|
||
#pragma clang diagnostic push | ||
#pragma clang diagnostic ignored "-Wdeprecated-implementations" | ||
@implementation _WKUserContentExtensionStore (WKPrivate) | ||
#pragma clang diagnostic pop | ||
|
||
// For testing only. | ||
|
||
- (void)_removeAllContentExtensions | ||
{ | ||
[_contentRuleListStore _removeAllContentRuleLists]; | ||
} | ||
|
||
- (void)_invalidateContentExtensionVersionForIdentifier:(NSString *)identifier | ||
{ | ||
[_contentRuleListStore _invalidateContentRuleListVersionForIdentifier:identifier]; | ||
} | ||
|
||
- (id)_initWithWKContentRuleListStore:(WKContentRuleListStore*)contentRuleListStore | ||
{ | ||
self = [super init]; | ||
if (!self) | ||
return nil; | ||
|
||
_contentRuleListStore = contentRuleListStore; | ||
|
||
return self; | ||
} | ||
|
||
- (WKContentRuleListStore *)_contentRuleListStore | ||
{ | ||
return _contentRuleListStore.get(); | ||
} | ||
|
||
@end |
37 changes: 37 additions & 0 deletions
37
Source/WebKit/UIProcess/API/Cocoa/_WKUserContentExtensionStoreInternal.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright (C) 2015 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 "_WKUserContentExtensionStorePrivate.h" | ||
|
||
#import "APIContentRuleListStore.h" | ||
#import "WKObject.h" | ||
|
||
@class WKContentRuleListStore; | ||
|
||
@interface _WKUserContentExtensionStore () <WKObject> { | ||
@package | ||
RetainPtr<WKContentRuleListStore> _contentRuleListStore; | ||
} | ||
@end |
39 changes: 39 additions & 0 deletions
39
Source/WebKit/UIProcess/API/Cocoa/_WKUserContentExtensionStorePrivate.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright (C) 2015 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/_WKUserContentExtensionStore.h> | ||
|
||
@class WKContentRuleListStore; | ||
|
||
@interface _WKUserContentExtensionStore (WKPrivate) | ||
|
||
// For testing only. | ||
- (void)_removeAllContentExtensions; | ||
- (void)_invalidateContentExtensionVersionForIdentifier:(NSString *)identifier; | ||
|
||
- (id)_initWithWKContentRuleListStore:(WKContentRuleListStore *)contentRuleListStore WK_API_AVAILABLE(macos(10.13), ios(11.0)); | ||
@property (nonatomic, readonly) WKContentRuleListStore *_contentRuleListStore WK_API_AVAILABLE(macos(10.15), ios(13.0)); | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright (C) 2015 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> | ||
|
||
// FIXME: Remove this once rdar://100785999 is unblocked. | ||
WK_CLASS_DEPRECATED_WITH_REPLACEMENT("WKContentRuleList", macos(10.11, WK_MAC_TBA), ios(9.0, WK_IOS_TBA)) | ||
@interface _WKUserContentFilter : NSObject | ||
|
||
@end |
Oops, something went wrong.