browser(webkit): support bypass list on Mac (#2479)

This commit is contained in:
Pavel Feldman 2020-06-04 21:01:38 -07:00 committed by GitHub
parent 1d37a10558
commit 616ae5044d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 23 additions and 10 deletions

View File

@ -1 +1 @@
1266
1267

View File

@ -40,6 +40,7 @@
NSString* _initialURL;
NSString* _userDataDir;
NSString* _proxyServer;
NSString* _proxyBypassList;
IBOutlet NSMenuItem *_newWebKit2WindowItem;
}

View File

@ -90,6 +90,7 @@ const NSActivityOptions ActivityOptions =
_initialURL = nil;
_userDataDir = nil;
_proxyServer = nil;
_proxyBypassList = nil;
NSArray *arguments = [[NSProcessInfo processInfo] arguments];
NSRange subargs = NSMakeRange(1, [arguments count] - 1);
NSArray *subArray = [arguments subarrayWithRange:subargs];
@ -105,6 +106,10 @@ const NSActivityOptions ActivityOptions =
NSRange range = NSMakeRange(8, [argument length] - 8);
_proxyServer = [[argument substringWithRange:range] copy];
}
if ([argument hasPrefix:@"--proxy-bypass-list="]) {
NSRange range = NSMakeRange(20, [argument length] - 20);
_proxyBypassList = [[argument substringWithRange:range] copy];
}
}
_headless = [arguments containsObject: @"--headless"];
@ -132,9 +137,9 @@ const NSActivityOptions ActivityOptions =
}
- (NSDictionary *)proxyConfiguration:(NSString *)proxyServer
- (NSDictionary *)proxyConfiguration:(NSString *)proxyServer WithBypassList:(NSString *)proxyBypassList
{
if (!proxyServer)
if (!proxyServer || ![proxyServer length])
return nil;
#pragma clang diagnostic push
@ -157,6 +162,11 @@ const NSActivityOptions ActivityOptions =
}
}
if (proxyBypassList && [proxyBypassList length]) {
NSArray* bypassList = [proxyBypassList componentsSeparatedByString:@","];
[dictionary setObject:bypassList forKey:@"ExceptionsList"];
}
#pragma clang diagnostic pop
return dictionary;
@ -202,7 +212,7 @@ const NSActivityOptions ActivityOptions =
NSURL *webSqlDirectory = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/WebSQL", _userDataDir]];
[configuration _setWebSQLDatabaseDirectory:webSqlDirectory];
}
[configuration setProxyConfiguration:[self proxyConfiguration:_proxyServer]];
[configuration setProxyConfiguration:[self proxyConfiguration:_proxyServer WithBypassList:_proxyBypassList]];
dataStore = [[WKWebsiteDataStore alloc] _initWithConfiguration:configuration];
}
@ -312,7 +322,7 @@ const NSActivityOptions ActivityOptions =
return [webView autorelease];
}
- (_WKBrowserContext *)createBrowserContext:(NSString *)proxyServer
- (_WKBrowserContext *)createBrowserContext:(NSString *)proxyServer WithBypassList:(NSString *) proxyBypassList
{
_WKBrowserContext *browserContext = [[_WKBrowserContext alloc] init];
_WKProcessPoolConfiguration *processConfiguration = [[[_WKProcessPoolConfiguration alloc] init] autorelease];
@ -320,7 +330,9 @@ const NSActivityOptions ActivityOptions =
_WKWebsiteDataStoreConfiguration *dataStoreConfiguration = [[[_WKWebsiteDataStoreConfiguration alloc] initNonPersistentConfiguration] autorelease];
if (!proxyServer || ![proxyServer length])
proxyServer = _proxyServer;
[dataStoreConfiguration setProxyConfiguration:[self proxyConfiguration:proxyServer]];
if (!proxyBypassList || ![proxyBypassList length])
proxyBypassList = _proxyBypassList;
[dataStoreConfiguration setProxyConfiguration:[self proxyConfiguration:proxyServer WithBypassList:proxyBypassList]];
browserContext.dataStore = [[WKWebsiteDataStore alloc] _initWithConfiguration:dataStoreConfiguration];
browserContext.processPool = [[[WKProcessPool alloc] _initWithConfiguration:processConfiguration] autorelease];
[browserContext.processPool _setDownloadDelegate:self];

View File

@ -7419,7 +7419,7 @@ index 591428f7f579e76ff01bc94b83f5994af8e48e00..03fc6cf2d3074d9227d7815ac5c72fdb
Vector<WebKit::WebsiteDataRecord> result;
diff --git a/Source/WebKit/UIProcess/API/Cocoa/_WKBrowserInspector.h b/Source/WebKit/UIProcess/API/Cocoa/_WKBrowserInspector.h
new file mode 100644
index 0000000000000000000000000000000000000000..2d7788193f85ce53860d2996650560a7dcc73457
index 0000000000000000000000000000000000000000..5fabe06a3289689246c36dfd96eb9900a48b2b0f
--- /dev/null
+++ b/Source/WebKit/UIProcess/API/Cocoa/_WKBrowserInspector.h
@@ -0,0 +1,55 @@
@ -7465,7 +7465,7 @@ index 0000000000000000000000000000000000000000..2d7788193f85ce53860d2996650560a7
+
+@protocol _WKBrowserInspectorDelegate <NSObject>
+- (WKWebView *)createNewPage:(uint64_t)sessionID;
+- (_WKBrowserContext *)createBrowserContext:(NSString *)proxyServer;
+- (_WKBrowserContext *)createBrowserContext:(NSString *)proxyServer WithBypassList:(NSString *)proxyBypassList;
+- (void)deleteBrowserContext:(uint64_t)sessionID;
+- (void)quit;
+@end
@ -13318,7 +13318,7 @@ index 0000000000000000000000000000000000000000..bce31b16fe37dc2a981389a6160e4094
+} // namespace API
diff --git a/Source/WebKit/UIProcess/mac/InspectorPlaywrightAgentClientMac.mm b/Source/WebKit/UIProcess/mac/InspectorPlaywrightAgentClientMac.mm
new file mode 100644
index 0000000000000000000000000000000000000000..b20118cb4bcd3bc962d5b5b052e408c2a0881aae
index 0000000000000000000000000000000000000000..600a1687094f5a209f24dc951206ba7faf4de991
--- /dev/null
+++ b/Source/WebKit/UIProcess/mac/InspectorPlaywrightAgentClientMac.mm
@@ -0,0 +1,77 @@
@ -13386,7 +13386,7 @@ index 0000000000000000000000000000000000000000..b20118cb4bcd3bc962d5b5b052e408c2
+
+BrowserContext InspectorPlaywrightAgentClientMac::createBrowserContext(WTF::String& error, const WTF::String& proxyServer, const WTF::String& proxyBypassList)
+{
+ _WKBrowserContext* wkBrowserContext = [[delegate_ createBrowserContext:proxyServer] autorelease];
+ _WKBrowserContext* wkBrowserContext = [[delegate_ createBrowserContext:proxyServer WithBypassList:proxyBypassList] autorelease];
+ BrowserContext browserContext;
+ browserContext.processPool = &static_cast<WebProcessPool&>([[wkBrowserContext processPool] _apiObject]);
+ browserContext.dataStore = &static_cast<WebsiteDataStore&>([[wkBrowserContext dataStore] _apiObject]);