Skip to content

Commit

Permalink
Merge pull request #249 from AzureAD/jak/wkwebview-session
Browse files Browse the repository at this point in the history
Update embedded webview to share process pool
  • Loading branch information
unpluggedk authored Sep 28, 2018
2 parents 265acb4 + 515d34c commit b442df0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
#import "UIApplication+MSIDExtensions.h"
#import "MSIDAppExtensionUtil.h"

static WKWebViewConfiguration *s_webConfig;

@interface MSIDWebviewUIController ( )
{
UIActivityIndicatorView *_loadingIndicator;
Expand All @@ -40,6 +42,14 @@ @interface MSIDWebviewUIController ( )

@implementation MSIDWebviewUIController

+ (void)initialize
{
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
s_webConfig = [WKWebViewConfiguration new];
});
}

- (id)initWithContext:(id<MSIDRequestContext>)context
{
self = [super init];
Expand Down Expand Up @@ -86,8 +96,7 @@ - (BOOL)loadView:(NSError **)error;
[rootView setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight];

// Prepare the WKWebView
WKWebViewConfiguration *webConfiguration = [WKWebViewConfiguration new];
WKWebView *webView = [[WKWebView alloc] initWithFrame:rootView.frame configuration:webConfiguration];
WKWebView *webView = [[WKWebView alloc] initWithFrame:rootView.frame configuration:s_webConfig];
[webView setAccessibilityIdentifier:@"MSID_SIGN_IN_WEBVIEW"];

// Customize the UI
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
#define DEFAULT_WINDOW_WIDTH 420
#define DEFAULT_WINDOW_HEIGHT 650

static WKWebViewConfiguration *s_webConfig;

@interface MSIDWebviewUIController ( ) <NSWindowDelegate>
{
NSProgressIndicator *_loadingIndicator;
Expand All @@ -37,6 +39,14 @@ @interface MSIDWebviewUIController ( ) <NSWindowDelegate>

@implementation MSIDWebviewUIController

+ (void)initialize
{
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
s_webConfig = [WKWebViewConfiguration new];
});
}

- (id)initWithContext:(id<MSIDRequestContext>)context
{
self = [super init];
Expand All @@ -60,8 +70,7 @@ - (BOOL)loadView:(NSError **)error
NSView *rootView = window.contentView;

// Prepare the WKWebView
WKWebViewConfiguration *webConfiguration = [WKWebViewConfiguration new];
WKWebView *webView = [[WKWebView alloc] initWithFrame:rootView.frame configuration:webConfiguration];
WKWebView *webView = [[WKWebView alloc] initWithFrame:rootView.frame configuration:s_webConfig];
[webView setAccessibilityIdentifier:@"MSID_SIGN_IN_WEBVIEW"];

// Customize the UI
Expand Down

0 comments on commit b442df0

Please sign in to comment.