cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject [03/10] cordova-plugin-wkwebview-engine git commit: CB-12297 Support WKProcessPool for cookie sharing
Date Fri, 03 Mar 2017 00:52:02 GMT
CB-12297 Support WKProcessPool for cookie sharing

 This closes #27


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-wkwebview-engine/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-wkwebview-engine/commit/8a085185
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-wkwebview-engine/tree/8a085185
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-wkwebview-engine/diff/8a085185

Branch: refs/heads/1.1.x
Commit: 8a08518593f1fbd80ece0b40122479a79ba7a9b5
Parents: 5c7cf8c
Author: anand.v.nath@gmail.com <anand.v.nath@gmail.com>
Authored: Fri Dec 23 14:13:22 2016 +0530
Committer: Steve Gill <stevengill97@gmail.com>
Committed: Thu Mar 2 16:51:33 2017 -0800

----------------------------------------------------------------------
 README.md                                       |  1 +
 plugin.xml                                      |  4 +-
 src/ios/CDVWKProcessPoolFactory.h               | 27 +++++++++++
 src/ios/CDVWKProcessPoolFactory.m               | 49 ++++++++++++++++++++
 src/ios/CDVWKWebViewEngine.m                    |  3 +-
 .../CDVWKWebViewEngineTest.m                    |  6 +++
 .../project.pbxproj                             |  6 +++
 7 files changed, 93 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-wkwebview-engine/blob/8a085185/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
index 7c416e7..73542d8 100644
--- a/README.md
+++ b/README.md
@@ -64,6 +64,7 @@ WKWebView may not fully launch (the deviceready event may not fire) unless
if th
 
 Notes
 ------
+This plugin creates a shared `WKProcessPool` which ensures the cookie sharing happens correctly
across `WKWebView` instances. `CDVWKProcessPoolFactory` class can be used to obtain the shared
`WKProcessPool` instance if app creates `WKWebView` outside of this plugin.
 
 On an iOS 8 system, Apache Cordova during runtime will switch to using the UIWebView engine
instead of using this plugin. If you want to use WKWebView on both iOS 8 and iOS 9 platforms,
you will have to resort to using a local webserver.
 

http://git-wip-us.apache.org/repos/asf/cordova-plugin-wkwebview-engine/blob/8a085185/plugin.xml
----------------------------------------------------------------------
diff --git a/plugin.xml b/plugin.xml
index 0d68f50..c30ee0a 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -54,7 +54,7 @@
         <source-file src="src/ios/CDVWKWebViewEngine.m" />
         <header-file src="src/ios/CDVWKWebViewUIDelegate.h" />
         <source-file src="src/ios/CDVWKWebViewUIDelegate.m" />
-
+        <header-file src="src/ios/CDVWKProcessPoolFactory.h" />
+        <source-file src="src/ios/CDVWKProcessPoolFactory.m" />
     </platform>
-
 </plugin>

http://git-wip-us.apache.org/repos/asf/cordova-plugin-wkwebview-engine/blob/8a085185/src/ios/CDVWKProcessPoolFactory.h
----------------------------------------------------------------------
diff --git a/src/ios/CDVWKProcessPoolFactory.h b/src/ios/CDVWKProcessPoolFactory.h
new file mode 100644
index 0000000..f4f8816
--- /dev/null
+++ b/src/ios/CDVWKProcessPoolFactory.h
@@ -0,0 +1,27 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License.  You may obtain a copy of the License at
+ 
+ http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied.  See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ */
+
+#import <WebKit/WebKit.h>
+
+@interface CDVWKProcessPoolFactory : NSObject
+@property (nonatomic, retain) WKProcessPool* sharedPool;
+
++(instancetype) sharedFactory;
+-(WKProcessPool*) sharedProcessPool;
+@end

http://git-wip-us.apache.org/repos/asf/cordova-plugin-wkwebview-engine/blob/8a085185/src/ios/CDVWKProcessPoolFactory.m
----------------------------------------------------------------------
diff --git a/src/ios/CDVWKProcessPoolFactory.m b/src/ios/CDVWKProcessPoolFactory.m
new file mode 100644
index 0000000..48ac09e
--- /dev/null
+++ b/src/ios/CDVWKProcessPoolFactory.m
@@ -0,0 +1,49 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License.  You may obtain a copy of the License at
+ 
+ http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied.  See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ */
+
+#import <Foundation/Foundation.h>
+#import <WebKit/WebKit.h>
+#import "CDVWKProcessPoolFactory.h"
+
+static CDVWKProcessPoolFactory *factory = nil;
+
+@implementation CDVWKProcessPoolFactory
+
++ (instancetype)sharedFactory
+{
+    static dispatch_once_t onceToken;
+    dispatch_once(&onceToken, ^{
+        factory = [[CDVWKProcessPoolFactory alloc] init];
+    });
+    
+    return factory;
+}
+
+- (instancetype)init
+{
+    if (self = [super init]) {
+        _sharedPool = [[WKProcessPool alloc] init];
+    }
+    return self;
+}
+
+- (WKProcessPool*) sharedProcessPool {
+    return _sharedPool;
+}
+@end

http://git-wip-us.apache.org/repos/asf/cordova-plugin-wkwebview-engine/blob/8a085185/src/ios/CDVWKWebViewEngine.m
----------------------------------------------------------------------
diff --git a/src/ios/CDVWKWebViewEngine.m b/src/ios/CDVWKWebViewEngine.m
index 7e2efa9..5ffe290 100644
--- a/src/ios/CDVWKWebViewEngine.m
+++ b/src/ios/CDVWKWebViewEngine.m
@@ -19,6 +19,7 @@
 
 #import "CDVWKWebViewEngine.h"
 #import "CDVWKWebViewUIDelegate.h"
+#import "CDVWKProcessPoolFactory.h"
 #import <Cordova/NSDictionary+CordovaPreferences.h>
 
 #import <objc/message.h>
@@ -67,6 +68,7 @@
 - (WKWebViewConfiguration*) createConfigurationFromSettings:(NSDictionary*)settings
 {
     WKWebViewConfiguration* configuration = [[WKWebViewConfiguration alloc] init];
+    configuration.processPool = [[CDVWKProcessPoolFactory sharedFactory] sharedProcessPool];
     if (settings == nil) {
         return configuration;
     }
@@ -75,7 +77,6 @@
     configuration.mediaPlaybackRequiresUserAction = [settings cordovaBoolSettingForKey:@"MediaPlaybackRequiresUserAction"
defaultValue:YES];
     configuration.suppressesIncrementalRendering = [settings cordovaBoolSettingForKey:@"SuppressesIncrementalRendering"
defaultValue:NO];
     configuration.mediaPlaybackAllowsAirPlay = [settings cordovaBoolSettingForKey:@"MediaPlaybackAllowsAirPlay"
defaultValue:YES];
-
     return configuration;
 }
 

http://git-wip-us.apache.org/repos/asf/cordova-plugin-wkwebview-engine/blob/8a085185/tests/ios/CDVWKWebViewEngineTest/CDVWKWebViewEngineLibTests/CDVWKWebViewEngineTest.m
----------------------------------------------------------------------
diff --git a/tests/ios/CDVWKWebViewEngineTest/CDVWKWebViewEngineLibTests/CDVWKWebViewEngineTest.m
b/tests/ios/CDVWKWebViewEngineTest/CDVWKWebViewEngineLibTests/CDVWKWebViewEngineTest.m
index 0c359c2..12d9598 100644
--- a/tests/ios/CDVWKWebViewEngineTest/CDVWKWebViewEngineLibTests/CDVWKWebViewEngineTest.m
+++ b/tests/ios/CDVWKWebViewEngineTest/CDVWKWebViewEngineLibTests/CDVWKWebViewEngineTest.m
@@ -20,6 +20,7 @@
 #import <UIKit/UIKit.h>
 #import <XCTest/XCTest.h>
 #import "CDVWKWebViewEngine.h"
+#import "CDVWKProcessPoolFactory.h"
 #import <Cordova/NSDictionary+CordovaPreferences.h>
 #import <Cordova/CDVAvailability.h>
 
@@ -231,4 +232,9 @@
     XCTAssertFalse(wkWebView.configuration.allowsAirPlayForMediaPlayback);    
 }
 
+- (void) testWKProcessPoolFactory {
+    WKProcessPool* shared = [[CDVWKProcessPoolFactory sharedFactory] sharedProcessPool];
+    XCTAssertTrue(shared != nil);
+}
+
 @end

http://git-wip-us.apache.org/repos/asf/cordova-plugin-wkwebview-engine/blob/8a085185/tests/ios/CDVWKWebViewEngineTest/CDVWKWebViewEngineTest.xcodeproj/project.pbxproj
----------------------------------------------------------------------
diff --git a/tests/ios/CDVWKWebViewEngineTest/CDVWKWebViewEngineTest.xcodeproj/project.pbxproj
b/tests/ios/CDVWKWebViewEngineTest/CDVWKWebViewEngineTest.xcodeproj/project.pbxproj
index d86832b..d95593f 100644
--- a/tests/ios/CDVWKWebViewEngineTest/CDVWKWebViewEngineTest.xcodeproj/project.pbxproj
+++ b/tests/ios/CDVWKWebViewEngineTest/CDVWKWebViewEngineTest.xcodeproj/project.pbxproj
@@ -15,6 +15,7 @@
 		7E9F51BA19DA1B2000DA31AC /* libCordova.a in Frameworks */ = {isa = PBXBuildFile; fileRef
= 7E9F519019DA0F8300DA31AC /* libCordova.a */; };
 		7EACDCE71D234E2A00494C9E /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef
= 7EACDCE61D234E2A00494C9E /* WebKit.framework */; };
 		7EACDCEB1D234FB300494C9E /* CDVWKWebViewUIDelegate.m in Sources */ = {isa = PBXBuildFile;
fileRef = 7EACDCEA1D234FB300494C9E /* CDVWKWebViewUIDelegate.m */; };
+		A9CC1CED1E0D42F50083E165 /* CDVWKProcessPoolFactory.m in Sources */ = {isa = PBXBuildFile;
fileRef = A9CC1CEC1E0D42F50083E165 /* CDVWKProcessPoolFactory.m */; };
 /* End PBXBuildFile section */
 
 /* Begin PBXContainerItemProxy section */
@@ -73,6 +74,8 @@
 		7EACDCE61D234E2A00494C9E /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType
= wrapper.framework; name = WebKit.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.3.sdk/System/Library/Frameworks/WebKit.framework;
sourceTree = DEVELOPER_DIR; };
 		7EACDCE91D234FB300494C9E /* CDVWKWebViewUIDelegate.h */ = {isa = PBXFileReference; fileEncoding
= 4; lastKnownFileType = sourcecode.c.h; name = CDVWKWebViewUIDelegate.h; path = ../../../src/ios/CDVWKWebViewUIDelegate.h;
sourceTree = SOURCE_ROOT; };
 		7EACDCEA1D234FB300494C9E /* CDVWKWebViewUIDelegate.m */ = {isa = PBXFileReference; fileEncoding
= 4; lastKnownFileType = sourcecode.c.objc; name = CDVWKWebViewUIDelegate.m; path = ../../../src/ios/CDVWKWebViewUIDelegate.m;
sourceTree = SOURCE_ROOT; };
+		A9CC1CEB1E0D42F50083E165 /* CDVWKProcessPoolFactory.h */ = {isa = PBXFileReference; fileEncoding
= 4; lastKnownFileType = sourcecode.c.h; name = CDVWKProcessPoolFactory.h; path = ../../../src/ios/CDVWKProcessPoolFactory.h;
sourceTree = SOURCE_ROOT; };
+		A9CC1CEC1E0D42F50083E165 /* CDVWKProcessPoolFactory.m */ = {isa = PBXFileReference; fileEncoding
= 4; lastKnownFileType = sourcecode.c.objc; name = CDVWKProcessPoolFactory.m; path = ../../../src/ios/CDVWKProcessPoolFactory.m;
sourceTree = SOURCE_ROOT; };
 /* End PBXFileReference section */
 
 /* Begin PBXFrameworksBuildPhase section */
@@ -131,6 +134,8 @@
 		7E9F519619DA102000DA31AC /* CDVWKWebViewEngineLib */ = {
 			isa = PBXGroup;
 			children = (
+				A9CC1CEB1E0D42F50083E165 /* CDVWKProcessPoolFactory.h */,
+				A9CC1CEC1E0D42F50083E165 /* CDVWKProcessPoolFactory.m */,
 				7EACDCE91D234FB300494C9E /* CDVWKWebViewUIDelegate.h */,
 				7EACDCEA1D234FB300494C9E /* CDVWKWebViewUIDelegate.m */,
 				7E9F51A919DA10AE00DA31AC /* CDVWKWebViewEngine.m */,
@@ -261,6 +266,7 @@
 			isa = PBXSourcesBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				A9CC1CED1E0D42F50083E165 /* CDVWKProcessPoolFactory.m in Sources */,
 				7EACDCEB1D234FB300494C9E /* CDVWKWebViewUIDelegate.m in Sources */,
 				7E9F51AB19DA10AE00DA31AC /* CDVWKWebViewEngine.m in Sources */,
 			);


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message