Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: dc8ef58782b8f08276f8731a52ebbdb54d08ac9d
https://github.com/WebKit/WebKit/commit/dc8ef58782b8f08276f8731a52ebbdb54d08ac9d
Author: Brian Weinstein <[email protected]>
Date: 2023-12-01 (Fri, 01 Dec 2023)
Changed paths:
A
Source/WebKit/Shared/Extensions/WebExtensionDeclarativeNetRequestConstants.h
M
Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIDeclarativeNetRequestCocoa.mm
M Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionCocoa.mm
M Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm
M Source/WebKit/UIProcess/Extensions/WebExtension.h
M Source/WebKit/UIProcess/Extensions/WebExtensionContext.h
M Source/WebKit/UIProcess/Extensions/WebExtensionContext.messages.in
M Source/WebKit/WebKit.xcodeproj/project.pbxproj
M
Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIDeclarativeNetRequestCocoa.mm
M
Source/WebKit/WebProcess/Extensions/API/WebExtensionAPIDeclarativeNetRequest.h
M
Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIDeclarativeNetRequest.mm
Log Message:
-----------
Implement declarativeNetRequest.updateEnabledRulesets
https://bugs.webkit.org/show_bug.cgi?id=265616
rdar://118940027
Reviewed by Timothy Hatcher.
When an extension calls updateEnabledRulesets - the following happens:
1) We validate the arguments in the WebProcess to make sure they are of the
correct format
2) We call into the UI process to perform the work
3) The UI process makes sure all of the passed identifiers exist, and if they
do, we attempt to perform the update
To do this, we modify the enabled state of the given rulesets, and attempt to
load the declarativeNetRequest rules again.
If this succeeds, we write the updated state to disk. If it fails, we revert
the changes that were made (and will continue to use
the old DNR rules).
This patch also adds tests for getEnabledRulesets and updateEnabledRulesets.
* Source/WebKit/Shared/Extensions/WebExtensionDeclarativeNetRequestConstants.h:
Copied from
Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIDeclarativeNetRequestCocoa.mm.
*
Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIDeclarativeNetRequestCocoa.mm:
(WebKit::WebExtensionContext::loadDeclarativeNetRequestRulesetStateFromStorage):
Read the modified state of rulesets from State.plist
and apply it.
(WebKit::WebExtensionContext::saveDeclarativeNetRequestRulesetStateToStorage):
Merge the given dictionary with the existing one and
save it to disk.
(WebKit::WebExtensionContext::declarativeNetRequestValidateRulesetIdentifiers):
Make sure all of the ruleset identifiers exist and throw
an error if any don't.
(WebKit::WebExtensionContext::declarativeNetRequestEnabledRulesetCount): Get
the count of enabled rulesets.
(WebKit::WebExtensionContext::declarativeNetRequestToggleRulesets): Set the
state of the given rulesets.
(WebKit::WebExtensionContext::declarativeNetRequestUpdateEnabledRulesets):
Perform the logic described in steps 3+ earlier in the commit message.
* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionCocoa.mm:
(WebKit::WebExtension::populateDeclarativeNetRequestPropertiesIfNeeded): Adopt
a few constants.
(WebKit::WebExtension::declarativeNetRequestRulesets): These ruleset objects
can be changed, so don't return const.
* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm:
(WebKit::WebExtensionContext::load): Call
loadDeclarativeNetRequestRulesetStateFromStorage at startup. We don't want to
call this each time that the
loadDeclarativeNetRequestRules is called, because we might be attempting to
update the enabled rulesets and in that case we don't want to consult storage
yet.
(WebKit::WebExtensionContext::queueStartupAndInstallEventsForExtensionIfNecessary):
Clear any customized rulesets upon update.
(WebKit::WebExtensionContext::compileDeclarativeNetRequestRules): Add a
completion handler.
(WebKit::WebExtensionContext::loadDeclarativeNetRequestRules): Ditto.
* Source/WebKit/UIProcess/Extensions/WebExtension.h:
* Source/WebKit/UIProcess/Extensions/WebExtensionContext.h:
* Source/WebKit/UIProcess/Extensions/WebExtensionContext.messages.in:
* Source/WebKit/WebKit.xcodeproj/project.pbxproj:
*
Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIDeclarativeNetRequestCocoa.mm:
(WebKit::WebExtensionAPIDeclarativeNetRequest::updateEnabledRulesets): Perform
argument validation.
*
Source/WebKit/WebProcess/Extensions/API/WebExtensionAPIDeclarativeNetRequest.h:
(WebKit::WebExtensionAPIDeclarativeNetRequest::maxNumberOfStaticRulesets
const): Use a constant.
(WebKit::WebExtensionAPIDeclarativeNetRequest::maxNumberOfEnabledRulesets
const): Ditto.
(WebKit::WebExtensionAPIDeclarativeNetRequest::maxNumberOfDynamicAndSessionRules
const): Ditto.
Canonical link: https://commits.webkit.org/271410@main
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes