You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by sh...@apache.org on 2015/05/28 07:39:25 UTC
ios commit: CB-8812 - moved system schemes handler into its own
plugin (CDVSystemSchemes)
Repository: cordova-ios
Updated Branches:
refs/heads/4.0.x 065111f33 -> 14f240013
CB-8812 - moved system schemes handler into its own plugin (CDVSystemSchemes)
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/14f24001
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/14f24001
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/14f24001
Branch: refs/heads/4.0.x
Commit: 14f240013ef4eacd8455659847010f9d6c5120ad
Parents: 065111f
Author: Shazron Abdullah <sh...@apache.org>
Authored: Wed May 27 22:39:24 2015 -0700
Committer: Shazron Abdullah <sh...@apache.org>
Committed: Wed May 27 22:39:24 2015 -0700
----------------------------------------------------------------------
.../Plugins/CDVSystemSchemes/CDVSystemSchemes.h | 26 +++++++++
.../Plugins/CDVSystemSchemes/CDVSystemSchemes.m | 58 ++++++++++++++++++++
.../CDVUIWebViewNavigationDelegate.m | 8 ---
CordovaLib/CordovaLib.xcodeproj/project.pbxproj | 16 ++++++
.../project/__PROJECT_NAME__/config.xml | 4 ++
bin/templates/scripts/cordova/defaults.xml | 5 ++
6 files changed, 109 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/14f24001/CordovaLib/Classes/Private/Plugins/CDVSystemSchemes/CDVSystemSchemes.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/Private/Plugins/CDVSystemSchemes/CDVSystemSchemes.h b/CordovaLib/Classes/Private/Plugins/CDVSystemSchemes/CDVSystemSchemes.h
new file mode 100644
index 0000000..48d1ff5
--- /dev/null
+++ b/CordovaLib/Classes/Private/Plugins/CDVSystemSchemes/CDVSystemSchemes.h
@@ -0,0 +1,26 @@
+/*
+ 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 "CDVPlugin.h"
+
+@interface CDVSystemSchemes : CDVPlugin
+
+@property (nonatomic, readonly) NSArray* systemSchemes;
+
+@end
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/14f24001/CordovaLib/Classes/Private/Plugins/CDVSystemSchemes/CDVSystemSchemes.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/Private/Plugins/CDVSystemSchemes/CDVSystemSchemes.m b/CordovaLib/Classes/Private/Plugins/CDVSystemSchemes/CDVSystemSchemes.m
new file mode 100644
index 0000000..7f54663
--- /dev/null
+++ b/CordovaLib/Classes/Private/Plugins/CDVSystemSchemes/CDVSystemSchemes.m
@@ -0,0 +1,58 @@
+/*
+ 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 "CDVSystemSchemes.h"
+#import "NSDictionary+CordovaPreferences.h"
+#import "CDV.h"
+
+@interface CDVSystemSchemes ()
+
+@property (nonatomic, readwrite) NSArray* systemSchemes;
+
+@end
+
+@implementation CDVSystemSchemes
+
+- (void)pluginInitialize
+{
+ // Read from preference, if not use default
+ NSString* schemesToOverride = [[self.commandDelegate settings] cordovaSettingForKey:@"CDVSystemSchemesOverride"];
+
+ if ((schemesToOverride == nil) || ([schemesToOverride length] == 0)) {
+ self.systemSchemes = @[@"maps", @"tel", @"telprompt"];
+ } else {
+ // parse csv naïvely
+ self.systemSchemes = [schemesToOverride componentsSeparatedByString:@","];
+ }
+}
+
+- (BOOL)shouldOverrideLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType
+{
+ NSURL* url = [request URL];
+
+ // Push these system schemes off to the system, and do not let the UIWebView handle them
+ if ([self.systemSchemes indexOfObject:[url scheme]] != NSNotFound) {
+ [[UIApplication sharedApplication] openURL:url];
+ return YES;
+ }
+
+ return NO;
+}
+
+@end
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/14f24001/CordovaLib/Classes/Private/Plugins/CDVUIWebViewEngine/CDVUIWebViewNavigationDelegate.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/Private/Plugins/CDVUIWebViewEngine/CDVUIWebViewNavigationDelegate.m b/CordovaLib/Classes/Private/Plugins/CDVUIWebViewEngine/CDVUIWebViewNavigationDelegate.m
index 38e8d24..b660638 100644
--- a/CordovaLib/Classes/Private/Plugins/CDVUIWebViewEngine/CDVUIWebViewNavigationDelegate.m
+++ b/CordovaLib/Classes/Private/Plugins/CDVUIWebViewEngine/CDVUIWebViewNavigationDelegate.m
@@ -89,14 +89,6 @@
NSURL* url = [request URL];
CDVViewController* vc = (CDVViewController*)self.enginePlugin.viewController;
- // Push these system schemes off to the system, and do not let the UIWebView handle them
- if ([request.URL.scheme isEqualToString:@"maps"] ||
- [request.URL.scheme isEqualToString:@"tel"] ||
- [request.URL.scheme isEqualToString:@"telprompt"]) {
- [[UIApplication sharedApplication] openURL:url];
- return NO;
- }
-
/*
* Execute any commands queued with cordova.exec() on the JS side.
* The part of the URL after gap:// is irrelevant.
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/14f24001/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
----------------------------------------------------------------------
diff --git a/CordovaLib/CordovaLib.xcodeproj/project.pbxproj b/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
index 63e9762..9502873 100644
--- a/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
+++ b/CordovaLib/CordovaLib.xcodeproj/project.pbxproj
@@ -9,6 +9,8 @@
/* Begin PBXBuildFile section */
30193A501AE6350A0069A75F /* CDVUIWebViewNavigationDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 30193A4E1AE6350A0069A75F /* CDVUIWebViewNavigationDelegate.m */; };
30193A511AE6350A0069A75F /* CDVUIWebViewNavigationDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 30193A4F1AE6350A0069A75F /* CDVUIWebViewNavigationDelegate.h */; };
+ 3093E2231B16D6A3003F381A /* CDVSystemSchemes.h in Headers */ = {isa = PBXBuildFile; fileRef = 3093E2211B16D6A3003F381A /* CDVSystemSchemes.h */; };
+ 3093E2241B16D6A3003F381A /* CDVSystemSchemes.m in Sources */ = {isa = PBXBuildFile; fileRef = 3093E2221B16D6A3003F381A /* CDVSystemSchemes.m */; };
7E7F69B61ABA35D8007546F4 /* CDVLocalStorage.h in Headers */ = {isa = PBXBuildFile; fileRef = 7ED95CFB1AB9028C008C4574 /* CDVLocalStorage.h */; };
7E7F69B81ABA368F007546F4 /* CDVUIWebViewEngine.h in Headers */ = {isa = PBXBuildFile; fileRef = 7ED95D001AB9028C008C4574 /* CDVUIWebViewEngine.h */; };
7E7F69B91ABA3692007546F4 /* CDVHandleOpenURL.h in Headers */ = {isa = PBXBuildFile; fileRef = 7ED95CF81AB9028C008C4574 /* CDVHandleOpenURL.h */; };
@@ -63,6 +65,8 @@
30193A4E1AE6350A0069A75F /* CDVUIWebViewNavigationDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDVUIWebViewNavigationDelegate.m; sourceTree = "<group>"; };
30193A4F1AE6350A0069A75F /* CDVUIWebViewNavigationDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDVUIWebViewNavigationDelegate.h; sourceTree = "<group>"; };
30325A0B136B343700982B63 /* VERSION */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = VERSION; sourceTree = "<group>"; };
+ 3093E2211B16D6A3003F381A /* CDVSystemSchemes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDVSystemSchemes.h; sourceTree = "<group>"; };
+ 3093E2221B16D6A3003F381A /* CDVSystemSchemes.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDVSystemSchemes.m; sourceTree = "<group>"; };
68A32D7114102E1C006B237C /* libCordova.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libCordova.a; sourceTree = BUILT_PRODUCTS_DIR; };
7ED95CF21AB9028C008C4574 /* CDVDebug.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDVDebug.h; sourceTree = "<group>"; };
7ED95CF31AB9028C008C4574 /* CDVJSON_private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDVJSON_private.h; sourceTree = "<group>"; };
@@ -145,6 +149,15 @@
name = CordovaLib;
sourceTree = "<group>";
};
+ 3093E2201B16D6A3003F381A /* CDVSystemSchemes */ = {
+ isa = PBXGroup;
+ children = (
+ 3093E2211B16D6A3003F381A /* CDVSystemSchemes.h */,
+ 3093E2221B16D6A3003F381A /* CDVSystemSchemes.m */,
+ );
+ path = CDVSystemSchemes;
+ sourceTree = "<group>";
+ };
7ED95CF11AB9028C008C4574 /* Private */ = {
isa = PBXGroup;
children = (
@@ -162,6 +175,7 @@
7ED95CF61AB9028C008C4574 /* Plugins */ = {
isa = PBXGroup;
children = (
+ 3093E2201B16D6A3003F381A /* CDVSystemSchemes */,
7ED95CF71AB9028C008C4574 /* CDVHandleOpenURL */,
7ED95CFA1AB9028C008C4574 /* CDVLocalStorage */,
7ED95CFD1AB9028C008C4574 /* CDVUIWebViewEngine */,
@@ -277,6 +291,7 @@
7ED95D021AB9028C008C4574 /* CDVDebug.h in Headers */,
7ED95D051AB9028C008C4574 /* CDVPlugin+Private.h in Headers */,
7E7F69B61ABA35D8007546F4 /* CDVLocalStorage.h in Headers */,
+ 3093E2231B16D6A3003F381A /* CDVSystemSchemes.h in Headers */,
7E7F69B81ABA368F007546F4 /* CDVUIWebViewEngine.h in Headers */,
7E7F69B91ABA3692007546F4 /* CDVHandleOpenURL.h in Headers */,
30193A511AE6350A0069A75F /* CDVUIWebViewNavigationDelegate.h in Headers */,
@@ -358,6 +373,7 @@
7ED95D0D1AB9028C008C4574 /* CDVUIWebViewEngine.m in Sources */,
7ED95D461AB9029B008C4574 /* CDVPlugin.m in Sources */,
7ED95D091AB9028C008C4574 /* CDVLocalStorage.m in Sources */,
+ 3093E2241B16D6A3003F381A /* CDVSystemSchemes.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/14f24001/bin/templates/project/__PROJECT_NAME__/config.xml
----------------------------------------------------------------------
diff --git a/bin/templates/project/__PROJECT_NAME__/config.xml b/bin/templates/project/__PROJECT_NAME__/config.xml
index 96360bb..338cf0f 100644
--- a/bin/templates/project/__PROJECT_NAME__/config.xml
+++ b/bin/templates/project/__PROJECT_NAME__/config.xml
@@ -67,4 +67,8 @@
<param name="ios-package" value="CDVHandleOpenURL"/>
<param name="onload" value="true"/>
</feature>
+ <feature name="SystemSchemes">
+ <param name="ios-package" value="CDVSystemSchemes"/>
+ <param name="onload" value="true"/>
+ </feature>
</widget>
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/14f24001/bin/templates/scripts/cordova/defaults.xml
----------------------------------------------------------------------
diff --git a/bin/templates/scripts/cordova/defaults.xml b/bin/templates/scripts/cordova/defaults.xml
index db5d7e6..ba6b2eb 100644
--- a/bin/templates/scripts/cordova/defaults.xml
+++ b/bin/templates/scripts/cordova/defaults.xml
@@ -41,4 +41,9 @@
<param name="ios-package" value="CDVHandleOpenURL"/>
<param name="onload" value="true"/>
</feature>
+ <feature name="SystemSchemes">
+ <param name="ios-package" value="CDVSystemSchemes"/>
+ <param name="onload" value="true"/>
+ </feature>
+
</widget>
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org