Branch: refs/heads/main Home: https://github.com/WebKit/WebKit Commit: f3d8deeacd7258224aacd25276f66e9d1d8e242a https://github.com/WebKit/WebKit/commit/f3d8deeacd7258224aacd25276f66e9d1d8e242a Author: Brian Weinstein <bweinst...@apple.com> Date: 2023-11-16 (Thu, 16 Nov 2023)
Changed paths: M Source/WebKit/Platform/cocoa/CocoaHelpers.h M Source/WebKit/Platform/cocoa/CocoaHelpers.mm A Source/WebKit/UIProcess/Extensions/Cocoa/_WKWebExtensionDeclarativeNetRequestRule.h A Source/WebKit/UIProcess/Extensions/Cocoa/_WKWebExtensionDeclarativeNetRequestRule.mm A Source/WebKit/UIProcess/Extensions/Cocoa/_WKWebExtensionDeclarativeNetRequestTranslator.h A Source/WebKit/UIProcess/Extensions/Cocoa/_WKWebExtensionDeclarativeNetRequestTranslator.mm M Source/WebKit/WebKit.xcodeproj/project.pbxproj Log Message: ----------- Add logic to convert declarativeNetRequest rules to WebKit content blocker rules https://bugs.webkit.org/show_bug.cgi?id=264982 rdar://118528800 Reviewed by Timothy Hatcher. This PR also gets rid of all of the `__kindof`s in the CocoaHelpers template functions. It is causing compile errors on older OSes. * Source/WebKit/UIProcess/Extensions/Cocoa/_WKWebExtensionDeclarativeNetRequestRule.h: Added. * Source/WebKit/UIProcess/Extensions/Cocoa/_WKWebExtensionDeclarativeNetRequestRule.mm: Added. (-[_WKWebExtensionDeclarativeNetRequestRule _validateHeaderInfoDictionary:]): Validates the header info dictionary. (isHeaderNameValid): Checks the name of the header against a list of known headers. (isArrayOfDomainsValid): Makes sure there are domains and they can all be converted to ASCII. (isArrayOfExcludedDomainsValid): Makes sure all domains can be converted to ASCII. (-[_WKWebExtensionDeclarativeNetRequestRule removeInvalidResourceTypesForKey:]): Remove any resource types WebKit can't handle. (-[_WKWebExtensionDeclarativeNetRequestRule ruleInWebKitFormat]): Convert the rule to WebKit format. (-[_WKWebExtensionDeclarativeNetRequestRule _convertedRulesForWebKitActionType:chromeActionType:]): Convert action type from Chrome to WebKit format. (-[_WKWebExtensionDeclarativeNetRequestRule _webKitRuleWithWebKitActionType:chromeActionType:chromeResourceTypes:]): Create a content blocking rule with the given parameters. (-[_WKWebExtensionDeclarativeNetRequestRule _chromeResourceTypeToWebKitLoadContext]): Convert a resource type to a load context. (-[_WKWebExtensionDeclarativeNetRequestRule _chromeDomainTypeToWebKitDomainType]): Convert a Chrome domain type to a WebKit domain type. (-[_WKWebExtensionDeclarativeNetRequestRule _chromeResourceTypeToWebKitResourceType]): Convert resource types. (-[_WKWebExtensionDeclarativeNetRequestRule _resourcesToTargetWhenNoneAreSpecifiedInRule]): (-[_WKWebExtensionDeclarativeNetRequestRule _allChromeResourceTypes]): (-[_WKWebExtensionDeclarativeNetRequestRule _convertedResourceTypesForChromeResourceTypes:]): (-[_WKWebExtensionDeclarativeNetRequestRule _regexURLFilterForChromeURLFilter:]): (-[_WKWebExtensionDeclarativeNetRequestRule compare:]): Compare two rules. (priorityForRuleType): (-[_WKWebExtensionDeclarativeNetRequestRule description]): Print out information about the rule. * Source/WebKit/UIProcess/Extensions/Cocoa/_WKWebExtensionDeclarativeNetRequestTranslator.h: Added. * Source/WebKit/UIProcess/Extensions/Cocoa/_WKWebExtensionDeclarativeNetRequestTranslator.mm: Added. (+[_WKWebExtensionDeclarativeNetRequestTranslator translateRules:errorStrings:]): Translate the rules. (+[_WKWebExtensionDeclarativeNetRequestTranslator jsonObjectsFromData:errorStrings:]): Perform JSON parsing. (+[_WKWebExtensionDeclarativeNetRequestTranslator jsonStringForJSONObject:]): Ditto. * Source/WebKit/WebKit.xcodeproj/project.pbxproj: Add the new files. Canonical link: https://commits.webkit.org/270861@main _______________________________________________ webkit-changes mailing list webkit-changes@lists.webkit.org https://lists.webkit.org/mailman/listinfo/webkit-changes