Diff
Modified: trunk/Source/WebInspectorUI/ChangeLog (270605 => 270606)
--- trunk/Source/WebInspectorUI/ChangeLog 2020-12-09 23:01:08 UTC (rev 270605)
+++ trunk/Source/WebInspectorUI/ChangeLog 2020-12-09 23:08:25 UTC (rev 270606)
@@ -1,3 +1,39 @@
+2020-11-30 Brian Burg <[email protected]>
+
+ [Cocoa] Web Inspector: add support for creating extension tabs in WebInspectorUI via _WKInspectorExtension
+ https://bugs.webkit.org/show_bug.cgi?id=219380
+
+ Reviewed by Devin Rousso and Timothy Hatcher.
+
+ * UserInterface/Controllers/WebInspectorExtensionController.js:
+ (WI.WebInspectorExtensionController):
+ (WI.WebInspectorExtensionController.prototype._makeNextExtensionTabID):
+ (WI.WebInspectorExtensionController.prototype.unregisterExtension):
+ (WI.WebInspectorExtensionController.prototype.createTabForExtension):
+ * UserInterface/Main.html:
+ * UserInterface/Protocol/InspectorFrontendAPI.js:
+ (InspectorFrontendAPI.createTabForExtension):
+ * UserInterface/Views/GeneralTabBarItem.js:
+ (WI.GeneralTabBarItem.fromTabContentView):
+ (WI.GeneralTabBarItem.get displayName): Deleted.
+ * UserInterface/Views/PinnedTabBarItem.js:
+ (WI.PinnedTabBarItem.fromTabContentView):
+ (WI.PinnedTabBarItem):
+ * UserInterface/Views/TabContentView.js:
+ (WI.TabContentView.prototype.get tabBarItem):
+ (WI.TabContentView.prototype.tabInfo):
+ (WI.TabContentView.prototype.get managesNavigationSidebarPanel): Deleted.
+ (WI.TabContentView.prototype.attached): Deleted.
+ * UserInterface/Views/WebInspectorExtensionTabContentView.css: Copied from Source/WebKit/UIProcess/API/Cocoa/_WKInspectorExtension.h.
+ (.content-view.web-inspector-extension-tab > iframe):
+ * UserInterface/Views/WebInspectorExtensionTabContentView.js: Copied from Source/WebKit/UIProcess/API/APIInspectorExtension.h.
+ (WI.WebInspectorExtensionTabContentView):
+ (WI.WebInspectorExtensionTabContentView.prototype.tabInfo):
+ (WI.WebInspectorExtensionTabContentView.prototype.get type):
+ (WI.WebInspectorExtensionTabContentView.prototype.get supportsSplitContentBrowser):
+ (WI.WebInspectorExtensionTabContentView.prototype.get extensionTabID):
+ (WI.WebInspectorExtensionTabContentView.prototype.initialLayout):
+
2020-12-09 Devin Rousso <[email protected]>
Web Inspector: add UI for request interception
Modified: trunk/Source/WebInspectorUI/UserInterface/Controllers/WebInspectorExtensionController.js (270605 => 270606)
--- trunk/Source/WebInspectorUI/UserInterface/Controllers/WebInspectorExtensionController.js 2020-12-09 23:01:08 UTC (rev 270605)
+++ trunk/Source/WebInspectorUI/UserInterface/Controllers/WebInspectorExtensionController.js 2020-12-09 23:08:25 UTC (rev 270606)
@@ -29,7 +29,10 @@
{
super();
- this._extensionIDMap = new Map;
+ this._extensionForExtensionIDMap = new Map;
+ this._extensionTabContentViewForExtensionTabIDMap = new Map;
+ this._tabIDsForExtensionIDMap = new Multimap;
+ this._nextExtensionTabID = 1;
}
// Public
@@ -36,13 +39,13 @@
registerExtension(extensionID, displayName)
{
- if (this._extensionIDMap.has(extensionID)) {
- WI.reportInternalError("Unable to register extension, it's already registered: ", extensionID, displayName);
+ if (this._extensionForExtensionIDMap.has(extensionID)) {
+ WI.reportInternalError("Unable to register extension, it's already registered: " + extensionID);
return WI.WebInspectorExtension.ErrorCode.RegistrationFailed;
}
let extension = new WI.WebInspectorExtension(extensionID, displayName);
- this._extensionIDMap.set(extensionID, extension);
+ this._extensionForExtensionIDMap.set(extensionID, extension);
this.dispatchEventToListeners(WI.WebInspectorExtensionController.Event.ExtensionAdded, {extension});
}
@@ -49,14 +52,39 @@
unregisterExtension(extensionID)
{
- let extension = this._extensionIDMap.take(extensionID);
+ let extension = this._extensionForExtensionIDMap.take(extensionID);
if (!extension) {
- WI.reportInternalError("Unable to unregister extension with unknown ID: ", extensionID);
+ WI.reportInternalError("Unable to unregister extension with unknown ID: " + extensionID);
return WI.WebInspectorExtension.ErrorCode.InvalidRequest;
}
+ let extensionTabIDsToRemove = this._tabIDsForExtensionIDMap.take(extensionID) || [];
+ for (let extensionTabID of extensionTabIDsToRemove) {
+ let tabContentView = this._extensionTabContentViewForExtensionTabIDMap.take(extensionTabID);
+ WI.tabBrowser.closeTabForContentView(tabContentView);
+ }
+
this.dispatchEventToListeners(WI.WebInspectorExtensionController.Event.ExtensionRemoved, {extension});
}
+
+ createTabForExtension(extensionID, tabName, tabIconURL, sourceURL)
+ {
+ let extension = this._extensionForExtensionIDMap.get(extensionID);
+ if (!extension) {
+ WI.reportInternalError("Unable to create tab for extension with unknown ID: " + extensionID + " sourceURL: " + sourceURL);
+ return WI.WebInspectorExtension.ErrorCode.InvalidRequest;
+ }
+
+ let extensionTabID = `WebExtensionTab-${extensionID}-${this._nextExtensionTabID++}`;
+ let tabContentView = new WI.WebInspectorExtensionTabContentView(extension, extensionTabID, tabName, tabIconURL, sourceURL);
+
+ this._tabIDsForExtensionIDMap.add(extensionID, extensionTabID);
+ this._extensionTabContentViewForExtensionTabIDMap.set(extensionTabID, tabContentView);
+ WI.tabBrowser.addTabForContentView(tabContentView);
+
+ // The calling convention is to return an error string or a result object.
+ return {extensionTabID};
+ }
};
WI.WebInspectorExtensionController.Event = {
Modified: trunk/Source/WebInspectorUI/UserInterface/Main.html (270605 => 270606)
--- trunk/Source/WebInspectorUI/UserInterface/Main.html 2020-12-09 23:01:08 UTC (rev 270605)
+++ trunk/Source/WebInspectorUI/UserInterface/Main.html 2020-12-09 23:08:25 UTC (rev 270606)
@@ -247,6 +247,7 @@
<link rel="stylesheet" href=""
<link rel="stylesheet" href=""
<link rel="stylesheet" href=""
+ <link rel="stylesheet" href=""
<link rel="stylesheet" href=""
<link rel="stylesheet" href=""
@@ -583,6 +584,7 @@
<script src=""
<script src=""
<script src=""
+ <script src=""
<script src=""
<script src=""
Modified: trunk/Source/WebInspectorUI/UserInterface/Protocol/InspectorFrontendAPI.js (270605 => 270606)
--- trunk/Source/WebInspectorUI/UserInterface/Protocol/InspectorFrontendAPI.js 2020-12-09 23:01:08 UTC (rev 270605)
+++ trunk/Source/WebInspectorUI/UserInterface/Protocol/InspectorFrontendAPI.js 2020-12-09 23:08:25 UTC (rev 270606)
@@ -209,4 +209,11 @@
{
return WI.sharedApp.extensionController.unregisterExtension(extensionID);
},
+
+ // Returns a WI.WebInspectorExtension.ErrorCode if an error occurred, otherwise an object
+ // with an 'inspectorExtensionID' key representing the tab identifier for the newly created tab.
+ createTabForExtension(extensionID, tabName, tabIconURL, sourceURL)
+ {
+ return WI.sharedApp.extensionController.createTabForExtension(extensionID, tabName, tabIconURL, sourceURL);
+ },
};
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/GeneralTabBarItem.js (270605 => 270606)
--- trunk/Source/WebInspectorUI/UserInterface/Views/GeneralTabBarItem.js 2020-12-09 23:01:08 UTC (rev 270605)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/GeneralTabBarItem.js 2020-12-09 23:08:25 UTC (rev 270606)
@@ -32,7 +32,7 @@
{
console.assert(tabContentView instanceof WI.TabContentView);
- let {image, displayName, title} = tabContentView.constructor.tabInfo();
+ let {image, displayName, title} = tabContentView.tabInfo();
return new WI.GeneralTabBarItem(tabContentView, image, displayName, title);
}
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/PinnedTabBarItem.js (270605 => 270606)
--- trunk/Source/WebInspectorUI/UserInterface/Views/PinnedTabBarItem.js 2020-12-09 23:01:08 UTC (rev 270605)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/PinnedTabBarItem.js 2020-12-09 23:08:25 UTC (rev 270606)
@@ -38,7 +38,7 @@
{
console.assert(tabContentView instanceof WI.TabContentView);
- let {image, displayName, title} = tabContentView.constructor.tabInfo();
+ let {image, displayName, title} = tabContentView.tabInfo();
return new WI.PinnedTabBarItem(tabContentView, image, displayName, title);
}
};
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/TabContentView.js (270605 => 270606)
--- trunk/Source/WebInspectorUI/UserInterface/Views/TabContentView.js 2020-12-09 23:01:08 UTC (rev 270605)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/TabContentView.js 2020-12-09 23:08:25 UTC (rev 270606)
@@ -33,7 +33,6 @@
super(null);
this._identifier = tabInfo.identifier;
- this._tabBarItem = this.constructor.shouldPinTab() ? WI.PinnedTabBarItem.fromTabContentView(this) : WI.GeneralTabBarItem.fromTabContentView(this);
this._navigationSidebarPanelConstructor = navigationSidebarPanelConstructor || null;
this._detailsSidebarPanelConstructors = detailsSidebarPanelConstructors || [];
@@ -82,6 +81,11 @@
get tabBarItem()
{
+ // This is created lazily to break a dependency cycle for dynamically-created TabContentViews.
+ // TabContentViews with a non-static tabInfo() must be fully constructed before calling tabInfo().
+ if (!this._tabBarItem)
+ this._tabBarItem = this.constructor.shouldPinTab() ? WI.PinnedTabBarItem.fromTabContentView(this) : WI.GeneralTabBarItem.fromTabContentView(this);
+
return this._tabBarItem;
}
@@ -125,6 +129,12 @@
return false;
}
+ tabInfo()
+ {
+ // Can be overridden by subclasses.
+ return this.constructor.tabInfo();
+ }
+
attached()
{
super.attached();
Copied: trunk/Source/WebInspectorUI/UserInterface/Views/WebInspectorExtensionTabContentView.css (from rev 270605, trunk/Source/WebKit/UIProcess/API/Cocoa/_WKInspectorExtension.h) (0 => 270606)
--- trunk/Source/WebInspectorUI/UserInterface/Views/WebInspectorExtensionTabContentView.css (rev 0)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/WebInspectorExtensionTabContentView.css 2020-12-09 23:08:25 UTC (rev 270606)
@@ -0,0 +1,39 @@
+/*
+ * 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.
+ */
+
+.content-view.tab.web-inspector-extension > iframe {
+ border: 0;
+
+ position: absolute;
+ top: 0;
+ left: 0;
+ right: 0;
+ bottom: 0;
+
+ /* This is required for the iframe to expand if its intrinsic size */
+ /* is smaller than the tab content view. */
+ width: 100%;
+ height: 100%;
+}
Copied: trunk/Source/WebInspectorUI/UserInterface/Views/WebInspectorExtensionTabContentView.js (from rev 270605, trunk/Source/WebKit/UIProcess/API/APIInspectorExtension.h) (0 => 270606)
--- trunk/Source/WebInspectorUI/UserInterface/Views/WebInspectorExtensionTabContentView.js (rev 0)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/WebInspectorExtensionTabContentView.js 2020-12-09 23:08:25 UTC (rev 270606)
@@ -0,0 +1,76 @@
+/*
+ * 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.
+ */
+
+WI.WebInspectorExtensionTabContentView = class WebInspectorExtensionTabContentView extends WI.TabContentView
+{
+ constructor(extension, extensionTabID, tabLabel, iconURL, sourceURL)
+ {
+ let tabInfo = {
+ identifier: WI.WebInspectorExtensionTabContentView.Type,
+ image: iconURL,
+ displayName: tabLabel,
+ title: tabLabel,
+ };
+ super(tabInfo);
+
+ this._extension = extension;
+ this._extensionTabID = extensionTabID;
+ this._tabInfo = tabInfo;
+ this._sourceURL = sourceURL;
+ }
+
+ // Public
+
+ get extensionTabID() { return this._extensionTabID; }
+
+ get type()
+ {
+ return WI.WebInspectorExtensionTabContentView.Type;
+ }
+
+ get supportsSplitContentBrowser()
+ {
+ return true;
+ }
+
+ tabInfo()
+ {
+ return this._tabInfo;
+ }
+
+ static shouldSaveTab() { return false; }
+
+ // Protected
+
+ initialLayout()
+ {
+ super.initialLayout();
+
+ let iframeElement = this.element.appendChild(document.createElement("iframe"));
+ iframeElement.src = ""
+ }
+};
+
+WI.WebInspectorExtensionTabContentView.Type = "web-inspector-extension";
Modified: trunk/Source/WebKit/ChangeLog (270605 => 270606)
--- trunk/Source/WebKit/ChangeLog 2020-12-09 23:01:08 UTC (rev 270605)
+++ trunk/Source/WebKit/ChangeLog 2020-12-09 23:08:25 UTC (rev 270606)
@@ -1,3 +1,68 @@
+2020-11-30 Brian Burg <[email protected]>
+
+ [Cocoa] Web Inspector: add support for creating extension tabs in WebInspectorUI via _WKInspectorExtension
+ https://bugs.webkit.org/show_bug.cgi?id=219380
+
+ Reviewed by Devin Rousso and Timothy Hatcher.
+
+ Add a new method to _WKInspectorExtension for creating an extension tab in WebInpectorUI.
+ This can be used to implement browser.devtools.panels.create() as provided by the Web Extensions API.
+
+ * Platform/Logging.h: Add Inspector channel for error logging.
+ * Shared/InspectorExtensionTypes.h: Add a missing EnumTraits case.
+ * WebKit.xcodeproj/project.pbxproj:
+ * Sources.txt: Add files.
+
+ * UIProcess/API/APIInspectorExtension.h:
+ * UIProcess/API/APIInspectorExtension.cpp:
+ (API::InspectorExtension::InspectorExtension):
+ (API::InspectorExtension::create):
+ (API::InspectorExtension::createTab):
+ Inspector extensions need to be able to invoke commands in the WebProcess-side
+ extension proxy controller, so keep a WeakRef to the extension controller that
+ created the extension object. Also, implement the new API by forwarding it on.
+
+ * UIProcess/API/Cocoa/_WKInspector.mm:
+ (-[_WKInspector registerExtensionWithID:displayName:completionHandler:]):
+ Adapt to the new constructor as explained above.
+
+ * UIProcess/API/Cocoa/_WKInspectorExtensionInternal.h:
+ Expose member m_remoteInspectorPorxy for use in the API::InspectorExtension constructor.
+
+ * UIProcess/API/Cocoa/_WKInspectorExtension.h:
+ * UIProcess/API/Cocoa/_WKInspectorExtension.mm:
+ (-[_WKInspectorExtension initWithIdentifier:]): Deleted.
+
+ (-[_WKInspectorExtension createTabWithName:tabIconURL:sourceURL:completionHandler:]):
+ Implement new API.
+
+ * UIProcess/API/Cocoa/_WKRemoteWebInspectorViewControllerInternal.h: Added.
+ Make the RefPtr<RemoteWebInspectorProxy> member variable accessible to the API object constructor.
+
+ * UIProcess/API/Cocoa/_WKRemoteWebInspectorViewController.mm:
+ (-[_WKRemoteWebInspectorViewController registerExtensionWithID:displayName:completionHandler:]):
+ Adapt to new constructor as explained above.
+
+ * UIProcess/Inspector/WebInspectorUIExtensionControllerProxy.h:
+ * UIProcess/Inspector/WebInspectorUIExtensionControllerProxy.cpp:
+ (WebKit::WebInspectorUIExtensionControllerProxy::createTabForExtension):
+ Forward the request to the inspector frontend WebProcess.
+
+ * WebProcess/Inspector/WebInspectorUIExtensionController.messages.in:
+ Add a new async IPC command for creating a new inspector extension tab.
+
+ * WebProcess/Inspector/WebInspectorUIExtensionController.h:
+ * WebProcess/Inspector/WebInspectorUIExtensionController.cpp:
+ (WebKit::WebInspectorUIExtensionController::unwrapEvaluationResultAsObject):
+ Added. Pull out the code needed for error-handling this common operation.
+
+ (WebKit::WebInspectorUIExtensionController::createTabForExtension):
+ Added. Call into InspectorFrontendAPI to request a new tab. Turn the result
+ into an InspectorExtensionError or InspectorExtensionTabID and send the IPC reply.
+
+ * UIProcess/RemoteLayerTree/mac/ScrollingTreeOverflowScrollingNodeRemoteMac.h:
+ Fix unified sources fallout.
+
2020-12-09 Said Abou-Hallawa <[email protected]>
[GPU Process]: Recording an in-process ImageBuffer drawing has to convert it to a NativeImage first
Modified: trunk/Source/WebKit/Platform/Logging.h (270605 => 270606)
--- trunk/Source/WebKit/Platform/Logging.h 2020-12-09 23:01:08 UTC (rev 270605)
+++ trunk/Source/WebKit/Platform/Logging.h 2020-12-09 23:08:25 UTC (rev 270606)
@@ -60,8 +60,8 @@
M(Images) \
M(IncrementalPDF) \
M(IncrementalPDFVerbose) \
+ M(IndexedDB) \
M(Inspector) \
- M(IndexedDB) \
M(KeyHandling) \
M(Layers) \
M(Layout) \
Modified: trunk/Source/WebKit/Shared/InspectorExtensionTypes.h (270605 => 270606)
--- trunk/Source/WebKit/Shared/InspectorExtensionTypes.h 2020-12-09 23:01:08 UTC (rev 270605)
+++ trunk/Source/WebKit/Shared/InspectorExtensionTypes.h 2020-12-09 23:08:25 UTC (rev 270606)
@@ -50,8 +50,9 @@
template<> struct EnumTraits<WebKit::InspectorExtensionError> {
using values = EnumValues<
WebKit::InspectorExtensionError,
+ WebKit::InspectorExtensionError::ContextDestroyed,
+ WebKit::InspectorExtensionError::InternalError,
WebKit::InspectorExtensionError::InvalidRequest,
- WebKit::InspectorExtensionError::ContextDestroyed,
WebKit::InspectorExtensionError::RegistrationFailed
>;
};
Modified: trunk/Source/WebKit/Sources.txt (270605 => 270606)
--- trunk/Source/WebKit/Sources.txt 2020-12-09 23:01:08 UTC (rev 270605)
+++ trunk/Source/WebKit/Sources.txt 2020-12-09 23:08:25 UTC (rev 270606)
@@ -353,6 +353,7 @@
UIProcess/API/APIHTTPCookieStore.cpp
UIProcess/API/APIHitTestResult.cpp
UIProcess/API/APIInspectorConfiguration.cpp
+UIProcess/API/APIInspectorExtension.cpp
UIProcess/API/APIInternalDebugFeature.cpp
UIProcess/API/APINavigation.cpp
UIProcess/API/APINavigationData.cpp
Copied: trunk/Source/WebKit/UIProcess/API/APIInspectorExtension.cpp (from rev 270605, trunk/Source/WebKit/UIProcess/API/APIInspectorExtension.h) (0 => 270606)
--- trunk/Source/WebKit/UIProcess/API/APIInspectorExtension.cpp (rev 0)
+++ trunk/Source/WebKit/UIProcess/API/APIInspectorExtension.cpp 2020-12-09 23:08:25 UTC (rev 270606)
@@ -0,0 +1,59 @@
+/*
+ * 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 "APIInspectorExtension.h"
+
+#if ENABLE(INSPECTOR_EXTENSIONS)
+
+#include "InspectorExtensionTypes.h"
+#include "WebInspectorUIExtensionControllerProxy.h"
+
+namespace API {
+
+InspectorExtension::InspectorExtension(const WTF::String& identifier, WebKit::WebInspectorUIExtensionControllerProxy& extensionControllerProxy)
+ : m_identifier(identifier)
+ , m_extensionControllerProxy(makeWeakPtr(extensionControllerProxy))
+{
+}
+
+Ref<InspectorExtension> InspectorExtension::create(const WTF::String& identifier, WebKit::WebInspectorUIExtensionControllerProxy& extensionControllerProxy)
+{
+ return adoptRef(*new InspectorExtension(identifier, extensionControllerProxy));
+}
+
+void InspectorExtension::createTab(const WTF::String& tabName, const WTF::URL& tabIconURL, const WTF::URL& sourceURL, WTF::CompletionHandler<void(Expected<WebKit::InspectorExtensionTabID, WebKit::InspectorExtensionError>)>&& completionHandler)
+{
+ if (!m_extensionControllerProxy) {
+ completionHandler(makeUnexpected(WebKit::InspectorExtensionError::ContextDestroyed));
+ return;
+ }
+
+ m_extensionControllerProxy->createTabForExtension(m_identifier, tabName, tabIconURL, sourceURL, WTFMove(completionHandler));
+}
+
+} // namespace API
+
+#endif // ENABLE(INSPECTOR_EXTENSIONS)
Modified: trunk/Source/WebKit/UIProcess/API/APIInspectorExtension.h (270605 => 270606)
--- trunk/Source/WebKit/UIProcess/API/APIInspectorExtension.h 2020-12-09 23:01:08 UTC (rev 270605)
+++ trunk/Source/WebKit/UIProcess/API/APIInspectorExtension.h 2020-12-09 23:08:25 UTC (rev 270606)
@@ -28,26 +28,31 @@
#if ENABLE(INSPECTOR_EXTENSIONS)
#include "APIObject.h"
+#include "InspectorExtensionTypes.h"
+#include <wtf/CompletionHandler.h>
#include <wtf/Forward.h>
+#include <wtf/WeakPtr.h>
+#include <wtf/text/WTFString.h>
+namespace WebKit {
+class WebInspectorUIExtensionControllerProxy;
+}
+
namespace API {
class InspectorExtension final : public API::ObjectImpl<Object::Type::InspectorExtension> {
public:
- static Ref<InspectorExtension> create(const WTF::String& identifier)
- {
- return adoptRef(*new InspectorExtension(identifier));
- }
+ static Ref<InspectorExtension> create(const WTF::String& identifier, WebKit::WebInspectorUIExtensionControllerProxy&);
- explicit InspectorExtension(const WTF::String& identifier)
- : m_identifier(identifier)
- {
- }
-
const WTF::String& identifier() const { return m_identifier; }
+ void createTab(const WTF::String& tabName, const WTF::URL& tabIconURL, const WTF::URL& sourceURL, WTF::CompletionHandler<void(Expected<WebKit::InspectorExtensionTabID, WebKit::InspectorExtensionError>)>&&);
+
private:
+ InspectorExtension(const WTF::String& identifier, WebKit::WebInspectorUIExtensionControllerProxy&);
+
WTF::String m_identifier;
+ WeakPtr<WebKit::WebInspectorUIExtensionControllerProxy> m_extensionControllerProxy;
};
} // namespace API
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKInspector.mm (270605 => 270606)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKInspector.mm 2020-12-09 23:01:08 UTC (rev 270605)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKInspector.mm 2020-12-09 23:08:25 UTC (rev 270606)
@@ -207,7 +207,7 @@
return;
}
- capturedBlock(nil, [[wrapper(API::InspectorExtension::create(protectedExtensionID.get())) retain] autorelease]);
+ capturedBlock(nil, [[wrapper(API::InspectorExtension::create(protectedExtensionID.get(), protectedSelf->_inspector->extensionController())) retain] autorelease]);
});
#else
completionHandler([NSError errorWithDomain:WKErrorDomain code:WKErrorUnknown userInfo:nil], nil);
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKInspectorExtension.h (270605 => 270606)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKInspectorExtension.h 2020-12-09 23:01:08 UTC (rev 270605)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKInspectorExtension.h 2020-12-09 23:08:25 UTC (rev 270606)
@@ -23,18 +23,35 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-#import <Foundation/Foundation.h>
+#pragma once
+
#import <WebKit/WKFoundation.h>
+#if TARGET_OS_OSX
+
+#import <Foundation/Foundation.h>
+
NS_ASSUME_NONNULL_BEGIN
WK_CLASS_AVAILABLE(macos(WK_MAC_TBA))
@interface _WKInspectorExtension : NSObject
+- (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
+/**
+ * @abstract Creates a new tab in the Web Inspector interface for this extension.
+ * @param tabName A localized display name for the tab.
+ * @param tabIconURL The location of an image resource to use for display in the created tab's title.
+ * @param sourceURL The location of the main resource to load in the new tab's iframe browsing context.
+ * @param completionHandler The completion handler to be called when creating a tab succeeds or fails.
+ */
+- (void)createTabWithName:(NSString *)tabName tabIconURL:(NSURL *)tabIconURL sourceURL:(NSURL *)sourceURL completionHandler:(void(^)(NSError * _Nullable, NSString * _Nullable inspectorTabID))completionHandler;
+
@property (readonly, nonatomic) NSString *extensionID;
@end
NS_ASSUME_NONNULL_END
+
+#endif // TARGET_OS_OSX
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKInspectorExtension.mm (270605 => 270606)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKInspectorExtension.mm 2020-12-09 23:01:08 UTC (rev 270605)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKInspectorExtension.mm 2020-12-09 23:08:25 UTC (rev 270606)
@@ -26,22 +26,10 @@
#import "config.h"
#import "_WKInspectorExtensionInternal.h"
-NS_ASSUME_NONNULL_BEGIN
+#if ENABLE(INSPECTOR_EXTENSIONS)
@implementation _WKInspectorExtension
-#if ENABLE(INSPECTOR_EXTENSIONS)
-
-- (instancetype)initWithIdentifier:(NSString *)extensionID
-{
- if (!(self = [super init]))
- return nil;
-
- API::Object::constructInWrapper<API::InspectorExtension>(self, extensionID);
-
- return self;
-}
-
- (void)dealloc
{
_extension->API::InspectorExtension::~InspectorExtension();
@@ -49,12 +37,25 @@
[super dealloc];
}
-
- (API::Object&)_apiObject
{
return *_extension;
}
+// MARK: API
+
+- (void)createTabWithName:(NSString *)tabName tabIconURL:(NSURL *)tabIconURL sourceURL:(NSURL *)sourceURL completionHandler:(void(^)(NSError *, NSString *))completionHandler
+{
+ _extension->createTab(tabName, tabIconURL, sourceURL, [protectedSelf = retainPtr(self), capturedBlock = makeBlockPtr(completionHandler)] (Expected<WebKit::InspectorExtensionTabID, WebKit::InspectorExtensionError> result) mutable {
+ if (!result) {
+ capturedBlock([NSError errorWithDomain:WKErrorDomain code:WKErrorUnknown userInfo:@{ NSLocalizedFailureReasonErrorKey: inspectorExtensionErrorToString(result.error())}], nil);
+ return;
+ }
+
+ capturedBlock(nil, result.value());
+ });
+}
+
// MARK: Properties.
- (NSString *)extensionID
@@ -62,8 +63,6 @@
return _extension->identifier();
}
-#endif // ENABLE(INSPECTOR_EXTENSIONS)
-
@end
-NS_ASSUME_NONNULL_END
+#endif // ENABLE(INSPECTOR_EXTENSIONS)
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKInspectorExtensionInternal.h (270605 => 270606)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKInspectorExtensionInternal.h 2020-12-09 23:01:08 UTC (rev 270605)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKInspectorExtensionInternal.h 2020-12-09 23:08:25 UTC (rev 270606)
@@ -38,17 +38,11 @@
} // namespace WebKit
-NS_ASSUME_NONNULL_BEGIN
-
@interface _WKInspectorExtension () <WKObject> {
@package
API::ObjectStorage<API::InspectorExtension> _extension;
}
-- (instancetype)initWithIdentifier:(NSString *)extensionIdentifier;
-
@end
-NS_ASSUME_NONNULL_END
-
#endif // ENABLE(INSPECTOR_EXTENSIONS)
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKRemoteWebInspectorViewController.mm (270605 => 270606)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKRemoteWebInspectorViewController.mm 2020-12-09 23:01:08 UTC (rev 270605)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKRemoteWebInspectorViewController.mm 2020-12-09 23:08:25 UTC (rev 270606)
@@ -24,7 +24,7 @@
*/
#import "config.h"
-#import "_WKRemoteWebInspectorViewControllerPrivate.h"
+#import "_WKRemoteWebInspectorViewControllerInternal.h"
#if PLATFORM(MAC)
@@ -87,7 +87,6 @@
} // namespace WebKit
@implementation _WKRemoteWebInspectorViewController {
- RefPtr<WebKit::RemoteWebInspectorProxy> m_remoteInspectorProxy;
std::unique_ptr<WebKit::_WKRemoteWebInspectorProxyClient> m_remoteInspectorClient;
_WKInspectorConfiguration *_configuration;
}
@@ -201,7 +200,7 @@
return;
}
- capturedBlock(nil, [[wrapper(API::InspectorExtension::create(protectedExtensionID.get())) retain] autorelease]);
+ capturedBlock(nil, [[wrapper(API::InspectorExtension::create(protectedExtensionID.get(), protectedSelf->m_remoteInspectorProxy->extensionController())) retain] autorelease]);
});
#else
completionHandler([NSError errorWithDomain:WKErrorDomain code:WKErrorUnknown userInfo:nil], nil);
Copied: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKRemoteWebInspectorViewControllerInternal.h (from rev 270605, trunk/Source/WebKit/UIProcess/API/Cocoa/_WKInspectorExtension.h) (0 => 270606)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKRemoteWebInspectorViewControllerInternal.h (rev 0)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKRemoteWebInspectorViewControllerInternal.h 2020-12-09 23:08:25 UTC (rev 270606)
@@ -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.
+ */
+
+#import "_WKRemoteWebInspectorViewControllerPrivate.h"
+
+#if !TARGET_OS_IPHONE
+
+namespace WebKit {
+class RemoteWebInspectorProxy;
+}
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface _WKRemoteWebInspectorViewController () {
+@package
+ RefPtr<WebKit::RemoteWebInspectorProxy> m_remoteInspectorProxy;
+}
+@end
+
+NS_ASSUME_NONNULL_END
+
+#endif // !TARGET_OS_IPHONE
Modified: trunk/Source/WebKit/UIProcess/Inspector/WebInspectorUIExtensionControllerProxy.cpp (270605 => 270606)
--- trunk/Source/WebKit/UIProcess/Inspector/WebInspectorUIExtensionControllerProxy.cpp 2020-12-09 23:01:08 UTC (rev 270605)
+++ trunk/Source/WebKit/UIProcess/Inspector/WebInspectorUIExtensionControllerProxy.cpp 2020-12-09 23:08:25 UTC (rev 270606)
@@ -98,6 +98,18 @@
});
}
+void WebInspectorUIExtensionControllerProxy::createTabForExtension(const InspectorExtensionID& extensionID, const String& tabName, const URL& tabIconURL, const URL& sourceURL, WTF::CompletionHandler<void(Expected<InspectorExtensionTabID, InspectorExtensionError>)>&& completionHandler)
+{
+ whenFrontendHasLoaded([weakThis = makeWeakPtr(this), extensionID, tabName, tabIconURL, sourceURL, completionHandler = WTFMove(completionHandler)] () mutable {
+ if (!weakThis || !weakThis->m_inspectorPage) {
+ completionHandler(makeUnexpected(InspectorExtensionError::InvalidRequest));
+ return;
+ }
+
+ weakThis->m_inspectorPage->sendWithAsyncReply(Messages::WebInspectorUIExtensionController::CreateTabForExtension { extensionID, tabName, tabIconURL, sourceURL }, WTFMove(completionHandler));
+ });
+}
+
} // namespace WebKit
#endif // ENABLE(INSPECTOR_EXTENSIONS)
Modified: trunk/Source/WebKit/UIProcess/Inspector/WebInspectorUIExtensionControllerProxy.h (270605 => 270606)
--- trunk/Source/WebKit/UIProcess/Inspector/WebInspectorUIExtensionControllerProxy.h 2020-12-09 23:01:08 UTC (rev 270605)
+++ trunk/Source/WebKit/UIProcess/Inspector/WebInspectorUIExtensionControllerProxy.h 2020-12-09 23:08:25 UTC (rev 270606)
@@ -49,6 +49,7 @@
// API.
void registerExtension(const InspectorExtensionID&, const String& displayName, WTF::CompletionHandler<void(Expected<bool, InspectorExtensionError>)>&&);
void unregisterExtension(const InspectorExtensionID&, WTF::CompletionHandler<void(Expected<bool, InspectorExtensionError>)>&&);
+ void createTabForExtension(const InspectorExtensionID&, const String& tabName, const URL& tabIconURL, const URL& sourceURL, WTF::CompletionHandler<void(Expected<InspectorExtensionTabID, InspectorExtensionError>)>&&);
// Notifications.
void inspectorFrontendLoaded();
Modified: trunk/Source/WebKit/UIProcess/RemoteLayerTree/mac/ScrollingTreeOverflowScrollingNodeRemoteMac.h (270605 => 270606)
--- trunk/Source/WebKit/UIProcess/RemoteLayerTree/mac/ScrollingTreeOverflowScrollingNodeRemoteMac.h 2020-12-09 23:01:08 UTC (rev 270605)
+++ trunk/Source/WebKit/UIProcess/RemoteLayerTree/mac/ScrollingTreeOverflowScrollingNodeRemoteMac.h 2020-12-09 23:08:25 UTC (rev 270606)
@@ -44,7 +44,7 @@
ScrollingTreeOverflowScrollingNodeRemoteMac(WebCore::ScrollingTree&, WebCore::ScrollingNodeID);
void commitStateBeforeChildren(const WebCore::ScrollingStateNode&) override;
- WebCore::WheelEventHandlingResult handleWheelEvent(const WebCore::PlatformWheelEvent&, EventTargeting) override;
+ WebCore::WheelEventHandlingResult handleWheelEvent(const WebCore::PlatformWheelEvent&, WebCore::EventTargeting) override;
void repositionRelatedLayers() override;
std::unique_ptr<ScrollerPairMac> m_scrollerPair;
Modified: trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj (270605 => 270606)
--- trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj 2020-12-09 23:01:08 UTC (rev 270605)
+++ trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj 2020-12-09 23:08:25 UTC (rev 270606)
@@ -4738,6 +4738,7 @@
99996A9D25004BCB004F7559 /* _WKInspectorPrivateForTesting.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKInspectorPrivateForTesting.h; sourceTree = "<group>"; };
99996A9E25004BCB004F7559 /* _WKInspectorTesting.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = _WKInspectorTesting.mm; sourceTree = "<group>"; };
999B7ED82550E4A800F450A4 /* InspectorExtensionTypes.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = InspectorExtensionTypes.cpp; sourceTree = "<group>"; };
+ 999B7F4F2554BA3F00F450A4 /* APIInspectorExtension.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = APIInspectorExtension.cpp; sourceTree = "<group>"; };
99B16754252BB7E00073140E /* _WKInspectorExtension.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKInspectorExtension.h; sourceTree = "<group>"; };
99B16755252BB7E10073140E /* _WKInspectorExtensionInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKInspectorExtensionInternal.h; sourceTree = "<group>"; };
99B16756252BB7E10073140E /* _WKInspectorExtension.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = _WKInspectorExtension.mm; sourceTree = "<group>"; };
@@ -9655,6 +9656,7 @@
9197940923DBC4E000257892 /* APIInspectorClient.h */,
994C6048253F820200BDF060 /* APIInspectorConfiguration.cpp */,
994C6046253CACB800BDF060 /* APIInspectorConfiguration.h */,
+ 999B7F4F2554BA3F00F450A4 /* APIInspectorExtension.cpp */,
99BE3B1225422F4100C6551C /* APIInspectorExtension.h */,
31B362902141EABC007BFA53 /* APIInternalDebugFeature.cpp */,
31B3628E2141EA4D007BFA53 /* APIInternalDebugFeature.h */,
Modified: trunk/Source/WebKit/WebProcess/Inspector/WebInspectorUIExtensionController.cpp (270605 => 270606)
--- trunk/Source/WebKit/WebProcess/Inspector/WebInspectorUIExtensionController.cpp 2020-12-09 23:01:08 UTC (rev 270605)
+++ trunk/Source/WebKit/WebProcess/Inspector/WebInspectorUIExtensionController.cpp 2020-12-09 23:08:25 UTC (rev 270606)
@@ -56,7 +56,7 @@
Optional<InspectorExtensionError> WebInspectorUIExtensionController::parseInspectorExtensionErrorFromEvaluationResult(InspectorFrontendAPIDispatcher::EvaluationResult result)
{
- if (!result.has_value()) {
+ if (!result) {
switch (result.error()) {
case WebCore::InspectorFrontendAPIDispatcher::EvaluationError::ContextDestroyed:
return InspectorExtensionError::ContextDestroyed;
@@ -149,6 +149,61 @@
});
}
+JSC::JSObject* WebInspectorUIExtensionController::unwrapEvaluationResultAsObject(InspectorFrontendAPIDispatcher::EvaluationResult result)
+{
+ if (!result)
+ return nullptr;
+
+ auto valueOrException = result.value();
+ if (!valueOrException.has_value())
+ return nullptr;
+
+ return valueOrException.value().getObject();
+}
+
+void WebInspectorUIExtensionController::createTabForExtension(const InspectorExtensionID& extensionID, const String& tabName, const URL& tabIconURL, const URL& sourceURL, WTF::CompletionHandler<void(Expected<InspectorExtensionTabID, InspectorExtensionError>)>&& completionHandler)
+{
+ if (!m_frontendClient) {
+ completionHandler(makeUnexpected(InspectorExtensionError::InvalidRequest));
+ return;
+ }
+
+ Vector<Ref<JSON::Value>> arguments {
+ JSON::Value::create(extensionID),
+ JSON::Value::create(tabName),
+ JSON::Value::create(tabIconURL.string()),
+ JSON::Value::create(sourceURL.string()),
+ };
+ m_frontendClient->frontendAPIDispatcher().dispatchCommandWithResultAsync("createTabForExtension"_s, WTFMove(arguments), [weakThis = makeWeakPtr(this), completionHandler = WTFMove(completionHandler)](InspectorFrontendAPIDispatcher::EvaluationResult&& result) mutable {
+ if (!weakThis || !result) {
+ completionHandler(makeUnexpected(InspectorExtensionError::ContextDestroyed));
+ return;
+ }
+
+ if (auto parsedError = weakThis->parseInspectorExtensionErrorFromEvaluationResult(result.value())) {
+ completionHandler(makeUnexpected(parsedError.value()));
+ return;
+ }
+
+ // Expected result is either an ErrorString or {extensionTabID: <string>}.
+ auto objectResult = weakThis->unwrapEvaluationResultAsObject(result);
+ if (!objectResult) {
+ LOG(Inspector, "Unexpected non-object value returned from InspectorFrontendAPI.createTabForExtension().");
+ completionHandler(makeUnexpected(InspectorExtensionError::InternalError));
+ return;
+ }
+
+ auto* frontendGlobalObject = weakThis->m_frontendClient->frontendAPIDispatcher().frontendGlobalObject();
+ JSC::JSValue foundProperty = objectResult->get(frontendGlobalObject, JSC::Identifier::fromString(frontendGlobalObject->vm(), "extensionTabID"_s));
+ if (!foundProperty || !foundProperty.isString()) {
+ completionHandler(makeUnexpected(InspectorExtensionError::InternalError));
+ return;
+ }
+
+ completionHandler({ foundProperty.toWTFString(frontendGlobalObject) });
+ });
+}
+
} // namespace WebKit
#endif // ENABLE(INSPECTOR_EXTENSIONS)
Modified: trunk/Source/WebKit/WebProcess/Inspector/WebInspectorUIExtensionController.h (270605 => 270606)
--- trunk/Source/WebKit/WebProcess/Inspector/WebInspectorUIExtensionController.h 2020-12-09 23:01:08 UTC (rev 270605)
+++ trunk/Source/WebKit/WebProcess/Inspector/WebInspectorUIExtensionController.h 2020-12-09 23:08:25 UTC (rev 270606)
@@ -64,8 +64,10 @@
// WebInspectorUIExtensionController IPC messages.
void registerExtension(const InspectorExtensionID&, const String& displayName, CompletionHandler<void(Expected<bool, InspectorExtensionError>)>&&);
void unregisterExtension(const InspectorExtensionID&, CompletionHandler<void(Expected<bool, InspectorExtensionError>)>&&);
+ void createTabForExtension(const InspectorExtensionID&, const String& tabName, const URL& tabIconURL, const URL& sourceURL, WTF::CompletionHandler<void(Expected<InspectorExtensionTabID, InspectorExtensionError>)>&&);
private:
+ JSC::JSObject* unwrapEvaluationResultAsObject(WebCore::InspectorFrontendAPIDispatcher::EvaluationResult);
Optional<InspectorExtensionError> parseInspectorExtensionErrorFromEvaluationResult(WebCore::InspectorFrontendAPIDispatcher::EvaluationResult);
WeakPtr<WebCore::InspectorFrontendClient> m_frontendClient;
Modified: trunk/Source/WebKit/WebProcess/Inspector/WebInspectorUIExtensionController.messages.in (270605 => 270606)
--- trunk/Source/WebKit/WebProcess/Inspector/WebInspectorUIExtensionController.messages.in 2020-12-09 23:01:08 UTC (rev 270605)
+++ trunk/Source/WebKit/WebProcess/Inspector/WebInspectorUIExtensionController.messages.in 2020-12-09 23:08:25 UTC (rev 270606)
@@ -25,6 +25,8 @@
messages -> WebInspectorUIExtensionController NotRefCounted {
RegisterExtension(String extensionID, String displayName) -> (Expected<bool, WebKit::InspectorExtensionError> result) Async
UnregisterExtension(String extensionID) -> (Expected<bool, WebKit::InspectorExtensionError> result) Async
+
+ CreateTabForExtension(String extensionID, String tabName, URL tabIconURL, URL sourceURL) -> (Expected<String, WebKit::InspectorExtensionError> result) Async
}
#endif // ENABLE(INSPECTOR_EXTENSIONS)