Title: [252637] trunk/Source
Revision
252637
Author
[email protected]
Date
2019-11-19 10:41:31 -0800 (Tue, 19 Nov 2019)

Log Message

[Cocoa] Add _WKInspector SPI to set diagnostic logging delegate for a local Web Inspector
https://bugs.webkit.org/show_bug.cgi?id=204323

Reviewed by Devin Rousso.

Source/WebInspectorUI:

* UserInterface/Protocol/InspectorFrontendAPI.js:
(InspectorFrontendAPI.setDiagnosticLoggingAvailable):
Add a stub FrontendAPI method to be filled in later.

Source/WebKit:

Testing this end-to-end isn't quite possible yet because WebInspectorUI does not
yet send any dummy diagnostic events that we can use for testing purposes.

* WebKit.xcodeproj/project.pbxproj:

* UIProcess/API/Cocoa/_WKInspectorInternal.h: Fix include.
* UIProcess/API/Cocoa/_WKInspectorPrivate.h: Added.
* UIProcess/API/Cocoa/_WKInspector.mm: Fix include.
(-[_WKInspector _setDiagnosticLoggingDelegate:]):
Allow clients to set the diagnosticLoggingDelegate directly on _WKInspector.
The implementation forwards this setter to the Inspector's WKWebView and notifies
the frontend that diagnostic logging availability did change.

* UIProcess/WebInspectorProxy.h:
* UIProcess/WebInspectorProxy.cpp:
(WebKit::WebInspectorProxy::setDiagnosticLoggingAvailable):
Plumbing.

* WebProcess/WebPage/WebInspectorUI.cpp:
(WebKit::WebInspectorUI::setDiagnosticLoggingAvailable):
* WebProcess/WebPage/WebInspectorUI.h:
* WebProcess/WebPage/WebInspectorUI.messages.in:
More plumbing.

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebInspectorUI/ChangeLog (252636 => 252637)


--- trunk/Source/WebInspectorUI/ChangeLog	2019-11-19 18:23:18 UTC (rev 252636)
+++ trunk/Source/WebInspectorUI/ChangeLog	2019-11-19 18:41:31 UTC (rev 252637)
@@ -1,3 +1,14 @@
+2019-11-19  Brian Burg  <[email protected]>
+
+        [Cocoa] Add _WKInspector SPI to set diagnostic logging delegate for a local Web Inspector
+        https://bugs.webkit.org/show_bug.cgi?id=204323
+
+        Reviewed by Devin Rousso.
+
+        * UserInterface/Protocol/InspectorFrontendAPI.js:
+        (InspectorFrontendAPI.setDiagnosticLoggingAvailable):
+        Add a stub FrontendAPI method to be filled in later.
+
 2019-11-18  Devin Rousso  <[email protected]>
 
         Web Inspector: Elements: copying multiple DOM nodes should copy more than just the last selected node

Modified: trunk/Source/WebInspectorUI/UserInterface/Protocol/InspectorFrontendAPI.js (252636 => 252637)


--- trunk/Source/WebInspectorUI/UserInterface/Protocol/InspectorFrontendAPI.js	2019-11-19 18:23:18 UTC (rev 252636)
+++ trunk/Source/WebInspectorUI/UserInterface/Protocol/InspectorFrontendAPI.js	2019-11-19 18:41:31 UTC (rev 252637)
@@ -75,6 +75,11 @@
         WI.updateVisibilityState(visible);
     },
 
+    setDiagnosticLoggingAvailable: function(available)
+    {
+        // FIXME: update diagnostic availability and start/stop diagnostic recorders.
+    },
+
     showConsole: function()
     {
         WI.showConsoleTab();

Modified: trunk/Source/WebKit/ChangeLog (252636 => 252637)


--- trunk/Source/WebKit/ChangeLog	2019-11-19 18:23:18 UTC (rev 252636)
+++ trunk/Source/WebKit/ChangeLog	2019-11-19 18:41:31 UTC (rev 252637)
@@ -1,3 +1,34 @@
+2019-11-19  Brian Burg  <[email protected]>
+
+        [Cocoa] Add _WKInspector SPI to set diagnostic logging delegate for a local Web Inspector
+        https://bugs.webkit.org/show_bug.cgi?id=204323
+
+        Reviewed by Devin Rousso.
+
+        Testing this end-to-end isn't quite possible yet because WebInspectorUI does not
+        yet send any dummy diagnostic events that we can use for testing purposes.
+
+        * WebKit.xcodeproj/project.pbxproj:
+
+        * UIProcess/API/Cocoa/_WKInspectorInternal.h: Fix include.
+        * UIProcess/API/Cocoa/_WKInspectorPrivate.h: Added.
+        * UIProcess/API/Cocoa/_WKInspector.mm: Fix include.
+        (-[_WKInspector _setDiagnosticLoggingDelegate:]):
+        Allow clients to set the diagnosticLoggingDelegate directly on _WKInspector.
+        The implementation forwards this setter to the Inspector's WKWebView and notifies
+        the frontend that diagnostic logging availability did change.
+
+        * UIProcess/WebInspectorProxy.h:
+        * UIProcess/WebInspectorProxy.cpp:
+        (WebKit::WebInspectorProxy::setDiagnosticLoggingAvailable):
+        Plumbing.
+
+        * WebProcess/WebPage/WebInspectorUI.cpp:
+        (WebKit::WebInspectorUI::setDiagnosticLoggingAvailable):
+        * WebProcess/WebPage/WebInspectorUI.h:
+        * WebProcess/WebPage/WebInspectorUI.messages.in:
+        More plumbing.
+
 2019-11-19  Chris Dumez  <[email protected]>
 
         Make sendWithAsyncReply() safe to call from any thread

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKInspector.mm (252636 => 252637)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKInspector.mm	2019-11-19 18:23:18 UTC (rev 252636)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKInspector.mm	2019-11-19 18:41:31 UTC (rev 252637)
@@ -24,18 +24,19 @@
  */
 
 #import "config.h"
-#import "_WKInspector.h"
+#import "_WKInspectorInternal.h"
 
 #import "WKWebViewInternal.h"
 #import "WebPageProxy.h"
 #import "WebProcessProxy.h"
 #import "_WKFrameHandleInternal.h"
-#import "_WKInspectorInternal.h"
 #import <WebCore/FrameIdentifier.h>
 #import <wtf/RetainPtr.h>
 
 @implementation _WKInspector
 
+// MARK: _WKInspector methods
+
 - (WKWebView *)webView
 {
     if (auto* page = _inspector->inspectedPage())
@@ -130,6 +131,16 @@
     [self.webView evaluateJavaScript:[NSString stringWithFormat:@"console.error(\"%@\");", error] completionHandler:nil];
 }
 
+// MARK: _WKInspectorPrivate methods
+
+- (void)_setDiagnosticLoggingDelegate:(id<_WKDiagnosticLoggingDelegate>)delegate
+{
+    self.webView._diagnosticLoggingDelegate = delegate;
+    _inspector->setDiagnosticLoggingAvailable(!!delegate);
+}
+
+// MARK: _WKInspectorInternal methods
+
 - (API::Object&)_apiObject
 {
     return *_inspector;

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKInspectorInternal.h (252636 => 252637)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKInspectorInternal.h	2019-11-19 18:23:18 UTC (rev 252636)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKInspectorInternal.h	2019-11-19 18:41:31 UTC (rev 252637)
@@ -23,7 +23,7 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#import "_WKInspector.h"
+#import "_WKInspectorPrivate.h"
 
 #import "WKObject.h"
 #import "WebInspectorProxy.h"

Copied: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKInspectorPrivate.h (from rev 252636, trunk/Source/WebKit/UIProcess/API/Cocoa/_WKInspectorInternal.h) (0 => 252637)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKInspectorPrivate.h	                        (rev 0)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKInspectorPrivate.h	2019-11-19 18:41:31 UTC (rev 252637)
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2019 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 "_WKInspector.h"
+
+@protocol _WKDiagnosticLoggingDelegate;
+
+@interface _WKInspector (WKPrivate)
+
+@property (nonatomic, weak, setter=_setDiagnosticLoggingDelegate:) id<_WKDiagnosticLoggingDelegate> _diagnosticLoggingDelegate;
+
+@end

Modified: trunk/Source/WebKit/UIProcess/WebInspectorProxy.cpp (252636 => 252637)


--- trunk/Source/WebKit/UIProcess/WebInspectorProxy.cpp	2019-11-19 18:23:18 UTC (rev 252636)
+++ trunk/Source/WebKit/UIProcess/WebInspectorProxy.cpp	2019-11-19 18:41:31 UTC (rev 252637)
@@ -610,6 +610,15 @@
 #endif
 }
 
+void WebInspectorProxy::setDiagnosticLoggingAvailable(bool available)
+{
+#if ENABLE(INSPECTOR_TELEMETRY)
+    m_inspectorPage->process().send(Messages::WebInspectorUI::SetDiagnosticLoggingAvailable(available), m_inspectorPage->webPageID());
+#else
+    UNUSED_PARAM(available);
+#endif
+}
+
 void WebInspectorProxy::save(const String& filename, const String& content, bool base64Encoded, bool forceSaveAs)
 {
     platformSave(filename, content, base64Encoded, forceSaveAs);

Modified: trunk/Source/WebKit/UIProcess/WebInspectorProxy.h (252636 => 252637)


--- trunk/Source/WebKit/UIProcess/WebInspectorProxy.h	2019-11-19 18:23:18 UTC (rev 252636)
+++ trunk/Source/WebKit/UIProcess/WebInspectorProxy.h	2019-11-19 18:41:31 UTC (rev 252637)
@@ -158,6 +158,8 @@
 
     bool isUnderTest() const { return m_underTest; }
 
+    void setDiagnosticLoggingAvailable(bool);
+
     // Provided by platform WebInspectorProxy implementations.
     static String inspectorPageURL();
     static String inspectorTestPageURL();

Modified: trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj (252636 => 252637)


--- trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2019-11-19 18:23:18 UTC (rev 252636)
+++ trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2019-11-19 18:41:31 UTC (rev 252637)
@@ -1332,6 +1332,7 @@
 		9955A6F61C7986E300EB6A93 /* AutomationProtocolObjects.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9955A6F21C79866400EB6A93 /* AutomationProtocolObjects.cpp */; };
 		9955A6F71C7986E500EB6A93 /* AutomationProtocolObjects.h in Headers */ = {isa = PBXBuildFile; fileRef = 9955A6F31C79866400EB6A93 /* AutomationProtocolObjects.h */; };
 		99788ACB1F421DDA00C08000 /* _WKAutomationSessionConfiguration.h in Headers */ = {isa = PBXBuildFile; fileRef = 99788AC91F421DCA00C08000 /* _WKAutomationSessionConfiguration.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		9979CA58237F49F10039EC05 /* _WKInspectorPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 9979CA57237F49F00039EC05 /* _WKInspectorPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		99C3AE2D1DADA6AD00AF5C16 /* WebAutomationSessionMacros.h in Headers */ = {isa = PBXBuildFile; fileRef = 99C3AE2C1DADA6A700AF5C16 /* WebAutomationSessionMacros.h */; };
 		99C81D5A1C20E7E2005C4C82 /* AutomationClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 99C81D551C20DFBE005C4C82 /* AutomationClient.h */; };
 		99C81D5D1C21F38B005C4C82 /* APIAutomationClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 99C81D5B1C20E817005C4C82 /* APIAutomationClient.h */; };
@@ -4058,6 +4059,7 @@
 		9955A6F31C79866400EB6A93 /* AutomationProtocolObjects.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AutomationProtocolObjects.h; path = DerivedSources/WebKit2/AutomationProtocolObjects.h; sourceTree = BUILT_PRODUCTS_DIR; };
 		99788AC91F421DCA00C08000 /* _WKAutomationSessionConfiguration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKAutomationSessionConfiguration.h; sourceTree = "<group>"; };
 		99788ACA1F421DCA00C08000 /* _WKAutomationSessionConfiguration.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = _WKAutomationSessionConfiguration.mm; sourceTree = "<group>"; };
+		9979CA57237F49F00039EC05 /* _WKInspectorPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKInspectorPrivate.h; sourceTree = "<group>"; };
 		99C3AE231DAD8E3400AF5C16 /* WebAutomationSessionMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebAutomationSessionMac.mm; sourceTree = "<group>"; };
 		99C3AE261DAD948500AF5C16 /* WebAutomationSessionCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebAutomationSessionCocoa.mm; sourceTree = "<group>"; };
 		99C3AE2C1DADA6A700AF5C16 /* WebAutomationSessionMacros.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebAutomationSessionMacros.h; sourceTree = "<group>"; };
@@ -6353,6 +6355,7 @@
 				5CAFDE422130843500B1F7E1 /* _WKInspector.h */,
 				5CAFDE432130843600B1F7E1 /* _WKInspector.mm */,
 				5CAFDE442130843600B1F7E1 /* _WKInspectorInternal.h */,
+				9979CA57237F49F00039EC05 /* _WKInspectorPrivate.h */,
 				A5C0F0AA2000656E00536536 /* _WKInspectorWindow.h */,
 				A5C0F0A92000656E00536536 /* _WKInspectorWindow.mm */,
 				31B362942141EBAD007BFA53 /* _WKInternalDebugFeature.h */,
@@ -9303,6 +9306,7 @@
 				5C4609E7224317B4009943C2 /* _WKContentRuleListAction.h in Headers */,
 				5C4609E8224317BB009943C2 /* _WKContentRuleListActionInternal.h in Headers */,
 				1A5704F81BE01FF400874AF1 /* _WKContextMenuElementInfo.h in Headers */,
+				9979CA58237F49F10039EC05 /* _WKInspectorPrivate.h in Headers */,
 				5C5D238C227A2CDA000B9BDA /* _WKCustomHeaderFields.h in Headers */,
 				83891B691A68BEBC0030F386 /* _WKDiagnosticLoggingDelegate.h in Headers */,
 				A1A4FE5A18DCE9FA00B5EA8A /* _WKDownload.h in Headers */,

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebInspectorUI.cpp (252636 => 252637)


--- trunk/Source/WebKit/WebProcess/WebPage/WebInspectorUI.cpp	2019-11-19 18:23:18 UTC (rev 252636)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebInspectorUI.cpp	2019-11-19 18:41:31 UTC (rev 252637)
@@ -300,6 +300,11 @@
 {
     m_page.corePage()->diagnosticLoggingClient().logDiagnosticMessageWithValueDictionary(eventName, "Web Inspector Frontend Diagnostics"_s, dictionary, ShouldSample::No);
 }
+
+void WebInspectorUI::setDiagnosticLoggingAvailable(bool available)
+{
+    m_frontendAPIDispatcher.dispatchCommand("setDiagnosticLoggingAvailable"_s, available);
+}
 #endif
 
 void WebInspectorUI::showConsole()

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebInspectorUI.h (252636 => 252637)


--- trunk/Source/WebKit/WebProcess/WebPage/WebInspectorUI.h	2019-11-19 18:23:18 UTC (rev 252636)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebInspectorUI.h	2019-11-19 18:41:31 UTC (rev 252637)
@@ -119,6 +119,7 @@
 #if ENABLE(INSPECTOR_TELEMETRY)
     bool supportsDiagnosticLogging() override;
     void logDiagnosticEvent(const WTF::String& eventName, const WebCore::DiagnosticLoggingClient::ValueDictionary&) override;
+    void setDiagnosticLoggingAvailable(bool avaliable);
 #endif
 
     void sendMessageToBackend(const String&) override;

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebInspectorUI.messages.in (252636 => 252637)


--- trunk/Source/WebKit/WebProcess/WebPage/WebInspectorUI.messages.in	2019-11-19 18:23:18 UTC (rev 252636)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebInspectorUI.messages.in	2019-11-19 18:41:31 UTC (rev 252637)
@@ -31,6 +31,10 @@
     SetDockingUnavailable(bool unavailable)
     SetIsVisible(bool visible)
 
+#if ENABLE(INSPECTOR_TELEMETRY)
+    SetDiagnosticLoggingAvailable(bool available)
+#endif
+
     ShowConsole()
     ShowResources()
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to