Title: [274697] trunk/Source/WebKit
Revision
274697
Author
[email protected]
Date
2021-03-18 19:37:52 -0700 (Thu, 18 Mar 2021)

Log Message

[Cocoa] Web Inspector: load inspector resources using a custom scheme handler
https://bugs.webkit.org/show_bug.cgi?id=179904
<rdar://problem/10887211>

Reviewed by Geoff Garen.

Load WebInspectorUI resources via the inspector-resource:// scheme.
Moving off of file:// URLs will allow for a tighter sandbox and
will fix the longstanding issue that Web Inspector's settings are
part of the file:// scheme and cleared when Safari clears website data.

This also has the effect of resetting Web Inspector settings since
they are no longer associated with file:///.

Loading via this scheme is exercised by existing inspector tests.

* SourcesCocoa.txt: Added new file.
* WebKit.xcodeproj/project.pbxproj:
* UIProcess/Inspector/mac/WKInspectorResourceURLSchemeHandler.h: Copied from Source/WebKit/WebProcess/Inspector/mac/WebInspectorUIMac.mm.
* UIProcess/Inspector/mac/WKInspectorResourceURLSchemeHandler.mm: Added.
(-[WKInspectorResourceURLSchemeHandler webView:startURLSchemeTask:]):
Use a global concurrent queue and NSOperation / NSOperationQueue to support
reading files off the main queue.

(-[WKInspectorResourceURLSchemeHandler webView:stopURLSchemeTask:]):
Translate the request URL to a bundle resource URL, read the data, and send a response
with the file data. Return an error if the file could not be found or read.

* UIProcess/Inspector/mac/WKInspectorViewController.h:
* UIProcess/Inspector/mac/WKInspectorViewController.mm:
(-[WKInspectorViewController webViewConfiguration]):
(+[WKInspectorViewController URLForInspectorResource:]):
(-[WKInspectorViewController webView:decidePolicyForNavigationAction:decisionHandler:]):
Allow navigations to URIs with the inspector-resource:// scheme.

* UIProcess/Inspector/mac/WebInspectorProxyMac.mm:
(WebKit::WebInspectorProxy::inspectorPageURL):
(WebKit::WebInspectorProxy::inspectorTestPageURL):
(WebKit::WebInspectorProxy::inspectorBaseURL):
Updated.

* WebProcess/Inspector/mac/WebInspectorUIMac.mm:
(WebKit::webInspectorUILocalizedStringsURL):
Updated.

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (274696 => 274697)


--- trunk/Source/WebKit/ChangeLog	2021-03-19 02:23:14 UTC (rev 274696)
+++ trunk/Source/WebKit/ChangeLog	2021-03-19 02:37:52 UTC (rev 274697)
@@ -1,3 +1,50 @@
+2021-03-18  BJ Burg  <[email protected]>
+
+        [Cocoa] Web Inspector: load inspector resources using a custom scheme handler
+        https://bugs.webkit.org/show_bug.cgi?id=179904
+        <rdar://problem/10887211>
+
+        Reviewed by Geoff Garen.
+
+        Load WebInspectorUI resources via the inspector-resource:// scheme.
+        Moving off of file:// URLs will allow for a tighter sandbox and
+        will fix the longstanding issue that Web Inspector's settings are
+        part of the file:// scheme and cleared when Safari clears website data.
+
+        This also has the effect of resetting Web Inspector settings since
+        they are no longer associated with file:///.
+
+        Loading via this scheme is exercised by existing inspector tests.
+
+        * SourcesCocoa.txt: Added new file.
+        * WebKit.xcodeproj/project.pbxproj:
+        * UIProcess/Inspector/mac/WKInspectorResourceURLSchemeHandler.h: Copied from Source/WebKit/WebProcess/Inspector/mac/WebInspectorUIMac.mm.
+        * UIProcess/Inspector/mac/WKInspectorResourceURLSchemeHandler.mm: Added.
+        (-[WKInspectorResourceURLSchemeHandler webView:startURLSchemeTask:]):
+        Use a global concurrent queue and NSOperation / NSOperationQueue to support
+        reading files off the main queue.
+
+        (-[WKInspectorResourceURLSchemeHandler webView:stopURLSchemeTask:]):
+        Translate the request URL to a bundle resource URL, read the data, and send a response
+        with the file data. Return an error if the file could not be found or read.
+
+        * UIProcess/Inspector/mac/WKInspectorViewController.h:
+        * UIProcess/Inspector/mac/WKInspectorViewController.mm:
+        (-[WKInspectorViewController webViewConfiguration]):
+        (+[WKInspectorViewController URLForInspectorResource:]):
+        (-[WKInspectorViewController webView:decidePolicyForNavigationAction:decisionHandler:]):
+        Allow navigations to URIs with the inspector-resource:// scheme.
+
+        * UIProcess/Inspector/mac/WebInspectorProxyMac.mm:
+        (WebKit::WebInspectorProxy::inspectorPageURL):
+        (WebKit::WebInspectorProxy::inspectorTestPageURL):
+        (WebKit::WebInspectorProxy::inspectorBaseURL):
+        Updated.
+
+        * WebProcess/Inspector/mac/WebInspectorUIMac.mm:
+        (WebKit::webInspectorUILocalizedStringsURL):
+        Updated.
+
 2021-03-18  Sihui Liu  <[email protected]>
 
         Handle empty bound size during animated resizing

Modified: trunk/Source/WebKit/SourcesCocoa.txt (274696 => 274697)


--- trunk/Source/WebKit/SourcesCocoa.txt	2021-03-19 02:23:14 UTC (rev 274696)
+++ trunk/Source/WebKit/SourcesCocoa.txt	2021-03-19 02:37:52 UTC (rev 274697)
@@ -429,6 +429,7 @@
 
 UIProcess/Inspector/mac/RemoteWebInspectorProxyMac.mm
 UIProcess/Inspector/mac/WebInspectorProxyMac.mm
+UIProcess/Inspector/mac/WKInspectorResourceURLSchemeHandler.mm
 UIProcess/Inspector/mac/WKInspectorViewController.mm
 UIProcess/Inspector/mac/WKInspectorWKWebView.mm
 

Copied: trunk/Source/WebKit/UIProcess/Inspector/mac/WKInspectorResourceURLSchemeHandler.h (from rev 274696, trunk/Source/WebKit/WebProcess/Inspector/mac/WebInspectorUIMac.mm) (0 => 274697)


--- trunk/Source/WebKit/UIProcess/Inspector/mac/WKInspectorResourceURLSchemeHandler.h	                        (rev 0)
+++ trunk/Source/WebKit/UIProcess/Inspector/mac/WKInspectorResourceURLSchemeHandler.h	2021-03-19 02:37:52 UTC (rev 274697)
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 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
+ * 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.
+ */
+
+#if PLATFORM(MAC)
+
+#import <WebKit/WKFoundation.h>
+#import <WebKit/WKURLSchemeHandler.h>
+
+@protocol WKInspectorViewControllerDelegate;
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface WKInspectorResourceURLSchemeHandler : NSObject <WKURLSchemeHandler>
+@end
+
+NS_ASSUME_NONNULL_END
+
+#endif // PLATFORM(MAC)

Added: trunk/Source/WebKit/UIProcess/Inspector/mac/WKInspectorResourceURLSchemeHandler.mm (0 => 274697)


--- trunk/Source/WebKit/UIProcess/Inspector/mac/WKInspectorResourceURLSchemeHandler.mm	                        (rev 0)
+++ trunk/Source/WebKit/UIProcess/Inspector/mac/WKInspectorResourceURLSchemeHandler.mm	2021-03-19 02:37:52 UTC (rev 274697)
@@ -0,0 +1,113 @@
+/*
+ * Copyright (C) 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
+ * 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 "WKInspectorResourceURLSchemeHandler.h"
+
+#if PLATFORM(MAC)
+
+#import "Logging.h"
+#import "WKURLSchemeTask.h"
+#import <WebCore/MIMETypeRegistry.h>
+#import <wtf/Assertions.h>
+
+@implementation WKInspectorResourceURLSchemeHandler {
+    RetainPtr<NSMapTable<id <WKURLSchemeTask>, NSOperation *>> _fileLoadOperations;
+    RetainPtr<NSBundle> _cachedBundle;
+    RetainPtr<NSOperationQueue> _operationQueue;
+}
+
+// MARK - WKURLSchemeHandler Protocol
+
+- (void)webView:(WKWebView *)webView startURLSchemeTask:(id <WKURLSchemeTask>)urlSchemeTask
+{
+    if (!_cachedBundle) {
+        _cachedBundle = [NSBundle bundleWithIdentifier:@"com.apple.WebInspectorUI"];
+
+        // It is an error if WebInspectorUI has not already been soft-linked by the time
+        // we load resources from it. And if soft-linking fails, we shouldn't start loads.
+        RELEASE_ASSERT(_cachedBundle);
+    }
+
+    if (!_fileLoadOperations)
+        _fileLoadOperations = [[NSMapTable alloc] initWithKeyOptions:NSPointerFunctionsStrongMemory valueOptions:NSPointerFunctionsStrongMemory capacity:5];
+
+    if (!_operationQueue) {
+        _operationQueue = [[NSOperationQueue alloc] init];
+        _operationQueue.get().underlyingQueue = dispatch_get_global_queue(QOS_CLASS_USER_INTERACTIVE, 0);
+        _operationQueue.get().qualityOfService = NSOperationQualityOfServiceUserInteractive;
+    }
+
+    NSBlockOperation *operation = [NSBlockOperation blockOperationWithBlock:^{
+        [_fileLoadOperations removeObjectForKey:urlSchemeTask];
+
+        NSURL *requestURL = urlSchemeTask.request.URL;
+        NSURL *fileURLForRequest = [_cachedBundle URLForResource:requestURL.relativePath withExtension:@""];
+        if (!fileURLForRequest) {
+            LOG_ERROR("Unable to find Web Inspector resource: %@", requestURL.absoluteString);
+            [urlSchemeTask didFailWithError:[NSError errorWithDomain:NSCocoaErrorDomain code:NSURLErrorFileDoesNotExist userInfo:nil]];
+            return;
+        }
+
+        NSError *readError;
+        NSData *fileData = [NSData dataWithContentsOfURL:fileURLForRequest options:0 error:&readError];
+        if (!fileData) {
+            LOG_ERROR("Unable to read data for Web Inspector resource: %@", requestURL.absoluteString);
+            [urlSchemeTask didFailWithError:[NSError errorWithDomain:NSCocoaErrorDomain code:NSURLErrorResourceUnavailable userInfo:@{
+                NSUnderlyingErrorKey: readError,
+            }]];
+            return;
+        }
+
+        NSString *mimeType = WebCore::MIMETypeRegistry::mimeTypeForExtension(fileURLForRequest.pathExtension);
+        if (!mimeType)
+            mimeType = @"application/octet-stream";
+
+        NSHTTPURLResponse *urlResponse = [[NSHTTPURLResponse alloc] initWithURL:urlSchemeTask.request.URL statusCode:200 HTTPVersion:nil headerFields:@{
+            @"Access-Control-Allow-Origin": @"*",
+            @"Content-Length": [NSString stringWithFormat:@"%zu", (size_t)fileData.length],
+            @"Content-Type": mimeType,
+        }];
+
+        [urlSchemeTask didReceiveResponse:urlResponse];
+        [urlSchemeTask didReceiveData:fileData];
+        [urlSchemeTask didFinish];
+    }];
+    
+    [_fileLoadOperations setObject:operation forKey:urlSchemeTask];
+    [_operationQueue addOperation:operation];
+}
+
+- (void)webView:(WKWebView *)webView stopURLSchemeTask:(id <WKURLSchemeTask>)urlSchemeTask
+{
+    if (NSOperation *operation = [_fileLoadOperations objectForKey:urlSchemeTask]) {
+        [operation cancel];
+        [_fileLoadOperations removeObjectForKey:urlSchemeTask];
+    }
+}
+
+@end
+
+#endif // PLATFORM(MAC)

Modified: trunk/Source/WebKit/UIProcess/Inspector/mac/WKInspectorViewController.h (274696 => 274697)


--- trunk/Source/WebKit/UIProcess/Inspector/mac/WKInspectorViewController.h	2021-03-19 02:23:14 UTC (rev 274696)
+++ trunk/Source/WebKit/UIProcess/Inspector/mac/WKInspectorViewController.h	2021-03-19 02:37:52 UTC (rev 274697)
@@ -47,6 +47,7 @@
 - (instancetype)initWithConfiguration:(_WKInspectorConfiguration *)configuration inspectedPage:(NakedPtr<WebKit::WebPageProxy>)inspectedPage;
 
 + (BOOL)viewIsInspectorWebView:(NSView *)view;
++ (NSURL * _Nullable)URLForInspectorResource:(NSString *)resource;
 
 @end
 

Modified: trunk/Source/WebKit/UIProcess/Inspector/mac/WKInspectorViewController.mm (274696 => 274697)


--- trunk/Source/WebKit/UIProcess/Inspector/mac/WKInspectorViewController.mm	2021-03-19 02:23:14 UTC (rev 274696)
+++ trunk/Source/WebKit/UIProcess/Inspector/mac/WKInspectorViewController.mm	2021-03-19 02:37:52 UTC (rev 274697)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2017-2020 Apple Inc. All rights reserved.
+ * Copyright (C) 2017-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
@@ -30,6 +30,7 @@
 
 #import "APINavigation.h"
 #import "WKFrameInfo.h"
+#import "WKInspectorResourceURLSchemeHandler.h"
 #import "WKInspectorWKWebView.h"
 #import "WKNavigationAction.h"
 #import "WKNavigationDelegate.h"
@@ -46,6 +47,8 @@
 #import <WebCore/VersionChecks.h>
 #import <wtf/WeakObjCPtr.h>
 
+static NSString * const WKInspectorResourceScheme = @"inspector-resource";
+
 @interface WKInspectorViewController () <WKUIDelegate, WKNavigationDelegate, WKInspectorWKWebViewDelegate>
 @end
 
@@ -110,7 +113,9 @@
 
 - (WKWebViewConfiguration *)webViewConfiguration
 {
-    auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
+    RetainPtr<WKWebViewConfiguration> configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
+    RetainPtr<WKInspectorResourceURLSchemeHandler> inspectorSchemeHandler = adoptNS([[WKInspectorResourceURLSchemeHandler alloc] init]);
+    [configuration setURLSchemeHandler:inspectorSchemeHandler.autorelease() forURLScheme:WKInspectorResourceScheme];
 
     WKPreferences *preferences = configuration.get().preferences;
     preferences._allowFileAccessFromFileURLs = YES;
@@ -160,6 +165,11 @@
     return [view isKindOfClass:[WKInspectorWKWebView class]];
 }
 
++ (NSURL *)URLForInspectorResource:(NSString *)resource
+{
+    return [NSURL URLWithString:[NSString stringWithFormat:@"%@:///%@", WKInspectorResourceScheme, resource]].URLByStandardizingPath;
+}
+
 // MARK: WKUIDelegate methods
 
 - (void)_webView:(WKWebView *)webView getWindowFrameWithCompletionHandler:(void (^)(CGRect))completionHandler
@@ -239,7 +249,7 @@
     }
 
     // Allow loading of the main inspector file.
-    if (WebKit::WebInspectorProxy::isMainOrTestInspectorPage(navigationAction.request.URL)) {
+    if ([navigationAction.request.URL.scheme isEqualToString:WKInspectorResourceScheme]) {
         decisionHandler(WKNavigationActionPolicyAllow);
         return;
     }

Modified: trunk/Source/WebKit/UIProcess/Inspector/mac/WebInspectorProxyMac.mm (274696 => 274697)


--- trunk/Source/WebKit/UIProcess/Inspector/mac/WebInspectorProxyMac.mm	2021-03-19 02:23:14 UTC (rev 274696)
+++ trunk/Source/WebKit/UIProcess/Inspector/mac/WebInspectorProxyMac.mm	2021-03-19 02:37:52 UTC (rev 274697)
@@ -779,42 +779,17 @@
 
 String WebInspectorProxy::inspectorPageURL()
 {
-    NSBundle *bundle = [NSBundle bundleWithIdentifier:@"com.apple.WebInspectorUI"];
-    if (!bundle)
-        return String();
-
-    NSString *path = [bundle pathForResource:@"Main" ofType:@"html"];
-    ASSERT(path && path.length);
-    if (!path)
-        return String();
-
-    return [NSURL fileURLWithPath:path isDirectory:NO].absoluteString;
+    return [WKInspectorViewController URLForInspectorResource:@"Main.html"].absoluteString;
 }
 
 String WebInspectorProxy::inspectorTestPageURL()
 {
-    NSBundle *bundle = [NSBundle bundleWithIdentifier:@"com.apple.WebInspectorUI"];
-    if (!bundle)
-        return String();
-
-    // We might not have a Test.html in Production builds.
-    NSString *path = [bundle pathForResource:@"Test" ofType:@"html"];
-    if (!path)
-        return String();
-
-    return [NSURL fileURLWithPath:path isDirectory:NO].absoluteString;
+    return [WKInspectorViewController URLForInspectorResource:@"Test.html"].absoluteString;
 }
 
 String WebInspectorProxy::inspectorBaseURL()
 {
-    NSBundle *bundle = [NSBundle bundleWithIdentifier:@"com.apple.WebInspectorUI"];
-    if (!bundle)
-        return String();
-
-    NSString *path = bundle.resourcePath;
-    ASSERT(path && path.length);
-
-    return [NSURL fileURLWithPath:path isDirectory:YES].absoluteString;
+    return [WKInspectorViewController URLForInspectorResource:@""].absoluteString;
 }
 
 static NSDictionary *systemVersionPlist()

Modified: trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj (274696 => 274697)


--- trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2021-03-19 02:23:14 UTC (rev 274696)
+++ trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2021-03-19 02:37:52 UTC (rev 274697)
@@ -1522,6 +1522,7 @@
 		997965A3253128C700B31AE3 /* _WKInspectorExtensionHost.h in Headers */ = {isa = PBXBuildFile; fileRef = 997965A2253128C700B31AE3 /* _WKInspectorExtensionHost.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		9979CA58237F49F10039EC05 /* _WKInspectorPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 9979CA57237F49F00039EC05 /* _WKInspectorPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		99996A9F25004BCC004F7559 /* _WKInspectorPrivateForTesting.h in Headers */ = {isa = PBXBuildFile; fileRef = 99996A9D25004BCB004F7559 /* _WKInspectorPrivateForTesting.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		99A7ACE526012922006D57FD /* WKInspectorResourceURLSchemeHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = 99A7ACE326012919006D57FD /* WKInspectorResourceURLSchemeHandler.h */; };
 		99B16757252BB7E10073140E /* _WKInspectorExtension.h in Headers */ = {isa = PBXBuildFile; fileRef = 99B16754252BB7E00073140E /* _WKInspectorExtension.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		99B16758252BB7E10073140E /* _WKInspectorExtensionInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 99B16755252BB7E10073140E /* _WKInspectorExtensionInternal.h */; };
 		99B1675B252BBADD0073140E /* WebInspectorUIExtensionControllerProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = 99B1675A252BBADD0073140E /* WebInspectorUIExtensionControllerProxy.h */; };
@@ -4894,6 +4895,8 @@
 		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>"; };
+		99A7ACE326012919006D57FD /* WKInspectorResourceURLSchemeHandler.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WKInspectorResourceURLSchemeHandler.h; sourceTree = "<group>"; };
+		99A7ACE42601291A006D57FD /* WKInspectorResourceURLSchemeHandler.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WKInspectorResourceURLSchemeHandler.mm; 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>"; };
@@ -9259,6 +9262,8 @@
 			children = (
 				A5D3504D1D78F0D2005124A9 /* RemoteWebInspectorProxyMac.mm */,
 				1CA8B935127C774E00576C2B /* WebInspectorProxyMac.mm */,
+				99A7ACE326012919006D57FD /* WKInspectorResourceURLSchemeHandler.h */,
+				99A7ACE42601291A006D57FD /* WKInspectorResourceURLSchemeHandler.mm */,
 				994BADF11F7D77EA00B571E7 /* WKInspectorViewController.h */,
 				994BADF21F7D77EB00B571E7 /* WKInspectorViewController.mm */,
 				A518B5D01FE1D55B00F9FA28 /* WKInspectorWKWebView.h */,
@@ -12590,6 +12595,7 @@
 				0F3C725B196F604E00AEDD0C /* WKInspectorHighlightView.h in Headers */,
 				A54293A4195A43DA002782C7 /* WKInspectorNodeSearchGestureRecognizer.h in Headers */,
 				6EE849C81368D9390038D481 /* WKInspectorPrivateMac.h in Headers */,
+				99A7ACE526012922006D57FD /* WKInspectorResourceURLSchemeHandler.h in Headers */,
 				994BADF41F7D781400B571E7 /* WKInspectorViewController.h in Headers */,
 				A518B5D21FE1D55B00F9FA28 /* WKInspectorWKWebView.h in Headers */,
 				2DD5E129210ADC7B00DB6012 /* WKKeyboardScrollingAnimator.h in Headers */,

Modified: trunk/Source/WebKit/WebProcess/Inspector/mac/WebInspectorUIMac.mm (274696 => 274697)


--- trunk/Source/WebKit/WebProcess/Inspector/mac/WebInspectorUIMac.mm	2021-03-19 02:23:14 UTC (rev 274696)
+++ trunk/Source/WebKit/WebProcess/Inspector/mac/WebInspectorUIMac.mm	2021-03-19 02:37:52 UTC (rev 274697)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010-2019 Apple Inc. All rights reserved.
+ * Copyright (C) 2010-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
@@ -26,6 +26,7 @@
 #import "config.h"
 #import "WebInspectorUI.h"
 #import "RemoteWebInspectorUI.h"
+#import "WKInspectorViewController.h"
 
 #if PLATFORM(MAC)
 
@@ -38,15 +39,7 @@
 
 static String webInspectorUILocalizedStringsURL()
 {
-    NSBundle *bundle = [NSBundle bundleWithIdentifier:@"com.apple.WebInspectorUI"];
-    if (!bundle)
-        return String();
-
-    NSString *path = [bundle pathForResource:@"localizedStrings" ofType:@"js"];
-    if (!path)
-        return String();
-    
-    return [NSURL fileURLWithPath:path isDirectory:NO].absoluteString;
+    return [WKInspectorViewController URLForInspectorResource:@"localizedStrings.js"].absoluteString;
 }
 
 String WebInspectorUI::localizedStringsURL() const
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to