Permalink
Browse files

BlackBerry 10 InAppBrowser support

- added common InAppBrowser to qnx platform
- created InAppBrowser qnx plugin
- updated qnx manager to route to InAppBrowser plugin
- exported the original window.open in the common InAppBrowser plugin
- updated .jshintrc to know about the webworks global to interface with
  our custom plugin.
  • Loading branch information...
1 parent 05f19ce commit 745314e3a3f9f81a1d8652b9774c40d1fb01ba79 @gtanner gtanner committed Jan 8, 2013
View
@@ -28,7 +28,7 @@
"dojo": false,
// Custom predefined globals.
- "predef": ["jasmine", "blackberry", "define", "alert", "prompt", "org", "deviceapis", "Osp", "_cordovaExec", "WinJS", "Windows", "MSApp", "PalmSystem", "PalmServiceBridge", "Acceleration"],
+ "predef": ["jasmine", "blackberry", "define", "alert", "prompt", "org", "deviceapis", "Osp", "_cordovaExec", "WinJS", "Windows", "MSApp", "PalmSystem", "PalmServiceBridge", "Acceleration", "webworks"],
// Development
@@ -0,0 +1,77 @@
+/*
+ *
+ * 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.
+ *
+*/
+
+var cordova = require('cordova'),
+ core = require('cordova/plugin/InAppBrowser');
+
+var navigate = {
+ "_blank": function (url, whitelisted) {
+ core._orig.apply(null, [url, "_blank"]);
+ },
+
+ "_self": function (url, whitelisted) {
+ if (whitelisted) {
+ window.location.href = url;
+ }
+ else {
+ core._orig.apply(null, [url, "_blank"]);
+ }
+ },
+
+ "_system": function (url, whitelisted) {
+ blackberry.invoke.invoke({
+ target: "sys.browser",
+ uri: url
+ }, function () {}, function () {});
+ }
+};
+
+
+module.exports = {
+ open: function (args, win, fail) {
+ var url = args[0],
+ target = args[1] || '_self',
+ a = document.createElement('a');
+
+ //Make all URLs absolute
+ a.href = url;
+ url = a.href;
+
+ switch (target) {
+ case '_self':
+ case '_system':
+ case '_blank':
+ break;
+ default:
+ target = '_blank';
+ break;
+ }
+
+ webworks.exec(function (whitelisted) {
+ navigate[target](url, whitelisted);
+ }, fail, "org.apache.cordova", "isWhitelisted", [url], true);
+
+ return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "" };
+ },
+ close: function (args, win, fail) {
+ return { "status" : cordova.callbackStatus.OK, "message" : "" };
+ }
+};
@@ -32,6 +32,7 @@ var cordova = require('cordova'),
'Notification' : require('cordova/plugin/webworks/notification'),
'Media': require('cordova/plugin/webworks/media'),
'File' : require('cordova/plugin/qnx/file'),
+ 'InAppBrowser' : require('cordova/plugin/qnx/InAppBrowser'),
'FileTransfer': require('cordova/plugin/qnx/fileTransfer')
};
@@ -41,6 +41,11 @@ module.exports = {
});
});
},
+ clobbers: {
+ open: {
+ path: "cordova/plugin/InAppBrowser"
+ }
+ },
merges: {
navigator: {
children: {
@@ -58,4 +58,7 @@ module.exports = function(strUrl, strWindowName, strWindowFeatures) {
};
exec(cb, null, "InAppBrowser", "open", [strUrl, strWindowName, strWindowFeatures]);
return iab;
-};
+};
+
+//Export the original open so it can be used if needed
+module.exports._orig = window.open;

0 comments on commit 745314e

Please sign in to comment.