Skip to content

Commit

Permalink
browser(webkit): support bypass list on Mac (#2479)
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelfeldman authored Jun 5, 2020
1 parent 1d37a10 commit 616ae50
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 10 deletions.
2 changes: 1 addition & 1 deletion browser_patches/webkit/BUILD_NUMBER
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1266
1267
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
NSString* _initialURL;
NSString* _userDataDir;
NSString* _proxyServer;
NSString* _proxyBypassList;
IBOutlet NSMenuItem *_newWebKit2WindowItem;
}

Expand Down
22 changes: 17 additions & 5 deletions browser_patches/webkit/embedder/Playwright/mac/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ - (id)init
_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];
Expand All @@ -105,6 +106,10 @@ - (id)init
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"];
Expand Down Expand Up @@ -132,9 +137,9 @@ - (void)awakeFromNib
}


- (NSDictionary *)proxyConfiguration:(NSString *)proxyServer
- (NSDictionary *)proxyConfiguration:(NSString *)proxyServer WithBypassList:(NSString *)proxyBypassList
{
if (!proxyServer)
if (!proxyServer || ![proxyServer length])
return nil;

#pragma clang diagnostic push
Expand All @@ -157,6 +162,11 @@ - (NSDictionary *)proxyConfiguration:(NSString *)proxyServer
}
}

if (proxyBypassList && [proxyBypassList length]) {
NSArray* bypassList = [proxyBypassList componentsSeparatedByString:@","];
[dictionary setObject:bypassList forKey:@"ExceptionsList"];
}

#pragma clang diagnostic pop

return dictionary;
Expand Down Expand Up @@ -202,7 +212,7 @@ - (WKWebsiteDataStore *)persistentDataStore
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];
}

Expand Down Expand Up @@ -312,15 +322,17 @@ - (WKWebView *)createHeadlessPage:(WKWebViewConfiguration *)configuration withUR
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];
processConfiguration.forceOverlayScrollbars = YES;
_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];
Expand Down
8 changes: 4 additions & 4 deletions browser_patches/webkit/patches/bootstrap.diff
Original file line number Diff line number Diff line change
Expand Up @@ -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 @@
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 @@
Expand Down Expand Up @@ -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]);
Expand Down

0 comments on commit 616ae50

Please sign in to comment.