Merge remote-tracking branch 'rodrigo/auto-permission' into react_on_features
This commit is contained in:
commit
cd7916d025
16
CONTRIBUTING.md
Normal file
16
CONTRIBUTING.md
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
# Contributing to Apache Cordova
|
||||||
|
|
||||||
|
Anyone can contribute to Cordova. And we need your contributions.
|
||||||
|
|
||||||
|
There are multiple ways to contribute: report bugs, improve the docs, and
|
||||||
|
contribute code.
|
||||||
|
|
||||||
|
For instructions on this, start with the
|
||||||
|
[contribution overview](http://cordova.apache.org/#contribute).
|
||||||
|
|
||||||
|
The details are explained there, but the important items are:
|
||||||
|
- Sign and submit an Apache ICLA (Contributor License Agreement).
|
||||||
|
- Have a Jira issue open that corresponds to your contribution.
|
||||||
|
- Run the tests so your patch doesn't break existing functionality.
|
||||||
|
|
||||||
|
We look forward to your contributions!
|
@ -83,3 +83,17 @@
|
|||||||
* CB-5534 Fix video/audio does not stop playing when browser is closed
|
* CB-5534 Fix video/audio does not stop playing when browser is closed
|
||||||
* CB-6172 Fix broken install on case-sensitive file-systems
|
* CB-6172 Fix broken install on case-sensitive file-systems
|
||||||
|
|
||||||
|
|
||||||
|
### 0.4.0 (Apr 17, 2014)
|
||||||
|
* CB-6360: [ios] Fix for crash on iOS < 6.0 (closes #37)
|
||||||
|
* CB-3324: [WP8] Add support for back-button inappbrowser [WP8] if there is no history -> InAppBrowser is closed
|
||||||
|
* [WP] await async calls, resolve warnings
|
||||||
|
* [WP] Make InAppBrowser work with embedded files, using system behavior
|
||||||
|
* CB-6402: [WP8] pass empty string instead of null for [optional] windowFeatures string
|
||||||
|
* CB-6422: [windows8] use cordova/exec/proxy
|
||||||
|
* CB-6389 CB-3617: Add clearcache and clearsessioncache options to iOS (like Android)
|
||||||
|
* Doc update: event name and example param (closes #31)
|
||||||
|
* CB-6253: [WP] Add Network Capability to WMAppManifest.xml
|
||||||
|
* CB-6212: [iOS] fix warnings compiled under arm64 64-bit
|
||||||
|
* CB-6218: Update docs for BB10
|
||||||
|
* CB-6460: Update license headers
|
||||||
|
13
doc/index.md
13
doc/index.md
@ -30,17 +30,6 @@ and can't access Cordova APIs.
|
|||||||
|
|
||||||
cordova plugin add org.apache.cordova.inappbrowser
|
cordova plugin add org.apache.cordova.inappbrowser
|
||||||
|
|
||||||
### Firefox OS
|
|
||||||
|
|
||||||
Create __www/manifest.webapp__ as described in
|
|
||||||
[Manifest Docs](https://developer.mozilla.org/en-US/Apps/Developing/Manifest).
|
|
||||||
Add relevant permisions.
|
|
||||||
|
|
||||||
"permissions": {
|
|
||||||
"browser": {}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
## window.open
|
## window.open
|
||||||
|
|
||||||
Opens a URL in a new `InAppBrowser` instance, the current browser
|
Opens a URL in a new `InAppBrowser` instance, the current browser
|
||||||
@ -76,6 +65,8 @@ instance, or the system browser.
|
|||||||
- __closebuttoncaption__: set to a string to use as the __Done__ button's caption. Note that you need to localize this value yourself.
|
- __closebuttoncaption__: set to a string to use as the __Done__ button's caption. Note that you need to localize this value yourself.
|
||||||
- __disallowoverscroll__: Set to `yes` or `no` (default is `no`). Turns on/off the UIWebViewBounce property.
|
- __disallowoverscroll__: Set to `yes` or `no` (default is `no`). Turns on/off the UIWebViewBounce property.
|
||||||
- __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.
|
- __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.
|
||||||
|
- __clearcache__: set to `yes` to have the browser's cookie cache cleared before the new window is opened
|
||||||
|
- __clearsessioncache__: set to `yes` to have the session cookie cache cleared before the new window is opened
|
||||||
- __toolbar__: set to `yes` or `no` to turn the toolbar on or off for the InAppBrowser (defaults to `yes`)
|
- __toolbar__: set to `yes` or `no` to turn the toolbar on or off for the InAppBrowser (defaults to `yes`)
|
||||||
- __enableViewportScale__: Set to `yes` or `no` to prevent viewport scaling through a meta tag (defaults to `no`).
|
- __enableViewportScale__: Set to `yes` or `no` to prevent viewport scaling through a meta tag (defaults to `no`).
|
||||||
- __mediaPlaybackRequiresUserAction__: Set to `yes` or `no` to prevent HTML5 audio or video from autoplaying (defaults to `no`).
|
- __mediaPlaybackRequiresUserAction__: Set to `yes` or `no` to prevent HTML5 audio or video from autoplaying (defaults to `no`).
|
||||||
|
31
plugin.xml
31
plugin.xml
@ -1,8 +1,26 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
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.
|
||||||
|
-->
|
||||||
|
|
||||||
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
||||||
id="org.apache.cordova.inappbrowser"
|
id="org.apache.cordova.inappbrowser"
|
||||||
version="0.3.4-dev">
|
version="0.4.1-dev">
|
||||||
|
|
||||||
<name>InAppBrowser</name>
|
<name>InAppBrowser</name>
|
||||||
<description>Cordova InAppBrowser Plugin</description>
|
<description>Cordova InAppBrowser Plugin</description>
|
||||||
@ -106,6 +124,10 @@
|
|||||||
</feature>
|
</feature>
|
||||||
</config-file>
|
</config-file>
|
||||||
|
|
||||||
|
<config-file target="Properties/WMAppManifest.xml" parent="/Deployment/App/Capabilities">
|
||||||
|
<Capability Name="ID_CAP_NETWORKING" />
|
||||||
|
</config-file>
|
||||||
|
|
||||||
<source-file src="src/wp/InAppBrowser.cs" />
|
<source-file src="src/wp/InAppBrowser.cs" />
|
||||||
</platform>
|
</platform>
|
||||||
|
|
||||||
@ -124,6 +146,10 @@
|
|||||||
</feature>
|
</feature>
|
||||||
</config-file>
|
</config-file>
|
||||||
|
|
||||||
|
<config-file target="Properties/WMAppManifest.xml" parent="/Deployment/App/Capabilities">
|
||||||
|
<Capability Name="ID_CAP_NETWORKING" />
|
||||||
|
</config-file>
|
||||||
|
|
||||||
<source-file src="src/wp/InAppBrowser.cs" />
|
<source-file src="src/wp/InAppBrowser.cs" />
|
||||||
</platform>
|
</platform>
|
||||||
|
|
||||||
@ -139,6 +165,9 @@
|
|||||||
|
|
||||||
<!-- firefoxos -->
|
<!-- firefoxos -->
|
||||||
<platform name="firefoxos">
|
<platform name="firefoxos">
|
||||||
|
<config-file target="config.xml" parent="/*">
|
||||||
|
<permission name="browser" description="Enables the app to implement a browser in an iframe." />
|
||||||
|
</config-file>
|
||||||
<js-module src="www/inappbrowser.js" name="inappbrowser">
|
<js-module src="www/inappbrowser.js" name="inappbrowser">
|
||||||
<clobbers target="window.open" />
|
<clobbers target="window.open" />
|
||||||
</js-module>
|
</js-module>
|
||||||
|
@ -1,3 +1,21 @@
|
|||||||
|
/*
|
||||||
|
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.
|
||||||
|
*/
|
||||||
package org.apache.cordova.inappbrowser;
|
package org.apache.cordova.inappbrowser;
|
||||||
|
|
||||||
import org.apache.cordova.CordovaWebView;
|
import org.apache.cordova.CordovaWebView;
|
||||||
|
@ -1,3 +1,21 @@
|
|||||||
|
/*
|
||||||
|
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.
|
||||||
|
*/
|
||||||
package org.apache.cordova.inappbrowser;
|
package org.apache.cordova.inappbrowser;
|
||||||
|
|
||||||
import org.apache.cordova.CordovaWebView;
|
import org.apache.cordova.CordovaWebView;
|
||||||
|
@ -1,3 +1,21 @@
|
|||||||
|
<!---
|
||||||
|
license: 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.
|
||||||
|
-->
|
||||||
# BlackBerry 10 In-App-Browser Plugin
|
# BlackBerry 10 In-App-Browser Plugin
|
||||||
|
|
||||||
The in app browser functionality is entirely contained within common js. There is no native implementation required.
|
The in app browser functionality is entirely contained within common js. There is no native implementation required.
|
||||||
|
@ -45,6 +45,8 @@
|
|||||||
@property (nonatomic, assign) BOOL toolbar;
|
@property (nonatomic, assign) BOOL toolbar;
|
||||||
@property (nonatomic, copy) NSString* closebuttoncaption;
|
@property (nonatomic, copy) NSString* closebuttoncaption;
|
||||||
@property (nonatomic, copy) NSString* toolbarposition;
|
@property (nonatomic, copy) NSString* toolbarposition;
|
||||||
|
@property (nonatomic, assign) BOOL clearcache;
|
||||||
|
@property (nonatomic, assign) BOOL clearsessioncache;
|
||||||
|
|
||||||
@property (nonatomic, copy) NSString* presentationstyle;
|
@property (nonatomic, copy) NSString* presentationstyle;
|
||||||
@property (nonatomic, copy) NSString* transitionstyle;
|
@property (nonatomic, copy) NSString* transitionstyle;
|
||||||
@ -61,7 +63,7 @@
|
|||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@interface CDVInAppBrowserViewController : UIViewController <UIWebViewDelegate>{
|
@interface CDVInAppBrowserViewController : UIViewController <UIWebViewDelegate, CDVScreenOrientationDelegate>{
|
||||||
@private
|
@private
|
||||||
NSString* _userAgent;
|
NSString* _userAgent;
|
||||||
NSString* _prevUserAgent;
|
NSString* _prevUserAgent;
|
||||||
@ -90,4 +92,10 @@
|
|||||||
|
|
||||||
- (id)initWithUserAgent:(NSString*)userAgent prevUserAgent:(NSString*)prevUserAgent browserOptions: (CDVInAppBrowserOptions*) browserOptions;
|
- (id)initWithUserAgent:(NSString*)userAgent prevUserAgent:(NSString*)prevUserAgent browserOptions: (CDVInAppBrowserOptions*) browserOptions;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
@interface CDVInAppBrowserNavigationController : UINavigationController
|
||||||
|
|
||||||
|
@property (nonatomic, weak) id <CDVScreenOrientationDelegate> orientationDelegate;
|
||||||
|
|
||||||
@end
|
@end
|
@ -115,6 +115,29 @@
|
|||||||
- (void)openInInAppBrowser:(NSURL*)url withOptions:(NSString*)options
|
- (void)openInInAppBrowser:(NSURL*)url withOptions:(NSString*)options
|
||||||
{
|
{
|
||||||
CDVInAppBrowserOptions* browserOptions = [CDVInAppBrowserOptions parseOptions:options];
|
CDVInAppBrowserOptions* browserOptions = [CDVInAppBrowserOptions parseOptions:options];
|
||||||
|
|
||||||
|
if (browserOptions.clearcache) {
|
||||||
|
NSHTTPCookie *cookie;
|
||||||
|
NSHTTPCookieStorage *storage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
|
||||||
|
for (cookie in [storage cookies])
|
||||||
|
{
|
||||||
|
if (![cookie.domain isEqual: @".^filecookies^"]) {
|
||||||
|
[storage deleteCookie:cookie];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (browserOptions.clearsessioncache) {
|
||||||
|
NSHTTPCookie *cookie;
|
||||||
|
NSHTTPCookieStorage *storage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
|
||||||
|
for (cookie in [storage cookies])
|
||||||
|
{
|
||||||
|
if (![cookie.domain isEqual: @".^filecookies^"] && cookie.isSessionOnly) {
|
||||||
|
[storage deleteCookie:cookie];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (self.inAppBrowserViewController == nil) {
|
if (self.inAppBrowserViewController == nil) {
|
||||||
NSString* originalUA = [CDVUserAgentUtil originalUserAgent];
|
NSString* originalUA = [CDVUserAgentUtil originalUserAgent];
|
||||||
self.inAppBrowserViewController = [[CDVInAppBrowserViewController alloc] initWithUserAgent:originalUA prevUserAgent:[self.commandDelegate userAgent] browserOptions: browserOptions];
|
self.inAppBrowserViewController = [[CDVInAppBrowserViewController alloc] initWithUserAgent:originalUA prevUserAgent:[self.commandDelegate userAgent] browserOptions: browserOptions];
|
||||||
@ -193,13 +216,14 @@
|
|||||||
|
|
||||||
_previousStatusBarStyle = [UIApplication sharedApplication].statusBarStyle;
|
_previousStatusBarStyle = [UIApplication sharedApplication].statusBarStyle;
|
||||||
|
|
||||||
UINavigationController* nav = [[UINavigationController alloc]
|
CDVInAppBrowserNavigationController* nav = [[CDVInAppBrowserNavigationController alloc]
|
||||||
initWithRootViewController:self.inAppBrowserViewController];
|
initWithRootViewController:self.inAppBrowserViewController];
|
||||||
|
nav.orientationDelegate = self.inAppBrowserViewController;
|
||||||
nav.navigationBarHidden = YES;
|
nav.navigationBarHidden = YES;
|
||||||
// Run later to avoid the "took a long time" log message.
|
// Run later to avoid the "took a long time" log message.
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
if (self.inAppBrowserViewController != nil) {
|
if (self.inAppBrowserViewController != nil) {
|
||||||
[self.viewController presentModalViewController:nav animated:YES];
|
[self.viewController presentViewController:nav animated:YES completion:nil];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -465,7 +489,6 @@
|
|||||||
self.webView.clearsContextBeforeDrawing = YES;
|
self.webView.clearsContextBeforeDrawing = YES;
|
||||||
self.webView.clipsToBounds = YES;
|
self.webView.clipsToBounds = YES;
|
||||||
self.webView.contentMode = UIViewContentModeScaleToFill;
|
self.webView.contentMode = UIViewContentModeScaleToFill;
|
||||||
self.webView.contentStretch = CGRectFromString(@"{{0, 0}, {1, 1}}");
|
|
||||||
self.webView.multipleTouchEnabled = YES;
|
self.webView.multipleTouchEnabled = YES;
|
||||||
self.webView.opaque = YES;
|
self.webView.opaque = YES;
|
||||||
self.webView.scalesPageToFit = NO;
|
self.webView.scalesPageToFit = NO;
|
||||||
@ -478,7 +501,6 @@
|
|||||||
self.spinner.clearsContextBeforeDrawing = NO;
|
self.spinner.clearsContextBeforeDrawing = NO;
|
||||||
self.spinner.clipsToBounds = NO;
|
self.spinner.clipsToBounds = NO;
|
||||||
self.spinner.contentMode = UIViewContentModeScaleToFill;
|
self.spinner.contentMode = UIViewContentModeScaleToFill;
|
||||||
self.spinner.contentStretch = CGRectFromString(@"{{0, 0}, {1, 1}}");
|
|
||||||
self.spinner.frame = CGRectMake(454.0, 231.0, 20.0, 20.0);
|
self.spinner.frame = CGRectMake(454.0, 231.0, 20.0, 20.0);
|
||||||
self.spinner.hidden = YES;
|
self.spinner.hidden = YES;
|
||||||
self.spinner.hidesWhenStopped = YES;
|
self.spinner.hidesWhenStopped = YES;
|
||||||
@ -506,7 +528,6 @@
|
|||||||
self.toolbar.clearsContextBeforeDrawing = NO;
|
self.toolbar.clearsContextBeforeDrawing = NO;
|
||||||
self.toolbar.clipsToBounds = NO;
|
self.toolbar.clipsToBounds = NO;
|
||||||
self.toolbar.contentMode = UIViewContentModeScaleToFill;
|
self.toolbar.contentMode = UIViewContentModeScaleToFill;
|
||||||
self.toolbar.contentStretch = CGRectFromString(@"{{0, 0}, {1, 1}}");
|
|
||||||
self.toolbar.hidden = NO;
|
self.toolbar.hidden = NO;
|
||||||
self.toolbar.multipleTouchEnabled = NO;
|
self.toolbar.multipleTouchEnabled = NO;
|
||||||
self.toolbar.opaque = NO;
|
self.toolbar.opaque = NO;
|
||||||
@ -525,11 +546,16 @@
|
|||||||
self.addressLabel.clearsContextBeforeDrawing = YES;
|
self.addressLabel.clearsContextBeforeDrawing = YES;
|
||||||
self.addressLabel.clipsToBounds = YES;
|
self.addressLabel.clipsToBounds = YES;
|
||||||
self.addressLabel.contentMode = UIViewContentModeScaleToFill;
|
self.addressLabel.contentMode = UIViewContentModeScaleToFill;
|
||||||
self.addressLabel.contentStretch = CGRectFromString(@"{{0, 0}, {1, 1}}");
|
|
||||||
self.addressLabel.enabled = YES;
|
self.addressLabel.enabled = YES;
|
||||||
self.addressLabel.hidden = NO;
|
self.addressLabel.hidden = NO;
|
||||||
self.addressLabel.lineBreakMode = NSLineBreakByTruncatingTail;
|
self.addressLabel.lineBreakMode = NSLineBreakByTruncatingTail;
|
||||||
self.addressLabel.minimumScaleFactor = 10.000;
|
|
||||||
|
if ([self.addressLabel respondsToSelector:NSSelectorFromString(@"setMinimumScaleFactor:")]) {
|
||||||
|
[self.addressLabel setValue:@(10.0/[UIFont labelFontSize]) forKey:@"minimumScaleFactor"];
|
||||||
|
} else if ([self.addressLabel respondsToSelector:NSSelectorFromString(@"setMinimumFontSize:")]) {
|
||||||
|
[self.addressLabel setValue:@(10.0) forKey:@"minimumFontSize"];
|
||||||
|
}
|
||||||
|
|
||||||
self.addressLabel.multipleTouchEnabled = NO;
|
self.addressLabel.multipleTouchEnabled = NO;
|
||||||
self.addressLabel.numberOfLines = 1;
|
self.addressLabel.numberOfLines = 1;
|
||||||
self.addressLabel.opaque = NO;
|
self.addressLabel.opaque = NO;
|
||||||
@ -719,7 +745,7 @@
|
|||||||
if ([self respondsToSelector:@selector(presentingViewController)]) {
|
if ([self respondsToSelector:@selector(presentingViewController)]) {
|
||||||
[[self presentingViewController] dismissViewControllerAnimated:YES completion:nil];
|
[[self presentingViewController] dismissViewControllerAnimated:YES completion:nil];
|
||||||
} else {
|
} else {
|
||||||
[[self parentViewController] dismissModalViewControllerAnimated:YES];
|
[[self parentViewController] dismissViewControllerAnimated:YES completion:nil];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -885,6 +911,8 @@
|
|||||||
self.toolbar = YES;
|
self.toolbar = YES;
|
||||||
self.closebuttoncaption = nil;
|
self.closebuttoncaption = nil;
|
||||||
self.toolbarposition = kInAppBrowserToolbarBarPositionBottom;
|
self.toolbarposition = kInAppBrowserToolbarBarPositionBottom;
|
||||||
|
self.clearcache = NO;
|
||||||
|
self.clearsessioncache = NO;
|
||||||
|
|
||||||
self.enableviewportscale = NO;
|
self.enableviewportscale = NO;
|
||||||
self.mediaplaybackrequiresuseraction = NO;
|
self.mediaplaybackrequiresuseraction = NO;
|
||||||
@ -935,4 +963,37 @@
|
|||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation CDVInAppBrowserNavigationController : UINavigationController
|
||||||
|
|
||||||
|
#pragma mark CDVScreenOrientationDelegate
|
||||||
|
|
||||||
|
- (BOOL)shouldAutorotate
|
||||||
|
{
|
||||||
|
if ((self.orientationDelegate != nil) && [self.orientationDelegate respondsToSelector:@selector(shouldAutorotate)]) {
|
||||||
|
return [self.orientationDelegate shouldAutorotate];
|
||||||
|
}
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSUInteger)supportedInterfaceOrientations
|
||||||
|
{
|
||||||
|
if ((self.orientationDelegate != nil) && [self.orientationDelegate respondsToSelector:@selector(supportedInterfaceOrientations)]) {
|
||||||
|
return [self.orientationDelegate supportedInterfaceOrientations];
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1 << UIInterfaceOrientationPortrait;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
|
||||||
|
{
|
||||||
|
if ((self.orientationDelegate != nil) && [self.orientationDelegate respondsToSelector:@selector(shouldAutorotateToInterfaceOrientation:)]) {
|
||||||
|
return [self.orientationDelegate shouldAutorotateToInterfaceOrientation:interfaceOrientation];
|
||||||
|
}
|
||||||
|
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@ -1,21 +1,38 @@
|
|||||||
using System;
|
/*
|
||||||
using System.Net;
|
Licensed 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using System.Windows.Documents;
|
|
||||||
using System.Windows.Ink;
|
|
||||||
using System.Windows.Input;
|
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using System.Windows.Media.Animation;
|
|
||||||
using System.Windows.Shapes;
|
|
||||||
using Microsoft.Phone.Controls;
|
using Microsoft.Phone.Controls;
|
||||||
using System.Diagnostics;
|
|
||||||
using System.Runtime.Serialization;
|
|
||||||
using WPCordovaClassLib.Cordova;
|
|
||||||
using WPCordovaClassLib.Cordova.Commands;
|
|
||||||
using WPCordovaClassLib.Cordova.JSON;
|
|
||||||
using Microsoft.Phone.Shell;
|
using Microsoft.Phone.Shell;
|
||||||
|
|
||||||
|
#if WP8
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Windows.ApplicationModel;
|
||||||
|
using Windows.Storage;
|
||||||
|
using Windows.System;
|
||||||
|
|
||||||
|
//Use alias in case Cordova File Plugin is enabled. Then the File class will be declared in both and error will occur.
|
||||||
|
using IOFile = System.IO.File;
|
||||||
|
#else
|
||||||
using Microsoft.Phone.Tasks;
|
using Microsoft.Phone.Tasks;
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace WPCordovaClassLib.Cordova.Commands
|
namespace WPCordovaClassLib.Cordova.Commands
|
||||||
{
|
{
|
||||||
@ -41,6 +58,8 @@ namespace WPCordovaClassLib.Cordova.Commands
|
|||||||
protected bool ShowLocation {get;set;}
|
protected bool ShowLocation {get;set;}
|
||||||
protected bool StartHidden {get;set;}
|
protected bool StartHidden {get;set;}
|
||||||
|
|
||||||
|
protected string NavigationCallbackId { get; set; }
|
||||||
|
|
||||||
public void open(string options)
|
public void open(string options)
|
||||||
{
|
{
|
||||||
// reset defaults on ShowLocation + StartHidden features
|
// reset defaults on ShowLocation + StartHidden features
|
||||||
@ -52,28 +71,31 @@ namespace WPCordovaClassLib.Cordova.Commands
|
|||||||
string urlLoc = args[0];
|
string urlLoc = args[0];
|
||||||
string target = args[1];
|
string target = args[1];
|
||||||
string featString = args[2];
|
string featString = args[2];
|
||||||
|
this.NavigationCallbackId = args[3];
|
||||||
|
|
||||||
string[] features = featString.Split(',');
|
if (!string.IsNullOrEmpty(featString))
|
||||||
foreach (string str in features)
|
|
||||||
{
|
{
|
||||||
try
|
string[] features = featString.Split(',');
|
||||||
|
foreach (string str in features)
|
||||||
{
|
{
|
||||||
string[] split = str.Split('=');
|
try
|
||||||
switch (split[0])
|
|
||||||
{
|
{
|
||||||
case "location":
|
string[] split = str.Split('=');
|
||||||
ShowLocation = split[1].ToLower().StartsWith("yes");
|
switch (split[0])
|
||||||
break;
|
{
|
||||||
case "hidden":
|
case "location":
|
||||||
StartHidden = split[1].ToLower().StartsWith("yes");
|
ShowLocation = split[1].StartsWith("yes", StringComparison.OrdinalIgnoreCase);
|
||||||
break;
|
break;
|
||||||
|
case "hidden":
|
||||||
|
StartHidden = split[1].StartsWith("yes", StringComparison.OrdinalIgnoreCase);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
// some sort of invalid param was passed, moving on ...
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(Exception)
|
|
||||||
{
|
|
||||||
// some sort of invalid param was passed, moving on ...
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
_self - opens in the Cordova WebView if url is in the white-list, else it opens in the InAppBrowser
|
_self - opens in the Cordova WebView if url is in the white-list, else it opens in the InAppBrowser
|
||||||
@ -184,7 +206,6 @@ namespace WPCordovaClassLib.Cordova.Commands
|
|||||||
//throw new NotImplementedException("Windows Phone does not currently support 'insertCSS'");
|
//throw new NotImplementedException("Windows Phone does not currently support 'insertCSS'");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void ShowCordovaBrowser(string url)
|
private void ShowCordovaBrowser(string url)
|
||||||
{
|
{
|
||||||
Uri loc = new Uri(url, UriKind.RelativeOrAbsolute);
|
Uri loc = new Uri(url, UriKind.RelativeOrAbsolute);
|
||||||
@ -200,7 +221,7 @@ namespace WPCordovaClassLib.Cordova.Commands
|
|||||||
if (cView != null)
|
if (cView != null)
|
||||||
{
|
{
|
||||||
WebBrowser br = cView.Browser;
|
WebBrowser br = cView.Browser;
|
||||||
br.Navigate(loc);
|
br.Navigate2(loc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,13 +229,53 @@ namespace WPCordovaClassLib.Cordova.Commands
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if WP8
|
||||||
|
private async void ShowSystemBrowser(string url)
|
||||||
|
{
|
||||||
|
var pathUri = new Uri(url, UriKind.Absolute);
|
||||||
|
if (pathUri.Scheme == Uri.UriSchemeHttp || pathUri.Scheme == Uri.UriSchemeHttps)
|
||||||
|
{
|
||||||
|
await Launcher.LaunchUriAsync(pathUri);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var file = await GetFile(pathUri.AbsolutePath.Replace('/', Path.DirectorySeparatorChar));
|
||||||
|
if (file != null)
|
||||||
|
{
|
||||||
|
await Launcher.LaunchFileAsync(file);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.WriteLine("File not found.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task<StorageFile> GetFile(string fileName)
|
||||||
|
{
|
||||||
|
//first try to get the file from the isolated storage
|
||||||
|
var localFolder = ApplicationData.Current.LocalFolder;
|
||||||
|
if (IOFile.Exists(Path.Combine(localFolder.Path, fileName)))
|
||||||
|
{
|
||||||
|
return await localFolder.GetFileAsync(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
//if file is not found try to get it from the xap
|
||||||
|
var filePath = Path.Combine(Package.Current.InstalledLocation.Path, fileName);
|
||||||
|
if (IOFile.Exists(filePath))
|
||||||
|
{
|
||||||
|
return await StorageFile.GetFileFromPathAsync(filePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
#else
|
||||||
private void ShowSystemBrowser(string url)
|
private void ShowSystemBrowser(string url)
|
||||||
{
|
{
|
||||||
WebBrowserTask webBrowserTask = new WebBrowserTask();
|
WebBrowserTask webBrowserTask = new WebBrowserTask();
|
||||||
webBrowserTask.Uri = new Uri(url, UriKind.Absolute);
|
webBrowserTask.Uri = new Uri(url, UriKind.Absolute);
|
||||||
webBrowserTask.Show();
|
webBrowserTask.Show();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
private void ShowInAppBrowser(string url)
|
private void ShowInAppBrowser(string url)
|
||||||
{
|
{
|
||||||
@ -225,7 +286,7 @@ namespace WPCordovaClassLib.Cordova.Commands
|
|||||||
if (browser != null)
|
if (browser != null)
|
||||||
{
|
{
|
||||||
//browser.IsGeolocationEnabled = opts.isGeolocationEnabled;
|
//browser.IsGeolocationEnabled = opts.isGeolocationEnabled;
|
||||||
browser.Navigate(loc);
|
browser.Navigate2(loc);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -248,7 +309,7 @@ namespace WPCordovaClassLib.Cordova.Commands
|
|||||||
browser.Navigating += new EventHandler<NavigatingEventArgs>(browser_Navigating);
|
browser.Navigating += new EventHandler<NavigatingEventArgs>(browser_Navigating);
|
||||||
browser.NavigationFailed += new System.Windows.Navigation.NavigationFailedEventHandler(browser_NavigationFailed);
|
browser.NavigationFailed += new System.Windows.Navigation.NavigationFailedEventHandler(browser_NavigationFailed);
|
||||||
browser.Navigated += new EventHandler<System.Windows.Navigation.NavigationEventArgs>(browser_Navigated);
|
browser.Navigated += new EventHandler<System.Windows.Navigation.NavigationEventArgs>(browser_Navigated);
|
||||||
browser.Navigate(loc);
|
browser.Navigate2(loc);
|
||||||
|
|
||||||
if (StartHidden)
|
if (StartHidden)
|
||||||
{
|
{
|
||||||
@ -287,6 +348,8 @@ namespace WPCordovaClassLib.Cordova.Commands
|
|||||||
bar.IsVisible = !StartHidden;
|
bar.IsVisible = !StartHidden;
|
||||||
AppBar = bar;
|
AppBar = bar;
|
||||||
|
|
||||||
|
page.BackKeyPress += page_BackKeyPress;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -294,6 +357,23 @@ namespace WPCordovaClassLib.Cordova.Commands
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void page_BackKeyPress(object sender, System.ComponentModel.CancelEventArgs e)
|
||||||
|
{
|
||||||
|
#if WP8
|
||||||
|
if (browser.CanGoBack)
|
||||||
|
{
|
||||||
|
browser.GoBack();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
e.Cancel = true;
|
||||||
|
#else
|
||||||
|
browser.InvokeScript("execScript", "history.back();");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void browser_LoadCompleted(object sender, System.Windows.Navigation.NavigationEventArgs e)
|
void browser_LoadCompleted(object sender, System.Windows.Navigation.NavigationEventArgs e)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -326,7 +406,7 @@ namespace WPCordovaClassLib.Cordova.Commands
|
|||||||
{
|
{
|
||||||
#if WP8
|
#if WP8
|
||||||
browser.GoBack();
|
browser.GoBack();
|
||||||
#else
|
#else
|
||||||
browser.InvokeScript("execScript", "history.back();");
|
browser.InvokeScript("execScript", "history.back();");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -361,13 +441,15 @@ namespace WPCordovaClassLib.Cordova.Commands
|
|||||||
grid.Children.Remove(browser);
|
grid.Children.Remove(browser);
|
||||||
}
|
}
|
||||||
page.ApplicationBar = null;
|
page.ApplicationBar = null;
|
||||||
|
page.BackKeyPress -= page_BackKeyPress;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
browser = null;
|
browser = null;
|
||||||
string message = "{\"type\":\"exit\"}";
|
string message = "{\"type\":\"exit\"}";
|
||||||
PluginResult result = new PluginResult(PluginResult.Status.OK, message);
|
PluginResult result = new PluginResult(PluginResult.Status.OK, message);
|
||||||
result.KeepCallback = false;
|
result.KeepCallback = false;
|
||||||
this.DispatchCommandResult(result);
|
this.DispatchCommandResult(result, NavigationCallbackId);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -385,7 +467,7 @@ namespace WPCordovaClassLib.Cordova.Commands
|
|||||||
string message = "{\"type\":\"loadstop\", \"url\":\"" + e.Uri.OriginalString + "\"}";
|
string message = "{\"type\":\"loadstop\", \"url\":\"" + e.Uri.OriginalString + "\"}";
|
||||||
PluginResult result = new PluginResult(PluginResult.Status.OK, message);
|
PluginResult result = new PluginResult(PluginResult.Status.OK, message);
|
||||||
result.KeepCallback = true;
|
result.KeepCallback = true;
|
||||||
this.DispatchCommandResult(result);
|
this.DispatchCommandResult(result, NavigationCallbackId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void browser_NavigationFailed(object sender, System.Windows.Navigation.NavigationFailedEventArgs e)
|
void browser_NavigationFailed(object sender, System.Windows.Navigation.NavigationFailedEventArgs e)
|
||||||
@ -393,7 +475,7 @@ namespace WPCordovaClassLib.Cordova.Commands
|
|||||||
string message = "{\"type\":\"error\",\"url\":\"" + e.Uri.OriginalString + "\"}";
|
string message = "{\"type\":\"error\",\"url\":\"" + e.Uri.OriginalString + "\"}";
|
||||||
PluginResult result = new PluginResult(PluginResult.Status.ERROR, message);
|
PluginResult result = new PluginResult(PluginResult.Status.ERROR, message);
|
||||||
result.KeepCallback = true;
|
result.KeepCallback = true;
|
||||||
this.DispatchCommandResult(result);
|
this.DispatchCommandResult(result, NavigationCallbackId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void browser_Navigating(object sender, NavigatingEventArgs e)
|
void browser_Navigating(object sender, NavigatingEventArgs e)
|
||||||
@ -401,8 +483,33 @@ namespace WPCordovaClassLib.Cordova.Commands
|
|||||||
string message = "{\"type\":\"loadstart\",\"url\":\"" + e.Uri.OriginalString + "\"}";
|
string message = "{\"type\":\"loadstart\",\"url\":\"" + e.Uri.OriginalString + "\"}";
|
||||||
PluginResult result = new PluginResult(PluginResult.Status.OK, message);
|
PluginResult result = new PluginResult(PluginResult.Status.OK, message);
|
||||||
result.KeepCallback = true;
|
result.KeepCallback = true;
|
||||||
this.DispatchCommandResult(result);
|
this.DispatchCommandResult(result, NavigationCallbackId);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal static class WebBrowserExtensions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Improved method to initiate request to the provided URI. Supports 'data:text/html' urls.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="browser">The browser instance</param>
|
||||||
|
/// <param name="uri">The requested uri</param>
|
||||||
|
internal static void Navigate2(this WebBrowser browser, Uri uri)
|
||||||
|
{
|
||||||
|
// IE10 does not support data uri so we use NavigateToString method instead
|
||||||
|
if (uri.Scheme == "data")
|
||||||
|
{
|
||||||
|
// we should remove the scheme identifier and unescape the uri
|
||||||
|
string uriString = Uri.UnescapeDataString(uri.AbsoluteUri);
|
||||||
|
// format is 'data:text/html, ...'
|
||||||
|
string html = new System.Text.RegularExpressions.Regex("^data:text/html,").Replace(uriString, "");
|
||||||
|
browser.NavigateToString(html);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
browser.Navigate(uri);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -90,6 +90,8 @@ module.exports = function(strUrl, strWindowName, strWindowFeatures) {
|
|||||||
iab._eventHandler(eventname);
|
iab._eventHandler(eventname);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
strWindowFeatures = strWindowFeatures || "";
|
||||||
|
|
||||||
exec(cb, cb, "InAppBrowser", "open", [strUrl, strWindowName, strWindowFeatures]);
|
exec(cb, cb, "InAppBrowser", "open", [strUrl, strWindowName, strWindowFeatures]);
|
||||||
return iab;
|
return iab;
|
||||||
};
|
};
|
||||||
|
@ -108,4 +108,4 @@ var IAB = {
|
|||||||
module.exports = IAB;
|
module.exports = IAB;
|
||||||
|
|
||||||
|
|
||||||
require("cordova/windows8/commandProxy").add("InAppBrowser", module.exports);
|
require("cordova/exec/proxy").add("InAppBrowser", module.exports);
|
||||||
|
Loading…
Reference in New Issue
Block a user