[webkit-changes] [WebKit/WebKit] f23885: Compile declarativeNetRequest rules and load them ...

Brian Weinstein noreply at github.com
Mon Nov 27 16:17:31 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: f23885142bfbfa43aa5ccecaffd0b094b3bb7611
      https://github.com/WebKit/WebKit/commit/f23885142bfbfa43aa5ccecaffd0b094b3bb7611
  Author: Brian Weinstein <bweinstein at apple.com>
  Date:   2023-11-27 (Mon, 27 Nov 2023)

  Changed paths:
    M Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm
    M Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionControllerConfigurationCocoa.mm
    M Source/WebKit/UIProcess/Extensions/Cocoa/_WKWebExtensionDeclarativeNetRequestTranslator.mm
    M Source/WebKit/UIProcess/Extensions/WebExtensionContext.h
    M Source/WebKit/UIProcess/Extensions/WebExtensionControllerConfiguration.h
    M Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIDeclarativeNetRequest.mm

  Log Message:
  -----------
  Compile declarativeNetRequest rules and load them into the proper user content controllers
https://bugs.webkit.org/show_bug.cgi?id=265399
<rdar://problem/118845373>

Reviewed by Timothy Hatcher.

* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm:
(WebKit::WebExtensionContext::unload): Remove the compiled rules from all userContentControllers.
(WebKit::WebExtensionContext::setHasAccessInPrivateBrowsing): Add or remove declarativeNetRequest rules from private browsing
user content controllers.
(WebKit::WebExtensionContext::declarativeNetRequestRuleStore): Returns the rule store.
(WebKit::WebExtensionContext::removeDeclarativeNetRequestRules): Removes the compiled rules for this extension from all userContentControllers.
(WebKit::WebExtensionContext::addDeclarativeNetRequestRulesToPrivateUserContentControllers): Adds the compiled rules for this extension to all
private browsing userContentControllers.
(WebKit::WebExtensionContext::compileDeclarativeNetRequestRules): Translate the NSData given to us into rules in the WebKit content blocker format
and compile them. When the compilation finishes, add the compiled content rule lists to the needed userContentControllers.
(WebKit::WebExtensionContext::loadDeclarativeNetRequestRules): Add a bug number to a FIXME.
* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionControllerConfigurationCocoa.mm:
(WebKit::WebExtensionControllerConfiguration::declarativeNetRequestStoreDirectory): Generate the directory to store these content blockers in.
* Source/WebKit/UIProcess/Extensions/Cocoa/_WKWebExtensionDeclarativeNetRequestTranslator.mm:
(+[_WKWebExtensionDeclarativeNetRequestTranslator jsonObjectsFromData:errorStrings:]): Allow fragments when parsing the JSON. This is needed
because the top level object of a DNR rule set is an array. We also make sure we were given an array.
* Source/WebKit/UIProcess/Extensions/WebExtensionContext.h:
* Source/WebKit/UIProcess/Extensions/WebExtensionControllerConfiguration.h:
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIDeclarativeNetRequest.mm:
(TestWebKitAPI::TEST): Add tests that DNR rules are blocking content in both regular and private browsing.

Canonical link: https://commits.webkit.org/271177@main




More information about the webkit-changes mailing list