Changeset 273215 in webkit


Ignore:
Timestamp:
Feb 20, 2021 8:24:31 PM (3 years ago)
Author:
BJ Burg
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.

Location:
trunk/Source/WebKit
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r273214 r273215  
     12021-02-20  BJ Burg  <bburg@apple.com>
     2
     3        [Cocoa] Web Inspector: expose the WKBrowsingContextHandle associated with Web Inspector's page
     4        https://bugs.webkit.org/show_bug.cgi?id=222226
     5
     6        Reviewed by Timothy Hatcher.
     7
     8        In order to implement browser.devtools.inspectedWindow.tabId for Web Extensions,
     9        we need a way to do a reverse lookup of the tabId using the current browsing context
     10        controller (WKWebProcessPlugInBrowserContextController) in the injected bundle.
     11
     12        This patch exposes the browsing context handle for the underlying WKWebView that
     13        hosts the inspector page. Clients can use this to precompute a tabId for each
     14        inspector browsing context that may be encountered by injected bundle code.
     15
     16        * UIProcess/API/Cocoa/_WKInspectorPrivate.h:
     17        * UIProcess/API/Cocoa/_WKInspector.mm:
     18        (-[_WKInspector handle]): Added.
     19
     20        * WebProcess/InjectedBundle/mac/InjectedBundleMac.mm:
     21        (WebKit::InjectedBundle::classesForCoder):
     22        Drive-by, make it possible to use WKBrowsingContextHandle in injected bundle parameters.
     23        This is easy because it conforms to NSSecureCoding and is simply a pageId + frameId.
     24
    1252021-02-20  Chris Fleizach  <cfleizach@apple.com>
    226
  • trunk/Source/WebKit/UIProcess/API/Cocoa/_WKInspector.mm

    r273128 r273215  
    11/*
    2  * Copyright (C) 2018 Apple Inc. All rights reserved.
     2 * Copyright (C) 2018-2021 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    170170}
    171171
     172- (WKBrowsingContextHandle *)handle
     173{
     174    return self.inspectorWebView._handle;
     175}
     176
    172177// MARK: _WKInspectorInternal methods
    173178
  • trunk/Source/WebKit/UIProcess/API/Cocoa/_WKInspectorPrivate.h

    r271424 r273215  
    11/*
    2  * Copyright (C) 2019 Apple Inc. All rights reserved.
     2 * Copyright (C) 2019-2021 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2626#import "_WKInspector.h"
    2727
     28@class WKBrowsingContextHandle;
    2829@protocol _WKDiagnosticLoggingDelegate;
    2930
     
    3233@property (nonatomic, weak, setter=_setDiagnosticLoggingDelegate:) id<_WKDiagnosticLoggingDelegate> _diagnosticLoggingDelegate;
    3334
     35/**
     36 * @abstract The browsing context handle associated with Web Inspector's user interface.
     37 * @discussion This can be used to identify the inspector page and any associated subframes
     38 * from within the injected bundle.
     39 */
     40@property (nonatomic, readonly) WKBrowsingContextHandle *handle;
     41
    3442@end
  • trunk/Source/WebKit/WebProcess/InjectedBundle/mac/InjectedBundleMac.mm

    r260215 r273215  
    3030#import "APIData.h"
    3131#import "ObjCObjectGraph.h"
     32#import "WKBrowsingContextHandle.h"
    3233#import "WKBundleAPICast.h"
    3334#import "WKBundleInitialize.h"
     
    267268{
    268269    if (!m_classesForCoder)
    269         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];
     270        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];
    270271
    271272    return m_classesForCoder.get();
Note: See TracChangeset for help on using the changeset viewer.