Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add logic to convert declarativeNetRequest rules to WebKit content bl…
…ocker 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
- Loading branch information