Title: [273215] trunk/Source/WebKit
Revision
273215
Author
[email protected]
Date
2021-02-20 20:24:31 -0800 (Sat, 20 Feb 2021)

Log Message

[Cocoa] Web Inspector: expose the WKBrowsingContextHandle associated with Web Inspector's page
https://bugs.webkit.org/show_bug.cgi?id=222226

Reviewed by Timothy Hatcher.

In order to implement browser.devtools.inspectedWindow.tabId for Web Extensions,
we need a way to do a reverse lookup of the tabId using the current browsing context
controller (WKWebProcessPlugInBrowserContextController) in the injected bundle.

This patch exposes the browsing context handle for the underlying WKWebView that
hosts the inspector page. Clients can use this to precompute a tabId for each
inspector browsing context that may be encountered by injected bundle code.

* UIProcess/API/Cocoa/_WKInspectorPrivate.h:
* UIProcess/API/Cocoa/_WKInspector.mm:
(-[_WKInspector handle]): Added.

* WebProcess/InjectedBundle/mac/InjectedBundleMac.mm:
(WebKit::InjectedBundle::classesForCoder):
Drive-by, make it possible to use WKBrowsingContextHandle in injected bundle parameters.
This is easy because it conforms to NSSecureCoding and is simply a pageId + frameId.

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (273214 => 273215)


--- trunk/Source/WebKit/ChangeLog	2021-02-21 04:15:52 UTC (rev 273214)
+++ trunk/Source/WebKit/ChangeLog	2021-02-21 04:24:31 UTC (rev 273215)
@@ -1,3 +1,27 @@
+2021-02-20  BJ Burg  <[email protected]>
+
+        [Cocoa] Web Inspector: expose the WKBrowsingContextHandle associated with Web Inspector's page
+        https://bugs.webkit.org/show_bug.cgi?id=222226
+
+        Reviewed by Timothy Hatcher.
+
+        In order to implement browser.devtools.inspectedWindow.tabId for Web Extensions,
+        we need a way to do a reverse lookup of the tabId using the current browsing context
+        controller (WKWebProcessPlugInBrowserContextController) in the injected bundle.
+
+        This patch exposes the browsing context handle for the underlying WKWebView that
+        hosts the inspector page. Clients can use this to precompute a tabId for each
+        inspector browsing context that may be encountered by injected bundle code.
+
+        * UIProcess/API/Cocoa/_WKInspectorPrivate.h:
+        * UIProcess/API/Cocoa/_WKInspector.mm:
+        (-[_WKInspector handle]): Added.
+
+        * WebProcess/InjectedBundle/mac/InjectedBundleMac.mm:
+        (WebKit::InjectedBundle::classesForCoder):
+        Drive-by, make it possible to use WKBrowsingContextHandle in injected bundle parameters.
+        This is easy because it conforms to NSSecureCoding and is simply a pageId + frameId.
+
 2021-02-20  Chris Fleizach  <[email protected]>
 
         AX: Image should report the embedded accessibility description if available

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


--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKInspector.mm	2021-02-21 04:15:52 UTC (rev 273214)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKInspector.mm	2021-02-21 04:24:31 UTC (rev 273215)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2018 Apple Inc. All rights reserved.
+ * Copyright (C) 2018-2021 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -169,6 +169,11 @@
     _inspector->setDiagnosticLoggingAvailable(!!delegate);
 }
 
+- (WKBrowsingContextHandle *)handle
+{
+    return self.inspectorWebView._handle;
+}
+
 // MARK: _WKInspectorInternal methods
 
 - (API::Object&)_apiObject

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKInspectorPrivate.h (273214 => 273215)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKInspectorPrivate.h	2021-02-21 04:15:52 UTC (rev 273214)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKInspectorPrivate.h	2021-02-21 04:24:31 UTC (rev 273215)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2019 Apple Inc. All rights reserved.
+ * Copyright (C) 2019-2021 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -25,6 +25,7 @@
 
 #import "_WKInspector.h"
 
+@class WKBrowsingContextHandle;
 @protocol _WKDiagnosticLoggingDelegate;
 
 @interface _WKInspector (WKPrivate)
@@ -31,4 +32,11 @@
 
 @property (nonatomic, weak, setter=_setDiagnosticLoggingDelegate:) id<_WKDiagnosticLoggingDelegate> _diagnosticLoggingDelegate;
 
+/**
+ * @abstract The browsing context handle associated with Web Inspector's user interface.
+ * @discussion This can be used to identify the inspector page and any associated subframes
+ * from within the injected bundle.
+ */
+@property (nonatomic, readonly) WKBrowsingContextHandle *handle;
+
 @end

Modified: trunk/Source/WebKit/WebProcess/InjectedBundle/mac/InjectedBundleMac.mm (273214 => 273215)


--- trunk/Source/WebKit/WebProcess/InjectedBundle/mac/InjectedBundleMac.mm	2021-02-21 04:15:52 UTC (rev 273214)
+++ trunk/Source/WebKit/WebProcess/InjectedBundle/mac/InjectedBundleMac.mm	2021-02-21 04:24:31 UTC (rev 273215)
@@ -29,6 +29,7 @@
 #import "APIArray.h"
 #import "APIData.h"
 #import "ObjCObjectGraph.h"
+#import "WKBrowsingContextHandle.h"
 #import "WKBundleAPICast.h"
 #import "WKBundleInitialize.h"
 #import "WKWebProcessBundleParameters.h"
@@ -266,7 +267,7 @@
 NSSet* InjectedBundle::classesForCoder()
 {
     if (!m_classesForCoder)
-        m_classesForCoder = [NSSet setWithObjects:[NSArray class], [NSData class], [NSDate class], [NSDictionary class], [NSNull class], [NSNumber class], [NSSet class], [NSString class], [NSTimeZone class], [NSURL class], [NSUUID class], nil];
+        m_classesForCoder = [NSSet setWithObjects:[NSArray class], [NSData class], [NSDate class], [NSDictionary class], [NSNull class], [NSNumber class], [NSSet class], [NSString class], [NSTimeZone class], [NSURL class], [NSUUID class], [WKBrowsingContextHandle class], nil];
 
     return m_classesForCoder.get();
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to