[webkit-changes] [WebKit/WebKit] 01d2ec: Sidebar extensions should temporarily receive the ...

Ariel Young noreply at github.com
Sat Sep 7 08:16:53 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 01d2ecafac25cb1c2defa2f65cec3a4ce7dac42d
      https://github.com/WebKit/WebKit/commit/01d2ecafac25cb1c2defa2f65cec3a4ce7dac42d
  Author: Ari Young <ari_young at apple.com>
  Date:   2024-09-07 (Sat, 07 Sep 2024)

  Changed paths:
    M Source/WebKit/UIProcess/API/Cocoa/_WKWebExtensionSidebar.h
    M Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPISidebarCocoa.mm
    M Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm
    M Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionSidebarCocoa.mm
    M Source/WebKit/UIProcess/Extensions/WebExtensionContext.h
    M Source/WebKit/UIProcess/Extensions/WebExtensionSidebar.h
    M Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPISidebar.mm

  Log Message:
  -----------
  Sidebar extensions should temporarily receive the activeTab permission when the user interacts with the sidebar.
https://webkit.org/b/279281
rdar://135375961

Reviewed by Timothy Hatcher.

This patch introduces changes to WebExtensionSidebar that allow it to
detect when a user opens the sidebar or interacts with the sidebar's
WKWebView, so that we can grant activeTab to the sidebar's extension
upon such interactions. It also cleans up some existing code in the same
class that was made unnecessary by this change. This patch also
includes a change that will cause WebKit to post notifications to the
browser when the activeTab permission is granted or remove, so that the
browser can immediately update the extension's UI/actionIcon to reflect
the presence or absence of this permission. Finally, this patch also
fixes some sidebar tests and fixes WebExtensionSidebar::icon to reflect
recent changes to WebExtension::bestImageInIconsDictionary.

* Source/WebKit/UIProcess/API/Cocoa/_WKWebExtensionSidebar.h: Amend doc
  comment to more accurately reflect the purpose of willOpenSidebar.
* Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPISidebarCocoa.mm:
(WebKit::WebExtensionContext::openSidebarForTab): Remove userTriggered
parameter, as this method should only be used for programmatic API
opening/closing.
(WebKit::WebExtensionContext::closeSidebarForTab): Remove userTriggered
parameter.
(WebKit::WebExtensionContext::sidebarOpen): Remove userTriggered
parameter from call to openSidebarForTab.
(WebKit::WebExtensionContext::sidebarClose): Remove userTriggered
parameter from call to closeSidebarForTab.
(WebKit::WebExtensionContext::sidebarToggle): Remove userTriggered
parameter from calls to openSidebarForTab and closeSidebarForTab.
* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm:
(WebKit::WebExtensionContext::userGesturePerformed): Call
permissionsDidChange when activeTab is granted to post notification to
browser.
(WebKit::WebExtensionContext::clearUserGesture): Call
permissionsDidChange when activeTab is revoked to post notification to
browser.
* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionSidebarCocoa.mm:
(-[_WKWebExtensionSidebarViewController viewWillAppear]): Call
sidebar->sidebarWillAppear rather than sidebar->willOpenSidebar.
(-[_WKWebExtensionSidebarViewController viewWillDisappear]): Call
sidebar->sidebarWillDisappear rather than sidebar->willCloseSidebar.
(-[_WKWebExtensionSidebarWebView initWithFrame:configuration:webExtensionSidebar:]): Added.
(-[_WKWebExtensionSidebarWebView mouseDown:]): Added -- calls
sidebar->didReceiveUserInteraction when web view receives left mouse
click events.
(-[_WKWebExtensionSidebarWebView rightMouseDown:]): Added -- calls
sidebar->didReceiveUserInteraction when web view receives right mouse
click events.
(-[_WKWebExtensionSidebarWebView otherMouseDown:]): Added -- calls
sidebar->didReceiveUserInteraction when web view receives middle mouse
click events.
(WebKit::WebExtensionSidebar::icon): Update usage of
WebExtension::bestImageInIconsDictionary to reflect new signature.
(WebKit::WebExtensionSidebar::willOpenSidebar): Remove erroneous assert
and log statement, add call to didReceiveUserInteraction.
(WebKit::WebExtensionSidebar::sidebarWillAppear): Added.
(WebKit::WebExtensionSidebar::sidebarWillDisappear): Added.
(WebKit::WebExtensionSidebar::didReceiveUserInteraction): Helper method
to call WebExtensionContext::userGesturePerformed if all necessary
information is present.
(WebKit::WebExtensionSidebar::webView): Instantiate a
_WKWebExtensionSidebarWebView rather than a WKWebView.
* Source/WebKit/UIProcess/Extensions/WebExtensionContext.h: Remove
  userTriggered parameter from declarations of openSidebarForTab and
closeSidebarForTab.
* Source/WebKit/UIProcess/Extensions/WebExtensionSidebar.h: Add
  declarations of sidebarWillAppear, sidebarWillDisappear, and
didReceiveUserInteraction.
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPISidebar.mm:
(TestWebKitAPI::TEST_F(WKWebExtensionAPISidebar, SidePanelAPIGlobalEnablePersists)):
Invert asserts to reflect changed default enablement value.
(TestWebKitAPI::TEST_F(WKWebExtensionAPISidebar, SidePanelAPITabEnablePersists)):
Invert asserts to reflect changed default enablement value.
(TestWebKitAPI::TEST_F(WKWebExtensionAPISidebar, SidePanelModifyGlobalEnable)):
Invert asserts to reflect changed default enablement value.

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



To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications


More information about the webkit-changes mailing list