-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement declarativeNetRequest dynamic and session rules APIs #21462
Merged
webkit-commit-queue
merged 1 commit into
WebKit:main
from
b-weinstein:eng/Implement-declarativeNetRequest-dynamic-and-session-rules-APIs
Dec 8, 2023
Merged
Implement declarativeNetRequest dynamic and session rules APIs #21462
webkit-commit-queue
merged 1 commit into
WebKit:main
from
b-weinstein:eng/Implement-declarativeNetRequest-dynamic-and-session-rules-APIs
Dec 8, 2023
Conversation
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
Contributor
EWS run on previous version of this PR (hash d1bc0e4) |
xeenon
approved these changes
Dec 7, 2023
...ce/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIDeclarativeNetRequestCocoa.mm
Outdated
Show resolved
Hide resolved
...ce/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIDeclarativeNetRequestCocoa.mm
Outdated
Show resolved
Hide resolved
...ce/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIDeclarativeNetRequestCocoa.mm
Outdated
Show resolved
Hide resolved
Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIDeclarativeNetRequestCocoa.mm
Outdated
Show resolved
Hide resolved
Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIDeclarativeNetRequestCocoa.mm
Outdated
Show resolved
Hide resolved
Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIDeclarativeNetRequest.mm
Outdated
Show resolved
Hide resolved
...ce/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIDeclarativeNetRequestCocoa.mm
Outdated
Show resolved
Hide resolved
d1bc0e4
to
730fd74
Compare
EWS run on previous version of this PR (hash 730fd74) |
730fd74
to
b4bd2c0
Compare
EWS run on current version of this PR (hash b4bd2c0)
|
b4bd2c0
to
8242b66
Compare
https://bugs.webkit.org/show_bug.cgi?id=266016 rdar://118476702&118476774 Reviewed by Timothy Hatcher. This patch implements: - declarativeNetRequest.getSessionRules() - declarativeNetRequest.updateSessionRules() - declarativeNetRequest.getDynamicRules() - declarativeNetRequest.updateDynamicRules() The big difference between these two APIs is that dynamic rules are persisted to disk and will be loaded across quitting and relaunching the browser. Session rules will go away. Also, while we are here, fix a typo in an error message and update the localizable strings. * Source/WebKit/Shared/Extensions/_WKWebExtensionSQLiteStore.h: * Source/WebKit/Shared/Extensions/_WKWebExtensionSQLiteStore.mm: (-[_WKWebExtensionSQLiteStore _savepointNameFromUUID:]): Generate a savepoint name based on the UUID. (-[_WKWebExtensionSQLiteStore createSavepointWithCompletionHandler:]): Create a savepoint in the database. (-[_WKWebExtensionSQLiteStore commitSavepoint:completionHandler:]): Commit the savepoint to the database. (-[_WKWebExtensionSQLiteStore rollbackToSavepoint:completionHandler:]): Rollback the database to a given savepoint. * Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIDeclarativeNetRequestCocoa.mm: (WebKit::WebExtensionContext::declarativeNetRequestDynamicRulesStore): Create and return a _WKWebExtensionDeclarativeNetRequestSQLiteStore for the dynamic rules. This will only use the in memory database if storage isn't persistent for the extension context. (WebKit::WebExtensionContext::declarativeNetRequestSessionRulesStore): Create and return a _WKWebExtensionDeclarativeNetRequestSQLiteStore for the session rules. This will always use the in memory database. (WebKit::WebExtensionContext::updateDeclarativeNetRequestRulesInStorage): Attempt to perform the given updates to the rules in the database. The flow is: - Create a savepoint - Update the rules by removing and adding rules. - If this fails, perform a rollback - If this succeeds, attempt to load the new rules - If this fails, perform a rollback, and attempt to load the old rules - If this succeeds, commit the savepoint (WebKit::WebExtensionContext::declarativeNetRequestGetDynamicRules): Get the rules from the dynamic rules store. (WebKit::WebExtensionContext::declarativeNetRequestUpdateDynamicRules): Call into updateDeclarativeNetRequestRulesInStorage. (WebKit::WebExtensionContext::declarativeNetRequestGetSessionRules): Get the rules from the session rules store. (WebKit::WebExtensionContext::declarativeNetRequestUpdateSessionRules): Call into updateDeclarativeNetRequestRulesInStorage. * Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm: (WebKit::WebExtensionContext::loadDeclarativeNetRequestRules): Chain together loading rules from the various sources, the order is: - Session rules - Dynamic rules - Static rules * Source/WebKit/UIProcess/Extensions/WebExtensionContext.h: * Source/WebKit/UIProcess/Extensions/WebExtensionContext.messages.in: * Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIDeclarativeNetRequestCocoa.mm: (WebKit::WebExtensionAPIDeclarativeNetRequest::updateDynamicRules): Call into the UI process after performing argument validation. (WebKit::WebExtensionAPIDeclarativeNetRequest::getDynamicRules): Call into the UI process. (WebKit::WebExtensionAPIDeclarativeNetRequest::updateSessionRules): Call into the UI process after performing argument validation. (WebKit::WebExtensionAPIDeclarativeNetRequest::getSessionRules): Call into the UI process. * Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIDeclarativeNetRequest.mm: (TestWebKitAPI::TEST): Add tests for updating dynamic and session rules and verifying that they block content. Canonical link: https://commits.webkit.org/271706@main
8242b66
to
14bd8a4
Compare
Committed 271706@main (14bd8a4): https://commits.webkit.org/271706@main Reviewed commits have been landed. Closing PR #21462 and removing active labels. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
14bd8a4
b4bd2c0
🛠 wincairo🧪 wpe-wk2🧪 api-mac🧪 ios-wk2-wpt🧪 mac-wk2🧪 gtk-wk2🛠 tv🧪 mac-AS-debug-wk2🧪 api-gtk🛠 watch🛠 watch-sim