Skip to content

Commit

Permalink
Revert [255512@main] Support loading Web Extension URLs and load the …
Browse files Browse the repository at this point in the history
…background page or service worker.

https://bugs.webkit.org/show_bug.cgi?id=246409
rdar://101174536

Reverting commit due to causing bot opensource API test to crash on macOS and iOS queues.

Unreviewed revert.

* Source/WebCore/en.lproj/Localizable.strings:
* Source/WebKit/Shared/WebPageCreationParameters.cpp:
(WebKit::WebPageCreationParameters::encode const):
(WebKit::WebPageCreationParameters::decode):
* Source/WebKit/Shared/WebPageCreationParameters.h:
* Source/WebKit/UIProcess/API/APIPageConfiguration.cpp:
(API::PageConfiguration::copy const):
(API::PageConfiguration::webExtensionController): Deleted.
(API::PageConfiguration::setWebExtensionController): Deleted.
* Source/WebKit/UIProcess/API/APIPageConfiguration.h:
* Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _setupPageConfiguration:]):
(-[WKWebView urlSchemeHandlerForURLScheme:]):
* Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm:
(-[WKWebViewConfiguration encodeWithCoder:]):
(-[WKWebViewConfiguration initWithCoder:]):
(-[WKWebViewConfiguration copyWithZone:]):
(-[WKWebViewConfiguration urlSchemeHandlerForURLScheme:]):
(-[WKWebViewConfiguration _webExtensionController]): Deleted.
(-[WKWebViewConfiguration _setWebExtensionController:]): Deleted.
* Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h:
* Source/WebKit/UIProcess/API/Cocoa/_WKWebExtensionContext.h:
(NS_ERROR_ENUM):
* Source/WebKit/UIProcess/API/Cocoa/_WKWebExtensionContext.mm:
(-[_WKWebExtensionContext setBaseURL:]):
* Source/WebKit/UIProcess/API/Cocoa/_WKWebExtensionController.mm:
(-[_WKWebExtensionController extensionContextForExtension:]):
* Source/WebKit/UIProcess/Cocoa/WebURLSchemeHandlerCocoa.h:
(): Deleted.
* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionCocoa.mm:
(WebKit::WebExtension::manifest):
(WebKit::WebExtension::resourceDataForPath):
(WebKit::WebExtension::createError):
(WebKit::WebExtension::recordError):
(WebKit::WebExtension::errors):
(WebKit::WebExtension::hasInjectedContentForURL):
(WebKit::WebExtension::allRequestedMatchPatterns):
(WebKit::WebExtension::isAccessibleResourcePath): Deleted.
(WebKit::WebExtension::removeError): Deleted.
(WebKit::WebExtension::backgroundContentPath): Deleted.
* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm:
(WebKit::WebExtensionContext::WebExtensionContext):
(WebKit::WebExtensionContext::createError):
(WebKit::WebExtensionContext::load):
(WebKit::WebExtensionContext::unload):
(WebKit::WebExtensionContext::setBaseURL):
(WebKit::WebExtensionContext::postAsyncNotification):
(-[_WKWebExtensionContextDelegate initWithWebExtensionContext:]): Deleted.
(-[_WKWebExtensionContextDelegate webView:decidePolicyForNavigationAction:decisionHandler:]): Deleted.
(-[_WKWebExtensionContextDelegate webView:didFinishNavigation:]): Deleted.
(-[_WKWebExtensionContextDelegate webView:didFailNavigation:withError:]): Deleted.
(-[_WKWebExtensionContextDelegate webViewWebContentProcessDidTerminate:]): Deleted.
(WebKit::toAPI): Deleted.
(WebKit::WebExtensionContext::webViewConfiguration): Deleted.
(WebKit::WebExtensionContext::backgroundContentURL): Deleted.
(WebKit::WebExtensionContext::loadBackgroundWebViewDuringLoad): Deleted.
(WebKit::WebExtensionContext::loadBackgroundWebView): Deleted.
(WebKit::WebExtensionContext::unloadBackgroundWebView): Deleted.
(WebKit::WebExtensionContext::performTasksAfterBackgroundContentLoads): Deleted.
(WebKit::WebExtensionContext::decidePolicyForNavigationAction): Deleted.
(WebKit::WebExtensionContext::didFinishNavigation): Deleted.
(WebKit::WebExtensionContext::didFailNavigation): Deleted.
(WebKit::WebExtensionContext::webViewWebContentProcessDidTerminate): Deleted.
* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionControllerCocoa.mm:
(WebKit::WebExtensionController::load):
(WebKit::WebExtensionController::unload):
(WebKit::WebExtensionController::extensionContext const):
(WebKit::WebExtensionController::addPage): Deleted.
(WebKit::WebExtensionController::removePage): Deleted.
* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionURLSchemeHandlerCocoa.mm: Removed.
* Source/WebKit/UIProcess/Extensions/WebExtension.h:
* Source/WebKit/UIProcess/Extensions/WebExtensionContext.h:
* Source/WebKit/UIProcess/Extensions/WebExtensionController.h:
(WebKit::WebExtensionController::wrapper const): Deleted.
* Source/WebKit/UIProcess/Extensions/WebExtensionURLSchemeHandler.h: Removed.
* Source/WebKit/UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::WebPageProxy):
(WebKit::m_fullscreenVideoTextRecognitionTimer):
(WebKit::WebPageProxy::close):
(WebKit::WebPageProxy::creationParameters):
* Source/WebKit/UIProcess/WebPageProxy.h:
* Source/WebKit/UIProcess/WebURLSchemeHandler.h:
(WebKit::WebURLSchemeHandler::isAPIHandler): Deleted.
* Source/WebKit/WebKit.xcodeproj/project.pbxproj:
* Source/WebKit/WebProcess/WebPage/WebPage.cpp:
* Source/WebKit/WebProcess/WebPage/WebPage.h:
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionController.mm:

Canonical link: https://commits.webkit.org/255535@main
  • Loading branch information
HerculesH committed Oct 14, 2022
1 parent db462f1 commit 8cc2178
Show file tree
Hide file tree
Showing 27 changed files with 54 additions and 866 deletions.
9 changes: 0 additions & 9 deletions Source/WebCore/en.lproj/Localizable.strings
Expand Up @@ -76,12 +76,6 @@
/* The domain and application using the camera and/or microphone. The first argument is domain, the second is the application name (iOS only). */
"%@ in %%@" = "%@ in %%@";

/* Label for an inspectable Web Extension background page */
"%@ — Extension Background Page" = "%@ — Extension Background Page";

/* Label for an inspectable Web Extension service worker */
"%@ — Extension Service Worker" = "%@ — Extension Service Worker";

/* Label to describe the number of files selected in a file upload control that allows multiple files */
"%d files" = "%d files";

Expand Down Expand Up @@ -211,9 +205,6 @@
/* WKWebExtensionErrorUnknown description */
"An unknown error has occurred." = "An unknown error has occurred.";

/* WKWebExtensionContextErrorUnknown description */
"An unknown error has occurred. (WKWebExtensionContext)" = "An unknown error has occurred.";

/* WKErrorUnknown description */
"An unknown error occurred" = "An unknown error occurred";

Expand Down
11 changes: 0 additions & 11 deletions Source/WebKit/Shared/WebPageCreationParameters.cpp
Expand Up @@ -145,9 +145,6 @@ void WebPageCreationParameters::encode(IPC::Encoder& encoder) const
encoder << iceCandidateFilteringEnabled;
encoder << enumeratingAllNetworkInterfacesEnabled;
encoder << userContentControllerParameters;
#if ENABLE(WK_WEB_EXTENSIONS)
encoder << webExtensionControllerParameters;
#endif
encoder << backgroundColor;
encoder << oldPageID;
encoder << overriddenMediaType;
Expand Down Expand Up @@ -487,14 +484,6 @@ std::optional<WebPageCreationParameters> WebPageCreationParameters::decode(IPC::
return std::nullopt;
parameters.userContentControllerParameters = WTFMove(*userContentControllerParameters);

#if ENABLE(WK_WEB_EXTENSIONS)
std::optional<WebExtensionControllerParameters> webExtensionControllerParameters;
decoder >> webExtensionControllerParameters;
if (!webExtensionControllerParameters)
return std::nullopt;
parameters.webExtensionControllerParameters = WTFMove(*webExtensionControllerParameters);
#endif

std::optional<std::optional<WebCore::Color>> backgroundColor;
decoder >> backgroundColor;
if (!backgroundColor)
Expand Down
8 changes: 0 additions & 8 deletions Source/WebKit/Shared/WebPageCreationParameters.h
Expand Up @@ -57,10 +57,6 @@
#include <WebCore/ApplicationManifest.h>
#endif

#if ENABLE(WK_WEB_EXTENSIONS)
#include "WebExtensionControllerParameters.h"
#endif

namespace IPC {
class Decoder;
class Encoder;
Expand Down Expand Up @@ -220,10 +216,6 @@ struct WebPageCreationParameters {

UserContentControllerParameters userContentControllerParameters;

#if ENABLE(WK_WEB_EXTENSIONS)
WebExtensionControllerParameters webExtensionControllerParameters;
#endif

std::optional<WebCore::Color> backgroundColor;

std::optional<WebCore::PageIdentifier> oldPageID;
Expand Down
19 changes: 0 additions & 19 deletions Source/WebKit/UIProcess/API/APIPageConfiguration.cpp
Expand Up @@ -39,10 +39,6 @@
#include "APIApplicationManifest.h"
#endif

#if ENABLE(WK_WEB_EXTENSIONS)
#include "WebExtensionController.h"
#endif

namespace API {
using namespace WebKit;

Expand All @@ -63,9 +59,6 @@ Ref<PageConfiguration> PageConfiguration::copy() const

copy->m_processPool = this->m_processPool;
copy->m_userContentController = this->m_userContentController;
#if ENABLE(WK_WEB_EXTENSIONS)
copy->m_webExtensionController = this->m_webExtensionController;
#endif
copy->m_pageGroup = this->m_pageGroup;
copy->m_preferences = this->m_preferences;
copy->m_relatedPage = this->m_relatedPage;
Expand Down Expand Up @@ -137,18 +130,6 @@ void PageConfiguration::setUserContentController(WebUserContentControllerProxy*
m_userContentController = userContentController;
}

#if ENABLE(WK_WEB_EXTENSIONS)
WebExtensionController* PageConfiguration::webExtensionController()
{
return m_webExtensionController.get();
}

void PageConfiguration::setWebExtensionController(WebExtensionController* webExtensionController)
{
m_webExtensionController = webExtensionController;
}
#endif // ENABLE(WK_WEB_EXTENSIONS)

WebPageGroup* PageConfiguration::pageGroup()
{
return m_pageGroup.get();
Expand Down
12 changes: 0 additions & 12 deletions Source/WebKit/UIProcess/API/APIPageConfiguration.h
Expand Up @@ -49,10 +49,6 @@ class WebURLSchemeHandler;
class WebUserContentControllerProxy;
class WebsiteDataStore;

#if ENABLE(WK_WEB_EXTENSIONS)
class WebExtensionController;
#endif

#if PLATFORM(IOS_FAMILY)
enum class AttributionOverrideTesting : uint8_t {
NoOverride,
Expand Down Expand Up @@ -86,11 +82,6 @@ class PageConfiguration : public ObjectImpl<Object::Type::PageConfiguration> {
WebKit::WebUserContentControllerProxy* userContentController();
void setUserContentController(WebKit::WebUserContentControllerProxy*);

#if ENABLE(WK_WEB_EXTENSIONS)
WebKit::WebExtensionController* webExtensionController();
void setWebExtensionController(WebKit::WebExtensionController*);
#endif

WebKit::WebPageGroup* pageGroup();
void setPageGroup(WebKit::WebPageGroup*);

Expand Down Expand Up @@ -212,9 +203,6 @@ class PageConfiguration : public ObjectImpl<Object::Type::PageConfiguration> {

RefPtr<WebKit::WebProcessPool> m_processPool;
RefPtr<WebKit::WebUserContentControllerProxy> m_userContentController;
#if ENABLE(WK_WEB_EXTENSIONS)
RefPtr<WebKit::WebExtensionController> m_webExtensionController;
#endif
RefPtr<WebKit::WebPageGroup> m_pageGroup;
RefPtr<WebKit::WebPreferences> m_preferences;
RefPtr<WebKit::WebPageProxy> m_relatedPage;
Expand Down
14 changes: 6 additions & 8 deletions Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm
Expand Up @@ -161,10 +161,6 @@
#import "WKDataDetectorTypesInternal.h"
#endif

#if ENABLE(WK_WEB_EXTENSIONS)
#import "_WKWebExtensionControllerInternal.h"
#endif

#if PLATFORM(IOS_FAMILY)
#import "RemoteLayerTreeDrawingAreaProxy.h"
#import "RemoteScrollingCoordinatorProxy.h"
Expand Down Expand Up @@ -460,10 +456,6 @@ - (void)_setupPageConfiguration:(Ref<API::PageConfiguration>&)pageConfiguration
pageConfiguration->setWebsiteDataStore([_configuration websiteDataStore]->_websiteDataStore.get());
pageConfiguration->setDefaultWebsitePolicies([_configuration defaultWebpagePreferences]->_websitePolicies.get());

#if ENABLE(WK_WEB_EXTENSIONS)
pageConfiguration->setWebExtensionController([_configuration _webExtensionController]->_webExtensionController.get());
#endif

#if PLATFORM(MAC)
if (auto pageGroup = WebKit::toImpl([_configuration _pageGroup]))
pageConfiguration->setPageGroup(pageGroup);
Expand Down Expand Up @@ -1720,6 +1712,12 @@ - (WKPageRef)_pageForTesting
return _page.get();
}

- (id <WKURLSchemeHandler>)urlSchemeHandlerForURLScheme:(NSString *)urlScheme
{
auto* handler = static_cast<WebKit::WebURLSchemeHandlerCocoa*>(_page->urlSchemeHandlerForScheme(urlScheme));
return handler ? handler->apiHandler() : nil;
}

- (std::optional<BOOL>)_resolutionForShareSheetImmediateCompletionForTesting
{
return _resolutionForShareSheetImmediateCompletionForTesting;
Expand Down
38 changes: 1 addition & 37 deletions Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm
Expand Up @@ -120,9 +120,6 @@ @implementation WKWebViewConfiguration {
LazyInitialized<RetainPtr<WKProcessPool>> _processPool;
LazyInitialized<RetainPtr<WKPreferences>> _preferences;
LazyInitialized<RetainPtr<WKUserContentController>> _userContentController;
#if ENABLE(WK_WEB_EXTENSIONS)
LazyInitialized<RetainPtr<_WKWebExtensionController>> _webExtensionController;
#endif
LazyInitialized<RetainPtr<_WKVisitedLinkStore>> _visitedLinkStore;
LazyInitialized<RetainPtr<WKWebsiteDataStore>> _websiteDataStore;
LazyInitialized<RetainPtr<WKWebpagePreferences>> _defaultWebpagePreferences;
Expand Down Expand Up @@ -300,11 +297,6 @@ - (void)encodeWithCoder:(NSCoder *)coder
[coder encodeObject:self.userContentController forKey:@"userContentController"];
[coder encodeObject:self.websiteDataStore forKey:@"websiteDataStore"];

#if ENABLE(WK_WEB_EXTENSIONS)
if (auto *controller = _webExtensionController.peek())
[coder encodeObject:controller forKey:@"webExtensionController"];
#endif

[coder encodeBool:self.suppressesIncrementalRendering forKey:@"suppressesIncrementalRendering"];

if (_applicationNameForUserAgent)
Expand Down Expand Up @@ -344,11 +336,6 @@ - (instancetype)initWithCoder:(NSCoder *)coder
self.userContentController = [coder decodeObjectOfClass:[WKUserContentController class] forKey:@"userContentController"];
self.websiteDataStore = [coder decodeObjectOfClass:[WKWebsiteDataStore class] forKey:@"websiteDataStore"];

#if ENABLE(WK_WEB_EXTENSIONS)
if ([coder containsValueForKey:@"webExtensionController"])
self._webExtensionController = [coder decodeObjectOfClass:[_WKWebExtensionController class] forKey:@"webExtensionController"];
#endif

self.suppressesIncrementalRendering = [coder decodeBoolForKey:@"suppressesIncrementalRendering"];

if ([coder containsValueForKey:@"applicationNameForUserAgent"])
Expand Down Expand Up @@ -401,10 +388,6 @@ - (id)copyWithZone:(NSZone *)zone
configuration._contentProviderRegistry = self._contentProviderRegistry;
#endif

#if ENABLE(WK_WEB_EXTENSIONS)
configuration._webExtensionController = self._webExtensionController;
#endif

configuration->_suppressesIncrementalRendering = self->_suppressesIncrementalRendering;
configuration->_applicationNameForUserAgent = self->_applicationNameForUserAgent;

Expand Down Expand Up @@ -508,22 +491,6 @@ - (void)setUserContentController:(WKUserContentController *)userContentControlle
_userContentController.set(userContentController);
}

- (_WKWebExtensionController *)_webExtensionController
{
#if ENABLE(WK_WEB_EXTENSIONS)
return _webExtensionController.get([] { return adoptNS([[_WKWebExtensionController alloc] init]); });
#else
return nullptr;
#endif
}

- (void)_setWebExtensionController:(_WKWebExtensionController *)webExtensionController
{
#if ENABLE(WK_WEB_EXTENSIONS)
_webExtensionController.set(webExtensionController);
#endif
}

- (BOOL)upgradeKnownHostsToHTTPS
{
return _pageConfiguration->httpsUpgradeEnabled();
Expand Down Expand Up @@ -612,10 +579,7 @@ - (void)setURLSchemeHandler:(id <WKURLSchemeHandler>)urlSchemeHandler forURLSche
return nil;

auto handler = _pageConfiguration->urlSchemeHandlerForURLScheme(*canonicalScheme);
if (!handler || !handler->isAPIHandler())
return nil;

return static_cast<WebKit::WebURLSchemeHandlerCocoa*>(handler.get())->apiHandler();
return handler ? static_cast<WebKit::WebURLSchemeHandlerCocoa*>(handler.get())->apiHandler() : nil;
}

#if PLATFORM(IOS_FAMILY)
Expand Down
Expand Up @@ -51,7 +51,6 @@ typedef NS_ENUM(NSUInteger, _WKContentSecurityPolicyModeForExtension) {
@class WKWebView;
@class _WKApplicationManifest;
@class _WKVisitedLinkStore;
@class _WKWebExtensionController;

@interface WKWebViewConfiguration (WKPrivate)

Expand All @@ -60,8 +59,6 @@ typedef NS_ENUM(NSUInteger, _WKContentSecurityPolicyModeForExtension) {

@property (nonatomic, strong, setter=_setVisitedLinkStore:) _WKVisitedLinkStore *_visitedLinkStore;

@property (nonatomic, strong, setter=_setWebExtensionController:) _WKWebExtensionController *_webExtensionController;

@property (nonatomic, weak, setter=_setAlternateWebViewForNavigationGestures:) WKWebView *_alternateWebViewForNavigationGestures;

@property (nonatomic, setter=_setRespectsImageOrientation:) BOOL _respectsImageOrientation WK_API_AVAILABLE(macos(10.12), ios(10.0));
Expand Down
1 change: 0 additions & 1 deletion Source/WebKit/UIProcess/API/Cocoa/_WKWebExtensionContext.h
Expand Up @@ -42,7 +42,6 @@ typedef NS_ERROR_ENUM(_WKWebExtensionContextErrorDomain, _WKWebExtensionContextE
_WKWebExtensionContextErrorUnknown = 1,
_WKWebExtensionContextErrorAlreadyLoaded,
_WKWebExtensionContextErrorNotLoaded,
_WKWebExtensionContextErrorBaseURLTaken,
} NS_SWIFT_NAME(_WKWebExtensionContext.Error) WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));

typedef NS_ENUM(NSInteger, _WKWebExtensionContextPermissionState) {
Expand Down
5 changes: 0 additions & 5 deletions Source/WebKit/UIProcess/API/Cocoa/_WKWebExtensionContext.mm
Expand Up @@ -31,15 +31,13 @@
#import "_WKWebExtensionContextInternal.h"

#import "CocoaHelpers.h"
#import "WKWebView.h"
#import "WebExtension.h"
#import "WebExtensionContext.h"
#import "_WKWebExtensionControllerInternal.h"
#import "_WKWebExtensionInternal.h"
#import "_WKWebExtensionMatchPatternInternal.h"
#import "_WKWebExtensionTab.h"
#import <WebCore/WebCoreObjCExtras.h>
#import <wtf/URLParser.h>

NSErrorDomain const _WKWebExtensionContextErrorDomain = @"_WKWebExtensionContextErrorDomain";

Expand Down Expand Up @@ -110,9 +108,6 @@ - (NSURL *)baseURL
- (void)setBaseURL:(NSURL *)baseURL
{
NSParameterAssert(baseURL);
NSAssert1(WTF::URLParser::maybeCanonicalizeScheme(String(baseURL.scheme)), @"Invalid parameter: '%@' is not a valid URL scheme", baseURL.scheme);
NSAssert1(![WKWebView handlesURLScheme:baseURL.scheme], @"Invalid parameter: '%@' is a URL scheme that WKWebView handles natively and cannot be used for extensions", baseURL.scheme);
NSAssert(!baseURL.path.length || [baseURL.path isEqualToString:@"/"], @"Invalid parameter: a URL with a path cannot be used");

_webExtensionContext->setBaseURL(baseURL);
}
Expand Down
Expand Up @@ -95,7 +95,7 @@ - (BOOL)unloadExtensionContext:(_WKWebExtensionContext *)extensionContext error:
- (_WKWebExtensionContext *)extensionContextForExtension:(_WKWebExtension *)extension
{
if (auto extensionContext = _webExtensionController->extensionContext(extension._webExtension))
return extensionContext->wrapper();
return extensionContext.value()->wrapper();
return nil;
}

Expand Down
2 changes: 0 additions & 2 deletions Source/WebKit/UIProcess/Cocoa/WebURLSchemeHandlerCocoa.h
Expand Up @@ -40,8 +40,6 @@ class WebURLSchemeHandlerCocoa : public WebURLSchemeHandler {

id <WKURLSchemeHandler> apiHandler() const { return m_apiHandler.get(); }

bool isAPIHandler() final { return true; }

private:
WebURLSchemeHandlerCocoa(id <WKURLSchemeHandler>);

Expand Down

0 comments on commit 8cc2178

Please sign in to comment.