fix!: remove deprecated platforms windows & osx (#1030)
This commit is contained in:
parent
44ead0fb34
commit
4b3c0f126d
24
README.md
24
README.md
@ -149,20 +149,12 @@ instance, or the system browser.
|
||||
- __toolbarposition__: Set to `top` or `bottom` (default is `bottom`). Causes the toolbar to be at the top or bottom of the window.
|
||||
- __hidespinner__: Set to `yes` or `no` to change the visibility of the loading indicator (defaults to `no`).
|
||||
|
||||
Windows supports these additional options:
|
||||
|
||||
- __hidden__: set to `yes` to create the browser and load the page, but not show it. The loadstop event fires when loading is complete. Omit or set to `no` (default) to have the browser open and load normally.
|
||||
- __hardwareback__: works the same way as on Android platform.
|
||||
- __fullscreen__: set to `yes` to create the browser control without a border around it. Please note that if __location=no__ is also specified, there will be no control presented to user to close IAB window.
|
||||
|
||||
|
||||
### Supported Platforms
|
||||
|
||||
- Android
|
||||
- Browser
|
||||
- iOS
|
||||
- OSX
|
||||
- Windows
|
||||
|
||||
### Example
|
||||
|
||||
@ -364,17 +356,11 @@ function downloadListener(params){
|
||||
- Android
|
||||
- Browser
|
||||
- iOS
|
||||
- Windows
|
||||
- OSX
|
||||
|
||||
### Browser Quirks
|
||||
|
||||
`loadstart`, `loaderror`, `message` events are not fired.
|
||||
|
||||
### Windows Quirks
|
||||
|
||||
`message` event is not fired.
|
||||
|
||||
### Quick Example
|
||||
|
||||
var ref = cordova.InAppBrowser.open('https://apache.org', '_blank', 'location=yes');
|
||||
@ -405,7 +391,6 @@ The function is passed an `InAppBrowserEvent` object.
|
||||
- Android
|
||||
- Browser
|
||||
- iOS
|
||||
- Windows
|
||||
|
||||
### Quick Example
|
||||
|
||||
@ -427,7 +412,6 @@ The function is passed an `InAppBrowserEvent` object.
|
||||
- Android
|
||||
- Browser
|
||||
- iOS
|
||||
- Windows
|
||||
|
||||
### Quick Example
|
||||
|
||||
@ -447,7 +431,6 @@ The function is passed an `InAppBrowserEvent` object.
|
||||
- Android
|
||||
- Browser
|
||||
- iOS
|
||||
- Windows
|
||||
|
||||
### Quick Example
|
||||
|
||||
@ -467,7 +450,6 @@ The function is passed an `InAppBrowserEvent` object.
|
||||
|
||||
- Android
|
||||
- iOS
|
||||
- Windows
|
||||
|
||||
### Quick Example
|
||||
|
||||
@ -499,7 +481,6 @@ The function is passed an `InAppBrowserEvent` object.
|
||||
- Android
|
||||
- Browser
|
||||
- iOS
|
||||
- Windows
|
||||
|
||||
### Quick Example
|
||||
|
||||
@ -512,10 +493,6 @@ The function is passed an `InAppBrowserEvent` object.
|
||||
|
||||
- only __code__ key is supported.
|
||||
|
||||
### Windows Quirks
|
||||
|
||||
Due to [MSDN docs](https://msdn.microsoft.com/en-us/library/windows.ui.xaml.controls.webview.invokescriptasync.aspx) the invoked script can return only string values, otherwise the parameter, passed to __callback__ will be `[null]`.
|
||||
|
||||
## InAppBrowser.insertCSS
|
||||
|
||||
> Injects CSS into the `InAppBrowser` window. (Only available when the target is set to `'_blank'`)
|
||||
@ -534,7 +511,6 @@ Due to [MSDN docs](https://msdn.microsoft.com/en-us/library/windows.ui.xaml.cont
|
||||
|
||||
- Android
|
||||
- iOS
|
||||
- Windows
|
||||
|
||||
### Quick Example
|
||||
|
||||
|
@ -8,9 +8,7 @@
|
||||
"platforms": [
|
||||
"android",
|
||||
"browser",
|
||||
"ios",
|
||||
"osx",
|
||||
"windows"
|
||||
"ios"
|
||||
]
|
||||
},
|
||||
"repository": "github:apache/cordova-plugin-inappbrowser",
|
||||
@ -24,9 +22,7 @@
|
||||
"ecosystem:cordova",
|
||||
"cordova-android",
|
||||
"cordova-browser",
|
||||
"cordova-ios",
|
||||
"cordova-osx",
|
||||
"cordova-windows"
|
||||
"cordova-ios"
|
||||
],
|
||||
"scripts": {
|
||||
"test": "npm run lint",
|
||||
|
26
plugin.xml
26
plugin.xml
@ -91,32 +91,6 @@
|
||||
<framework src="CoreGraphics.framework" />
|
||||
</platform>
|
||||
|
||||
<!-- osx -->
|
||||
<platform name="osx">
|
||||
<js-module src="www/inappbrowser.js" name="inappbrowser">
|
||||
<clobbers target="cordova.InAppBrowser.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>
|
||||
|
||||
<!-- windows -->
|
||||
<platform name="windows">
|
||||
<js-module src="www/inappbrowser.js" name="inappbrowser">
|
||||
<clobbers target="cordova.InAppBrowser.open" />
|
||||
</js-module>
|
||||
<js-module src="src/windows/InAppBrowserProxy.js" name="InAppBrowserProxy">
|
||||
<runs />
|
||||
</js-module>
|
||||
<asset src="www/inappbrowser.css" target="css/inappbrowser.css" />
|
||||
</platform>
|
||||
|
||||
<!-- browser -->
|
||||
<platform name="browser">
|
||||
<js-module src="www/inappbrowser.js" name="inappbrowser">
|
||||
|
@ -1,30 +0,0 @@
|
||||
/*
|
||||
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
|
||||
|
@ -1,89 +0,0 @@
|
||||
/*
|
||||
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
|
||||
|
@ -1,407 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/* eslint-disable standard/no-callback-literal */
|
||||
/* global Windows, setImmediate */
|
||||
|
||||
var cordova = require('cordova');
|
||||
var urlutil = require('cordova/urlutil');
|
||||
|
||||
var browserWrap,
|
||||
popup,
|
||||
navigationButtonsDiv,
|
||||
navigationButtonsDivInner,
|
||||
backButton,
|
||||
forwardButton,
|
||||
closeButton,
|
||||
bodyOverflowStyle,
|
||||
navigationEventsCallback,
|
||||
hardwareBackCallback;
|
||||
|
||||
// x-ms-webview is available starting from Windows 8.1 (platformId is 'windows')
|
||||
// http://msdn.microsoft.com/en-us/library/windows/apps/dn301831.aspx
|
||||
var isWebViewAvailable = cordova.platformId === 'windows';
|
||||
|
||||
function attachNavigationEvents (element, callback) {
|
||||
if (isWebViewAvailable) {
|
||||
element.addEventListener('MSWebViewNavigationStarting', function (e) {
|
||||
callback({ type: 'loadstart', url: e.uri }, { keepCallback: true });
|
||||
});
|
||||
|
||||
element.addEventListener('MSWebViewNavigationCompleted', function (e) {
|
||||
if (e.isSuccess) {
|
||||
callback({ type: 'loadstop', url: e.uri }, { keepCallback: true });
|
||||
} else {
|
||||
callback(
|
||||
{
|
||||
type: 'loaderror',
|
||||
url: e.uri,
|
||||
code: e.webErrorStatus,
|
||||
message: 'Navigation failed with error code ' + e.webErrorStatus
|
||||
},
|
||||
{ keepCallback: true }
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
element.addEventListener('MSWebViewUnviewableContentIdentified', function (e) {
|
||||
// WebView found the content to be not HTML.
|
||||
// http://msdn.microsoft.com/en-us/library/windows/apps/dn609716.aspx
|
||||
callback(
|
||||
{ type: 'loaderror', url: e.uri, code: e.webErrorStatus, message: 'Navigation failed with error code ' + e.webErrorStatus },
|
||||
{ keepCallback: true }
|
||||
);
|
||||
});
|
||||
|
||||
element.addEventListener('MSWebViewContentLoading', function (e) {
|
||||
if (navigationButtonsDiv && popup) {
|
||||
if (popup.canGoBack) {
|
||||
backButton.removeAttribute('disabled');
|
||||
} else {
|
||||
backButton.setAttribute('disabled', 'true');
|
||||
}
|
||||
|
||||
if (popup.canGoForward) {
|
||||
forwardButton.removeAttribute('disabled');
|
||||
} else {
|
||||
forwardButton.setAttribute('disabled', 'true');
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
var onError = function () {
|
||||
callback({ type: 'loaderror', url: this.contentWindow.location }, { keepCallback: true });
|
||||
};
|
||||
|
||||
element.addEventListener('unload', function () {
|
||||
callback({ type: 'loadstart', url: this.contentWindow.location }, { keepCallback: true });
|
||||
});
|
||||
|
||||
element.addEventListener('load', function () {
|
||||
callback({ type: 'loadstop', url: this.contentWindow.location }, { keepCallback: true });
|
||||
});
|
||||
|
||||
element.addEventListener('error', onError);
|
||||
element.addEventListener('abort', onError);
|
||||
}
|
||||
}
|
||||
|
||||
var IAB = {
|
||||
close: function (win, lose) {
|
||||
setImmediate(function () {
|
||||
if (browserWrap) {
|
||||
if (navigationEventsCallback) {
|
||||
navigationEventsCallback({ type: 'exit' });
|
||||
}
|
||||
|
||||
browserWrap.parentNode.removeChild(browserWrap);
|
||||
// Reset body overflow style to initial value
|
||||
document.body.style.msOverflowStyle = bodyOverflowStyle;
|
||||
browserWrap = null;
|
||||
popup = null;
|
||||
|
||||
document.removeEventListener('backbutton', hardwareBackCallback, false);
|
||||
}
|
||||
});
|
||||
},
|
||||
show: function (win, lose) {
|
||||
setImmediate(function () {
|
||||
if (browserWrap) {
|
||||
browserWrap.style.display = 'block';
|
||||
}
|
||||
});
|
||||
},
|
||||
hide: function (win, lose) {
|
||||
if (browserWrap) {
|
||||
browserWrap.style.display = 'none';
|
||||
}
|
||||
},
|
||||
open: function (win, lose, args) {
|
||||
// make function async so that we can add navigation events handlers before view is loaded and navigation occured
|
||||
setImmediate(function () {
|
||||
var strUrl = args[0];
|
||||
var target = args[1];
|
||||
var features = args[2];
|
||||
var url;
|
||||
|
||||
navigationEventsCallback = win;
|
||||
|
||||
if (target === '_system') {
|
||||
url = new Windows.Foundation.Uri(strUrl);
|
||||
Windows.System.Launcher.launchUriAsync(url);
|
||||
} else if (target === '_self' || !target) {
|
||||
window.location = strUrl;
|
||||
} else {
|
||||
// "_blank" or anything else
|
||||
if (!browserWrap) {
|
||||
var browserWrapStyle = document.createElement('link');
|
||||
browserWrapStyle.rel = 'stylesheet';
|
||||
browserWrapStyle.type = 'text/css';
|
||||
browserWrapStyle.href = urlutil.makeAbsolute('/www/css/inappbrowser.css');
|
||||
|
||||
document.head.appendChild(browserWrapStyle);
|
||||
|
||||
browserWrap = document.createElement('div');
|
||||
browserWrap.className = 'inAppBrowserWrap';
|
||||
|
||||
if (features.indexOf('fullscreen=yes') > -1) {
|
||||
browserWrap.classList.add('inAppBrowserWrapFullscreen');
|
||||
}
|
||||
|
||||
// Save body overflow style to be able to reset it back later
|
||||
bodyOverflowStyle = document.body.style.msOverflowStyle;
|
||||
|
||||
browserWrap.onclick = function () {
|
||||
setTimeout(function () {
|
||||
IAB.close(navigationEventsCallback);
|
||||
}, 0);
|
||||
};
|
||||
|
||||
document.body.appendChild(browserWrap);
|
||||
// Hide scrollbars for the whole body while inappbrowser's window is open
|
||||
document.body.style.msOverflowStyle = 'none';
|
||||
}
|
||||
|
||||
if (features.indexOf('hidden=yes') !== -1) {
|
||||
browserWrap.style.display = 'none';
|
||||
}
|
||||
|
||||
popup = document.createElement(isWebViewAvailable ? 'x-ms-webview' : 'iframe');
|
||||
if (popup instanceof HTMLIFrameElement) {
|
||||
// eslint-disable-line no-undef
|
||||
// For iframe we need to override bacground color of parent element here
|
||||
// otherwise pages without background color set will have transparent background
|
||||
popup.style.backgroundColor = 'white';
|
||||
}
|
||||
popup.style.borderWidth = '0px';
|
||||
popup.style.width = '100%';
|
||||
popup.style.marginBottom = '-5px';
|
||||
|
||||
browserWrap.appendChild(popup);
|
||||
|
||||
var closeHandler = function (e) {
|
||||
setTimeout(function () {
|
||||
IAB.close(navigationEventsCallback);
|
||||
}, 0);
|
||||
};
|
||||
|
||||
if (features.indexOf('hardwareback=yes') > -1 || features.indexOf('hardwareback') === -1) {
|
||||
hardwareBackCallback = function () {
|
||||
if (browserWrap.style.display === 'none') {
|
||||
// NOTE: backbutton handlers have to throw an exception in order to prevent
|
||||
// returning 'true' inside cordova-js, which would mean that the event is handled by user.
|
||||
// Throwing an exception means that the default/system navigation behavior will take place,
|
||||
// which is to exit the app if the navigation stack is empty.
|
||||
throw 'Exit the app'; // eslint-disable-line no-throw-literal
|
||||
}
|
||||
|
||||
if (popup.canGoBack) {
|
||||
popup.goBack();
|
||||
} else {
|
||||
closeHandler();
|
||||
}
|
||||
};
|
||||
} else if (features.indexOf('hardwareback=no') > -1) {
|
||||
hardwareBackCallback = function () {
|
||||
if (browserWrap.style.display === 'none') {
|
||||
// See comment above
|
||||
throw 'Exit the app'; // eslint-disable-line no-throw-literal
|
||||
}
|
||||
|
||||
closeHandler();
|
||||
};
|
||||
}
|
||||
|
||||
document.addEventListener('backbutton', hardwareBackCallback, false);
|
||||
|
||||
if (features.indexOf('location=yes') !== -1 || features.indexOf('location') === -1) {
|
||||
popup.style.height = 'calc(100% - 70px)';
|
||||
|
||||
navigationButtonsDiv = document.createElement('div');
|
||||
navigationButtonsDiv.className = 'inappbrowser-app-bar';
|
||||
navigationButtonsDiv.onclick = function (e) {
|
||||
e.cancelBubble = true;
|
||||
};
|
||||
|
||||
navigationButtonsDivInner = document.createElement('div');
|
||||
navigationButtonsDivInner.className = 'inappbrowser-app-bar-inner';
|
||||
navigationButtonsDivInner.onclick = function (e) {
|
||||
e.cancelBubble = true;
|
||||
};
|
||||
|
||||
backButton = document.createElement('div');
|
||||
backButton.innerText = 'back';
|
||||
backButton.className = 'app-bar-action action-back';
|
||||
backButton.addEventListener('click', function (e) {
|
||||
if (popup.canGoBack) {
|
||||
popup.goBack();
|
||||
}
|
||||
});
|
||||
|
||||
forwardButton = document.createElement('div');
|
||||
forwardButton.innerText = 'forward';
|
||||
forwardButton.className = 'app-bar-action action-forward';
|
||||
forwardButton.addEventListener('click', function (e) {
|
||||
if (popup.canGoForward) {
|
||||
popup.goForward();
|
||||
}
|
||||
});
|
||||
|
||||
closeButton = document.createElement('div');
|
||||
closeButton.innerText = 'close';
|
||||
closeButton.className = 'app-bar-action action-close';
|
||||
closeButton.addEventListener('click', closeHandler);
|
||||
|
||||
if (!isWebViewAvailable) {
|
||||
// iframe navigation is not yet supported
|
||||
backButton.setAttribute('disabled', 'true');
|
||||
forwardButton.setAttribute('disabled', 'true');
|
||||
}
|
||||
|
||||
navigationButtonsDivInner.appendChild(backButton);
|
||||
navigationButtonsDivInner.appendChild(forwardButton);
|
||||
navigationButtonsDivInner.appendChild(closeButton);
|
||||
navigationButtonsDiv.appendChild(navigationButtonsDivInner);
|
||||
|
||||
browserWrap.appendChild(navigationButtonsDiv);
|
||||
} else {
|
||||
popup.style.height = '100%';
|
||||
}
|
||||
|
||||
// start listening for navigation events
|
||||
attachNavigationEvents(popup, navigationEventsCallback);
|
||||
|
||||
if (isWebViewAvailable) {
|
||||
strUrl = strUrl.replace('ms-appx://', 'ms-appx-web://');
|
||||
}
|
||||
popup.src = strUrl;
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
injectScriptCode: function (win, fail, args) {
|
||||
setImmediate(function () {
|
||||
var code = args[0];
|
||||
var hasCallback = args[1];
|
||||
|
||||
if (isWebViewAvailable && browserWrap && popup) {
|
||||
var op = popup.invokeScriptAsync('eval', code);
|
||||
op.oncomplete = function (e) {
|
||||
if (hasCallback) {
|
||||
// return null if event target is unavailable by some reason
|
||||
var result = e && e.target ? [e.target.result] : [null];
|
||||
win(result);
|
||||
}
|
||||
};
|
||||
op.onerror = function () {};
|
||||
op.start();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
injectScriptFile: function (win, fail, args) {
|
||||
setImmediate(function () {
|
||||
var filePath = args[0];
|
||||
var hasCallback = args[1];
|
||||
|
||||
if (filePath) {
|
||||
filePath = urlutil.makeAbsolute(filePath);
|
||||
}
|
||||
|
||||
if (isWebViewAvailable && browserWrap && popup) {
|
||||
// CB-12364 getFileFromApplicationUriAsync does not support ms-appx-web
|
||||
var uri = new Windows.Foundation.Uri(filePath.replace('ms-appx-web:', 'ms-appx:'));
|
||||
Windows.Storage.StorageFile.getFileFromApplicationUriAsync(uri).done(function (file) {
|
||||
Windows.Storage.FileIO.readTextAsync(file).done(function (code) {
|
||||
var op = popup.invokeScriptAsync('eval', code);
|
||||
op.oncomplete = function (e) {
|
||||
if (hasCallback) {
|
||||
var result = [e.target.result];
|
||||
win(result);
|
||||
}
|
||||
};
|
||||
op.onerror = function () {};
|
||||
op.start();
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
injectStyleCode: function (win, fail, args) {
|
||||
setImmediate(function () {
|
||||
var code = args[0];
|
||||
var hasCallback = args[1];
|
||||
|
||||
if (isWebViewAvailable && browserWrap && popup) {
|
||||
injectCSS(popup, code, hasCallback && win);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
injectStyleFile: function (win, fail, args) {
|
||||
setImmediate(function () {
|
||||
var filePath = args[0];
|
||||
var hasCallback = args[1];
|
||||
|
||||
filePath = filePath && urlutil.makeAbsolute(filePath);
|
||||
|
||||
if (isWebViewAvailable && browserWrap && popup) {
|
||||
// CB-12364 getFileFromApplicationUriAsync does not support ms-appx-web
|
||||
var uri = new Windows.Foundation.Uri(filePath.replace('ms-appx-web:', 'ms-appx:'));
|
||||
Windows.Storage.StorageFile.getFileFromApplicationUriAsync(uri)
|
||||
.then(function (file) {
|
||||
return Windows.Storage.FileIO.readTextAsync(file);
|
||||
})
|
||||
.done(
|
||||
function (code) {
|
||||
injectCSS(popup, code, hasCallback && win);
|
||||
},
|
||||
function () {
|
||||
// no-op, just catch an error
|
||||
}
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
function injectCSS (webView, cssCode, callback) {
|
||||
// This will automatically escape all thing that we need (quotes, slashes, etc.)
|
||||
var escapedCode = JSON.stringify(cssCode);
|
||||
var evalWrapper = "(function(d){var c=d.createElement('style');c.innerHTML=%s;d.head.appendChild(c);})(document)".replace(
|
||||
'%s',
|
||||
escapedCode
|
||||
);
|
||||
|
||||
var op = webView.invokeScriptAsync('eval', evalWrapper);
|
||||
op.oncomplete = function () {
|
||||
if (callback) {
|
||||
callback([]);
|
||||
}
|
||||
};
|
||||
op.onerror = function () {};
|
||||
op.start();
|
||||
}
|
||||
|
||||
module.exports = IAB;
|
||||
|
||||
require('cordova/exec/proxy').add('InAppBrowser', module.exports);
|
@ -19,19 +19,12 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/* global MSApp */
|
||||
|
||||
var cordova = require('cordova');
|
||||
var isWindows = cordova.platformId === 'windows';
|
||||
var isIos = cordova.platformId === 'ios';
|
||||
var isAndroid = cordova.platformId === 'android';
|
||||
var isBrowser = cordova.platformId === 'browser';
|
||||
|
||||
window.alert = window.alert || navigator.notification.alert;
|
||||
if (isWindows && navigator && navigator.notification && navigator.notification.alert) {
|
||||
// window.alert is defined but not functional on UWP
|
||||
window.alert = navigator.notification.alert;
|
||||
}
|
||||
|
||||
exports.defineAutoTests = function () {
|
||||
var createTests = function (platformOpts) {
|
||||
@ -539,43 +532,21 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
||||
'<p/> <div id="openHardwareBackDefaultAfterNo"></div>' +
|
||||
'Expected result: consistently open browsers with with the appropriate option: hardwareback=defaults to yes then hardwareback=no then hardwareback=defaults to yes. By default hardwareback is yes so pressing back button should navigate backwards in history then close InAppBrowser';
|
||||
|
||||
// CB-7490 We need to wrap this code due to Windows security restrictions
|
||||
// see http://msdn.microsoft.com/en-us/library/windows/apps/hh465380.aspx#differences for details
|
||||
if (window.MSApp && window.MSApp.execUnsafeLocalFunction) {
|
||||
MSApp.execUnsafeLocalFunction(function () {
|
||||
contentEl.innerHTML =
|
||||
info_div +
|
||||
platform_info +
|
||||
local_tests +
|
||||
white_listed_tests +
|
||||
non_white_listed_tests +
|
||||
page_with_redirects_tests +
|
||||
pdf_url_tests +
|
||||
invalid_url_tests +
|
||||
css_js_injection_tests +
|
||||
open_hidden_tests +
|
||||
clearing_cache_tests +
|
||||
video_tag_tests +
|
||||
local_with_anchor_tag_tests +
|
||||
hardwareback_tests;
|
||||
});
|
||||
} else {
|
||||
contentEl.innerHTML =
|
||||
info_div +
|
||||
platform_info +
|
||||
local_tests +
|
||||
white_listed_tests +
|
||||
non_white_listed_tests +
|
||||
page_with_redirects_tests +
|
||||
pdf_url_tests +
|
||||
invalid_url_tests +
|
||||
css_js_injection_tests +
|
||||
open_hidden_tests +
|
||||
clearing_cache_tests +
|
||||
video_tag_tests +
|
||||
local_with_anchor_tag_tests +
|
||||
hardwareback_tests;
|
||||
}
|
||||
contentEl.innerHTML =
|
||||
info_div +
|
||||
platform_info +
|
||||
local_tests +
|
||||
white_listed_tests +
|
||||
non_white_listed_tests +
|
||||
page_with_redirects_tests +
|
||||
pdf_url_tests +
|
||||
invalid_url_tests +
|
||||
css_js_injection_tests +
|
||||
open_hidden_tests +
|
||||
clearing_cache_tests +
|
||||
video_tag_tests +
|
||||
local_with_anchor_tag_tests +
|
||||
hardwareback_tests;
|
||||
|
||||
document.getElementById('user-agent').textContent = navigator.userAgent;
|
||||
|
||||
@ -584,8 +555,8 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
||||
var localhtml = basePath + 'local.html';
|
||||
var localpdf = basePath + 'local.pdf';
|
||||
var injecthtml = basePath + 'inject.html';
|
||||
var injectjs = isWindows ? basePath + 'inject.js' : 'inject.js';
|
||||
var injectcss = isWindows ? basePath + 'inject.css' : 'inject.css';
|
||||
var injectjs = 'inject.js';
|
||||
var injectcss = 'inject.css';
|
||||
var videohtml = basePath + 'video.html';
|
||||
|
||||
// Local
|
||||
|
Loading…
Reference in New Issue
Block a user