Title: [276727] trunk
Revision
276727
Author
[email protected]
Date
2021-04-28 12:00:33 -0700 (Wed, 28 Apr 2021)

Log Message

Add SPI to query whether a URL would be upgraded to HTTPS
https://bugs.webkit.org/show_bug.cgi?id=225154
<rdar://77269904>

Reviewed by Geoff Garen.

Source/WebCore:

Covered by API tests.

* contentextensions/ContentExtensionsBackend.cpp:
(WebCore::ContentExtensions::ContentExtensionsBackend::shouldBeMadeSecure):
* contentextensions/ContentExtensionsBackend.h:

Source/WebKit:

* UIProcess/API/Cocoa/WKWebView.mm:
(+[WKWebView _shouldUpgradeToHTTPS:]):
* UIProcess/API/Cocoa/WKWebViewPrivate.h:

Tools:

* TestWebKitAPI/Tests/WebKitCocoa/WKWebViewConfiguration.mm:
(TEST):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (276726 => 276727)


--- trunk/Source/WebCore/ChangeLog	2021-04-28 18:53:12 UTC (rev 276726)
+++ trunk/Source/WebCore/ChangeLog	2021-04-28 19:00:33 UTC (rev 276727)
@@ -1,3 +1,17 @@
+2021-04-28  Alex Christensen  <[email protected]>
+
+        Add SPI to query whether a URL would be upgraded to HTTPS
+        https://bugs.webkit.org/show_bug.cgi?id=225154
+        <rdar://77269904>
+
+        Reviewed by Geoff Garen.
+
+        Covered by API tests.
+
+        * contentextensions/ContentExtensionsBackend.cpp:
+        (WebCore::ContentExtensions::ContentExtensionsBackend::shouldBeMadeSecure):
+        * contentextensions/ContentExtensionsBackend.h:
+
 2021-04-28  Basuke Suzuki  <[email protected]>
 
         [clang] Remove implicit cast related warnings

Modified: trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.cpp (276726 => 276727)


--- trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.cpp	2021-04-28 18:53:12 UTC (rev 276726)
+++ trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.cpp	2021-04-28 19:00:33 UTC (rev 276727)
@@ -71,6 +71,13 @@
 }
 #endif
 
+bool ContentExtensionsBackend::shouldBeMadeSecure(const URL& url)
+{
+    ContentRuleListResults results;
+    makeSecureIfNecessary(results, url);
+    return results.summary.madeHTTPS;
+}
+
 void ContentExtensionsBackend::addContentExtension(const String& identifier, Ref<CompiledContentExtension> compiledContentExtension, ContentExtension::ShouldCompileCSS shouldCompileCSS)
 {
     ASSERT(!identifier.isEmpty());

Modified: trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.h (276726 => 276727)


--- trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.h	2021-04-28 18:53:12 UTC (rev 276726)
+++ trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.h	2021-04-28 19:00:33 UTC (rev 276727)
@@ -70,6 +70,8 @@
 
     void forEach(const Function<void(const String&, ContentExtension&)>&);
 
+    WEBCORE_EXPORT static bool shouldBeMadeSecure(const URL&);
+
 private:
     HashMap<String, Ref<ContentExtension>> m_contentExtensions;
 };

Modified: trunk/Source/WebKit/ChangeLog (276726 => 276727)


--- trunk/Source/WebKit/ChangeLog	2021-04-28 18:53:12 UTC (rev 276726)
+++ trunk/Source/WebKit/ChangeLog	2021-04-28 19:00:33 UTC (rev 276727)
@@ -1,3 +1,15 @@
+2021-04-28  Alex Christensen  <[email protected]>
+
+        Add SPI to query whether a URL would be upgraded to HTTPS
+        https://bugs.webkit.org/show_bug.cgi?id=225154
+        <rdar://77269904>
+
+        Reviewed by Geoff Garen.
+
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (+[WKWebView _shouldUpgradeToHTTPS:]):
+        * UIProcess/API/Cocoa/WKWebViewPrivate.h:
+
 2021-04-28  Brent Fulgham  <[email protected]>
 
         [iOS] [GPU] The UI process should issue mach sandbox extensions to 'iconservices'

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (276726 => 276727)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2021-04-28 18:53:12 UTC (rev 276726)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2021-04-28 19:00:33 UTC (rev 276727)
@@ -124,6 +124,7 @@
 #import <WebCore/AttributedString.h>
 #import <WebCore/ColorCocoa.h>
 #import <WebCore/ColorSerialization.h>
+#import <WebCore/ContentExtensionsBackend.h>
 #import <WebCore/ElementContext.h>
 #import <WebCore/JSDOMBinding.h>
 #import <WebCore/JSDOMExceptionHandling.h>
@@ -2517,6 +2518,11 @@
     return true;
 }
 
++ (BOOL)_willUpgradeToHTTPS:(NSURL *)url
+{
+    return WebCore::ContentExtensions::ContentExtensionsBackend::shouldBeMadeSecure(url);
+}
+
 - (void)_showSafeBrowsingWarningWithTitle:(NSString *)title warning:(NSString *)warning details:(NSAttributedString *)details completionHandler:(void(^)(BOOL))completionHandler
 {
     [self _showSafeBrowsingWarningWithURL:nil title:title warning:warning detailsWithLinks:details completionHandler:^(BOOL continueUnsafeLoad, NSURL *url) {

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h (276726 => 276727)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h	2021-04-28 18:53:12 UTC (rev 276726)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h	2021-04-28 19:00:33 UTC (rev 276727)
@@ -246,6 +246,8 @@
 
 - (void)_simulateDeviceOrientationChangeWithAlpha:(double)alpha beta:(double)beta gamma:(double)gamma WK_API_AVAILABLE(macos(10.14.4), ios(12.2));
 
++ (BOOL)_willUpgradeToHTTPS:(NSURL *)url WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
+
 + (BOOL)_handlesSafeBrowsing WK_API_AVAILABLE(macos(10.14.4), ios(12.2));
 + (NSURL *)_confirmMalwareSentinel WK_API_AVAILABLE(macos(10.14.4), ios(12.2));
 + (NSURL *)_visitUnsafeWebsiteSentinel WK_API_AVAILABLE(macos(10.14.4), ios(12.2));

Modified: trunk/Tools/ChangeLog (276726 => 276727)


--- trunk/Tools/ChangeLog	2021-04-28 18:53:12 UTC (rev 276726)
+++ trunk/Tools/ChangeLog	2021-04-28 19:00:33 UTC (rev 276727)
@@ -1,3 +1,14 @@
+2021-04-28  Alex Christensen  <[email protected]>
+
+        Add SPI to query whether a URL would be upgraded to HTTPS
+        https://bugs.webkit.org/show_bug.cgi?id=225154
+        <rdar://77269904>
+
+        Reviewed by Geoff Garen.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/WKWebViewConfiguration.mm:
+        (TEST):
+
 2021-04-28  Jonathan Bedard  <[email protected]>
 
         [configure-xcode-for-embedded-development] Support Xcode 12.5

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebViewConfiguration.mm (276726 => 276727)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebViewConfiguration.mm	2021-04-28 18:53:12 UTC (rev 276726)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebViewConfiguration.mm	2021-04-28 19:00:33 UTC (rev 276727)
@@ -143,4 +143,9 @@
     checkRequestBytesStartsWith("CONNECT www.opengl.org:443 HTTP/1.1\r\n");
     runTest(false);
     checkRequestBytesStartsWith("GET http://www.opengl.org/ HTTP/1.1\r\n");
+    
+    EXPECT_TRUE([WKWebView _willUpgradeToHTTPS:[NSURL URLWithString:@"http://www.opengl.org/"]]);
+    EXPECT_FALSE([WKWebView _willUpgradeToHTTPS:[NSURL URLWithString:@"https://www.opengl.org/"]]);
+    EXPECT_FALSE([WKWebView _willUpgradeToHTTPS:[NSURL URLWithString:@"custom-scheme://www.opengl.org/"]]);
+    EXPECT_FALSE([WKWebView _willUpgradeToHTTPS:[NSURL URLWithString:@"http://example.com/"]]);
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to