Title: [239322] trunk/Source
Revision
239322
Author
sbar...@apple.com
Date
2018-12-17 22:33:58 -0800 (Mon, 17 Dec 2018)

Log Message

Enable HTTP and HTTPS proxies on iOS and make it a property of the NSURLSession
https://bugs.webkit.org/show_bug.cgi?id=192374
<rdar://problem/46506286>

Reviewed by Alex Christensen.

Source/WebCore/PAL:

* pal/spi/cf/CFNetworkSPI.h:
Remove the now-unused SPI declaration.

Source/WebKit:

This patch makes it so that we can use HTTP/HTTPS proxies on iOS as well.
To enable on iOS, you can do something like:
$ defaults write -g WebKit2HTTPProxy -string "http://localhost:8080"
$ defaults write -g WebKit2HTTPSProxy -string "http://localhost:8080"

This patch also changes the Proxy to be enabled on a per NSURLSession
basis instead of a per process basis.

* NetworkProcess/NetworkProcess.cpp:
(WebKit::NetworkProcess::initializeNetworkProcess):
* NetworkProcess/NetworkSessionCreationParameters.cpp:
(WebKit::NetworkSessionCreationParameters::privateSessionParameters):
(WebKit::NetworkSessionCreationParameters::encode const):
(WebKit::NetworkSessionCreationParameters::decode):
* NetworkProcess/NetworkSessionCreationParameters.h:
* NetworkProcess/cocoa/NetworkSessionCocoa.mm:
(WebKit::proxyDictionary):
(WebKit::NetworkSessionCocoa::NetworkSessionCocoa):
* NetworkProcess/mac/NetworkProcessMac.mm:
(WebKit::NetworkProcess::platformInitializeNetworkProcess):
(WebKit::overrideSystemProxies): Deleted.
* UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
(-[WKWebsiteDataStore _initWithConfiguration:]):
* UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.h:
* UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.mm:
(-[_WKWebsiteDataStoreConfiguration httpProxy]):
(-[_WKWebsiteDataStoreConfiguration setHTTPProxy:]):
(-[_WKWebsiteDataStoreConfiguration httpsProxy]):
(-[_WKWebsiteDataStoreConfiguration setHTTPSProxy:]):
* UIProcess/Cocoa/WebProcessPoolCocoa.mm:
(WebKit::WebProcessPool::platformInitializeNetworkProcess):
* UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm:
(WebKit::WebsiteDataStore::parameters):
* UIProcess/WebsiteData/WebsiteDataStoreConfiguration.cpp:
(WebKit::WebsiteDataStoreConfiguration::copy):
* UIProcess/WebsiteData/WebsiteDataStoreConfiguration.h:
(WebKit::WebsiteDataStoreConfiguration::httpProxy const):
(WebKit::WebsiteDataStoreConfiguration::setHTTPProxy):
(WebKit::WebsiteDataStoreConfiguration::httpsProxy const):
(WebKit::WebsiteDataStoreConfiguration::setHTTPSProxy):

Modified Paths

Diff

Modified: trunk/Source/WebCore/PAL/ChangeLog (239321 => 239322)


--- trunk/Source/WebCore/PAL/ChangeLog	2018-12-18 06:30:34 UTC (rev 239321)
+++ trunk/Source/WebCore/PAL/ChangeLog	2018-12-18 06:33:58 UTC (rev 239322)
@@ -1,3 +1,14 @@
+2018-12-17  Saam barati  <sbar...@apple.com>
+
+        Enable HTTP and HTTPS proxies on iOS and make it a property of the NSURLSession
+        https://bugs.webkit.org/show_bug.cgi?id=192374
+        <rdar://problem/46506286>
+
+        Reviewed by Alex Christensen.
+
+        * pal/spi/cf/CFNetworkSPI.h:
+        Remove the now-unused SPI declaration.
+
 2018-12-17  Simon Fraser  <simon.fra...@apple.com>
 
         Don't use more expensive layer backing store formats when subpixel text antialiasing is not enabled

Modified: trunk/Source/WebCore/PAL/pal/spi/cf/CFNetworkSPI.h (239321 => 239322)


--- trunk/Source/WebCore/PAL/pal/spi/cf/CFNetworkSPI.h	2018-12-18 06:30:34 UTC (rev 239321)
+++ trunk/Source/WebCore/PAL/pal/spi/cf/CFNetworkSPI.h	2018-12-18 06:33:58 UTC (rev 239322)
@@ -33,6 +33,7 @@
 #if PLATFORM(WIN) || USE(APPLE_INTERNAL_SDK)
 
 #include <CFNetwork/CFHTTPCookiesPriv.h>
+#include <CFNetwork/CFHTTPStream.h>
 #include <CFNetwork/CFProxySupportPriv.h>
 #include <CFNetwork/CFURLCachePriv.h>
 #include <CFNetwork/CFURLConnectionPriv.h>
@@ -265,7 +266,6 @@
 void CFHTTPCookieStorageAddObserver(CFHTTPCookieStorageRef, CFRunLoopRef, CFStringRef, CFHTTPCookieStorageChangedProcPtr, void*);
 void CFHTTPCookieStorageRemoveObserver(CFHTTPCookieStorageRef, CFRunLoopRef, CFStringRef, CFHTTPCookieStorageChangedProcPtr, void*);
 
-void _CFNetworkSetOverrideSystemProxySettings(CFDictionaryRef);
 CFURLCredentialStorageRef CFURLCredentialStorageCreate(CFAllocatorRef);
 CFURLCredentialRef CFURLCredentialStorageCopyDefaultCredentialForProtectionSpace(CFURLCredentialStorageRef, CFURLProtectionSpaceRef);
 CFURLRequestPriority CFURLRequestGetRequestPriority(CFURLRequestRef);

Modified: trunk/Source/WebKit/ChangeLog (239321 => 239322)


--- trunk/Source/WebKit/ChangeLog	2018-12-18 06:30:34 UTC (rev 239321)
+++ trunk/Source/WebKit/ChangeLog	2018-12-18 06:33:58 UTC (rev 239322)
@@ -1,3 +1,52 @@
+2018-12-17  Saam barati  <sbar...@apple.com>
+
+        Enable HTTP and HTTPS proxies on iOS and make it a property of the NSURLSession
+        https://bugs.webkit.org/show_bug.cgi?id=192374
+        <rdar://problem/46506286>
+
+        Reviewed by Alex Christensen.
+
+        This patch makes it so that we can use HTTP/HTTPS proxies on iOS as well.
+        To enable on iOS, you can do something like:
+        $ defaults write -g WebKit2HTTPProxy -string "http://localhost:8080"
+        $ defaults write -g WebKit2HTTPSProxy -string "http://localhost:8080"
+        
+        This patch also changes the Proxy to be enabled on a per NSURLSession
+        basis instead of a per process basis.
+
+        * NetworkProcess/NetworkProcess.cpp:
+        (WebKit::NetworkProcess::initializeNetworkProcess):
+        * NetworkProcess/NetworkSessionCreationParameters.cpp:
+        (WebKit::NetworkSessionCreationParameters::privateSessionParameters):
+        (WebKit::NetworkSessionCreationParameters::encode const):
+        (WebKit::NetworkSessionCreationParameters::decode):
+        * NetworkProcess/NetworkSessionCreationParameters.h:
+        * NetworkProcess/cocoa/NetworkSessionCocoa.mm:
+        (WebKit::proxyDictionary):
+        (WebKit::NetworkSessionCocoa::NetworkSessionCocoa):
+        * NetworkProcess/mac/NetworkProcessMac.mm:
+        (WebKit::NetworkProcess::platformInitializeNetworkProcess):
+        (WebKit::overrideSystemProxies): Deleted.
+        * UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
+        (-[WKWebsiteDataStore _initWithConfiguration:]):
+        * UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.h:
+        * UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.mm:
+        (-[_WKWebsiteDataStoreConfiguration httpProxy]):
+        (-[_WKWebsiteDataStoreConfiguration setHTTPProxy:]):
+        (-[_WKWebsiteDataStoreConfiguration httpsProxy]):
+        (-[_WKWebsiteDataStoreConfiguration setHTTPSProxy:]):
+        * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
+        (WebKit::WebProcessPool::platformInitializeNetworkProcess):
+        * UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm:
+        (WebKit::WebsiteDataStore::parameters):
+        * UIProcess/WebsiteData/WebsiteDataStoreConfiguration.cpp:
+        (WebKit::WebsiteDataStoreConfiguration::copy):
+        * UIProcess/WebsiteData/WebsiteDataStoreConfiguration.h:
+        (WebKit::WebsiteDataStoreConfiguration::httpProxy const):
+        (WebKit::WebsiteDataStoreConfiguration::setHTTPProxy):
+        (WebKit::WebsiteDataStoreConfiguration::httpsProxy const):
+        (WebKit::WebsiteDataStoreConfiguration::setHTTPSProxy):
+
 2018-12-17  Wenson Hsieh  <wenson_hs...@apple.com>
 
         Tap highlights should not be shown on iOSMac

Modified: trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp (239321 => 239322)


--- trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp	2018-12-18 06:30:34 UTC (rev 239321)
+++ trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp	2018-12-18 06:33:58 UTC (rev 239322)
@@ -299,7 +299,12 @@
     if (parameters.shouldUseTestingNetworkSession)
         NetworkStorageSession::switchToNewTestingSession();
 
-    SessionTracker::setSession(PAL::SessionID::defaultSessionID(), NetworkSession::create(NetworkSessionCreationParameters()));
+    NetworkSessionCreationParameters sessionCreationParameters { };
+#if PLATFORM(COCOA)
+    sessionCreationParameters.httpProxy = URL(URL(), parameters.httpProxy);
+    sessionCreationParameters.httpsProxy = URL(URL(), parameters.httpsProxy);
+#endif
+    SessionTracker::setSession(PAL::SessionID::defaultSessionID(), NetworkSession::create(WTFMove(sessionCreationParameters)));
 
 #if ENABLE(INDEXED_DATABASE)
     addIndexedDatabaseSession(PAL::SessionID::defaultSessionID(), parameters.indexedDatabaseDirectory, parameters.indexedDatabaseDirectoryExtensionHandle);

Modified: trunk/Source/WebKit/NetworkProcess/NetworkSessionCreationParameters.cpp (239321 => 239322)


--- trunk/Source/WebKit/NetworkProcess/NetworkSessionCreationParameters.cpp	2018-12-18 06:30:34 UTC (rev 239321)
+++ trunk/Source/WebKit/NetworkProcess/NetworkSessionCreationParameters.cpp	2018-12-18 06:33:58 UTC (rev 239322)
@@ -42,7 +42,7 @@
 {
     return { sessionID, { }, AllowsCellularAccess::Yes
 #if PLATFORM(COCOA)
-        , { }, { }, { }, false, { }
+        , { }, { }, { }, false, { }, { }, { }
 #endif
 #if USE(CURL)
         , { }
@@ -61,6 +61,8 @@
     encoder << sourceApplicationSecondaryIdentifier;
     encoder << shouldLogCookieInformation;
     encoder << loadThrottleLatency;
+    encoder << httpProxy;
+    encoder << httpsProxy;
 #endif
 #if USE(CURL)
     encoder << proxySettings;
@@ -107,6 +109,16 @@
     decoder >> loadThrottleLatency;
     if (!loadThrottleLatency)
         return std::nullopt;
+    
+    std::optional<URL> httpProxy;
+    decoder >> httpProxy;
+    if (!httpProxy)
+        return std::nullopt;
+
+    std::optional<URL> httpsProxy;
+    decoder >> httpsProxy;
+    if (!httpsProxy)
+        return std::nullopt;
 #endif
     
 #if USE(CURL)
@@ -126,6 +138,8 @@
         , WTFMove(*sourceApplicationSecondaryIdentifier)
         , WTFMove(*shouldLogCookieInformation)
         , WTFMove(*loadThrottleLatency)
+        , WTFMove(*httpProxy)
+        , WTFMove(*httpsProxy)
 #endif
 #if USE(CURL)
         , WTFMove(*proxySettings)

Modified: trunk/Source/WebKit/NetworkProcess/NetworkSessionCreationParameters.h (239321 => 239322)


--- trunk/Source/WebKit/NetworkProcess/NetworkSessionCreationParameters.h	2018-12-18 06:30:34 UTC (rev 239321)
+++ trunk/Source/WebKit/NetworkProcess/NetworkSessionCreationParameters.h	2018-12-18 06:33:58 UTC (rev 239322)
@@ -27,6 +27,7 @@
 
 #include <pal/SessionID.h>
 #include <wtf/Seconds.h>
+#include <wtf/URL.h>
 #include <wtf/text/WTFString.h>
 
 #if USE(CURL)
@@ -38,6 +39,11 @@
 class Decoder;
 }
 
+#if PLATFORM(COCOA)
+extern "C" CFStringRef const WebKit2HTTPProxyDefaultsKey;
+extern "C" CFStringRef const WebKit2HTTPSProxyDefaultsKey;
+#endif
+    
 namespace WebKit {
 
 enum class AllowsCellularAccess : bool { No, Yes };
@@ -56,6 +62,8 @@
     String sourceApplicationSecondaryIdentifier;
     bool shouldLogCookieInformation { false };
     Seconds loadThrottleLatency;
+    URL httpProxy;
+    URL httpsProxy;
 #endif
 #if USE(CURL)
     WebCore::CurlProxySettings proxySettings;

Modified: trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm (239321 => 239322)


--- trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm	2018-12-18 06:30:34 UTC (rev 239321)
+++ trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm	2018-12-18 06:33:58 UTC (rev 239322)
@@ -55,6 +55,9 @@
 
 using namespace WebKit;
 
+CFStringRef const WebKit2HTTPProxyDefaultsKey = static_cast<CFStringRef>(@"WebKit2HTTPProxy");
+CFStringRef const WebKit2HTTPSProxyDefaultsKey = static_cast<CFStringRef>(@"WebKit2HTTPSProxy");
+
 static NSURLSessionResponseDisposition toNSURLSessionResponseDisposition(WebCore::PolicyAction disposition)
 {
     switch (disposition) {
@@ -601,6 +604,29 @@
     return adoptRef(*new NetworkSessionCocoa(WTFMove(parameters)));
 }
 
+static NSDictionary *proxyDictionary(const URL& httpProxy, const URL& httpsProxy)
+{
+    if (!httpProxy.isValid() && !httpsProxy.isValid())
+        return nil;
+
+    ALLOW_DEPRECATED_DECLARATIONS_BEGIN
+
+    NSMutableDictionary *dictionary = [[[NSMutableDictionary alloc] init] autorelease];
+    if (httpProxy.isValid()) {
+        [dictionary setObject:httpProxy.host().toString() forKey:(NSString *)kCFStreamPropertyHTTPProxyHost];
+        if (auto port = httpProxy.port())
+            [dictionary setObject:@(*port) forKey:(NSString *)kCFStreamPropertyHTTPProxyPort];
+    }
+    if (httpsProxy.isValid()) {
+        [dictionary setObject:httpsProxy.host().toString() forKey:(NSString *)kCFStreamPropertyHTTPSProxyHost];
+        if (auto port = httpsProxy.port())
+            [dictionary setObject:@(*port) forKey:(NSString *)kCFStreamPropertyHTTPSProxyPort];
+    }
+    return dictionary;
+
+    ALLOW_DEPRECATED_DECLARATIONS_END
+}
+
 NetworkSessionCocoa::NetworkSessionCocoa(NetworkSessionCreationParameters&& parameters)
     : NetworkSession(parameters.sessionID)
     , m_boundInterfaceIdentifier(parameters.boundInterfaceIdentifier)
@@ -640,6 +666,8 @@
     if (!parameters.sourceApplicationSecondaryIdentifier.isEmpty())
         configuration._sourceApplicationSecondaryIdentifier = parameters.sourceApplicationSecondaryIdentifier;
 
+    configuration.connectionProxyDictionary = proxyDictionary(parameters.httpProxy, parameters.httpsProxy);
+
 #if PLATFORM(IOS_FAMILY)
     auto& ctDataConnectionServiceType = globalCTDataConnectionServiceType();
     if (!ctDataConnectionServiceType.isEmpty())

Modified: trunk/Source/WebKit/NetworkProcess/mac/NetworkProcessMac.mm (239321 => 239322)


--- trunk/Source/WebKit/NetworkProcess/mac/NetworkProcessMac.mm	2018-12-18 06:30:34 UTC (rev 239321)
+++ trunk/Source/WebKit/NetworkProcess/mac/NetworkProcessMac.mm	2018-12-18 06:33:58 UTC (rev 239322)
@@ -64,41 +64,6 @@
 #endif
 }
 
-static void overrideSystemProxies(const String& httpProxy, const String& httpsProxy)
-{
-    NSMutableDictionary *proxySettings = [NSMutableDictionary dictionary];
-
-    if (!httpProxy.isNull()) {
-        URL httpProxyURL(URL(), httpProxy);
-        if (httpProxyURL.isValid()) {
-            [proxySettings setObject:nsStringFromWebCoreString(httpProxyURL.host().toString()) forKey:(NSString *)kCFNetworkProxiesHTTPProxy];
-            if (httpProxyURL.port()) {
-                NSNumber *port = [NSNumber numberWithInt:httpProxyURL.port().value()];
-                [proxySettings setObject:port forKey:(NSString *)kCFNetworkProxiesHTTPPort];
-            }
-        }
-        else
-            NSLog(@"Malformed HTTP Proxy URL '%s'.  Expected 'http://<hostname>[:<port>]'\n", httpProxy.utf8().data());
-    }
-
-    if (!httpsProxy.isNull()) {
-        URL httpsProxyURL(URL(), httpsProxy);
-        if (httpsProxyURL.isValid()) {
-#if !PLATFORM(IOSMAC)
-            [proxySettings setObject:nsStringFromWebCoreString(httpsProxyURL.host().toString()) forKey:(NSString *)kCFNetworkProxiesHTTPSProxy];
-            if (httpsProxyURL.port()) {
-                NSNumber *port = [NSNumber numberWithInt:httpsProxyURL.port().value()];
-                [proxySettings setObject:port forKey:(NSString *)kCFNetworkProxiesHTTPSPort];
-            }
-#endif
-        } else
-            NSLog(@"Malformed HTTPS Proxy URL '%s'.  Expected 'https://<hostname>[:<port>]'\n", httpsProxy.utf8().data());
-    }
-
-    if ([proxySettings count] > 0)
-        _CFNetworkSetOverrideSystemProxySettings((__bridge CFDictionaryRef)proxySettings);
-}
-
 void NetworkProcess::platformInitializeNetworkProcess(const NetworkProcessCreationParameters& parameters)
 {
     platformInitializeNetworkProcessCocoa(parameters);
@@ -107,9 +72,6 @@
     // SecItemShim is needed for CFNetwork APIs that query Keychains beneath us.
     initializeSecItemShim(*this);
 #endif
-
-    if (!parameters.httpProxy.isNull() || !parameters.httpsProxy.isNull())
-        overrideSystemProxies(parameters.httpProxy, parameters.httpsProxy);
 }
 
 void NetworkProcess::allowSpecificHTTPSCertificateForHost(const CertificateInfo& certificateInfo, const String& host)

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm (239321 => 239322)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm	2018-12-18 06:30:34 UTC (rev 239321)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm	2018-12-18 06:33:58 UTC (rev 239322)
@@ -214,6 +214,10 @@
         config->setSourceApplicationBundleIdentifier(configuration.sourceApplicationBundleIdentifier);
     if (configuration.sourceApplicationSecondaryIdentifier)
         config->setSourceApplicationSecondaryIdentifier(configuration.sourceApplicationSecondaryIdentifier);
+    if (configuration.httpProxy)
+        config->setHTTPProxy(configuration.httpProxy);
+    if (configuration.httpsProxy)
+        config->setHTTPSProxy(configuration.httpsProxy);
 
     API::Object::constructInWrapper<API::WebsiteDataStore>(self, WTFMove(config), PAL::SessionID::generatePersistentSessionID());
 

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.h (239321 => 239322)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.h	2018-12-18 06:30:34 UTC (rev 239321)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.h	2018-12-18 06:33:58 UTC (rev 239322)
@@ -43,6 +43,8 @@
 @property (nonatomic, copy, setter=_setServiceWorkerRegistrationDirectory:) NSURL *_serviceWorkerRegistrationDirectory WK_API_AVAILABLE(macosx(10.13.4), ios(11.3));
 @property (nonatomic, nullable, copy) NSString *sourceApplicationBundleIdentifier WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
 @property (nonatomic, nullable, copy) NSString *sourceApplicationSecondaryIdentifier WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
+@property (nonatomic, nullable, copy, setter=setHTTPProxy:) NSURL *httpProxy WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
+@property (nonatomic, nullable, copy, setter=setHTTPSProxy:) NSURL *httpsProxy WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
 
 @end
 

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.mm (239321 => 239322)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.mm	2018-12-18 06:30:34 UTC (rev 239321)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.mm	2018-12-18 06:33:58 UTC (rev 239322)
@@ -71,6 +71,26 @@
     _configuration->setWebSQLDatabaseDirectory(url.path);
 }
 
+- (NSURL *)httpProxy
+{
+    return _configuration->httpProxy();
+}
+
+- (void)setHTTPProxy:(NSURL *)proxy
+{
+    _configuration->setHTTPProxy(proxy);
+}
+
+- (NSURL *)httpsProxy
+{
+    return _configuration->httpsProxy();
+}
+
+- (void)setHTTPSProxy:(NSURL *)proxy
+{
+    _configuration->setHTTPSProxy(proxy);
+}
+
 - (NSURL *)_cookieStorageFile
 {
     return [NSURL fileURLWithPath:_configuration->cookieStorageFile() isDirectory:NO];

Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm (239321 => 239322)


--- trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm	2018-12-18 06:30:34 UTC (rev 239321)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm	2018-12-18 06:33:58 UTC (rev 239322)
@@ -69,9 +69,6 @@
 static NSString *WebKitApplicationDidChangeAccessibilityEnhancedUserInterfaceNotification = @"NSApplicationDidChangeAccessibilityEnhancedUserInterfaceNotification";
 #endif
 
-static NSString * const WebKit2HTTPProxyDefaultsKey = @"WebKit2HTTPProxy";
-static NSString * const WebKit2HTTPSProxyDefaultsKey = @"WebKit2HTTPSProxy";
-
 static NSString * const WebKitNetworkCacheEfficacyLoggingEnabledDefaultsKey = @"WebKitNetworkCacheEfficacyLoggingEnabled";
 
 static NSString * const WebKitSuppressMemoryPressureHandlerDefaultsKey = @"WebKitSuppressMemoryPressureHandler";
@@ -259,8 +256,19 @@
 
     NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
 
-    parameters.httpProxy = [defaults stringForKey:WebKit2HTTPProxyDefaultsKey];
-    parameters.httpsProxy = [defaults stringForKey:WebKit2HTTPSProxyDefaultsKey];
+    {
+        bool isSafari = false;
+#if PLATFORM(IOS_FAMILY)
+        isSafari = WebCore::IOSApplication::isMobileSafari();
+#elif PLATFORM(MAC)
+        isSafari = WebCore::MacApplication::isSafari();
+#endif
+        if (isSafari) {
+            parameters.httpProxy = [defaults stringForKey:(NSString *)WebKit2HTTPProxyDefaultsKey];
+            parameters.httpsProxy = [defaults stringForKey:(NSString *)WebKit2HTTPSProxyDefaultsKey];
+        }
+    }
+
     parameters.networkATSContext = adoptCF(_CFNetworkCopyATSContext());
 
     parameters.shouldEnableNetworkCacheEfficacyLogging = [defaults boolForKey:WebKitNetworkCacheEfficacyLoggingEnabledDefaultsKey];

Modified: trunk/Source/WebKit/UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm (239321 => 239322)


--- trunk/Source/WebKit/UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm	2018-12-18 06:30:34 UTC (rev 239321)
+++ trunk/Source/WebKit/UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm	2018-12-18 06:33:58 UTC (rev 239322)
@@ -31,6 +31,7 @@
 #import "WebResourceLoadStatisticsStore.h"
 #import "WebsiteDataStoreParameters.h"
 #import <WebCore/FileSystem.h>
+#import <WebCore/RuntimeApplicationChecks.h>
 #import <WebCore/SearchPopupMenuCocoa.h>
 #import <pal/spi/cf/CFNetworkSPI.h>
 #import <wtf/NeverDestroyed.h>
@@ -67,6 +68,21 @@
     bool shouldLogCookieInformation = false;
 #endif
 
+    URL httpProxy = m_configuration->httpProxy();
+    URL httpsProxy = m_configuration->httpsProxy();
+    
+    bool isSafari = false;
+#if PLATFORM(IOS_FAMILY)
+    isSafari = WebCore::IOSApplication::isMobileSafari();
+#elif PLATFORM(MAC)
+    isSafari = WebCore::MacApplication::isSafari();
+#endif
+    // FIXME: Remove these once Safari adopts _WKWebsiteDataStoreConfiguration.httpProxy and .httpsProxy.
+    if (!httpProxy.isValid() && isSafari)
+        httpProxy = URL(URL(), [defaults stringForKey:(NSString *)WebKit2HTTPProxyDefaultsKey]);
+    if (!httpsProxy.isValid() && isSafari)
+        httpsProxy = URL(URL(), [defaults stringForKey:(NSString *)WebKit2HTTPSProxyDefaultsKey]);
+
     WebsiteDataStoreParameters parameters;
     parameters.networkSessionParameters = {
         m_sessionID,
@@ -76,7 +92,9 @@
         m_configuration->sourceApplicationBundleIdentifier(),
         m_configuration->sourceApplicationSecondaryIdentifier(),
         shouldLogCookieInformation,
-        Seconds { [defaults integerForKey:WebKitNetworkLoadThrottleLatencyMillisecondsDefaultsKey] / 1000. }
+        Seconds { [defaults integerForKey:WebKitNetworkLoadThrottleLatencyMillisecondsDefaultsKey] / 1000. },
+        WTFMove(httpProxy),
+        WTFMove(httpsProxy),
     };
 
     auto cookieFile = resolvedCookieStorageFile();

Modified: trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStoreConfiguration.cpp (239321 => 239322)


--- trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStoreConfiguration.cpp	2018-12-18 06:30:34 UTC (rev 239321)
+++ trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStoreConfiguration.cpp	2018-12-18 06:33:58 UTC (rev 239322)
@@ -57,6 +57,8 @@
     copy->m_cookieStorageFile = this->m_cookieStorageFile;
     copy->m_sourceApplicationBundleIdentifier = this->m_sourceApplicationBundleIdentifier;
     copy->m_sourceApplicationSecondaryIdentifier = this->m_sourceApplicationSecondaryIdentifier;
+    copy->m_httpProxy = this->m_httpProxy;
+    copy->m_httpsProxy = this->m_httpsProxy;
 
     return copy;
 }

Modified: trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStoreConfiguration.h (239321 => 239322)


--- trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStoreConfiguration.h	2018-12-18 06:30:34 UTC (rev 239321)
+++ trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStoreConfiguration.h	2018-12-18 06:33:58 UTC (rev 239322)
@@ -26,6 +26,7 @@
 #pragma once
 
 #include "APIObject.h"
+#include <wtf/URL.h>
 #include <wtf/text/WTFString.h>
 
 namespace WebKit {
@@ -87,6 +88,12 @@
     const String& sourceApplicationSecondaryIdentifier() const { return m_sourceApplicationSecondaryIdentifier; }
     void setSourceApplicationSecondaryIdentifier(String&& identifier) { m_sourceApplicationSecondaryIdentifier = WTFMove(identifier); }
 
+    const URL& httpProxy() const { return m_httpProxy; }
+    void setHTTPProxy(URL&& proxy) { m_httpProxy = WTFMove(proxy); }
+
+    const URL& httpsProxy() const { return m_httpsProxy; }
+    void setHTTPSProxy(URL&& proxy) { m_httpsProxy = WTFMove(proxy); }
+
     constexpr static uint64_t defaultCacheStoragePerOriginQuota = 50 * 1024 * 1024;
 
 private:
@@ -110,6 +117,8 @@
     String m_cookieStorageFile;
     String m_sourceApplicationBundleIdentifier;
     String m_sourceApplicationSecondaryIdentifier;
+    URL m_httpProxy;
+    URL m_httpsProxy;
 };
 
 }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to