Skip to content

Commit

Permalink
Address Web Extensions API review feedback.
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=249271

Reviewed by Brian Weinstein.

* Source/WebKit/UIProcess/API/Cocoa/_WKWebExtension.h:
* Source/WebKit/UIProcess/API/Cocoa/_WKWebExtension.mm:
(-[_WKWebExtension supportsManifestVersion:]):
(-[_WKWebExtension usesManifestVersion:]): Deleted.
* Source/WebKit/UIProcess/API/Cocoa/_WKWebExtensionContext.h:
(NS_ERROR_ENUM):
* Source/WebKit/UIProcess/API/Cocoa/_WKWebExtensionContext.mm:
(+[_WKWebExtensionContext contextForExtension:]):
(-[_WKWebExtensionContext initForExtension:]):
(toAPI):
(toImpl):
(-[_WKWebExtensionContext permissionStatusForPermission:]):
(-[_WKWebExtensionContext permissionStatusForPermission:inTab:]):
(-[_WKWebExtensionContext setPermissionStatus:forPermission:]):
(-[_WKWebExtensionContext setPermissionStatus:forPermission:expirationDate:]):
(-[_WKWebExtensionContext permissionStatusForURL:]):
(-[_WKWebExtensionContext permissionStatusForURL:inTab:]):
(-[_WKWebExtensionContext setPermissionStatus:forURL:]):
(-[_WKWebExtensionContext setPermissionStatus:forURL:expirationDate:]):
(-[_WKWebExtensionContext permissionStatusForMatchPattern:]):
(-[_WKWebExtensionContext permissionStatusForMatchPattern:inTab:]):
(-[_WKWebExtensionContext setPermissionStatus:forMatchPattern:]):
(-[_WKWebExtensionContext setPermissionStatus:forMatchPattern:expirationDate:]):
(+[_WKWebExtensionContext contextWithExtension:]): Deleted.
(-[_WKWebExtensionContext initWithExtension:]): Deleted.
(-[_WKWebExtensionContext permissionStateForPermission:]): Deleted.
(-[_WKWebExtensionContext permissionStateForPermission:inTab:]): Deleted.
(-[_WKWebExtensionContext setPermissionState:forPermission:]): Deleted.
(-[_WKWebExtensionContext setPermissionState:forPermission:expirationDate:]): Deleted.
(-[_WKWebExtensionContext permissionStateForURL:]): Deleted.
(-[_WKWebExtensionContext permissionStateForURL:inTab:]): Deleted.
(-[_WKWebExtensionContext setPermissionState:forURL:]): Deleted.
(-[_WKWebExtensionContext setPermissionState:forURL:expirationDate:]): Deleted.
(-[_WKWebExtensionContext permissionStateForMatchPattern:]): Deleted.
(-[_WKWebExtensionContext permissionStateForMatchPattern:inTab:]): Deleted.
(-[_WKWebExtensionContext setPermissionState:forMatchPattern:]): Deleted.
(-[_WKWebExtensionContext setPermissionState:forMatchPattern:expirationDate:]): Deleted.
* Source/WebKit/UIProcess/API/Cocoa/_WKWebExtensionControllerConfiguration.h:
* Source/WebKit/UIProcess/API/Cocoa/_WKWebExtensionMatchPattern.h:
* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionCocoa.mm:
(WebKit::WebExtension::createError):
(WebKit::WebExtension::errors):
(WebKit::WebExtension::actionIcon):
(WebKit::WebExtension::populateActionPropertiesIfNeeded):
(WebKit::WebExtension::populateBackgroundPropertiesIfNeeded):
(WebKit::WebExtension::populatePermissionsPropertiesIfNeeded):
* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm:
(WebKit::toAPI):
(WebKit::WebExtensionContext::createError):
* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionControllerCocoa.mm:
(WebKit::WebExtensionController::load):
* Source/WebKit/UIProcess/Extensions/WebExtension.h:
(WebKit::WebExtension::supportsManifestVersion):
(WebKit::WebExtension::usesManifestVersion): Deleted.
* Source/WebKit/UIProcess/Extensions/WebExtensionContext.h:
* Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIExtensionCocoa.mm:
(WebKit::WebExtensionAPIExtension::isPropertyAllowed):
* Source/WebKit/WebProcess/Extensions/WebExtensionContextProxy.h:
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtension.mm:
(TestWebKitAPI::TEST):
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIExtension.mm:
(TestWebKitAPI::TEST):
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIRuntime.mm:
(TestWebKitAPI::TEST):
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionContext.mm:
(TestWebKitAPI::TEST):
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionController.mm:
(TestWebKitAPI::TEST):
* Tools/TestWebKitAPI/cocoa/WebExtensionUtilities.h:
* Tools/TestWebKitAPI/cocoa/WebExtensionUtilities.mm:
(-[TestWebExtensionManager initForExtension:]):
(TestWebKitAPI::Util::loadAndRunExtension):
(-[TestWebExtensionManager initWithExtension:]): Deleted.

Canonical link: https://commits.webkit.org/257824@main
  • Loading branch information
xeenon committed Dec 14, 2022
1 parent 46e6b3f commit ea93ede
Show file tree
Hide file tree
Showing 20 changed files with 359 additions and 371 deletions.
40 changes: 11 additions & 29 deletions Source/WebKit/UIProcess/API/Cocoa/_WKWebExtension.h
Expand Up @@ -27,8 +27,8 @@

#import <Foundation/Foundation.h>

#import <WebKit/_WKWebExtensionPermission.h>
#import <WebKit/_WKWebExtensionMatchPattern.h>
#import <WebKit/_WKWebExtensionPermission.h>

#if TARGET_OS_IPHONE
@class UIImage;
Expand All @@ -39,7 +39,7 @@
NS_ASSUME_NONNULL_BEGIN

/*! @abstract Indicates a @link WKWebExtension @/link error. */
WK_EXTERN NSErrorDomain const _WKWebExtensionErrorDomain WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
WK_EXTERN NSErrorDomain const _WKWebExtensionErrorDomain NS_SWIFT_NAME(_WKWebExtension.ErrorDomain) WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));

/*!
@abstract Constants used by NSError to indicate errors in the @link WKWebExtension @/link domain.
Expand Down Expand Up @@ -115,9 +115,9 @@ WK_CLASS_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA))

/*!
@abstract The active errors for the extension.
@discussion This property returns an array of NSError objects if there are any errors, or `nil` if there are no errors.
@discussion This property returns an array of NSError objects if there are any errors, or an empty array if there are no errors.
*/
@property (nonatomic, nullable, readonly, copy) NSArray<NSError *> *errors;
@property (nonatomic, readonly, copy) NSArray<NSError *> *errors;

/*! @abstract The parsed manifest as a dictionary. */
@property (nonatomic, readonly, copy) NSDictionary<NSString *, id> *manifest;
Expand All @@ -133,10 +133,10 @@ WK_CLASS_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA))
@param manifestVersion The version number to check.
@result Returns `YES` if the extension specified a manifest version that is greater than or equal to `manifestVersion`.
*/
- (BOOL)usesManifestVersion:(double)manifestVersion;
- (BOOL)supportsManifestVersion:(double)manifestVersion;

/*! @abstract The default locale for the extension. Returns `nil` if there was no default locale specified. */
@property (nonatomic, readonly, copy) NSLocale *defaultLocale;
@property (nonatomic, nullable, readonly, copy) NSLocale *defaultLocale;

/*! @abstract The localized extension name. Returns `nil` if there was no name specified. */
@property (nonatomic, nullable, readonly, copy) NSString *displayName;
Expand All @@ -156,8 +156,6 @@ WK_CLASS_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA))
/*! @abstract The extension version. Returns `nil` if there was no version specified. */
@property (nonatomic, nullable, readonly, copy) NSString *version;

#if TARGET_OS_IPHONE

/*!
@abstract Returns the extension's icon image for the specified size.
@param size The size to use when looking up the icon.
Expand All @@ -166,29 +164,11 @@ WK_CLASS_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA))
match for the specified size that is available in the extension's icon set. If no matching icon can be found, the method will return `nil`.
@seealso actionIconForSize:
*/
#if TARGET_OS_IPHONE
- (nullable UIImage *)iconForSize:(CGSize)size;

/*!
@abstract Returns the action icon for the specified size.
@param size The size to use when looking up the action icon.
@result The action icon, or `nil` if the icon was unable to be loaded.
@discussion This icon should represent the extension in action sheets or toolbars. The returned image will be the best match for the specified
size that is available in the extension's action icon set. If no matching icon is available, the method will fall back to the extension's icon.
@seealso iconForSize:
*/
- (nullable UIImage *)actionIconForSize:(CGSize)size;

#else

/*!
@abstract Returns the extension's icon image for the specified size.
@param size The size to use when looking up the icon.
@result The extension's icon image, or `nil` if the icon was unable to be loaded.
@discussion This icon should represent the extension in settings or other areas that show the extension. The returned image will be the best
match for the specified size that is available in the extension's icon set. If no matching icon can be found, the method will return `nil`.
@seealso actionIconForSize:
*/
- (nullable NSImage *)iconForSize:(CGSize)size;
#endif

/*!
@abstract Returns the action icon for the specified size.
Expand All @@ -198,8 +178,10 @@ WK_CLASS_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA))
size that is available in the extension's action icon set. If no matching icon is available, the method will fall back to the extension's icon.
@seealso iconForSize:
*/
#if TARGET_OS_IPHONE
- (nullable UIImage *)actionIconForSize:(CGSize)size;
#else
- (nullable NSImage *)actionIconForSize:(CGSize)size;

#endif

/*! @abstract The set of permissions that the extension requires for its base functionality. */
Expand Down
6 changes: 3 additions & 3 deletions Source/WebKit/UIProcess/API/Cocoa/_WKWebExtension.mm
Expand Up @@ -159,9 +159,9 @@ - (double)manifestVersion
return _webExtension->manifestVersion();
}

- (BOOL)usesManifestVersion:(double)version
- (BOOL)supportsManifestVersion:(double)version
{
return _webExtension->usesManifestVersion(version);
return _webExtension->supportsManifestVersion(version);
}

- (NSLocale *)defaultLocale
Expand Down Expand Up @@ -321,7 +321,7 @@ - (double)manifestVersion
return 0;
}

- (BOOL)usesManifestVersion:(double)version
- (BOOL)supportsManifestVersion:(double)version
{
return NO;
}
Expand Down

0 comments on commit ea93ede

Please sign in to comment.