Fix crash when opening in new tab
This commit is contained in:
@@ -60,32 +60,38 @@
|
||||
return interface;
|
||||
}
|
||||
|
||||
- (WKWebView *)webView
|
||||
- (instancetype)initWithWebViewConfiguration:(WKWebViewConfiguration *)webViewConfiguration
|
||||
{
|
||||
if (!_webView) {
|
||||
// Inject bundle
|
||||
_WKProcessPoolConfiguration *poolConfiguration = [[_WKProcessPoolConfiguration alloc] init];
|
||||
NSURL *bundleURL = [[[NSBundle mainBundle] builtInPlugInsURL] URLByAppendingPathComponent:@"SBrowserProcessBundle.bundle"];
|
||||
|
||||
// Make sure it exists. Bail if otherwise.
|
||||
NSBundle *pluginBundle = [NSBundle bundleWithURL:bundleURL];
|
||||
NSAssert(pluginBundle != nil, @"Attix process bundle not found at %@", bundleURL.path);
|
||||
|
||||
[poolConfiguration setInjectedBundleURL:bundleURL];
|
||||
self = [super init];
|
||||
if (self) {
|
||||
if (!webViewConfiguration) {
|
||||
webViewConfiguration = [[WKWebViewConfiguration alloc] init];
|
||||
|
||||
// Inject bundle
|
||||
_WKProcessPoolConfiguration *poolConfiguration = [[_WKProcessPoolConfiguration alloc] init];
|
||||
NSURL *bundleURL = [[[NSBundle mainBundle] builtInPlugInsURL] URLByAppendingPathComponent:@"SBrowserProcessBundle.bundle"];
|
||||
|
||||
// Make sure it exists. Bail if otherwise.
|
||||
NSBundle *pluginBundle = [NSBundle bundleWithURL:bundleURL];
|
||||
NSAssert(pluginBundle != nil, @"Attix process bundle not found at %@", bundleURL.path);
|
||||
|
||||
[poolConfiguration setInjectedBundleURL:bundleURL];
|
||||
|
||||
// Set up process pool
|
||||
_processPool = [[WKProcessPool alloc] _initWithConfiguration:poolConfiguration];
|
||||
// Set up process pool
|
||||
_processPool = [[WKProcessPool alloc] _initWithConfiguration:poolConfiguration];
|
||||
|
||||
// Initialize allowed origins now
|
||||
NSArray<NSString *> *allowedOrigins = [[_policyDataSource allowedOriginsForScriptResources] allObjects];
|
||||
[_processPool _setObject:allowedOrigins forBundleParameter:SBRGetAllowedOriginsKey()];
|
||||
[_processPool _setObject:@(_allowAllScripts) forBundleParameter:SBRGetAllScriptsAllowedKey()];
|
||||
|
||||
webViewConfiguration.processPool = _processPool;
|
||||
}
|
||||
|
||||
// Initialize allowed origins now
|
||||
NSArray<NSString *> *allowedOrigins = [[_policyDataSource allowedOriginsForScriptResources] allObjects];
|
||||
[_processPool _setObject:allowedOrigins forBundleParameter:SBRGetAllowedOriginsKey()];
|
||||
[_processPool _setObject:@(_allowAllScripts) forBundleParameter:SBRGetAllScriptsAllowedKey()];
|
||||
|
||||
WKWebViewConfiguration *configuration = [[WKWebViewConfiguration alloc] init];
|
||||
configuration.processPool = _processPool;
|
||||
_webViewConfiguration = webViewConfiguration;
|
||||
|
||||
// Instantiate web view
|
||||
WKWebView *webView = [[WKWebView alloc] initWithFrame:CGRectZero configuration:configuration];
|
||||
WKWebView *webView = [[WKWebView alloc] initWithFrame:CGRectZero configuration:webViewConfiguration];
|
||||
|
||||
// Configure proxy interface (interface to remote web process)
|
||||
_webProcessProxy = [[webView _remoteObjectRegistry] remoteObjectProxyWithInterface:[self _webProcessProxyInterface]];
|
||||
@@ -94,10 +100,9 @@
|
||||
[[webView _remoteObjectRegistry] registerExportedObject:self interface:[self _webProcessDelegateInterface]];
|
||||
|
||||
_webView = webView;
|
||||
_webViewConfiguration = configuration;
|
||||
}
|
||||
|
||||
return _webView;
|
||||
return self;
|
||||
}
|
||||
|
||||
#pragma mark <SBRWebProcessDelegate>
|
||||
|
||||
Reference in New Issue
Block a user