[webkit-changes] [WebKit/WebKit] a4a639: Add support for nativeMessaging with NSExtension m...

Timothy Hatcher noreply at github.com
Tue Sep 10 17:08:24 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: a4a63949921ef119388c9e154b743ad928ebf47f
      https://github.com/WebKit/WebKit/commit/a4a63949921ef119388c9e154b743ad928ebf47f
  Author: Timothy Hatcher <timothy at apple.com>
  Date:   2024-09-10 (Tue, 10 Sep 2024)

  Changed paths:
    M Source/WTF/wtf/CallbackAggregator.h
    M Source/WTF/wtf/WeakObjCPtr.h
    M Source/WebKit/Platform/spi/Cocoa/FoundationSPI.h
    M Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIRuntimeCocoa.mm
    M Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionActionCocoa.mm
    M Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionMessagePortCocoa.mm
    M Source/WebKit/UIProcess/Extensions/WebExtension.h
    M Source/WebKit/UIProcess/Extensions/WebExtensionContext.h
    M Source/WebKit/UIProcess/Extensions/WebExtensionMessagePort.h

  Log Message:
  -----------
  Add support for nativeMessaging with NSExtension messages.
https://webkit.org/b/262081
rdar://problem/116022628

Reviewed by Brian Weinstein.

If the app does not implement WKWebExtensionControllerDelegate methods for native messages, fall back to
sending them directly via NSExtension to align with Safari’s behavior.

Manual testing performed with various extensions like 1Password and Userscripts. API tests were not added due
to challenges with testing bundle loading and NSExtension.

* Source/WTF/wtf/CallbackAggregator.h:
(WTF::EagerCallbackAggregator): Use ThreadSafeRefCounted so it can be used in threaded code, like NSExtension blocks.
* Source/WTF/wtf/WeakObjCPtr.h: Added template to allow making a WeakObjCPtr without a type like RetainPtr.
* Source/WebKit/Platform/spi/Cocoa/FoundationSPI.h: Added NSExtension.
* Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIRuntimeCocoa.mm:
(WebKit::WebExtensionContext::sendNativeMessage): Added. Added NSExtension fallback.
(WebKit::WebExtensionContext::runtimeSendNativeMessage): Refactored into sendNativeMessage().
(WebKit::WebExtensionContext::runtimeConnectNative): Fallback to using sendNativeMessage.
* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionActionCocoa.mm:
(WebKit::WebExtensionAction::closePopup): Drive-by ASSERT fix I was hitting with Userscripts.
* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionMessagePortCocoa.mm:
(WebKit::WebExtensionMessagePort::remove): Protect this since removeNativePort() might drop the last reference.
(WebKit::WebExtensionMessagePort::sendMessage): Made completionHandler optional.
* Source/WebKit/UIProcess/Extensions/WebExtension.h:
(WebKit::WebExtension::bundle const): Added.
* Source/WebKit/UIProcess/Extensions/WebExtensionContext.h:
* Source/WebKit/UIProcess/Extensions/WebExtensionMessagePort.h:

Canonical link: https://commits.webkit.org/283446@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