Skip to content

Commit

Permalink
BlackBerry 10 InAppBrowser support
Browse files Browse the repository at this point in the history
- 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
gtanner committed Jan 9, 2013
1 parent 05f19ce commit 745314e
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .jshintrc
Expand Up @@ -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
Expand Down
77 changes: 77 additions & 0 deletions lib/blackberry/plugin/qnx/InAppBrowser.js
@@ -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" : "" };
}
};
1 change: 1 addition & 0 deletions lib/blackberry/plugin/qnx/manager.js
Expand Up @@ -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')
};

Expand Down
5 changes: 5 additions & 0 deletions lib/blackberry/plugin/qnx/platform.js
Expand Up @@ -41,6 +41,11 @@ module.exports = {
});
});
},
clobbers: {
open: {
path: "cordova/plugin/InAppBrowser"
}
},
merges: {
navigator: {
children: {
Expand Down
5 changes: 4 additions & 1 deletion lib/common/plugin/InAppBrowser.js
Expand Up @@ -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.