[webkit-changes] [WebKit/WebKit] 9aac1c: Add Web Extension support for loading images and p...

Timothy Hatcher noreply at github.com
Fri Oct 7 11:56:08 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 9aac1c9848c4cecd92016e689a4bb7af115b2abd
      https://github.com/WebKit/WebKit/commit/9aac1c9848c4cecd92016e689a4bb7af115b2abd
  Author: Timothy Hatcher <timothy at apple.com>
  Date:   2022-10-07 (Fri, 07 Oct 2022)

  Changed paths:
    M Source/WTF/wtf/PlatformUse.h
    M Source/WTF/wtf/spi/cocoa/SecuritySPI.h
    M Source/WebCore/PAL/pal/spi/mac/NSImageSPI.h
    M Source/WebCore/en.lproj/Localizable.strings
    M Source/WebCore/platform/LocalizedStrings.h
    A Source/WebKit/Platform/spi/Cocoa/CoreSVGSPI.h
    A Source/WebKit/Platform/spi/Cocoa/FoundationSPI.h
    M Source/WebKit/Platform/spi/ios/UIKitSPI.h
    M Source/WebKit/UIProcess/API/Cocoa/_WKWebExtension.h
    M Source/WebKit/UIProcess/API/Cocoa/_WKWebExtension.mm
    M Source/WebKit/UIProcess/API/Cocoa/_WKWebExtensionPrivate.h
    M Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionCocoa.mm
    M Source/WebKit/UIProcess/Extensions/WebExtension.h
    M Source/WebKit/WebKit.xcodeproj/project.pbxproj
    M Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtension.mm

  Log Message:
  -----------
  Add Web Extension support for loading images and parsing `icons`, `action`, `browser_action`, and `page_action`.
https://bugs.webkit.org/show_bug.cgi?id=246168

Reviewed by Brian Weinstein.

Added support for loading and validating resources from the extension. This is now used for loading the
manifest.json file and also icons. The icons are generated using the platform's image class. On macOS
the 1x and 2x sizes are retrieved and put into a single NSImage. On iOS the largest scale factor is used
based on the main UIScreen scale. SVG images are also supported via some SPIs.

This loading mechanism is now also used for the special "_generated_background_page.html" path. It will also
be used to load content scripts and stylesheets for injected content.

* Source/WTF/wtf/PlatformUse.h: Added USE_NSIMAGE_FOR_SVG_SUPPORT define.
* Source/WTF/wtf/spi/cocoa/SecuritySPI.h: Added SecCodeValidateFileResource.
* Source/WebCore/PAL/pal/spi/mac/NSImageSPI.h: Added _NSSVGImageRep class.
* Source/WebCore/en.lproj/Localizable.strings: Updated with update-webkit-localizable-strings.
* Source/WebCore/platform/LocalizedStrings.h: Exported formatLocalizedString to use in WebKit.
* Source/WebKit/Platform/spi/Cocoa/CoreSVGSPI.h: Added.
* Source/WebKit/Platform/spi/Cocoa/FoundationSPI.h: Added.
* Source/WebKit/Platform/spi/ios/UIKitSPI.h: Added _imageWithCGSVGDocument: method to UIImage.
* Source/WebKit/UIProcess/API/Cocoa/_WKWebExtension.h:
Simplify the exposed enum values for _WKWebExtensionError to reduce API surface and stay nimble.
* Source/WebKit/UIProcess/API/Cocoa/_WKWebExtension.mm:
(-[_WKWebExtension _initWithManifestDictionary:]):
(-[_WKWebExtension _initWithManifestDictionary:resources:]): Added.
(-[_WKWebExtension _initWithResources:]): Renamed from _initWithManifestData:.
(-[_WKWebExtension displayActionLabel]): Added.
(-[_WKWebExtension iconForSize:]): Added.
(-[_WKWebExtension actionIconForSize:]): Added.
* Source/WebKit/UIProcess/API/Cocoa/_WKWebExtensionPrivate.h:
* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionCocoa.mm:
(WebKit::WebExtension::WebExtension):
(WebKit::WebExtension::manifest):
(WebKit::WebExtension::bundleStaticCode): Added.
(WebKit::WebExtension::validateResourceData): Added.
(WebKit::WebExtension::resourceFileURLForPath): Added.
(WebKit::WebExtension::resourceDataForPath): Added.
(WebKit::WebExtension::createError): Tweaked strings and API enum values used.
(WebKit::WebExtension::errors): Call populateActionPropertiesIfNeeded.
(WebKit::WebExtension::icon): Added.
(WebKit::WebExtension::actionIcon): Added.
(WebKit::WebExtension::displayActionLabel): Added.
(WebKit::WebExtension::actionPopupPath): Added.
(WebKit::WebExtension::populateActionPropertiesIfNeeded): Added.
(WebKit::WebExtension::imageForPath): Added.
(WebKit::WebExtension::pathForBestImageInIconsDictionary): Added.
(WebKit::WebExtension::bestImageInIconsDictionary): Added.
(WebKit::WebExtension::bestImageForIconsDictionaryManifestKey): Added.
* Source/WebKit/UIProcess/Extensions/WebExtension.h:
* Source/WebKit/WebKit.xcodeproj/project.pbxproj:
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtension.mm:
 Added ActionParsing test and tweaks error enum names.

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




More information about the webkit-changes mailing list