-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Implement declarativeNetRequest.setExtensionActionOptions #21305
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.setExtensionActionOptions #21305
Conversation
|
EWS run on previous version of this PR (hash 4791e6b) Details
|
...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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this still take the count to zero? What do other browsers do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it should be able to take it to zero - that would clear the badge text.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean, if m_blockedResourceCount is 1, and amount is -2, should it just reset m_blockedResourceCount to 0? Right now it will stay at 1 with the return.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will see what Chrome does.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What you described is what Chrome does. I will make that change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should move this out of the loops, since it is the same for all results.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it? Getting the tab seems to require the context, and what happens if one specific extension doesn't have access to a tab?
If they are the same, then I'm fine moving this out of the loop - how would you recommend getting the tab for one particular extension?
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/xcshareddata/xcschemes/TestWebKitAPI.xcscheme
Outdated
Show resolved
Hide resolved
4791e6b to
5b216e1
Compare
|
EWS run on previous version of this PR (hash 5b216e1) Details |
5b216e1 to
dfb2ff0
Compare
|
EWS run on current version of this PR (hash dfb2ff0) Details
|
https://bugs.webkit.org/show_bug.cgi?id=265829 rdar://118476776 Reviewed by Timothy Hatcher. This API has two use cases: 1) To opt an extension into a behavior where the extension's action shows the number of blocked resources on the current page 2) To manually increment or decrement this badged number It's a bit unfortunate that these two disparate behaviors are combined into one API, but here we are. This PR implements both of them and adds tests for them. * Source/WebKit/UIProcess/Cocoa/NavigationState.mm: (WebKit::NavigationState::NavigationClient::contentRuleListNotification): Call into the WebExtensionController. * Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIDeclarativeNetRequestCocoa.mm: (WebKit::WebExtensionContext::shouldDisplayBlockedResourceCountAsBadgeText): Returns whether or not the blocked resource count should be the badge text. (WebKit::WebExtensionContext::saveShouldDisplayBlockedResourceCountAsBadgeText): Sets whether or not the blocked resource count should be the badge text, and saves to disk. (WebKit::WebExtensionContext::incrementActionCountForTab): Get the action for the tab and increment the blocked resource count. (WebKit::WebExtensionContext::declarativeNetRequestDisplayActionCountAsBadgeText): Call saveShouldDisplayBlockedResourceCountAsBadgeText with the new value, and clear any blocked resource counts if the flag is turned off. (WebKit::WebExtensionContext::declarativeNetRequestIncrementActionCount): Call into incrementActionCountForTab after finding the tab. * Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionActionCocoa.mm: (WebKit::WebExtensionAction::clearCustomizations): Clear the blocked resource count. (WebKit::WebExtensionAction::clearBlockedResourceCount): Ditto. (WebKit::WebExtensionAction::badgeText const): If we have a blocked resource count - use it as the badge text. (WebKit::WebExtensionAction::incrementBlockedResourceCount): Modify the blocked resource count member variable. * Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionControllerCocoa.mm: (WebKit::WebExtensionController::handleContentRuleListNotification): Iterate over all of the actions, find the extension if it exists, and call incrementActionCountForTab. * Source/WebKit/UIProcess/Extensions/WebExtensionAction.h: * Source/WebKit/UIProcess/Extensions/WebExtensionContext.h: * Source/WebKit/UIProcess/Extensions/WebExtensionContext.messages.in: * Source/WebKit/UIProcess/Extensions/WebExtensionController.h: * Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIDeclarativeNetRequestCocoa.mm: (WebKit::WebExtensionAPIDeclarativeNetRequest::setExtensionActionOptions): Perform object validation and call into the UI process based on if flavor (1) or (2) was called. * Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIDeclarativeNetRequest.mm: (TestWebKitAPI::TEST): Canonical link: https://commits.webkit.org/271561@main
dfb2ff0 to
c26e66f
Compare
|
Committed 271561@main (c26e66f): https://commits.webkit.org/271561@main Reviewed commits have been landed. Closing PR #21305 and removing active labels. |
c26e66f
dfb2ff0
🧪 wpe-wk2🧪 api-mac🧪 api-wpe🧪 ios-wk2-wpt🧪 mac-wk1🧪 mac-wk2🧪 gtk-wk2🛠 tv🧪 mac-AS-debug-wk2🧪 api-gtk