Skip to content

Commit 6b8c40e

Browse files
pavelfeldmandgozman
authored andcommitted
browser(webkit): respect --user-data-dir on MacOS (#579)
1 parent 3b2993f commit 6b8c40e

File tree

2 files changed

+95
-57
lines changed

2 files changed

+95
-57
lines changed

browser_patches/webkit/BUILD_NUMBER

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1106
1+
1107

browser_patches/webkit/patches/bootstrap.diff

Lines changed: 94 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -5393,6 +5393,49 @@ index 1d2febfba8833912f72216aa53c8c20090ee2d8b..1b2c3d84b15b12f1a187c0b7622db43c
53935393
} WKPageUIClientV14;
53945394

53955395
#ifdef __cplusplus
5396+
diff --git a/Source/WebKit/UIProcess/API/Cocoa/WKProcessPool.mm b/Source/WebKit/UIProcess/API/Cocoa/WKProcessPool.mm
5397+
index 08e5b9f0135eafe1aa8f4de4a82b6b890bb919b3..aeba2827bf182556aed407dd8956ef93d267893d 100644
5398+
--- a/Source/WebKit/UIProcess/API/Cocoa/WKProcessPool.mm
5399+
+++ b/Source/WebKit/UIProcess/API/Cocoa/WKProcessPool.mm
5400+
@@ -47,6 +47,7 @@
5401+
#import "_WKDownloadDelegate.h"
5402+
#import "_WKDownloadInternal.h"
5403+
#import "_WKProcessPoolConfigurationInternal.h"
5404+
+#import "_WKWebsiteDataStoreInternal.h"
5405+
#import <WebCore/CertificateInfo.h>
5406+
#import <WebCore/PluginData.h>
5407+
#import <WebCore/RegistrableDomain.h>
5408+
@@ -84,6 +85,18 @@ static WKProcessPool *sharedProcessPool;
5409+
return self;
5410+
}
5411+
5412+
+- (instancetype)_initWithConfiguration:(_WKProcessPoolConfiguration *)configuration AndDataStore:(WKWebsiteDataStore*)dataStore
5413+
+{
5414+
+ if (!(self = [super init]))
5415+
+ return nil;
5416+
+
5417+
+ API::Object::constructInWrapper<WebKit::WebProcessPool>(self, *configuration->_processPoolConfiguration);
5418+
+ _processPool->setPrimaryDataStore(*dataStore->_websiteDataStore);
5419+
+
5420+
+ return self;
5421+
+}
5422+
+
5423+
+
5424+
- (instancetype)init
5425+
{
5426+
return [self _initWithConfiguration:adoptNS([[_WKProcessPoolConfiguration alloc] init]).get()];
5427+
diff --git a/Source/WebKit/UIProcess/API/Cocoa/WKProcessPoolPrivate.h b/Source/WebKit/UIProcess/API/Cocoa/WKProcessPoolPrivate.h
5428+
index 7cfd05697f25ca66a530b2d497706adbf284b068..c24081d210e4baeb5f7f7868eddd5afc111f687b 100644
5429+
--- a/Source/WebKit/UIProcess/API/Cocoa/WKProcessPoolPrivate.h
5430+
+++ b/Source/WebKit/UIProcess/API/Cocoa/WKProcessPoolPrivate.h
5431+
@@ -37,6 +37,7 @@
5432+
5433+
@interface WKProcessPool ()
5434+
- (instancetype)_initWithConfiguration:(_WKProcessPoolConfiguration *)configuration __attribute__((objc_method_family(init))) NS_DESIGNATED_INITIALIZER;
5435+
+- (instancetype)_initWithConfiguration:(_WKProcessPoolConfiguration *)configuration AndDataStore:(WKWebsiteDataStore *)dataStore __attribute__((objc_method_family(init))) NS_DESIGNATED_INITIALIZER;
5436+
@end
5437+
5438+
@interface WKProcessPool (WKPrivate)
53965439
diff --git a/Source/WebKit/UIProcess/API/Cocoa/WKUIDelegate.h b/Source/WebKit/UIProcess/API/Cocoa/WKUIDelegate.h
53975440
index cad87f3ef2ab93d93a74cec0c34b47c695de6bc6..66145a384638b97ee08516e56e1e86a83713c634 100644
53985441
--- a/Source/WebKit/UIProcess/API/Cocoa/WKUIDelegate.h
@@ -12111,10 +12154,10 @@ index 0000000000000000000000000000000000000000..44dc1139c298bd119368ef4f45bbf088
1211112154
+#include "../../ccache/ccache.xcconfig"
1211212155
diff --git a/Tools/Playwright/Configurations/Playwright.xcconfig b/Tools/Playwright/Configurations/Playwright.xcconfig
1211312156
new file mode 100644
12114-
index 0000000000000000000000000000000000000000..085126eb199ec714f7e8d7bc7d7b361ef55ebb73
12157+
index 0000000000000000000000000000000000000000..d05c841a5b0f5fce481f16b8c98caf3a5846db77
1211512158
--- /dev/null
1211612159
+++ b/Tools/Playwright/Configurations/Playwright.xcconfig
12117-
@@ -0,0 +1,31 @@
12160+
@@ -0,0 +1,30 @@
1211812161
+// Copyright (C) 2010 Apple Inc. All rights reserved.
1211912162
+//
1212012163
+// Redistribution and use in source and binary forms, with or without
@@ -12139,7 +12182,6 @@ index 0000000000000000000000000000000000000000..085126eb199ec714f7e8d7bc7d7b361e
1213912182
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1214012183
+
1214112184
+PRODUCT_NAME = Playwright
12142-
+CODE_SIGN_ENTITLEMENTS = Playwright.entitlements;
1214312185
+PRODUCT_BUNDLE_IDENTIFIER = org.webkit.$(PRODUCT_NAME:rfc1034identifier)
1214412186
+GCC_PREFIX_HEADER = mac/Playwright_Prefix.pch
1214512187
+INFOPLIST_FILE = mac/Info.plist
@@ -12298,33 +12340,6 @@ index 0000000000000000000000000000000000000000..58e52428388d927ae7681d999e6dd28e
1229812340
+clean: ;
1229912341
+
1230012342
+endif
12301-
diff --git a/Tools/Playwright/Playwright.entitlements b/Tools/Playwright/Playwright.entitlements
12302-
new file mode 100644
12303-
index 0000000000000000000000000000000000000000..e4c2ba180f395dca1d341db666d5c34c2ea3ec2e
12304-
--- /dev/null
12305-
+++ b/Tools/Playwright/Playwright.entitlements
12306-
@@ -0,0 +1,21 @@
12307-
+<?xml version="1.0" encoding="UTF-8"?>
12308-
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
12309-
+<plist version="1.0">
12310-
+<dict>
12311-
+ <key>com.apple.security.app-sandbox</key>
12312-
+ <true/>
12313-
+ <key>com.apple.security.device.usb</key>
12314-
+ <true/>
12315-
+ <key>com.apple.security.files.user-selected.read-write</key>
12316-
+ <true/>
12317-
+ <key>com.apple.security.network.client</key>
12318-
+ <true/>
12319-
+ <key>com.apple.security.temporary-exception.files.absolute-path.read-only</key>
12320-
+ <string>/</string>
12321-
+ <key>com.apple.security.temporary-exception.mach-lookup.global-name</key>
12322-
+ <array>
12323-
+ <string>com.apple.Safari.SafeBrowsing.Service</string>
12324-
+ <string>com.apple.WebKit.NetworkingDaemon</string>
12325-
+ </array>
12326-
+</dict>
12327-
+</plist>
1232812343
diff --git a/Tools/Playwright/Playwright.xcodeproj/project.pbxproj b/Tools/Playwright/Playwright.xcodeproj/project.pbxproj
1232912344
new file mode 100644
1233012345
index 0000000000000000000000000000000000000000..75a945e72d9fcad94bb89fc6325df18d3259383d
@@ -12681,10 +12696,10 @@ index 0000000000000000000000000000000000000000..00fb6b0006c743091a8bbf8edb18b211
1268112696
+</Scheme>
1268212697
diff --git a/Tools/Playwright/mac/AppDelegate.h b/Tools/Playwright/mac/AppDelegate.h
1268312698
new file mode 100644
12684-
index 0000000000000000000000000000000000000000..8d655761a2fb4e0295a965d4fe9e4908deaf89ec
12699+
index 0000000000000000000000000000000000000000..465cb7827fc47927c4e1fc6e47c6608f4ef21d26
1268512700
--- /dev/null
1268612701
+++ b/Tools/Playwright/mac/AppDelegate.h
12687-
@@ -0,0 +1,55 @@
12702+
@@ -0,0 +1,56 @@
1268812703
+/*
1268912704
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
1269012705
+ *
@@ -12725,6 +12740,7 @@ index 0000000000000000000000000000000000000000..8d655761a2fb4e0295a965d4fe9e4908
1272512740
+ bool _headless;
1272612741
+ NSMutableSet *_dialogs;
1272712742
+ NSString* _initialURL;
12743+
+ NSString* _userDataDir;
1272812744
+ IBOutlet NSMenuItem *_newWebKit2WindowItem;
1272912745
+}
1273012746
+
@@ -12742,10 +12758,10 @@ index 0000000000000000000000000000000000000000..8d655761a2fb4e0295a965d4fe9e4908
1274212758
+@end
1274312759
diff --git a/Tools/Playwright/mac/AppDelegate.m b/Tools/Playwright/mac/AppDelegate.m
1274412760
new file mode 100644
12745-
index 0000000000000000000000000000000000000000..46c514097df0555f4f4ad5a135359fe1a31459dc
12761+
index 0000000000000000000000000000000000000000..84e0cd9c2d20111e936e4b16519d20bcd5aa37db
1274612762
--- /dev/null
1274712763
+++ b/Tools/Playwright/mac/AppDelegate.m
12748-
@@ -0,0 +1,448 @@
12764+
@@ -0,0 +1,486 @@
1274912765
+/*
1275012766
+ * Copyright (C) 2010-2016 Apple Inc. All rights reserved.
1275112767
+ *
@@ -12833,13 +12849,18 @@ index 0000000000000000000000000000000000000000..46c514097df0555f4f4ad5a135359fe1
1283312849
+ return nil;
1283412850
+
1283512851
+ _initialURL = nil;
12852+
+ _userDataDir = nil;
1283612853
+ NSArray *arguments = [[NSProcessInfo processInfo] arguments];
1283712854
+ NSRange subargs = NSMakeRange(1, [arguments count] - 1);
1283812855
+ NSArray *subArray = [arguments subarrayWithRange:subargs];
1283912856
+
1284012857
+ for (NSString *argument in subArray) {
1284112858
+ if (![argument hasPrefix:@"--"])
1284212859
+ _initialURL = argument;
12860+
+ if ([argument hasPrefix:@"--user-data-dir="]) {
12861+
+ NSRange range = NSMakeRange(16, [argument length] - 16);
12862+
+ _userDataDir = [[argument substringWithRange:range] copy];
12863+
+ }
1284312864
+ }
1284412865
+
1284512866
+ _headless = [arguments containsObject: @"--headless"];
@@ -12866,13 +12887,46 @@ index 0000000000000000000000000000000000000000..46c514097df0555f4f4ad5a135359fe1
1286612887
+ [NSApp setAutomaticCustomizeTouchBarMenuItemEnabled:YES];
1286712888
+}
1286812889
+
12869-
+static WKWebsiteDataStore *persistentDataStore()
12890+
+- (WKWebsiteDataStore *)persistentDataStore
1287012891
+{
1287112892
+ static WKWebsiteDataStore *dataStore;
1287212893
+
1287312894
+ if (!dataStore) {
1287412895
+ _WKWebsiteDataStoreConfiguration *configuration = [[[_WKWebsiteDataStoreConfiguration alloc] init] autorelease];
12875-
+ configuration.networkCacheSpeculativeValidationEnabled = YES;
12896+
+ if (_userDataDir) {
12897+
+ NSURL *cookieFile = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/cookie.db", _userDataDir]];
12898+
+ [configuration _setCookieStorageFile:cookieFile];
12899+
+
12900+
+ NSURL *applicationCacheDirectory = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/ApplicationCache", _userDataDir]];
12901+
+ [configuration setApplicationCacheDirectory:applicationCacheDirectory];
12902+
+
12903+
+ NSURL *cacheStorageDirectory = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/CacheStorage", _userDataDir]];
12904+
+ [configuration _setCacheStorageDirectory:cacheStorageDirectory];
12905+
+
12906+
+ NSURL *indexedDBDirectory = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/IndexedDB", _userDataDir]];
12907+
+ [configuration _setIndexedDBDatabaseDirectory:indexedDBDirectory];
12908+
+
12909+
+ NSURL *localStorageDirectory = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/LocalStorage", _userDataDir]];
12910+
+ [configuration _setWebStorageDirectory:localStorageDirectory];
12911+
+
12912+
+ NSURL *mediaCacheDirectory = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/MediaCache", _userDataDir]];
12913+
+ [configuration setMediaCacheDirectory:mediaCacheDirectory];
12914+
+
12915+
+ NSURL *mediaKeysDirectory = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/MediaKeys", _userDataDir]];
12916+
+ [configuration setMediaKeysStorageDirectory:mediaKeysDirectory];
12917+
+
12918+
+ NSURL *networkCacheDirectory = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/NetworkCache", _userDataDir]];
12919+
+ [configuration setNetworkCacheDirectory:networkCacheDirectory];
12920+
+
12921+
+ NSURL *loadStatsDirectory = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/ResourceLoadStatistics", _userDataDir]];
12922+
+ [configuration _setResourceLoadStatisticsDirectory:loadStatsDirectory];
12923+
+
12924+
+ NSURL *serviceWorkersDirectory = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/ServiceWorkers", _userDataDir]];
12925+
+ [configuration _setServiceWorkerRegistrationDirectory:serviceWorkersDirectory];
12926+
+
12927+
+ NSURL *webSqlDirectory = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/WebSQL", _userDataDir]];
12928+
+ [configuration _setWebSQLDatabaseDirectory:webSqlDirectory];
12929+
+ }
1287612930
+ dataStore = [[WKWebsiteDataStore alloc] _initWithConfiguration:configuration];
1287712931
+ }
1287812932
+
@@ -12885,7 +12939,7 @@ index 0000000000000000000000000000000000000000..46c514097df0555f4f4ad5a135359fe1
1288512939
+
1288612940
+ if (!configuration) {
1288712941
+ configuration = [[WKWebViewConfiguration alloc] init];
12888-
+ configuration.websiteDataStore = persistentDataStore();
12942+
+ configuration.websiteDataStore = [self persistentDataStore];
1288912943
+ configuration.preferences._fullScreenEnabled = YES;
1289012944
+ configuration.preferences._developerExtrasEnabled = YES;
1289112945
+ configuration.preferences._mediaDevicesEnabled = YES;
@@ -12896,7 +12950,7 @@ index 0000000000000000000000000000000000000000..46c514097df0555f4f4ad5a135359fe1
1289612950
+ configuration.preferences._domTimersThrottlingEnabled = NO;
1289712951
+ configuration.preferences._requestAnimationFrameEnabled = YES;
1289812952
+ _WKProcessPoolConfiguration *processConfiguration = [[[_WKProcessPoolConfiguration alloc] init] autorelease];
12899-
+ configuration.processPool = [[[WKProcessPool alloc] _initWithConfiguration:processConfiguration] autorelease];
12953+
+ configuration.processPool = [[[WKProcessPool alloc] _initWithConfiguration:processConfiguration AndDataStore:configuration.websiteDataStore] autorelease];
1290012954
+ }
1290112955
+ return configuration;
1290212956
+}
@@ -13196,10 +13250,10 @@ index 0000000000000000000000000000000000000000..46c514097df0555f4f4ad5a135359fe1
1319613250
+@end
1319713251
diff --git a/Tools/Playwright/mac/BrowserWindow.xib b/Tools/Playwright/mac/BrowserWindow.xib
1319813252
new file mode 100644
13199-
index 0000000000000000000000000000000000000000..aed963e861f27a467bb6a38859f8d3a446f578b8
13253+
index 0000000000000000000000000000000000000000..f6f3d8e3a0f163e61b2f3d54819e9d25a0a3eb75
1320013254
--- /dev/null
1320113255
+++ b/Tools/Playwright/mac/BrowserWindow.xib
13202-
@@ -0,0 +1,169 @@
13256+
@@ -0,0 +1,153 @@
1320313257
+<?xml version="1.0" encoding="UTF-8"?>
1320413258
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="11191" systemVersion="16D17a" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
1320513259
+ <dependencies>
@@ -13288,22 +13342,6 @@ index 0000000000000000000000000000000000000000..aed963e861f27a467bb6a38859f8d3a4
1328813342
+ </connections>
1328913343
+ </button>
1329013344
+ </toolbarItem>
13291-
+ <toolbarItem implicitItemIdentifier="76DCF2B0-1DDE-47D2-9212-705E6E310CCE" label="Use Shrink To Fit" paletteLabel="Use Shrink To Fit" image="NSEnterFullScreenTemplate" id="81" customClass="MBToolbarItem">
13292-
+ <nil key="toolTip"/>
13293-
+ <size key="minSize" width="29" height="27"/>
13294-
+ <size key="maxSize" width="29" height="27"/>
13295-
+ <button key="view" verticalHuggingPriority="750" id="82">
13296-
+ <rect key="frame" x="34" y="14" width="29" height="25"/>
13297-
+ <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
13298-
+ <buttonCell key="cell" type="roundTextured" bezelStyle="texturedRounded" image="NSEnterFullScreenTemplate" imagePosition="overlaps" alignment="center" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="83">
13299-
+ <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
13300-
+ <font key="font" metaFont="system"/>
13301-
+ </buttonCell>
13302-
+ <connections>
13303-
+ <action selector="toggleShrinkToFit:" target="-2" id="gp7-Vk-KTI"/>
13304-
+ </connections>
13305-
+ </button>
13306-
+ </toolbarItem>
1330713345
+ <toolbarItem implicitItemIdentifier="F1738B7F-895C-48F7-955D-0915E150BE1B" label="Share" paletteLabel="Share" image="NSShareTemplate" id="dJx-dw-gcC" customClass="MBToolbarItem">
1330813346
+ <nil key="toolTip"/>
1330913347
+ <size key="minSize" width="29" height="27"/>

0 commit comments

Comments
 (0)