232
function makeUrlFromIntentResult(intentFilterResult) {
231
function makeUrlFromResult(result) {
233
232
var scheme = null
234
233
var hostname = null
235
234
var url = root.currentWebview.url || root.url
236
if (intentFilterResult.host
237
&& intentFilterResult.host.length !== 0) {
238
hostname = intentFilterResult.host
236
&& result.host.length !== 0) {
237
hostname = result.host
241
240
var matchHostname = url.toString().match(/.*:\/\/([^/]*)\/.*/)
243
242
hostname = matchHostname[1]
246
if (intentFilterResult.scheme
247
&& intentFilterResult.scheme.length !== 0) {
248
scheme = intentFilterResult.scheme
247
&& result.scheme.length !== 0) {
248
scheme = result.scheme
251
251
var matchScheme = url.toString().match(/(.*):\/\/[^/]*\/.*/)
260
+ (intentFilterResult.uri
261
? intentFilterResult.uri : "")
265
* Identity function for non-intent URIs.
267
* Otherwise if the URI is an intent, tries to apply a webapp
268
* local filter (or identity) and reconstruct the target URI based
271
function handleIntentUri(uri) {
273
if (webappIntentFilter
274
&& webappIntentFilter.isValidIntentUri(_uri)) {
275
var result = webappIntentFilter.applyFilter(_uri)
276
_uri = makeUrlFromIntentResult(result)
278
console.log("Intent URI '" + uri + "' was mapped to '" + _uri + "'")
267
function translateHandlerUri(uri) {
269
var scheme = uri.substr(0, uri.indexOf(":"))
270
if (scheme.indexOf("http") === 0) {
271
schemeUriHandleFilterResult(uri)
275
var result = webappSchemeFilter.applyFilter(uri)
276
var mapped_uri = makeUrlFromResult(result)
281
280
// Report the result of the intent uri filtering (if any)
282
281
// Done for testing purposed. It is not possible at this point
283
282
// to have AP call a slot and retrieve its result synchronously.
284
intentUriHandleResult(_uri)
283
schemeUriHandleFilterResult(uri)
289
288
// Handle runtime requests to open urls as defined