Repository: cordova-plugin-inappbrowser
Updated Branches:
  refs/heads/master d4156fb19 -> 32253b96a


CB-11955 Added Initial OSX platform support

- Added src/osx plugin folder structure.
- Added OSX platform to plugin.xml and package.json files.
- Added _system target functionality for OSX.
- Modified README.md to include information about OSX support.
- Disabled 'open method' jasmine tests for OSX.

 This closes #190


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/commit/32253b96
Tree: 
http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/tree/32253b96
Diff: 
http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/diff/32253b96

Branch: refs/heads/master
Commit: 32253b96a61b3ac68f2eec9ec2ee225f87b92793
Parents: d4156fb
Author: pwlin <pwli...@gmail.com>
Authored: Thu Oct 6 18:39:10 2016 +0200
Committer: Tobias Bocanegra <tri...@adobe.com>
Committed: Thu Oct 13 12:43:39 2016 +0900

----------------------------------------------------------------------
 README.md                 |  9 ++++-
 package.json              |  2 +
 plugin.xml                | 16 ++++++++
 src/osx/CDVInAppBrowser.h | 30 ++++++++++++++
 src/osx/CDVInAppBrowser.m | 89 ++++++++++++++++++++++++++++++++++++++++++
 tests/tests.js            |  5 +++
 6 files changed, 150 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/blob/32253b96/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
index e7e9697..3eecf1a 100644
--- a/README.md
+++ b/README.md
@@ -69,7 +69,7 @@ Although `window.open` is in the global scope, InAppBrowser 
is not available unt
 Report issues with this plugin on the [Apache Cordova issue 
tracker](https://issues.apache.org/jira/issues/?jql=project%20%3D%20CB%20AND%20status%20in%20%28Open%2C%20%22In%20Progress%22%2C%20Reopened%29%20AND%20resolution%20%3D%20Unresolved%20AND%20component%20%3D%20%22Plugin%20InAppBrowser%22%20ORDER%20BY%20priority%20DESC%2C%20summary%20ASC%2C%20updatedDate%20DESC)
 
 
-## <a id="reference">Reference
+## <a id="reference">Reference</a>
 ## Installation
 
     cordova plugin add cordova-plugin-inappbrowser
@@ -145,6 +145,7 @@ instance, or the system browser.
 - BlackBerry 10
 - Firefox OS
 - iOS
+- OSX
 - Windows 8 and 8.1
 - Windows Phone 7 and 8
 - Browser
@@ -185,6 +186,12 @@ opened with `target='_blank'`. The rules might look like 
these
 }
 ```
 
+### OSX Quirks
+
+At the moment the only supported target in OSX is `_system`.
+
+`_blank` and `_self` targets are not yet implemented and are ignored silently. 
Pull requests and patches to get these to work are greatly appreciated.
+
 ### Windows Quirks
 
 Windows 8.0, 8.1 and Windows Phone 8.1 don't support remote urls to be opened 
in the Cordova WebView so remote urls are always showed in the system's web 
browser if opened with `target='_self'`.

http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/blob/32253b96/package.json
----------------------------------------------------------------------
diff --git a/package.json b/package.json
index 7acaf87..334d7c9 100644
--- a/package.json
+++ b/package.json
@@ -9,6 +9,7 @@
       "amazon-fireos",
       "ubuntu",
       "ios",
+      "osx",
       "wp7",
       "wp8",
       "windows8",
@@ -31,6 +32,7 @@
     "cordova-amazon-fireos",
     "cordova-ubuntu",
     "cordova-ios",
+    "cordova-osx",
     "cordova-wp7",
     "cordova-wp8",
     "cordova-windows8",

http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/blob/32253b96/plugin.xml
----------------------------------------------------------------------
diff --git a/plugin.xml b/plugin.xml
index 42018a5..388e767 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -131,6 +131,22 @@
            <framework src="CoreGraphics.framework" />
     </platform>
 
+    <!-- osx -->
+    <platform name="osx">
+        <js-module src="www/inappbrowser.js" name="inappbrowser">
+            <clobbers target="cordova.InAppBrowser.open" />
+            <clobbers target="window.open" />
+        </js-module>
+        <config-file target="config.xml" parent="/*">
+            <feature name="InAppBrowser">
+                <param name="osx-package" value="CDVInAppBrowser" />
+            </feature>
+        </config-file>
+
+        <header-file src="src/osx/CDVInAppBrowser.h" />
+        <source-file src="src/osx/CDVInAppBrowser.m" />
+    </platform>
+
     <!-- wp7 -->
     <platform name="wp7">
         <config-file target="Properties/WMAppManifest.xml" 
parent="/Deployment/App/Capabilities">

http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/blob/32253b96/src/osx/CDVInAppBrowser.h
----------------------------------------------------------------------
diff --git a/src/osx/CDVInAppBrowser.h b/src/osx/CDVInAppBrowser.h
new file mode 100644
index 0000000..742af70
--- /dev/null
+++ b/src/osx/CDVInAppBrowser.h
@@ -0,0 +1,30 @@
+/*
+ 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 <Cordova/CDVPlugin.h>
+
+@interface CDVInAppBrowser : CDVPlugin {
+}
+
+@property (nonatomic, copy) NSString* callbackId;
+
+- (void)open:(CDVInvokedUrlCommand*)command;
+
+@end
+

http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/blob/32253b96/src/osx/CDVInAppBrowser.m
----------------------------------------------------------------------
diff --git a/src/osx/CDVInAppBrowser.m b/src/osx/CDVInAppBrowser.m
new file mode 100644
index 0000000..9d579e1
--- /dev/null
+++ b/src/osx/CDVInAppBrowser.m
@@ -0,0 +1,89 @@
+/*
+ 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 "CDVInAppBrowser.h"
+#import <Cordova/CDVPluginResult.h>
+
+#define    kInAppBrowserTargetSelf @"_self"
+#define    kInAppBrowserTargetSystem @"_system"
+#define    kInAppBrowserTargetBlank @"_blank"
+
+@interface CDVInAppBrowser () {
+}
+@end
+
+@implementation CDVInAppBrowser
+
+- (void)pluginInitialize
+{
+}
+
+- (BOOL) isSystemUrl:(NSURL*)url
+{
+    if ([[url host] isEqualToString:@"itunes.apple.com"]) {
+        return YES;
+    }
+
+    return NO;
+}
+
+- (void)open:(CDVInvokedUrlCommand*)command
+{
+    CDVPluginResult* pluginResult;
+
+    NSString* url = [command argumentAtIndex:0];
+    NSString* target = [command argumentAtIndex:1 
withDefault:kInAppBrowserTargetSelf];
+
+    self.callbackId = command.callbackId;
+
+    if (url != nil) {
+
+        NSURL* baseUrl = [NSURL URLWithString:url];
+
+        NSURL* absoluteUrl = [[NSURL URLWithString:url relativeToURL:baseUrl] 
absoluteURL];
+
+        if ([self isSystemUrl:absoluteUrl]) {
+            target = kInAppBrowserTargetSystem;
+        }
+
+        if ([target isEqualToString:kInAppBrowserTargetSelf]) {
+            //[self openInCordovaWebView:absoluteUrl withOptions:options];
+            pluginResult = [CDVPluginResult 
resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Not Yet Implemented 
for OSX: [self openInCordovaWebView:absoluteUrl withOptions:options]"];
+        } else if ([target isEqualToString:kInAppBrowserTargetSystem]) {
+            [self openInSystem:absoluteUrl];
+            pluginResult = [CDVPluginResult 
resultWithStatus:CDVCommandStatus_OK];
+        } else { // _blank or anything else
+            //[self openInInAppBrowser:absoluteUrl withOptions:options];
+            pluginResult = [CDVPluginResult 
resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Not Yet Implemented 
for OSX: [self openInInAppBrowser:absoluteUrl withOptions:options]"];
+        }
+
+    } else {
+        pluginResult = [CDVPluginResult 
resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"incorrect number of 
arguments"];
+    }
+    [pluginResult setKeepCallback:[NSNumber numberWithBool:YES]];
+    [self.commandDelegate sendPluginResult:pluginResult 
callbackId:command.callbackId];
+}
+
+- (void)openInSystem:(NSURL*)url
+{
+    [[NSWorkspace sharedWorkspace] openURL:url];
+}
+
+@end
+

http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/blob/32253b96/tests/tests.js
----------------------------------------------------------------------
diff --git a/tests/tests.js b/tests/tests.js
index 102d5ff..a5645aa 100644
--- a/tests/tests.js
+++ b/tests/tests.js
@@ -43,6 +43,11 @@ exports.defineAutoTests = function () {
 
     describe('open method', function () {
 
+        if (cordova.platformId == 'osx') {
+            pending('Open method not fully supported on OSX.');
+            return;
+        }
+
         var iabInstance;
         var originalTimeout;
         var url = 'https://dist.apache.org/repos/dist/dev/cordova/';


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

Reply via email to