Diff
Modified: trunk/Source/WebKit/ChangeLog (269067 => 269068)
--- trunk/Source/WebKit/ChangeLog 2020-10-27 20:22:10 UTC (rev 269067)
+++ trunk/Source/WebKit/ChangeLog 2020-10-27 20:54:03 UTC (rev 269068)
@@ -1,3 +1,98 @@
+2020-10-27 Brian Burg <[email protected]>
+
+ [Cocoa] Introduce _WKInspectorConfiguration for customizing local and remote Web Inspectors
+ https://bugs.webkit.org/show_bug.cgi?id=217896
+ <rdar://problem/70355910>
+
+ Reviewed by Devin Rousso.
+
+ Introduce _WKInspectorConfiguration for customizing the behavior of Web Inspector instances.
+ The initial customization is to allow for custom WKURLSchemeHandlers to be used by Web Inspector's
+ WebView to load resources from client-controlled locations. This can be used to implement loading
+ of extension resources using a custom scheme such as web-extension://.
+
+ Scheme handlers need to be registered at WebView creation time via WKWebViewConfiguration. In
+ order to configure a inspector page summoned from within WebKit (i.e., Inspect Element context menu item),
+ we need to add a method to the UI delegate to get a configuration when the page is being created.
+
+ This configuration object is used in two different SPI (local and remote cases):
+
+ - As part of WKUIDelegatePrivate, to retrieve a _WKInspectorConfiguration given a _WKInspector.
+ - As an argument to the _WKRemoteWebInspectorViewController initializer. It's used later as needed.
+
+ New API test: WKInspectorDelegate.InspectorConfiguration.
+
+ * SourcesCocoa.txt:
+ * WebKit.xcodeproj/project.pbxproj:
+ Add new files.
+
+ * UIProcess/API/APIInspectorConfiguration.h: Added.
+ * UIProcess/API/APIInspectorConfiguration.cpp: Added.
+ * UIProcess/API/Cocoa/_WKInspectorConfiguration.h: Added.
+ * UIProcess/API/Cocoa/_WKInspectorConfigurationInternal.h: Added.
+ * UIProcess/API/Cocoa/_WKInspectorConfiguration.mm: Added.
+ (-[_WKInspectorConfiguration init]):
+ (-[_WKInspectorConfiguration dealloc]):
+ (-[_WKInspectorConfiguration _apiObject]):
+ (-[_WKInspectorConfiguration setURLSchemeHandler:forURLScheme:]):
+ (-[_WKInspectorConfiguration applyToWebViewConfiguration:]):
+ (-[_WKInspectorConfiguration copyWithZone:]):
+ Create _WKInspectorConfiguration and add a method to register WKURLSchemeHandlers.
+
+ * Shared/API/APIObject.h:
+ * Shared/Cocoa/APIObject.mm:
+ (API::Object::newObject):
+ Add new API object types. Add missing InspectorExtension.
+
+ * UIProcess/API/Cocoa/WKUIDelegatePrivate.h:
+ * UIProcess/API/APIUIClient.h:
+ (API::UIClient::configurationForLocalInspector):
+ * UIProcess/Cocoa/UIDelegate.h:
+ * UIProcess/Cocoa/UIDelegate.mm:
+ (WebKit::UIDelegate::setDelegate):
+ (WebKit::UIDelegate::UIClient::configurationForLocalInspector):
+ Add new client/delegate method to fetch an inspector configuration as needed.
+
+ * UIProcess/API/Cocoa/_WKRemoteWebInspectorViewController.h:
+ * UIProcess/API/Cocoa/_WKRemoteWebInspectorViewControllerPrivate.h:
+ * UIProcess/API/Cocoa/_WKRemoteWebInspectorViewController.mm:
+ (-[_WKRemoteWebInspectorViewController initWithConfiguration:]): Renamed from -init.
+ (-[_WKRemoteWebInspectorViewController init]): Deleted.
+ (-[_WKRemoteWebInspectorViewController loadForDebuggableType:backendCommandsURL:]):
+ (-[_WKRemoteWebInspectorViewController configurationForDebuggable:]):
+ (-[_WKRemoteWebInspectorViewController _setDiagnosticLoggingDelegate:]):
+ Store a _WKInspectorConfiguration and provide it when asked by RemoteWebInspectorProxy.
+
+ * UIProcess/Inspector/RemoteWebInspectorProxy.h:
+ * UIProcess/Inspector/RemoteWebInspectorProxy.cpp:
+ (WebKit::RemoteWebInspectorProxy::load):
+ Store m_debuggableInfo before creating the page and window. It's used from inside
+ platformCreateFrontendPageAndWindow to pass as an argument to the delegate method.
+
+ * UIProcess/Inspector/mac/RemoteWebInspectorProxyMac.mm:
+ (WebKit::RemoteWebInspectorProxy::platformCreateFrontendPageAndWindow):
+ * UIProcess/Inspector/mac/WebInspectorProxyMac.mm:
+ (WebKit::WebInspectorProxy::platformCreateFrontendPage):
+ Obtain a configuration and use it to initialize the WKInspectorViewController.
+
+ * UIProcess/Inspector/mac/WKInspectorViewController.h:
+ * UIProcess/Inspector/mac/WKInspectorViewController.mm:
+ (-[WKInspectorViewController initWithConfiguration:inspectedPage:]):
+ (-[WKInspectorViewController webView]):
+ (-[WKInspectorViewController webViewConfiguration]): Renamed from -configuration.
+ (-[WKInspectorViewController initWithInspectedPage:]): Deleted.
+ (-[WKInspectorViewController configuration]): Deleted.
+ Apply the URL scheme handlers registered in the _WKInspectorConfiguration to the
+ WKWebViewConfiguration.
+
+ * UIProcess/Inspector/glib/RemoteInspectorClient.cpp:
+ * UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
+ Stub out RemoteWebInspectorProxyClient::configurationForRemoteInspector().
+
+ * UIProcess/API/Cocoa/_WKUserStyleSheet.h:
+ * UIProcess/API/Cocoa/_WKUserStyleSheet.mm:
+ Fix build problems caused by repartitioning of unified sources.
+
2020-10-27 Said Abou-Hallawa <[email protected]>
[GPU Process]: Implement DisplayList::DrawImageBuffer item
Modified: trunk/Source/WebKit/Shared/API/APIObject.h (269067 => 269068)
--- trunk/Source/WebKit/Shared/API/APIObject.h 2020-10-27 20:22:10 UTC (rev 269067)
+++ trunk/Source/WebKit/Shared/API/APIObject.h 2020-10-27 20:54:03 UTC (rev 269068)
@@ -136,6 +136,7 @@
GrammarDetail,
IconDatabase,
Inspector,
+ InspectorConfiguration,
KeyValueStorageManager,
MediaCacheManager,
MessageListener,
@@ -380,6 +381,7 @@
API::Object::Type::GrammarDetail,
API::Object::Type::IconDatabase,
API::Object::Type::Inspector,
+ API::Object::Type::InspectorConfiguration,
API::Object::Type::KeyValueStorageManager,
API::Object::Type::MediaCacheManager,
API::Object::Type::MessageListener,
Modified: trunk/Source/WebKit/Shared/Cocoa/APIObject.mm (269067 => 269068)
--- trunk/Source/WebKit/Shared/Cocoa/APIObject.mm 2020-10-27 20:22:10 UTC (rev 269067)
+++ trunk/Source/WebKit/Shared/Cocoa/APIObject.mm 2020-10-27 20:54:03 UTC (rev 269068)
@@ -79,6 +79,7 @@
#import "_WKFrameTreeNodeInternal.h"
#import "_WKGeolocationPositionInternal.h"
#import "_WKHitTestResultInternal.h"
+#import "_WKInspectorConfigurationInternal.h"
#import "_WKInspectorDebuggableInfoInternal.h"
#import "_WKInspectorInternal.h"
#import "_WKInternalDebugFeatureInternal.h"
@@ -264,7 +265,11 @@
case Type::Inspector:
wrapper = [_WKInspector alloc];
break;
-
+
+ case Type::InspectorConfiguration:
+ wrapper = [_WKInspectorConfiguration alloc];
+ break;
+
case Type::Navigation:
wrapper = [WKNavigation alloc];
break;
Modified: trunk/Source/WebKit/Sources.txt (269067 => 269068)
--- trunk/Source/WebKit/Sources.txt 2020-10-27 20:22:10 UTC (rev 269067)
+++ trunk/Source/WebKit/Sources.txt 2020-10-27 20:54:03 UTC (rev 269068)
@@ -343,6 +343,7 @@
UIProcess/API/APIFrameTreeNode.cpp
UIProcess/API/APIHTTPCookieStore.cpp
UIProcess/API/APIHitTestResult.cpp
+UIProcess/API/APIInspectorConfiguration.cpp
UIProcess/API/APIInternalDebugFeature.cpp
UIProcess/API/APINavigation.cpp
UIProcess/API/APINavigationData.cpp
Modified: trunk/Source/WebKit/SourcesCocoa.txt (269067 => 269068)
--- trunk/Source/WebKit/SourcesCocoa.txt 2020-10-27 20:22:10 UTC (rev 269067)
+++ trunk/Source/WebKit/SourcesCocoa.txt 2020-10-27 20:54:03 UTC (rev 269068)
@@ -256,6 +256,7 @@
UIProcess/API/Cocoa/_WKFrameTreeNode.mm
UIProcess/API/Cocoa/_WKGeolocationPosition.mm
UIProcess/API/Cocoa/_WKInspector.mm
+UIProcess/API/Cocoa/_WKInspectorConfiguration.mm
UIProcess/API/Cocoa/_WKInspectorTesting.mm
UIProcess/API/Cocoa/_WKInspectorDebuggableInfo.mm
UIProcess/API/Cocoa/_WKInspectorWindow.mm
Copied: trunk/Source/WebKit/UIProcess/API/APIInspectorConfiguration.cpp (from rev 269067, trunk/Source/WebKit/UIProcess/API/Cocoa/_WKRemoteWebInspectorViewControllerPrivate.h) (0 => 269068)
--- trunk/Source/WebKit/UIProcess/API/APIInspectorConfiguration.cpp (rev 0)
+++ trunk/Source/WebKit/UIProcess/API/APIInspectorConfiguration.cpp 2020-10-27 20:54:03 UTC (rev 269068)
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2020 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "APIInspectorConfiguration.h"
+
+#include "WebURLSchemeHandler.h"
+
+namespace API {
+
+Ref<InspectorConfiguration> InspectorConfiguration::create()
+{
+ return adoptRef(*new InspectorConfiguration);
+}
+
+void InspectorConfiguration::addURLSchemeHandler(Ref<WebKit::WebURLSchemeHandler>&& urlSchemeHandler, const WTF::String& urlScheme)
+{
+ m_customURLSchemes.append(std::make_pair(WTFMove(urlSchemeHandler), urlScheme));
+}
+
+} // namespace API
+
Copied: trunk/Source/WebKit/UIProcess/API/APIInspectorConfiguration.h (from rev 269067, trunk/Source/WebKit/UIProcess/API/Cocoa/_WKRemoteWebInspectorViewControllerPrivate.h) (0 => 269068)
--- trunk/Source/WebKit/UIProcess/API/APIInspectorConfiguration.h (rev 0)
+++ trunk/Source/WebKit/UIProcess/API/APIInspectorConfiguration.h 2020-10-27 20:54:03 UTC (rev 269068)
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2020 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include "APIObject.h"
+#include <wtf/RefPtr.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebKit {
+class WebURLSchemeHandler;
+}
+
+namespace API {
+
+using URLSchemeHandlerPair = std::pair<Ref<WebKit::WebURLSchemeHandler>, WTF::String>;
+
+class InspectorConfiguration final : public API::ObjectImpl<Object::Type::InspectorConfiguration> {
+public:
+ static Ref<InspectorConfiguration> create();
+
+ void addURLSchemeHandler(Ref<WebKit::WebURLSchemeHandler>&&, const WTF::String& urlScheme);
+ const Vector<URLSchemeHandlerPair>& urlSchemeHandlers() { return m_customURLSchemes; }
+
+private:
+ Vector<URLSchemeHandlerPair> m_customURLSchemes;
+};
+
+} // namespace API
Modified: trunk/Source/WebKit/UIProcess/API/APIUIClient.h (269067 => 269068)
--- trunk/Source/WebKit/UIProcess/API/APIUIClient.h 2020-10-27 20:22:10 UTC (rev 269067)
+++ trunk/Source/WebKit/UIProcess/API/APIUIClient.h 2020-10-27 20:54:03 UTC (rev 269068)
@@ -25,6 +25,7 @@
#pragma once
+#include "APIInspectorConfiguration.h"
#include "WKPage.h"
#include "WebEvent.h"
#include "WebHitTestResultData.h"
@@ -196,6 +197,11 @@
virtual void didAttachLocalInspector(WebKit::WebPageProxy&, WebKit::WebInspectorProxy&) { }
virtual void willCloseLocalInspector(WebKit::WebPageProxy&, WebKit::WebInspectorProxy&) { }
+ virtual Ref<API::InspectorConfiguration> configurationForLocalInspector(WebKit::WebPageProxy&, WebKit::WebInspectorProxy&)
+ {
+ return API::InspectorConfiguration::create();
+ }
+
};
} // namespace API
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKUIDelegatePrivate.h (269067 => 269068)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKUIDelegatePrivate.h 2020-10-27 20:22:10 UTC (rev 269067)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKUIDelegatePrivate.h 2020-10-27 20:54:03 UTC (rev 269068)
@@ -38,6 +38,9 @@
@class _WKActivatedElementInfo;
@class _WKElementAction;
@class _WKFrameHandle;
+@class _WKInspector;
+@class _WKInspectorConfiguration;
+@class _WKInspectorDebuggableInfo;
#if TARGET_OS_IOS
@@ -247,6 +250,12 @@
- (void)_webView:(WKWebView *)webView getContextMenuFromProposedMenu:(NSMenu *)menu forElement:(_WKContextMenuElementInfo *)element userInfo:(id <NSSecureCoding>)userInfo completionHandler:(void (^)(NSMenu *))completionHandler WK_API_AVAILABLE(macos(10.14));
- (void)_webView:(WKWebView *)webView didPerformDragOperation:(BOOL)handled WK_API_AVAILABLE(macos(10.14.4));
+/*! @abstract Called when the _WKInspector for this WKWebView is about to be displayed. The client can
+ provide a custom _WKInspectorConfiguration that should be used when creating the Web Inspector.
+ @param inspector The Web Inspector instance that is about to be initialized.
+ */
+- (_WKInspectorConfiguration *)_webView:(WKWebView *)webView configurationForLocalInspector:(_WKInspector *)inspector WK_API_AVAILABLE(macos(WK_MAC_TBA));
+
/*! @abstract Called when a Web Inspector instance is attached to this WKWebView. This is not called in the case of remote inspection.
@param webView The WKWebView instance being inspected.
@param inspector The Web Inspector instance attached to this WKWebView.
Copied: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKInspectorConfiguration.h (from rev 269067, trunk/Source/WebKit/UIProcess/API/Cocoa/_WKRemoteWebInspectorViewControllerPrivate.h) (0 => 269068)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKInspectorConfiguration.h (rev 0)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKInspectorConfiguration.h 2020-10-27 20:54:03 UTC (rev 269068)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2020 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import <Foundation/Foundation.h>
+#import <WebKit/WKFoundation.h>
+
+NS_ASSUME_NONNULL_BEGIN
+
+@protocol WKURLSchemeHandler;
+
+WK_CLASS_AVAILABLE(macos(WK_MAC_TBA))
+@interface _WKInspectorConfiguration : NSObject <NSCopying>
+/**
+ * @abstract Sets the URL scheme handler object for the given URL scheme.
+ * @param urlSchemeHandler The object to register.
+ * @param scheme The URL scheme the object will handle.
+ * @discussion This is used to register additional schemes for loading resources in the inspector page,
+ * such as to register schemes used by extensions. This method has the same behavior and restrictions as
+ * described in the documentation of -[WKWebView setURLSchemeHnadler:forURLScheme:].
+ */
+- (void)setURLSchemeHandler:(id <WKURLSchemeHandler>)urlSchemeHandler forURLScheme:(NSString *)urlScheme;
+@end
+
+NS_ASSUME_NONNULL_END
Added: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKInspectorConfiguration.mm (0 => 269068)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKInspectorConfiguration.mm (rev 0)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKInspectorConfiguration.mm 2020-10-27 20:54:03 UTC (rev 269068)
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2020 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "_WKInspectorConfigurationInternal.h"
+
+#import "WebURLSchemeHandlerCocoa.h"
+
+@implementation _WKInspectorConfiguration
+
+- (instancetype)init
+{
+ if (!(self = [super init]))
+ return nil;
+
+ API::Object::constructInWrapper<API::InspectorConfiguration>(self);
+
+ return self;
+}
+
+- (void)dealloc
+{
+ _configuration->API::InspectorConfiguration::~InspectorConfiguration();
+ [super dealloc];
+}
+
+- (API::Object&)_apiObject
+{
+ return *_configuration;
+}
+
+- (void)setURLSchemeHandler:(id <WKURLSchemeHandler>)urlSchemeHandler forURLScheme:(NSString *)urlScheme
+{
+ _configuration->addURLSchemeHandler(WebKit::WebURLSchemeHandlerCocoa::create(urlSchemeHandler), urlScheme);
+}
+
+- (void)applyToWebViewConfiguration:(WKWebViewConfiguration *)configuration
+{
+ for (auto pair : _configuration->urlSchemeHandlers()) {
+ auto& handler = static_cast<WebKit::WebURLSchemeHandlerCocoa&>(pair.first.get());
+ [configuration setURLSchemeHandler:handler.apiHandler() forURLScheme:pair.second];
+ }
+}
+
+- (id)copyWithZone:(NSZone *)zone
+{
+ _WKInspectorConfiguration *configuration = [(_WKInspectorConfiguration *)[[self class] allocWithZone:zone] init];
+
+ for (auto pair : _configuration->urlSchemeHandlers()) {
+ auto& handler = static_cast<WebKit::WebURLSchemeHandlerCocoa&>(pair.first.get());
+ [configuration setURLSchemeHandler:handler.apiHandler() forURLScheme:pair.second];
+ }
+
+ return configuration;
+}
+
+@end
Copied: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKInspectorConfigurationInternal.h (from rev 269067, trunk/Source/WebKit/UIProcess/API/Cocoa/_WKRemoteWebInspectorViewControllerPrivate.h) (0 => 269068)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKInspectorConfigurationInternal.h (rev 0)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKInspectorConfigurationInternal.h 2020-10-27 20:54:03 UTC (rev 269068)
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2020 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "_WKInspectorConfiguration.h"
+
+#import "APIInspectorConfiguration.h"
+#import "WKObject.h"
+
+namespace WebKit {
+
+template<> struct WrapperTraits<API::InspectorConfiguration> {
+ using WrapperClass = _WKInspectorConfiguration;
+};
+
+} // namespace WebKit
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface _WKInspectorConfiguration () <WKObject> {
+@package
+ API::ObjectStorage<API::InspectorConfiguration> _configuration;
+}
+
+- (void)applyToWebViewConfiguration:(WKWebViewConfiguration *)webViewConfiguration;
+
+@end
+
+NS_ASSUME_NONNULL_END
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKRemoteWebInspectorViewController.h (269067 => 269068)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKRemoteWebInspectorViewController.h 2020-10-27 20:22:10 UTC (rev 269067)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKRemoteWebInspectorViewController.h 2020-10-27 20:54:03 UTC (rev 269068)
@@ -28,6 +28,7 @@
#if !TARGET_OS_IPHONE
@class WKWebView;
+@class _WKInspectorConfiguration;
@protocol _WKRemoteWebInspectorViewControllerDelegate;
@@ -49,7 +50,9 @@
@property (nonatomic, readonly, retain) NSWindow *window;
@property (nonatomic, readonly, retain) WKWebView *webView;
+@property (nonatomic, readonly, copy) _WKInspectorConfiguration *configuration;
+- (instancetype)initWithConfiguration:(_WKInspectorConfiguration *)configuration;
- (void)loadForDebuggableType:(WKRemoteWebInspectorDebuggableType)debuggableType backendCommandsURL:(NSURL *)backendCommandsURL;
- (void)close;
- (void)show;
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKRemoteWebInspectorViewController.mm (269067 => 269068)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKRemoteWebInspectorViewController.mm 2020-10-27 20:22:10 UTC (rev 269067)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKRemoteWebInspectorViewController.mm 2020-10-27 20:54:03 UTC (rev 269068)
@@ -24,16 +24,20 @@
*/
#import "config.h"
-#import "_WKRemoteWebInspectorViewController.h"
+#import "_WKRemoteWebInspectorViewControllerPrivate.h"
#if PLATFORM(MAC)
#import "APIDebuggableInfo.h"
+#import "APIInspectorConfiguration.h"
#import "DebuggableInfoData.h"
#import "RemoteWebInspectorProxy.h"
#import "WKWebViewInternal.h"
+#import "_WKInspectorConfigurationInternal.h"
#import "_WKInspectorDebuggableInfoInternal.h"
+NS_ASSUME_NONNULL_BEGIN
+
@interface _WKRemoteWebInspectorViewController ()
- (void)sendMessageToBackend:(NSString *)message;
- (void)closeFromFrontend;
@@ -62,6 +66,11 @@
{
[m_controller closeFromFrontend];
}
+
+ Ref<API::InspectorConfiguration> configurationForRemoteInspector(RemoteWebInspectorProxy& inspector) override
+ {
+ return static_cast<API::InspectorConfiguration&>([m_controller.configuration _apiObject]);
+ }
private:
_WKRemoteWebInspectorViewController *m_controller;
@@ -72,13 +81,16 @@
@implementation _WKRemoteWebInspectorViewController {
RefPtr<WebKit::RemoteWebInspectorProxy> m_remoteInspectorProxy;
std::unique_ptr<WebKit::_WKRemoteWebInspectorProxyClient> m_remoteInspectorClient;
+ _WKInspectorConfiguration *_configuration;
}
-- (instancetype)init
+- (instancetype)initWithConfiguration:(_WKInspectorConfiguration *)configuration
{
if (!(self = [super init]))
return nil;
+ _configuration = [configuration copy];
+
m_remoteInspectorProxy = WebKit::RemoteWebInspectorProxy::create();
m_remoteInspectorClient = makeUnique<WebKit::_WKRemoteWebInspectorProxyClient>(self);
m_remoteInspectorProxy->setClient(m_remoteInspectorClient.get());
@@ -124,7 +136,7 @@
debuggableInfo.targetPlatformName = @"macOS";
debuggableInfo.targetBuildVersion = @"Unknown";
debuggableInfo.targetProductVersion = @"Unknown";
- debuggableInfo.targetIsSimulator = false;
+ debuggableInfo.targetIsSimulator = NO;
[self loadForDebuggable:debuggableInfo backendCommandsURL:backendCommandsURL];
}
@@ -148,6 +160,8 @@
m_remoteInspectorProxy->sendMessageToFrontend(message);
}
+// MARK: RemoteWebInspectorProxyClient methods
+
- (void)sendMessageToBackend:(NSString *)message
{
if (_delegate && [_delegate respondsToSelector:@selector(inspectorViewController:sendMessageToBackend:)])
@@ -162,7 +176,7 @@
// MARK: _WKRemoteWebInspectorViewControllerPrivate methods
-- (void)_setDiagnosticLoggingDelegate:(id<_WKDiagnosticLoggingDelegate>)delegate
+- (void)_setDiagnosticLoggingDelegate:(id<_WKDiagnosticLoggingDelegate> _Nullable)delegate
{
self.webView._diagnosticLoggingDelegate = delegate;
m_remoteInspectorProxy->setDiagnosticLoggingAvailable(!!delegate);
@@ -170,4 +184,6 @@
@end
+NS_ASSUME_NONNULL_END
+
#endif // PLATFORM(MAC)
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKRemoteWebInspectorViewControllerPrivate.h (269067 => 269068)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKRemoteWebInspectorViewControllerPrivate.h 2020-10-27 20:22:10 UTC (rev 269067)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKRemoteWebInspectorViewControllerPrivate.h 2020-10-27 20:54:03 UTC (rev 269068)
@@ -30,6 +30,7 @@
NS_ASSUME_NONNULL_BEGIN
@class _WKInspectorDebuggableInfo;
+@protocol _WKDiagnosticLoggingDelegate;
@interface _WKRemoteWebInspectorViewController (WKPrivate)
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKUserStyleSheet.h (269067 => 269068)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKUserStyleSheet.h 2020-10-27 20:22:10 UTC (rev 269067)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKUserStyleSheet.h 2020-10-27 20:54:03 UTC (rev 269068)
@@ -29,6 +29,7 @@
NS_ASSUME_NONNULL_BEGIN
@class _WKUserContentWorld;
+@class WKContentWorld;
@class WKWebView;
typedef NS_ENUM(NSInteger, _WKUserStyleLevel) {
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKUserStyleSheet.mm (269067 => 269068)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKUserStyleSheet.mm 2020-10-27 20:22:10 UTC (rev 269067)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKUserStyleSheet.mm 2020-10-27 20:54:03 UTC (rev 269068)
@@ -27,6 +27,7 @@
#import "_WKUserStyleSheetInternal.h"
#import "APIArray.h"
+#import "WKContentWorldInternal.h"
#import "WKNSArray.h"
#import "WKNSURLExtras.h"
#import "WKWebViewInternal.h"
Modified: trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.h (269067 => 269068)
--- trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.h 2020-10-27 20:22:10 UTC (rev 269067)
+++ trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.h 2020-10-27 20:54:03 UTC (rev 269068)
@@ -124,6 +124,7 @@
bool runOpenPanel(WebPageProxy&, WebFrameProxy*, FrameInfoData&&, API::OpenPanelParameters*, WebOpenPanelResultListenerProxy*) final;
void didExceedBackgroundResourceLimitWhileInForeground(WebPageProxy&, WKResourceLimit) final;
void saveDataToFileInDownloadsFolder(WebPageProxy*, const WTF::String&, const WTF::String&, const URL&, API::Data&) final;
+ Ref<API::InspectorConfiguration> configurationForLocalInspector(WebPageProxy&, WebInspectorProxy&) final;
void didAttachLocalInspector(WebPageProxy&, WebInspectorProxy&) final;
void willCloseLocalInspector(WebPageProxy&, WebInspectorProxy&) final;
#endif
@@ -201,6 +202,7 @@
bool webViewSaveDataToFileSuggestedFilenameMimeTypeOriginatingURL : 1;
bool webViewRunOpenPanelWithParametersInitiatedByFrameCompletionHandler : 1;
bool webViewRequestNotificationPermissionForSecurityOriginDecisionHandler : 1;
+ bool webViewConfigurationForLocalInspector : 1;
bool webViewDidAttachLocalInspector : 1;
bool webViewWillCloseLocalInspector : 1;
#endif
Modified: trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.mm (269067 => 269068)
--- trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.mm 2020-10-27 20:22:10 UTC (rev 269067)
+++ trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.mm 2020-10-27 20:54:03 UTC (rev 269068)
@@ -29,6 +29,7 @@
#import "APIArray.h"
#import "APIFrameInfo.h"
#import "APIHitTestResult.h"
+#import "APIInspectorConfiguration.h"
#import "CompletionHandlerCallChecker.h"
#import "MediaUtilities.h"
#import "NativeWebWheelEvent.h"
@@ -54,6 +55,7 @@
#import "_WKContextMenuElementInfo.h"
#import "_WKFrameHandleInternal.h"
#import "_WKHitTestResultInternal.h"
+#import "_WKInspectorConfigurationInternal.h"
#import "_WKInspectorInternal.h"
#import "_WKWebAuthenticationPanelInternal.h"
#import <AVFoundation/AVCaptureDevice.h>
@@ -131,6 +133,7 @@
m_delegateMethods.webViewSaveDataToFileSuggestedFilenameMimeTypeOriginatingURL = [delegate respondsToSelector:@selector(_webView:saveDataToFile:suggestedFilename:mimeType:originatingURL:)];
m_delegateMethods.webViewRunOpenPanelWithParametersInitiatedByFrameCompletionHandler = [delegate respondsToSelector:@selector(webView:runOpenPanelWithParameters:initiatedByFrame:completionHandler:)];
m_delegateMethods.webViewRequestNotificationPermissionForSecurityOriginDecisionHandler = [delegate respondsToSelector:@selector(_webView:requestNotificationPermissionForSecurityOrigin:decisionHandler:)];
+ m_delegateMethods.webViewConfigurationForLocalInspector = [delegate respondsToSelector:@selector(_webView:configurationForLocalInspector:)];
m_delegateMethods.webViewDidAttachLocalInspector = [delegate respondsToSelector:@selector(_webView:didAttachLocalInspector:)];
m_delegateMethods.webViewWillCloseLocalInspector = [delegate respondsToSelector:@selector(_webView:willCloseLocalInspector:)];
#endif
@@ -817,6 +820,18 @@
}).get()];
}
+Ref<API::InspectorConfiguration> UIDelegate::UIClient::configurationForLocalInspector(WebPageProxy&, WebInspectorProxy& inspector)
+{
+ if (!m_uiDelegate.m_delegateMethods.webViewConfigurationForLocalInspector)
+ return API::InspectorConfiguration::create();
+
+ auto delegate = m_uiDelegate.m_delegate.get();
+ if (!delegate)
+ return API::InspectorConfiguration::create();
+
+ return static_cast<API::InspectorConfiguration&>([[(id <WKUIDelegatePrivate>)delegate _webView:m_uiDelegate.m_webView configurationForLocalInspector:wrapper(inspector)] _apiObject]);
+}
+
void UIDelegate::UIClient::didAttachLocalInspector(WebPageProxy&, WebInspectorProxy& inspector)
{
if (!m_uiDelegate.m_delegateMethods.webViewDidAttachLocalInspector)
Modified: trunk/Source/WebKit/UIProcess/Inspector/RemoteWebInspectorProxy.cpp (269067 => 269068)
--- trunk/Source/WebKit/UIProcess/Inspector/RemoteWebInspectorProxy.cpp 2020-10-27 20:22:10 UTC (rev 269067)
+++ trunk/Source/WebKit/UIProcess/Inspector/RemoteWebInspectorProxy.cpp 2020-10-27 20:54:03 UTC (rev 269068)
@@ -65,11 +65,11 @@
void RemoteWebInspectorProxy::load(Ref<API::DebuggableInfo>&& debuggableInfo, const String& backendCommandsURL)
{
- createFrontendPageAndWindow();
-
m_debuggableInfo = WTFMove(debuggableInfo);
m_backendCommandsURL = backendCommandsURL;
+ createFrontendPageAndWindow();
+
m_inspectorPage->send(Messages::RemoteWebInspectorUI::Initialize(m_debuggableInfo->debuggableInfoData(), backendCommandsURL));
m_inspectorPage->loadRequest(URL(URL(), WebInspectorProxy::inspectorPageURL()));
}
Modified: trunk/Source/WebKit/UIProcess/Inspector/RemoteWebInspectorProxy.h (269067 => 269068)
--- trunk/Source/WebKit/UIProcess/Inspector/RemoteWebInspectorProxy.h 2020-10-27 20:22:10 UTC (rev 269067)
+++ trunk/Source/WebKit/UIProcess/Inspector/RemoteWebInspectorProxy.h 2020-10-27 20:54:03 UTC (rev 269068)
@@ -48,10 +48,12 @@
namespace API {
class DebuggableInfo;
+class InspectorConfiguration;
}
namespace WebKit {
+class RemoteWebInspectorProxy;
class WebPageProxy;
class WebView;
@@ -60,6 +62,7 @@
virtual ~RemoteWebInspectorProxyClient() { }
virtual void sendMessageToBackend(const String& message) = 0;
virtual void closeFromFrontend() = 0;
+ virtual Ref<API::InspectorConfiguration> configurationForRemoteInspector(RemoteWebInspectorProxy&) = 0;
};
class RemoteWebInspectorProxy : public RefCounted<RemoteWebInspectorProxy>, public IPC::MessageReceiver {
Modified: trunk/Source/WebKit/UIProcess/Inspector/glib/RemoteInspectorClient.cpp (269067 => 269068)
--- trunk/Source/WebKit/UIProcess/Inspector/glib/RemoteInspectorClient.cpp 2020-10-27 20:22:10 UTC (rev 269067)
+++ trunk/Source/WebKit/UIProcess/Inspector/glib/RemoteInspectorClient.cpp 2020-10-27 20:54:03 UTC (rev 269068)
@@ -29,6 +29,7 @@
#if ENABLE(REMOTE_INSPECTOR)
#include "APIDebuggableInfo.h"
+#include "APIInspectorConfiguration.h"
#include "RemoteWebInspectorProxy.h"
#include <_javascript_Core/RemoteInspectorUtils.h>
#include <WebCore/InspectorDebuggableType.h>
@@ -77,6 +78,8 @@
#endif
}
+ // MARK: RemoteWebInspectorProxyClient methods
+
void sendMessageToFrontend(const String& message)
{
m_proxy->sendMessageToFrontend(message);
@@ -92,6 +95,11 @@
m_inspectorClient.closeFromFrontend(m_connectionID, m_targetID);
}
+ Ref<API::InspectorConfiguration> configurationForRemoteInspector(RemoteWebInspectorProxy&)
+ {
+ return API::InspectorConfiguration::create();
+ }
+
private:
Ref<RemoteWebInspectorProxy> m_proxy;
RemoteInspectorClient& m_inspectorClient;
Modified: trunk/Source/WebKit/UIProcess/Inspector/mac/RemoteWebInspectorProxyMac.mm (269067 => 269068)
--- trunk/Source/WebKit/UIProcess/Inspector/mac/RemoteWebInspectorProxyMac.mm 2020-10-27 20:22:10 UTC (rev 269067)
+++ trunk/Source/WebKit/UIProcess/Inspector/mac/RemoteWebInspectorProxyMac.mm 2020-10-27 20:54:03 UTC (rev 269068)
@@ -39,6 +39,7 @@
#import "WebInspectorProxy.h"
#import "WebPageGroup.h"
#import "WebPageProxy.h"
+#import "_WKInspectorConfigurationInternal.h"
#import <SecurityInterface/SFCertificatePanel.h>
#import <SecurityInterface/SFCertificateView.h>
#import <WebCore/CertificateInfo.h>
@@ -103,7 +104,8 @@
{
m_objCAdapter = adoptNS([[WKRemoteWebInspectorProxyObjCAdapter alloc] initWithRemoteWebInspectorProxy:this]);
- m_inspectorView = adoptNS([[WKInspectorViewController alloc] initWithInspectedPage:nullptr]);
+ Ref<API::InspectorConfiguration> configuration = m_client->configurationForRemoteInspector(*this);
+ m_inspectorView = adoptNS([[WKInspectorViewController alloc] initWithConfiguration: WebKit::wrapper(configuration) inspectedPage:nullptr]);
[m_inspectorView.get() setDelegate:m_objCAdapter.get()];
m_window = WebInspectorProxy::createFrontendWindow(NSZeroRect, WebInspectorProxy::InspectionTargetType::Remote);
Modified: trunk/Source/WebKit/UIProcess/Inspector/mac/WKInspectorViewController.h (269067 => 269068)
--- trunk/Source/WebKit/UIProcess/Inspector/mac/WKInspectorViewController.h 2020-10-27 20:22:10 UTC (rev 269067)
+++ trunk/Source/WebKit/UIProcess/Inspector/mac/WKInspectorViewController.h 2020-10-27 20:54:03 UTC (rev 269068)
@@ -29,6 +29,7 @@
#import <wtf/NakedPtr.h>
OBJC_CLASS WKWebView;
+OBJC_CLASS _WKInspectorConfiguration;
namespace WebKit {
class WebPageProxy;
@@ -43,7 +44,7 @@
@property (nonatomic, readonly) WKWebView *webView;
@property (nonatomic, weak) id <WKInspectorViewControllerDelegate> delegate;
-- (instancetype)initWithInspectedPage:(NakedPtr<WebKit::WebPageProxy>)inspectedPage;
+- (instancetype)initWithConfiguration:(_WKInspectorConfiguration *)configuration inspectedPage:(NakedPtr<WebKit::WebPageProxy>)inspectedPage;
+ (BOOL)viewIsInspectorWebView:(NSView *)view;
Modified: trunk/Source/WebKit/UIProcess/Inspector/mac/WKInspectorViewController.mm (269067 => 269068)
--- trunk/Source/WebKit/UIProcess/Inspector/mac/WKInspectorViewController.mm 2020-10-27 20:22:10 UTC (rev 269067)
+++ trunk/Source/WebKit/UIProcess/Inspector/mac/WKInspectorViewController.mm 2020-10-27 20:54:03 UTC (rev 269068)
@@ -42,6 +42,7 @@
#import "WebInspectorProxy.h"
#import "WebInspectorUtilities.h"
#import "WebPageProxy.h"
+#import "_WKInspectorConfigurationInternal.h"
#import <WebCore/VersionChecks.h>
#import <wtf/WeakObjCPtr.h>
@@ -52,13 +53,16 @@
NakedPtr<WebKit::WebPageProxy> _inspectedPage;
RetainPtr<WKInspectorWKWebView> _webView;
WeakObjCPtr<id <WKInspectorViewControllerDelegate>> _delegate;
+ _WKInspectorConfiguration *_configuration;
}
-- (instancetype)initWithInspectedPage:(NakedPtr<WebKit::WebPageProxy>)inspectedPage
+- (instancetype)initWithConfiguration:(_WKInspectorConfiguration *)configuration inspectedPage:(NakedPtr<WebKit::WebPageProxy>)inspectedPage
{
if (!(self = [super init]))
return nil;
+ _configuration = [configuration copy];
+
// The (local) inspected page is nil if the controller is hosting a Remote Web Inspector view.
_inspectedPage = inspectedPage;
@@ -87,7 +91,7 @@
// Construct lazily so the client can set the delegate before the WebView is created.
if (!_webView) {
NSRect initialFrame = NSMakeRect(0, 0, WebKit::WebInspectorProxy::initialWindowWidth, WebKit::WebInspectorProxy::initialWindowHeight);
- _webView = adoptNS([[WKInspectorWKWebView alloc] initWithFrame:initialFrame configuration:[self configuration]]);
+ _webView = adoptNS([[WKInspectorWKWebView alloc] initWithFrame:initialFrame configuration:self.webViewConfiguration]);
[_webView setUIDelegate:self];
[_webView setNavigationDelegate:self];
[_webView setInspectorWKWebViewDelegate:self];
@@ -104,7 +108,7 @@
_delegate = delegate;
}
-- (WKWebViewConfiguration *)configuration
+- (WKWebViewConfiguration *)webViewConfiguration
{
auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
@@ -123,6 +127,8 @@
preferences._diagnosticLoggingEnabled = YES;
+ [_configuration applyToWebViewConfiguration:configuration.get()];
+
if (!!_delegate && [_delegate respondsToSelector:@selector(inspectorViewControllerInspectorIsUnderTest:)]) {
if ([_delegate inspectorViewControllerInspectorIsUnderTest:self]) {
preferences._hiddenPageDOMTimerThrottlingEnabled = NO;
Modified: trunk/Source/WebKit/UIProcess/Inspector/mac/WebInspectorProxyMac.mm (269067 => 269068)
--- trunk/Source/WebKit/UIProcess/Inspector/mac/WebInspectorProxyMac.mm 2020-10-27 20:22:10 UTC (rev 269067)
+++ trunk/Source/WebKit/UIProcess/Inspector/mac/WebInspectorProxyMac.mm 2020-10-27 20:54:03 UTC (rev 269068)
@@ -28,14 +28,19 @@
#if PLATFORM(MAC)
+#import "APIInspectorClient.h"
+#import "APIInspectorConfiguration.h"
+#import "APIUIClient.h"
#import "GlobalFindInPageState.h"
#import "WKInspectorPrivateMac.h"
#import "WKInspectorViewController.h"
+#import "WKObject.h"
#import "WKViewInternal.h"
#import "WKWebViewInternal.h"
#import "WebInspectorUIMessages.h"
#import "WebPageGroup.h"
#import "WebPageProxy.h"
+#import "_WKInspectorConfigurationInternal.h"
#import "_WKInspectorInternal.h"
#import "_WKInspectorWindow.h"
#import <SecurityInterface/SFCertificatePanel.h>
@@ -291,7 +296,8 @@
NSView *inspectedView = inspectedPage()->inspectorAttachmentView();
[[NSNotificationCenter defaultCenter] addObserver:m_objCAdapter.get() selector:@selector(inspectedViewFrameDidChange:) name:NSViewFrameDidChangeNotification object:inspectedView];
- m_inspectorViewController = adoptNS([[WKInspectorViewController alloc] initWithInspectedPage:inspectedPage()]);
+ auto configuration = inspectedPage()->uiClient().configurationForLocalInspector(*inspectedPage(), *this);
+ m_inspectorViewController = adoptNS([[WKInspectorViewController alloc] initWithConfiguration: WebKit::wrapper(configuration.get()) inspectedPage:inspectedPage()]);
[m_inspectorViewController.get() setDelegate:m_objCAdapter.get()];
WebPageProxy *inspectorPage = [m_inspectorViewController webView]->_page.get();
Modified: trunk/Source/WebKit/UIProcess/Inspector/socket/RemoteInspectorClient.cpp (269067 => 269068)
--- trunk/Source/WebKit/UIProcess/Inspector/socket/RemoteInspectorClient.cpp 2020-10-27 20:22:10 UTC (rev 269067)
+++ trunk/Source/WebKit/UIProcess/Inspector/socket/RemoteInspectorClient.cpp 2020-10-27 20:54:03 UTC (rev 269068)
@@ -29,6 +29,7 @@
#if ENABLE(REMOTE_INSPECTOR)
#include "APIDebuggableInfo.h"
+#include "APIInspectorConfiguration.h"
#include "RemoteWebInspectorProxy.h"
#include <wtf/MainThread.h>
#include <wtf/text/Base64.h>
@@ -67,6 +68,8 @@
m_proxy->show();
}
+ // MARK: RemoteWebInspectorProxyClient methods
+
void sendMessageToFrontend(const String& message)
{
m_proxy->sendMessageToFrontend(message);
@@ -82,6 +85,11 @@
m_inspectorClient.closeFromFrontend(m_connectionID, m_targetID);
}
+ Ref<API::InspectorConfiguration> configurationForRemoteInspector(RemoteWebInspectorProxy&)
+ {
+ return API::InspectorConfiguration::create();
+ }
+
private:
Ref<RemoteWebInspectorProxy> m_proxy;
RemoteInspectorClient& m_inspectorClient;
Modified: trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj (269067 => 269068)
--- trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj 2020-10-27 20:22:10 UTC (rev 269067)
+++ trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj 2020-10-27 20:54:03 UTC (rev 269068)
@@ -1418,6 +1418,9 @@
99249AD51F1F1E5600B62FBB /* AutomationFrontendDispatchers.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 99249AD31F1F1E3300B62FBB /* AutomationFrontendDispatchers.cpp */; };
99249AD61F1F1E5F00B62FBB /* AutomationFrontendDispatchers.h in Headers */ = {isa = PBXBuildFile; fileRef = 99249AD41F1F1E3300B62FBB /* AutomationFrontendDispatchers.h */; };
994BADF41F7D781400B571E7 /* WKInspectorViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 994BADF11F7D77EA00B571E7 /* WKInspectorViewController.h */; };
+ 994C6042253CA54400BDF060 /* _WKInspectorConfiguration.h in Headers */ = {isa = PBXBuildFile; fileRef = 994C6040253CA54300BDF060 /* _WKInspectorConfiguration.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 994C6045253CABA200BDF060 /* _WKInspectorConfigurationInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 994C6044253CABA200BDF060 /* _WKInspectorConfigurationInternal.h */; };
+ 994C6047253CACB800BDF060 /* APIInspectorConfiguration.h in Headers */ = {isa = PBXBuildFile; fileRef = 994C6046253CACB800BDF060 /* APIInspectorConfiguration.h */; };
995226D6207D184600F78420 /* SimulatedInputDispatcher.h in Headers */ = {isa = PBXBuildFile; fileRef = 995226D4207D184500F78420 /* SimulatedInputDispatcher.h */; };
9955A6EC1C7980C200EB6A93 /* WebAutomationSession.h in Headers */ = {isa = PBXBuildFile; fileRef = 9955A6EB1C7980BB00EB6A93 /* WebAutomationSession.h */; };
9955A6EF1C79810800EB6A93 /* Automation.json in Headers */ = {isa = PBXBuildFile; fileRef = 9955A6E91C7980BB00EB6A93 /* Automation.json */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -4534,6 +4537,11 @@
9946EF851E7B026600541E79 /* WebAutomationSessionIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebAutomationSessionIOS.mm; sourceTree = "<group>"; };
994BADF11F7D77EA00B571E7 /* WKInspectorViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKInspectorViewController.h; sourceTree = "<group>"; };
994BADF21F7D77EB00B571E7 /* WKInspectorViewController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKInspectorViewController.mm; sourceTree = "<group>"; };
+ 994C6040253CA54300BDF060 /* _WKInspectorConfiguration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKInspectorConfiguration.h; sourceTree = "<group>"; };
+ 994C6041253CA54400BDF060 /* _WKInspectorConfiguration.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = _WKInspectorConfiguration.mm; sourceTree = "<group>"; };
+ 994C6044253CABA200BDF060 /* _WKInspectorConfigurationInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKInspectorConfigurationInternal.h; sourceTree = "<group>"; };
+ 994C6046253CACB800BDF060 /* APIInspectorConfiguration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APIInspectorConfiguration.h; sourceTree = "<group>"; };
+ 994C6048253F820200BDF060 /* APIInspectorConfiguration.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = APIInspectorConfiguration.cpp; sourceTree = "<group>"; };
995226D4207D184500F78420 /* SimulatedInputDispatcher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SimulatedInputDispatcher.h; sourceTree = "<group>"; };
995226D5207D184600F78420 /* SimulatedInputDispatcher.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SimulatedInputDispatcher.cpp; sourceTree = "<group>"; };
9955A6E91C7980BB00EB6A93 /* Automation.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = Automation.json; sourceTree = "<group>"; };
@@ -7328,6 +7336,9 @@
37A64E5418F38E3C00EB30F1 /* _WKInputDelegate.h */,
5CAFDE422130843500B1F7E1 /* _WKInspector.h */,
5CAFDE432130843600B1F7E1 /* _WKInspector.mm */,
+ 994C6040253CA54300BDF060 /* _WKInspectorConfiguration.h */,
+ 994C6041253CA54400BDF060 /* _WKInspectorConfiguration.mm */,
+ 994C6044253CABA200BDF060 /* _WKInspectorConfigurationInternal.h */,
991F492D23A812C50054642B /* _WKInspectorDebuggableInfo.h */,
991F492E23A812C60054642B /* _WKInspectorDebuggableInfo.mm */,
99036AE123A949CE0000B06A /* _WKInspectorDebuggableInfoInternal.h */,
@@ -9320,6 +9331,8 @@
5143B2611DDD0DA00014FAC6 /* APIIconLoadingClient.h */,
7A8A9D571EF119AA009801AE /* APIInjectedBundleClient.h */,
9197940923DBC4E000257892 /* APIInspectorClient.h */,
+ 994C6048253F820200BDF060 /* APIInspectorConfiguration.cpp */,
+ 994C6046253CACB800BDF060 /* APIInspectorConfiguration.h */,
31B362902141EABC007BFA53 /* APIInternalDebugFeature.cpp */,
31B3628E2141EA4D007BFA53 /* APIInternalDebugFeature.h */,
7CE4D2061A46775700C7F152 /* APILegacyContextHistoryClient.h */,
@@ -10754,6 +10767,8 @@
510F59101DDE296900412FF5 /* _WKIconLoadingDelegate.h in Headers */,
37A64E5518F38E3C00EB30F1 /* _WKInputDelegate.h in Headers */,
5CAFDE452130846300B1F7E1 /* _WKInspector.h in Headers */,
+ 994C6042253CA54400BDF060 /* _WKInspectorConfiguration.h in Headers */,
+ 994C6045253CABA200BDF060 /* _WKInspectorConfigurationInternal.h in Headers */,
991F492F23A812C60054642B /* _WKInspectorDebuggableInfo.h in Headers */,
99036AE223A949CF0000B06A /* _WKInspectorDebuggableInfoInternal.h in Headers */,
9197940C23DBC50300257892 /* _WKInspectorDelegate.h in Headers */,
@@ -10867,6 +10882,7 @@
7A8A9D5C1EF14598009801AE /* APIInjectedBundlePageResourceLoadClient.h in Headers */,
3769079A18F31CB2001DFF04 /* APIInjectedBundlePageUIClient.h in Headers */,
9197940A23DBC4E000257892 /* APIInspectorClient.h in Headers */,
+ 994C6047253CACB800BDF060 /* APIInspectorConfiguration.h in Headers */,
31B3628F2141EA5D007BFA53 /* APIInternalDebugFeature.h in Headers */,
7CE4D2071A46776100C7F152 /* APILegacyContextHistoryClient.h in Headers */,
1A2464F31891E45100234C5B /* APILoaderClient.h in Headers */,
Modified: trunk/Tools/ChangeLog (269067 => 269068)
--- trunk/Tools/ChangeLog 2020-10-27 20:22:10 UTC (rev 269067)
+++ trunk/Tools/ChangeLog 2020-10-27 20:54:03 UTC (rev 269068)
@@ -1,3 +1,21 @@
+2020-10-27 Brian Burg <[email protected]>
+
+ [Cocoa] Introduce _WKInspectorConfiguration for customizing local and remote Web Inspectors
+ https://bugs.webkit.org/show_bug.cgi?id=217896
+ <rdar://problem/70355910>
+
+ Reviewed by Devin Rousso.
+
+ Add an API test for _WKInspectorConfiguration. Disabled for now, will
+ be turned back on when more web extensions API has landed.
+
+ * TestWebKitAPI/Tests/WebKitCocoa/WKInspectorDelegate.mm:
+ (-[SimpleURLSchemeHandler webView:startURLSchemeTask:]):
+ (-[SimpleURLSchemeHandler webView:stopURLSchemeTask:]):
+ (-[UIDelegate _webView:configurationForLocalInspector:]):
+ (-[UIDelegate _webView:didAttachLocalInspector:]):
+ (TEST):
+
2020-10-27 Keith Rollin <[email protected]>
Update generate_xcfilelists to accommodate paths with symlinks
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKInspectorDelegate.mm (269067 => 269068)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKInspectorDelegate.mm 2020-10-27 20:22:10 UTC (rev 269067)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKInspectorDelegate.mm 2020-10-27 20:54:03 UTC (rev 269068)
@@ -28,9 +28,13 @@
#import "Test.h"
#import "Utilities.h"
#import <WebKit/WKPreferencesPrivate.h>
+#import <WebKit/WKURLSchemeHandler.h>
+#import <WebKit/WKURLSchemeTask.h>
#import <WebKit/WKWebViewPrivate.h>
#import <WebKit/WKWebViewPrivateForTesting.h>
#import <WebKit/_WKInspector.h>
+#import <WebKit/_WKInspectorConfiguration.h>
+#import <WebKit/_WKInspectorDebuggableInfo.h>
#import <WebKit/_WKInspectorDelegate.h>
#import <WebKit/_WKInspectorPrivateForTesting.h>
#import <wtf/RetainPtr.h>
@@ -39,6 +43,7 @@
#if PLATFORM(MAC)
@class InspectorDelegate;
+@class SimpleURLSchemeHandler;
static bool didAttachLocalInspectorCalled = false;
static bool willCloseLocalInspectorCalled = false;
@@ -46,9 +51,54 @@
static bool browserDomainDisabledForInspectorCalled = false;
static bool shouldCallInspectorCloseReentrantly = false;
static bool openURLExternallyCalled = false;
+static bool configurationForLocalInspectorCalled = false;
+static bool startURLSchemeTaskCalled = false;
+
+static RetainPtr<SimpleURLSchemeHandler> sharedURLSchemeHandler;
static RetainPtr<id <_WKInspectorDelegate>> sharedInspectorDelegate;
static RetainPtr<NSURL> urlToOpen;
+static void resetGlobalState()
+{
+ didAttachLocalInspectorCalled = false;
+ willCloseLocalInspectorCalled = false;
+ browserDomainEnabledForInspectorCalled = false;
+ browserDomainDisabledForInspectorCalled = false;
+ shouldCallInspectorCloseReentrantly = false;
+ openURLExternallyCalled = false;
+ configurationForLocalInspectorCalled = false;
+ startURLSchemeTaskCalled = false;
+
+ sharedURLSchemeHandler.clear();
+ sharedInspectorDelegate.clear();
+ urlToOpen.clear();
+}
+
+@interface SimpleURLSchemeHandler : NSObject <WKURLSchemeHandler>
+@property (nonatomic, weak) NSURL *expectedURL;
+@end
+
+@implementation SimpleURLSchemeHandler
+
+- (void)webView:(WKWebView *)webView startURLSchemeTask:(id <WKURLSchemeTask>)task
+{
+ if (_expectedURL)
+ EXPECT_STREQ(_expectedURL.absoluteString.UTF8String, task.request.URL.absoluteString.UTF8String);
+
+ RetainPtr<NSURLResponse> response = adoptNS([[NSURLResponse alloc] initWithURL:task.request.URL MIMEType:@"text/html" expectedContentLength:1 textEncodingName:nil]);
+ [task didReceiveResponse:response.get()];
+ [task didReceiveData:[NSData dataWithBytes:"1" length:1]];
+ [task didFinish];
+
+ startURLSchemeTaskCalled = true;
+}
+
+- (void)webView:(WKWebView *)webView stopURLSchemeTask:(id <WKURLSchemeTask>)task
+{
+}
+
+@end
+
@interface InspectorDelegate : NSObject <_WKInspectorDelegate>
@end
@@ -77,18 +127,23 @@
@implementation UIDelegate
-- (void)_webView:(WKWebView *)webView didAttachLocalInspector:(_WKInspector *)inspector
+- (_WKInspectorConfiguration *)_webView:(WKWebView *)webView configurationForLocalInspector:(_WKInspector *)inspector
{
- didAttachLocalInspectorCalled = false;
- willCloseLocalInspectorCalled = false;
- browserDomainEnabledForInspectorCalled = false;
- browserDomainDisabledForInspectorCalled = false;
+ configurationForLocalInspectorCalled = true;
- EXPECT_EQ(webView._inspector, inspector);
-
sharedInspectorDelegate = [InspectorDelegate new];
[inspector setDelegate:sharedInspectorDelegate.get()];
+ sharedURLSchemeHandler = [[SimpleURLSchemeHandler alloc] init];
+ RetainPtr<_WKInspectorConfiguration> inspectorConfiguration = [[_WKInspectorConfiguration alloc] init];
+ [inspectorConfiguration setURLSchemeHandler:sharedURLSchemeHandler.get() forURLScheme:@"testing"];
+ return [inspectorConfiguration autorelease];
+}
+
+- (void)_webView:(WKWebView *)webView didAttachLocalInspector:(_WKInspector *)inspector
+{
+ EXPECT_EQ(webView._inspector, inspector);
+
didAttachLocalInspectorCalled = true;
}
@@ -105,6 +160,8 @@
TEST(WKInspectorDelegate, InspectorLifecycleCallbacks)
{
+ resetGlobalState();
+
auto webViewConfiguration = adoptNS([WKWebViewConfiguration new]);
webViewConfiguration.get().preferences._developerExtrasEnabled = YES;
auto webView = adoptNS([[WKWebView alloc] initWithFrame:CGRectMake(0, 0, 800, 600) configuration:webViewConfiguration.get()]);
@@ -127,6 +184,8 @@
TEST(WKInspectorDelegate, InspectorCloseCalledReentrantly)
{
+ resetGlobalState();
+
auto webViewConfiguration = adoptNS([WKWebViewConfiguration new]);
webViewConfiguration.get().preferences._developerExtrasEnabled = YES;
auto webView = adoptNS([[WKWebView alloc] initWithFrame:CGRectMake(0, 0, 800, 600) configuration:webViewConfiguration.get()]);
@@ -149,6 +208,8 @@
TEST(WKInspectorDelegate, ShowURLExternally)
{
+ resetGlobalState();
+
auto webViewConfiguration = adoptNS([WKWebViewConfiguration new]);
webViewConfiguration.get().preferences._developerExtrasEnabled = YES;
auto webView = adoptNS([[WKWebView alloc] initWithFrame:CGRectMake(0, 0, 800, 600) configuration:webViewConfiguration.get()]);
@@ -171,4 +232,35 @@
TestWebKitAPI::Util::run(&openURLExternallyCalled);
}
+// FIXME: re-enabling this test case is blocked, tracking this task in <rdar://problem/70505272>.
+TEST(WKInspectorDelegate, DISABLED_InspectorConfiguration)
+{
+ resetGlobalState();
+
+ auto webViewConfiguration = adoptNS([WKWebViewConfiguration new]);
+ webViewConfiguration.get().preferences._developerExtrasEnabled = YES;
+ auto webView = adoptNS([[WKWebView alloc] initWithFrame:CGRectMake(0, 0, 800, 600) configuration:webViewConfiguration.get()]);
+ auto uiDelegate = adoptNS([UIDelegate new]);
+
+ [webView setUIDelegate:uiDelegate.get()];
+ [webView loadHTMLString:@"<head><title>Test page to be inspected</title></head><body><p>Filler content</p></body>" baseURL:[NSURL URLWithString:@"http://example.com/"]];
+
+ EXPECT_FALSE(webView.get()._isBeingInspected);
+
+ [[webView _inspector] show];
+ TestWebKitAPI::Util::run(&configurationForLocalInspectorCalled);
+ TestWebKitAPI::Util::run(&didAttachLocalInspectorCalled);
+
+ // FIXME: WKInspectorViewController's navigation delegate cancels all main frame
+ // loads that are not the Web Inspector page. So, this cannot be fully tested until
+ // we can used the createTab API to load the custom URL scheme resource in an iframe.
+ urlToOpen = [NSURL URLWithString:@"testing:main1"];
+ sharedURLSchemeHandler.get().expectedURL = urlToOpen.get();
+ [[webView _inspector] _openURLExternallyForTesting:urlToOpen.get() useFrontendAPI:NO];
+ TestWebKitAPI::Util::run(&startURLSchemeTaskCalled);
+
+ [[webView _inspector] close];
+ TestWebKitAPI::Util::run(&willCloseLocalInspectorCalled);
+}
+
#endif // PLATFORM(MAC)