Changeset 239023 in webkit
- Timestamp:
- Dec 9, 2018 5:56:16 PM (5 years ago)
- Location:
- trunk/Source
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/PAL/ChangeLog
r238913 r239023 1 2018-12-09 Saam barati <sbarati@apple.com> 2 3 Enable HTTP and HTTPS proxies on iOS and make it a property of the NSURLSession 4 https://bugs.webkit.org/show_bug.cgi?id=192374 5 <rdar://problem/46506286> 6 7 Reviewed by Alex Christensen. 8 9 * pal/spi/cf/CFNetworkSPI.h: 10 Remove the now-unused SPI declaration. 11 1 12 2018-12-05 Don Olmstead <don.olmstead@sony.com> 2 13 -
trunk/Source/WebCore/PAL/pal/spi/cf/CFNetworkSPI.h
r238785 r239023 34 34 35 35 #include <CFNetwork/CFHTTPCookiesPriv.h> 36 #include <CFNetwork/CFHTTPStream.h> 36 37 #include <CFNetwork/CFProxySupportPriv.h> 37 38 #include <CFNetwork/CFURLCachePriv.h> … … 266 267 void CFHTTPCookieStorageRemoveObserver(CFHTTPCookieStorageRef, CFRunLoopRef, CFStringRef, CFHTTPCookieStorageChangedProcPtr, void*); 267 268 268 void _CFNetworkSetOverrideSystemProxySettings(CFDictionaryRef);269 269 CFURLCredentialStorageRef CFURLCredentialStorageCreate(CFAllocatorRef); 270 270 CFURLCredentialRef CFURLCredentialStorageCopyDefaultCredentialForProtectionSpace(CFURLCredentialStorageRef, CFURLProtectionSpaceRef); -
trunk/Source/WebKit/ChangeLog
r239022 r239023 1 2018-12-09 Saam barati <sbarati@apple.com> 2 3 Enable HTTP and HTTPS proxies on iOS and make it a property of the NSURLSession 4 https://bugs.webkit.org/show_bug.cgi?id=192374 5 <rdar://problem/46506286> 6 7 Reviewed by Alex Christensen. 8 9 This patch makes it so that we can use HTTP/HTTPS proxies on iOS as well. 10 To enable on iOS, you can do something like: 11 $ defaults write -g WebKit2HTTPProxy -string "http://localhost:8080" 12 $ defaults write -g WebKit2HTTPSProxy -string "http://localhost:8080" 13 14 This patch also changes the Proxy to be enabled on a per NSURLSession 15 basis instead of a per process basis. 16 17 * NetworkProcess/NetworkProcess.cpp: 18 (WebKit::NetworkProcess::initializeNetworkProcess): 19 * NetworkProcess/NetworkSessionCreationParameters.cpp: 20 (WebKit::NetworkSessionCreationParameters::privateSessionParameters): 21 (WebKit::NetworkSessionCreationParameters::encode const): 22 (WebKit::NetworkSessionCreationParameters::decode): 23 * NetworkProcess/NetworkSessionCreationParameters.h: 24 * NetworkProcess/cocoa/NetworkSessionCocoa.mm: 25 (WebKit::proxyDictionary): 26 (WebKit::NetworkSessionCocoa::NetworkSessionCocoa): 27 * NetworkProcess/mac/NetworkProcessMac.mm: 28 (WebKit::NetworkProcess::platformInitializeNetworkProcess): 29 (WebKit::overrideSystemProxies): Deleted. 30 * UIProcess/API/Cocoa/WKWebsiteDataStore.mm: 31 (-[WKWebsiteDataStore _initWithConfiguration:]): 32 * UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.h: 33 * UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.mm: 34 (-[_WKWebsiteDataStoreConfiguration httpProxy]): 35 (-[_WKWebsiteDataStoreConfiguration setHTTPProxy:]): 36 (-[_WKWebsiteDataStoreConfiguration httpsProxy]): 37 (-[_WKWebsiteDataStoreConfiguration setHTTPSProxy:]): 38 * UIProcess/Cocoa/WebProcessPoolCocoa.mm: 39 (WebKit::WebProcessPool::platformInitializeNetworkProcess): 40 * UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm: 41 (WebKit::WebsiteDataStore::parameters): 42 * UIProcess/WebsiteData/WebsiteDataStoreConfiguration.cpp: 43 (WebKit::WebsiteDataStoreConfiguration::copy): 44 * UIProcess/WebsiteData/WebsiteDataStoreConfiguration.h: 45 (WebKit::WebsiteDataStoreConfiguration::httpProxy const): 46 (WebKit::WebsiteDataStoreConfiguration::setHTTPProxy): 47 (WebKit::WebsiteDataStoreConfiguration::httpsProxy const): 48 (WebKit::WebsiteDataStoreConfiguration::setHTTPSProxy): 49 1 50 2018-12-09 Adrian Perez de Castro <aperez@igalia.com> 2 51 -
trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp
r239007 r239023 300 300 NetworkStorageSession::switchToNewTestingSession(); 301 301 302 SessionTracker::setSession(PAL::SessionID::defaultSessionID(), NetworkSession::create(NetworkSessionCreationParameters())); 302 NetworkSessionCreationParameters sessionCreationParameters { }; 303 #if PLATFORM(COCOA) 304 sessionCreationParameters.httpProxy = URL(URL(), parameters.httpProxy); 305 sessionCreationParameters.httpsProxy = URL(URL(), parameters.httpsProxy); 306 #endif 307 SessionTracker::setSession(PAL::SessionID::defaultSessionID(), NetworkSession::create(WTFMove(sessionCreationParameters))); 303 308 304 309 #if ENABLE(INDEXED_DATABASE) -
trunk/Source/WebKit/NetworkProcess/NetworkSessionCreationParameters.cpp
r238654 r239023 43 43 return { sessionID, { }, AllowsCellularAccess::Yes 44 44 #if PLATFORM(COCOA) 45 , { }, { }, { }, false, { } 45 , { }, { }, { }, false, { }, { }, { } 46 46 #endif 47 47 #if USE(CURL) … … 62 62 encoder << shouldLogCookieInformation; 63 63 encoder << loadThrottleLatency; 64 encoder << httpProxy; 65 encoder << httpsProxy; 64 66 #endif 65 67 #if USE(CURL) … … 108 110 if (!loadThrottleLatency) 109 111 return std::nullopt; 112 113 std::optional<URL> httpProxy; 114 decoder >> httpProxy; 115 if (!httpProxy) 116 return std::nullopt; 117 118 std::optional<URL> httpsProxy; 119 decoder >> httpsProxy; 120 if (!httpsProxy) 121 return std::nullopt; 110 122 #endif 111 123 … … 127 139 , WTFMove(*shouldLogCookieInformation) 128 140 , WTFMove(*loadThrottleLatency) 141 , WTFMove(*httpProxy) 142 , WTFMove(*httpsProxy) 129 143 #endif 130 144 #if USE(CURL) -
trunk/Source/WebKit/NetworkProcess/NetworkSessionCreationParameters.h
r238654 r239023 28 28 #include <pal/SessionID.h> 29 29 #include <wtf/Seconds.h> 30 #include <wtf/URL.h> 30 31 #include <wtf/text/WTFString.h> 31 32 … … 39 40 } 40 41 42 #if PLATFORM(COCOA) 43 extern "C" CFStringRef const WebKit2HTTPProxyDefaultsKey; 44 extern "C" CFStringRef const WebKit2HTTPSProxyDefaultsKey; 45 #endif 46 41 47 namespace WebKit { 42 48 … … 57 63 bool shouldLogCookieInformation { false }; 58 64 Seconds loadThrottleLatency; 65 URL httpProxy; 66 URL httpsProxy; 59 67 #endif 60 68 #if USE(CURL) -
trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm
r238886 r239023 56 56 using namespace WebKit; 57 57 58 CFStringRef const WebKit2HTTPProxyDefaultsKey = static_cast<CFStringRef>(@"WebKit2HTTPProxy"); 59 CFStringRef const WebKit2HTTPSProxyDefaultsKey = static_cast<CFStringRef>(@"WebKit2HTTPSProxy"); 60 58 61 static NSURLSessionResponseDisposition toNSURLSessionResponseDisposition(WebCore::PolicyAction disposition) 59 62 { … … 605 608 } 606 609 610 static NSDictionary *proxyDictionary(const URL& httpProxy, const URL& httpsProxy) 611 { 612 if (!httpProxy.isValid() && !httpsProxy.isValid()) 613 return nil; 614 615 ALLOW_DEPRECATED_DECLARATIONS_BEGIN 616 617 NSMutableDictionary *dictionary = [[[NSMutableDictionary alloc] init] autorelease]; 618 if (httpProxy.isValid()) { 619 [dictionary setObject:httpProxy.host().toString() forKey:(NSString *)kCFStreamPropertyHTTPProxyHost]; 620 if (auto port = httpProxy.port()) 621 [dictionary setObject:@(*port) forKey:(NSString *)kCFStreamPropertyHTTPProxyHost]; 622 } 623 if (httpsProxy.isValid()) { 624 [dictionary setObject:httpsProxy.host().toString() forKey:(NSString *)kCFStreamPropertyHTTPSProxyHost]; 625 if (auto port = httpsProxy.port()) 626 [dictionary setObject:@(*port) forKey:(NSString *)kCFStreamPropertyHTTPSProxyPort]; 627 } 628 return dictionary; 629 630 ALLOW_DEPRECATED_DECLARATIONS_END 631 } 632 607 633 NetworkSessionCocoa::NetworkSessionCocoa(NetworkSessionCreationParameters&& parameters) 608 634 : NetworkSession(parameters.sessionID) … … 643 669 if (!parameters.sourceApplicationSecondaryIdentifier.isEmpty()) 644 670 configuration._sourceApplicationSecondaryIdentifier = parameters.sourceApplicationSecondaryIdentifier; 671 672 configuration.connectionProxyDictionary = proxyDictionary(parameters.httpProxy, parameters.httpsProxy); 645 673 646 674 #if PLATFORM(IOS_FAMILY) -
trunk/Source/WebKit/NetworkProcess/mac/NetworkProcessMac.mm
r236568 r239023 66 66 } 67 67 68 static void overrideSystemProxies(const String& httpProxy, const String& httpsProxy)69 {70 NSMutableDictionary *proxySettings = [NSMutableDictionary dictionary];71 72 if (!httpProxy.isNull()) {73 URL httpProxyURL(URL(), httpProxy);74 if (httpProxyURL.isValid()) {75 [proxySettings setObject:nsStringFromWebCoreString(httpProxyURL.host().toString()) forKey:(NSString *)kCFNetworkProxiesHTTPProxy];76 if (httpProxyURL.port()) {77 NSNumber *port = [NSNumber numberWithInt:httpProxyURL.port().value()];78 [proxySettings setObject:port forKey:(NSString *)kCFNetworkProxiesHTTPPort];79 }80 }81 else82 NSLog(@"Malformed HTTP Proxy URL '%s'. Expected 'http://<hostname>[:<port>]'\n", httpProxy.utf8().data());83 }84 85 if (!httpsProxy.isNull()) {86 URL httpsProxyURL(URL(), httpsProxy);87 if (httpsProxyURL.isValid()) {88 #if !PLATFORM(IOSMAC)89 [proxySettings setObject:nsStringFromWebCoreString(httpsProxyURL.host().toString()) forKey:(NSString *)kCFNetworkProxiesHTTPSProxy];90 if (httpsProxyURL.port()) {91 NSNumber *port = [NSNumber numberWithInt:httpsProxyURL.port().value()];92 [proxySettings setObject:port forKey:(NSString *)kCFNetworkProxiesHTTPSPort];93 }94 #endif95 } else96 NSLog(@"Malformed HTTPS Proxy URL '%s'. Expected 'https://<hostname>[:<port>]'\n", httpsProxy.utf8().data());97 }98 99 if ([proxySettings count] > 0)100 _CFNetworkSetOverrideSystemProxySettings((__bridge CFDictionaryRef)proxySettings);101 }102 103 68 void NetworkProcess::platformInitializeNetworkProcess(const NetworkProcessCreationParameters& parameters) 104 69 { … … 109 74 initializeSecItemShim(*this); 110 75 #endif 111 112 if (!parameters.httpProxy.isNull() || !parameters.httpsProxy.isNull())113 overrideSystemProxies(parameters.httpProxy, parameters.httpsProxy);114 76 } 115 77 -
trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm
r238900 r239023 215 215 if (configuration.sourceApplicationSecondaryIdentifier) 216 216 config->setSourceApplicationSecondaryIdentifier(configuration.sourceApplicationSecondaryIdentifier); 217 if (configuration.httpProxy) 218 config->setHTTPProxy(configuration.httpProxy); 219 if (configuration.httpsProxy) 220 config->setHTTPSProxy(configuration.httpsProxy); 217 221 218 222 API::Object::constructInWrapper<API::WebsiteDataStore>(self, WTFMove(config), PAL::SessionID::generatePersistentSessionID()); -
trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.h
r235127 r239023 44 44 @property (nonatomic, nullable, copy) NSString *sourceApplicationBundleIdentifier WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA)); 45 45 @property (nonatomic, nullable, copy) NSString *sourceApplicationSecondaryIdentifier WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA)); 46 @property (nonatomic, nullable, copy, setter=setHTTPProxy:) NSURL *httpProxy WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA)); 47 @property (nonatomic, nullable, copy, setter=setHTTPSProxy:) NSURL *httpsProxy WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA)); 46 48 47 49 @end -
trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.mm
r238900 r239023 70 70 checkURLArgument(url); 71 71 _configuration->setWebSQLDatabaseDirectory(url.path); 72 } 73 74 - (NSURL *)httpProxy 75 { 76 return _configuration->httpProxy(); 77 } 78 79 - (void)setHTTPProxy:(NSURL *)proxy 80 { 81 _configuration->setHTTPProxy(proxy); 82 } 83 84 - (NSURL *)httpsProxy 85 { 86 return _configuration->httpsProxy(); 87 } 88 89 - (void)setHTTPSProxy:(NSURL *)proxy 90 { 91 _configuration->setHTTPSProxy(proxy); 72 92 } 73 93 -
trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm
r238886 r239023 70 70 #endif 71 71 72 static NSString * const WebKit2HTTPProxyDefaultsKey = @"WebKit2HTTPProxy";73 static NSString * const WebKit2HTTPSProxyDefaultsKey = @"WebKit2HTTPSProxy";74 75 72 static NSString * const WebKitNetworkCacheEfficacyLoggingEnabledDefaultsKey = @"WebKitNetworkCacheEfficacyLoggingEnabled"; 76 73 … … 260 257 NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; 261 258 262 parameters.httpProxy = [defaults stringForKey:WebKit2HTTPProxyDefaultsKey]; 263 parameters.httpsProxy = [defaults stringForKey:WebKit2HTTPSProxyDefaultsKey]; 259 { 260 bool isSafari = false; 261 #if PLATFORM(IOS_FAMILY) 262 isSafari = WebCore::IOSApplication::isMobileSafari(); 263 #elif PLATFORM(MAC) 264 isSafari = WebCore::MacApplication::isSafari(); 265 #endif 266 if (isSafari) { 267 parameters.httpProxy = [defaults stringForKey:(NSString *)WebKit2HTTPProxyDefaultsKey]; 268 parameters.httpsProxy = [defaults stringForKey:(NSString *)WebKit2HTTPSProxyDefaultsKey]; 269 } 270 } 271 264 272 parameters.networkATSContext = adoptCF(_CFNetworkCopyATSContext()); 265 273 -
trunk/Source/WebKit/UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm
r238900 r239023 32 32 #import "WebsiteDataStoreParameters.h" 33 33 #import <WebCore/FileSystem.h> 34 #import <WebCore/RuntimeApplicationChecks.h> 34 35 #import <WebCore/SearchPopupMenuCocoa.h> 35 36 #import <pal/spi/cf/CFNetworkSPI.h> … … 68 69 #endif 69 70 71 URL httpProxy = m_configuration->httpProxy(); 72 URL httpsProxy = m_configuration->httpsProxy(); 73 74 bool isSafari = false; 75 #if PLATFORM(IOS_FAMILY) 76 isSafari = WebCore::IOSApplication::isMobileSafari(); 77 #elif PLATFORM(MAC) 78 isSafari = WebCore::MacApplication::isSafari(); 79 #endif 80 // FIXME: Remove these once Safari adopts _WKWebsiteDataStoreConfiguration.httpProxy and .httpsProxy. 81 if (!httpProxy.isValid() && isSafari) 82 httpProxy = URL(URL(), [defaults stringForKey:(NSString *)WebKit2HTTPProxyDefaultsKey]); 83 if (!httpsProxy.isValid() && isSafari) 84 httpsProxy = URL(URL(), [defaults stringForKey:(NSString *)WebKit2HTTPSProxyDefaultsKey]); 85 70 86 WebsiteDataStoreParameters parameters; 71 87 parameters.networkSessionParameters = { … … 77 93 m_configuration->sourceApplicationSecondaryIdentifier(), 78 94 shouldLogCookieInformation, 79 Seconds { [defaults integerForKey:WebKitNetworkLoadThrottleLatencyMillisecondsDefaultsKey] / 1000. } 95 Seconds { [defaults integerForKey:WebKitNetworkLoadThrottleLatencyMillisecondsDefaultsKey] / 1000. }, 96 WTFMove(httpProxy), 97 WTFMove(httpsProxy), 80 98 }; 81 99 -
trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStoreConfiguration.cpp
r239022 r239023 58 58 copy->m_sourceApplicationBundleIdentifier = this->m_sourceApplicationBundleIdentifier; 59 59 copy->m_sourceApplicationSecondaryIdentifier = this->m_sourceApplicationSecondaryIdentifier; 60 copy->m_httpProxy = this->m_httpProxy; 61 copy->m_httpsProxy = this->m_httpsProxy; 60 62 61 63 return copy; -
trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStoreConfiguration.h
r238900 r239023 27 27 28 28 #include "APIObject.h" 29 #include <wtf/URL.h> 29 30 #include <wtf/text/WTFString.h> 30 31 … … 88 89 void setSourceApplicationSecondaryIdentifier(String&& identifier) { m_sourceApplicationSecondaryIdentifier = WTFMove(identifier); } 89 90 91 const URL& httpProxy() const { return m_httpProxy; } 92 void setHTTPProxy(URL&& proxy) { m_httpProxy = WTFMove(proxy); } 93 94 const URL& httpsProxy() const { return m_httpsProxy; } 95 void setHTTPSProxy(URL&& proxy) { m_httpsProxy = WTFMove(proxy); } 96 90 97 constexpr static uint64_t defaultCacheStoragePerOriginQuota = 50 * 1024 * 1024; 91 98 … … 111 118 String m_sourceApplicationBundleIdentifier; 112 119 String m_sourceApplicationSecondaryIdentifier; 120 URL m_httpProxy; 121 URL m_httpsProxy; 113 122 }; 114 123
Note: See TracChangeset
for help on using the changeset viewer.