Compare commits
33 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1c98bc5b3f | ||
|
|
c5061ec333 | ||
|
|
932f078e2d | ||
|
|
1c32236353 | ||
|
|
34c29dc2ec | ||
|
|
aa6c1519d2 | ||
|
|
2fc9f3da1f | ||
|
|
bddf86c3ce | ||
|
|
25f306d11e | ||
|
|
04de070dcd | ||
|
|
22c7a0e51e | ||
|
|
9399ed3955 | ||
|
|
749d55c676 | ||
|
|
fceea502a3 | ||
|
|
aa9a5db941 | ||
|
|
e282cc9e38 | ||
|
|
7dbad601f0 | ||
|
|
5680f18bb4 | ||
|
|
a5dedae631 | ||
|
|
d0dd10103c | ||
|
|
497a23efc7 | ||
|
|
6f373f7ed9 | ||
|
|
300f1e782e | ||
|
|
4d3c7b17d2 | ||
|
|
a5201cc1e3 | ||
|
|
942d17981e | ||
|
|
17ba417572 | ||
|
|
77085aa547 | ||
|
|
26702cb072 | ||
|
|
39e64c988a | ||
|
|
cd31b3a64d | ||
|
|
4c07917c0a | ||
|
|
24e6a1feeb |
6
NOTICE
6
NOTICE
@@ -1 +1,5 @@
|
||||
Icons used in ths plugin are reproduced from work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.
|
||||
Apache Cordova
|
||||
Copyright 2012 The Apache Software Foundation
|
||||
|
||||
This product includes software developed at
|
||||
The Apache Software Foundation (http://www.apache.org/).
|
||||
|
||||
@@ -73,3 +73,27 @@
|
||||
* CB-5756: Android: Use WebView.evaluateJavascript for script injection on Android 4.4+
|
||||
* Remove alive from InAppBrowser.js since it didn't catch the case where the browser is closed by the user.
|
||||
* CB-5733 Fix IAB.close() not working if called before show() animation is done
|
||||
|
||||
### 0.3.2 (Feb 26, 2014)
|
||||
* Validate that callbackId is correctly formed
|
||||
* CB-6035 Move js-module so it is not loaded on unsupported platforms
|
||||
* Removed some iOS6 Deprecations
|
||||
|
||||
### 0.3.3 (Mar 5, 2014)
|
||||
* CB-5534 Fix video/audio does not stop playing when browser is closed
|
||||
* 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
|
||||
|
||||
16
doc/index.md
16
doc/index.md
@@ -56,7 +56,7 @@ instance, or the system browser.
|
||||
Android only:
|
||||
|
||||
- __closebuttoncaption__: set to a string to use as the __Done__ button's caption.
|
||||
- __hidden__: set to `yes` to create the browser and load the page, but not show it. The load 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
|
||||
|
||||
@@ -64,7 +64,9 @@ 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.
|
||||
- __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 load 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`)
|
||||
- __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`).
|
||||
@@ -133,14 +135,13 @@ The object returned from a call to `window.open`.
|
||||
|
||||
- Amazon Fire OS
|
||||
- Android
|
||||
- BlackBerry 10
|
||||
- iOS
|
||||
- Windows Phone 7 and 8
|
||||
|
||||
### Quick Example
|
||||
|
||||
var ref = window.open('http://apache.org', '_blank', 'location=yes');
|
||||
ref.addEventListener('loadstart', function() { alert(event.url); });
|
||||
ref.addEventListener('loadstart', function(event) { alert(event.url); });
|
||||
|
||||
## removeEventListener
|
||||
|
||||
@@ -164,14 +165,13 @@ The function is passed an `InAppBrowserEvent` object.
|
||||
|
||||
- Amazon Fire OS
|
||||
- Android
|
||||
- BlackBerry 10
|
||||
- iOS
|
||||
- Windows Phone 7 and 8
|
||||
|
||||
### Quick Example
|
||||
|
||||
var ref = window.open('http://apache.org', '_blank', 'location=yes');
|
||||
var myCallback = function() { alert(event.url); }
|
||||
var myCallback = function(event) { alert(event.url); }
|
||||
ref.addEventListener('loadstart', myCallback);
|
||||
ref.removeEventListener('loadstart', myCallback);
|
||||
|
||||
@@ -187,7 +187,6 @@ The function is passed an `InAppBrowserEvent` object.
|
||||
|
||||
- Amazon Fire OS
|
||||
- Android
|
||||
- BlackBerry 10
|
||||
- iOS
|
||||
- Windows Phone 7 and 8
|
||||
|
||||
@@ -208,7 +207,6 @@ The function is passed an `InAppBrowserEvent` object.
|
||||
|
||||
- Amazon Fire OS
|
||||
- Android
|
||||
- BlackBerry 10
|
||||
- iOS
|
||||
|
||||
### Quick Example
|
||||
@@ -240,7 +238,6 @@ The function is passed an `InAppBrowserEvent` object.
|
||||
|
||||
- Amazon Fire OS
|
||||
- Android
|
||||
- BlackBerry 10
|
||||
- iOS
|
||||
|
||||
### Quick Example
|
||||
@@ -268,7 +265,6 @@ The function is passed an `InAppBrowserEvent` object.
|
||||
|
||||
- Amazon Fire OS
|
||||
- Android
|
||||
- BlackBerry 10
|
||||
- iOS
|
||||
|
||||
### Quick Example
|
||||
|
||||
65
plugin.xml
65
plugin.xml
@@ -1,8 +1,26 @@
|
||||
<?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"
|
||||
id="org.apache.cordova.inappbrowser"
|
||||
version="0.3.1">
|
||||
version="0.4.0">
|
||||
|
||||
<name>InAppBrowser</name>
|
||||
<description>Cordova InAppBrowser Plugin</description>
|
||||
@@ -14,13 +32,12 @@
|
||||
<engines>
|
||||
<engine name="cordova" version=">=3.1.0" /><!-- Needs cordova/urlutil -->
|
||||
</engines>
|
||||
|
||||
<js-module src="www/InAppBrowser.js" name="InAppBrowser">
|
||||
<clobbers target="window.open" />
|
||||
</js-module>
|
||||
|
||||
<!-- -->
|
||||
<!-- android -->
|
||||
<platform name="android">
|
||||
<js-module src="www/inappbrowser.js" name="inappbrowser">
|
||||
<clobbers target="window.open" />
|
||||
</js-module>
|
||||
<config-file target="res/xml/config.xml" parent="/*">
|
||||
<feature name="InAppBrowser">
|
||||
<param name="android-package" value="org.apache.cordova.inappbrowser.InAppBrowser"/>
|
||||
@@ -28,6 +45,7 @@
|
||||
</config-file>
|
||||
|
||||
<source-file src="src/android/InAppBrowser.java" target-dir="src/org/apache/cordova/inappbrowser" />
|
||||
<source-file src="src/android/InAppBrowserDialog.java" target-dir="src/org/apache/cordova/inappbrowser" />
|
||||
<source-file src="src/android/InAppChromeClient.java" target-dir="src/org/apache/cordova/inappbrowser" />
|
||||
|
||||
<!-- drawable src/android/resources -->
|
||||
@@ -50,6 +68,9 @@
|
||||
|
||||
<!-- amazon-fireos -->
|
||||
<platform name="amazon-fireos">
|
||||
<js-module src="www/inappbrowser.js" name="inappbrowser">
|
||||
<clobbers target="window.open" />
|
||||
</js-module>
|
||||
<config-file target="res/xml/config.xml" parent="/*">
|
||||
<feature name="InAppBrowser">
|
||||
<param name="android-package" value="org.apache.cordova.inappbrowser.InAppBrowser"/>
|
||||
@@ -62,6 +83,9 @@
|
||||
|
||||
<!-- ubuntu -->
|
||||
<platform name="ubuntu">
|
||||
<js-module src="www/inappbrowser.js" name="inappbrowser">
|
||||
<clobbers target="window.open" />
|
||||
</js-module>
|
||||
<header-file src="src/ubuntu/inappbrowser.h" />
|
||||
<source-file src="src/ubuntu/inappbrowser.cpp" />
|
||||
<resource-file src="src/ubuntu/InAppBrowser.qml" />
|
||||
@@ -69,7 +93,10 @@
|
||||
</platform>
|
||||
|
||||
<!-- ios -->
|
||||
<platform name="ios">
|
||||
<platform name="ios">
|
||||
<js-module src="www/inappbrowser.js" name="inappbrowser">
|
||||
<clobbers target="window.open" />
|
||||
</js-module>
|
||||
<config-file target="config.xml" parent="/*">
|
||||
<feature name="InAppBrowser">
|
||||
<param name="ios-package" value="CDVInAppBrowser" />
|
||||
@@ -82,15 +109,15 @@
|
||||
<framework src="CoreGraphics.framework" />
|
||||
</platform>
|
||||
|
||||
<!-- blackberry10 -->
|
||||
<!-- <platform name="blackberry10">
|
||||
<config-file target="www/config.xml" parent="/widget">
|
||||
<feature name="InAppBrowser" value="InAppBrowser"/>
|
||||
</config-file>
|
||||
</platform>
|
||||
-->
|
||||
<!-- wp7 -->
|
||||
<platform name="wp7">
|
||||
<config-file target="Properties/WMAppManifest.xml" parent="/Deployment/App/Capabilities">
|
||||
<Capability Name="ID_CAP_NETWORKING"/>
|
||||
</config-file>
|
||||
|
||||
<js-module src="www/inappbrowser.js" name="inappbrowser">
|
||||
<clobbers target="window.open" />
|
||||
</js-module>
|
||||
<config-file target="config.xml" parent="/*">
|
||||
<feature name="InAppBrowser">
|
||||
<param name="wp-package" value="InAppBrowser"/>
|
||||
@@ -102,6 +129,13 @@
|
||||
|
||||
<!-- wp8 -->
|
||||
<platform name="wp8">
|
||||
<config-file target="Properties/WMAppManifest.xml" parent="/Deployment/App/Capabilities">
|
||||
<Capability Name="ID_CAP_NETWORKING"/>
|
||||
</config-file>
|
||||
|
||||
<js-module src="www/inappbrowser.js" name="inappbrowser">
|
||||
<clobbers target="window.open" />
|
||||
</js-module>
|
||||
<config-file target="config.xml" parent="/*">
|
||||
<feature name="InAppBrowser">
|
||||
<param name="wp-package" value="InAppBrowser"/>
|
||||
@@ -113,6 +147,9 @@
|
||||
|
||||
<!-- windows8 -->
|
||||
<platform name="windows8">
|
||||
<js-module src="www/inappbrowser.js" name="inappbrowser">
|
||||
<clobbers target="window.open" />
|
||||
</js-module>
|
||||
<js-module src="www/windows8/InAppBrowserProxy.js" name="InAppBrowserProxy">
|
||||
<merges target="" />
|
||||
</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;
|
||||
|
||||
import org.apache.cordova.CordovaWebView;
|
||||
|
||||
@@ -19,9 +19,8 @@
|
||||
package org.apache.cordova.inappbrowser;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Dialog;
|
||||
import org.apache.cordova.inappbrowser.InAppBrowserDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Bitmap;
|
||||
@@ -80,7 +79,7 @@ public class InAppBrowser extends CordovaPlugin {
|
||||
private static final String CLEAR_ALL_CACHE = "clearcache";
|
||||
private static final String CLEAR_SESSION_CACHE = "clearsessioncache";
|
||||
|
||||
private Dialog dialog;
|
||||
private InAppBrowserDialog dialog;
|
||||
private WebView inAppWebView;
|
||||
private EditText edittext;
|
||||
private CallbackContext callbackContext;
|
||||
@@ -337,12 +336,21 @@ public class InAppBrowser extends CordovaPlugin {
|
||||
this.cordova.getActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
childView.loadUrl("about:blank");
|
||||
childView.setWebViewClient(new WebViewClient() {
|
||||
// NB: wait for about:blank before dismissing
|
||||
public void onPageFinished(WebView view, String url) {
|
||||
if (dialog != null) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
}
|
||||
});
|
||||
// NB: From SDK 19: "If you call methods on WebView from any thread
|
||||
// other than your app's UI thread, it can cause unexpected results."
|
||||
// http://developer.android.com/guide/webapps/migrating.html#Threads
|
||||
childView.loadUrl("about:blank");
|
||||
}
|
||||
});
|
||||
|
||||
try {
|
||||
JSONObject obj = new JSONObject();
|
||||
obj.put("type", EXIT_EVENT);
|
||||
@@ -350,7 +358,6 @@ public class InAppBrowser extends CordovaPlugin {
|
||||
} catch (JSONException ex) {
|
||||
Log.d(LOG_TAG, "Should never happen");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -398,6 +405,10 @@ public class InAppBrowser extends CordovaPlugin {
|
||||
return this.showLocationBar;
|
||||
}
|
||||
|
||||
private InAppBrowser getInAppBrowser(){
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a new browser with the specified URL.
|
||||
*
|
||||
@@ -448,15 +459,11 @@ public class InAppBrowser extends CordovaPlugin {
|
||||
|
||||
public void run() {
|
||||
// Let's create the main dialog
|
||||
dialog = new Dialog(cordova.getActivity(), android.R.style.Theme_NoTitleBar);
|
||||
dialog = new InAppBrowserDialog(cordova.getActivity(), android.R.style.Theme_NoTitleBar);
|
||||
dialog.getWindow().getAttributes().windowAnimations = android.R.style.Animation_Dialog;
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog.setCancelable(true);
|
||||
dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
|
||||
public void onDismiss(DialogInterface dialog) {
|
||||
closeDialog();
|
||||
}
|
||||
});
|
||||
dialog.setInAppBroswer(getInAppBrowser());
|
||||
|
||||
// Main container layout
|
||||
LinearLayout main = new LinearLayout(cordova.getActivity());
|
||||
|
||||
54
src/android/InAppBrowserDialog.java
Normal file
54
src/android/InAppBrowserDialog.java
Normal file
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
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;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
/**
|
||||
* Created by Oliver on 22/11/2013.
|
||||
*/
|
||||
public class InAppBrowserDialog extends Dialog {
|
||||
Context context;
|
||||
InAppBrowser inAppBrowser = null;
|
||||
|
||||
public InAppBrowserDialog(Context context, int theme) {
|
||||
super(context, theme);
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
public void setInAppBroswer(InAppBrowser browser) {
|
||||
this.inAppBrowser = browser;
|
||||
}
|
||||
|
||||
public void onBackPressed () {
|
||||
if (this.inAppBrowser == null) {
|
||||
this.dismiss();
|
||||
} else {
|
||||
// better to go through the in inAppBrowser
|
||||
// because it does a clean up
|
||||
this.inAppBrowser.closeDialog();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
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
|
||||
|
||||
The in app browser functionality is entirely contained within common js. There is no native implementation required.
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
|
||||
@property (nonatomic, retain) CDVInAppBrowserViewController* inAppBrowserViewController;
|
||||
@property (nonatomic, copy) NSString* callbackId;
|
||||
@property (nonatomic, copy) NSRegularExpression *callbackIdPattern;
|
||||
|
||||
- (void)open:(CDVInvokedUrlCommand*)command;
|
||||
- (void)close:(CDVInvokedUrlCommand*)command;
|
||||
@@ -44,6 +45,8 @@
|
||||
@property (nonatomic, assign) BOOL toolbar;
|
||||
@property (nonatomic, copy) NSString* closebuttoncaption;
|
||||
@property (nonatomic, copy) NSString* toolbarposition;
|
||||
@property (nonatomic, assign) BOOL clearcache;
|
||||
@property (nonatomic, assign) BOOL clearsessioncache;
|
||||
|
||||
@property (nonatomic, copy) NSString* presentationstyle;
|
||||
@property (nonatomic, copy) NSString* transitionstyle;
|
||||
|
||||
@@ -47,6 +47,7 @@
|
||||
self = [super initWithWebView:theWebView];
|
||||
if (self != nil) {
|
||||
_previousStatusBarStyle = -1;
|
||||
_callbackIdPattern = nil;
|
||||
}
|
||||
|
||||
return self;
|
||||
@@ -114,6 +115,29 @@
|
||||
- (void)openInInAppBrowser:(NSURL*)url withOptions:(NSString*)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) {
|
||||
NSString* originalUA = [CDVUserAgentUtil originalUserAgent];
|
||||
self.inAppBrowserViewController = [[CDVInAppBrowserViewController alloc] initWithUserAgent:originalUA prevUserAgent:[self.commandDelegate userAgent] browserOptions: browserOptions];
|
||||
@@ -297,6 +321,23 @@
|
||||
[self injectDeferredObject:[command argumentAtIndex:0] withWrapper:jsWrapper];
|
||||
}
|
||||
|
||||
- (BOOL)isValidCallbackId:(NSString *)callbackId
|
||||
{
|
||||
NSError *err = nil;
|
||||
// Initialize on first use
|
||||
if (self.callbackIdPattern == nil) {
|
||||
self.callbackIdPattern = [NSRegularExpression regularExpressionWithPattern:@"^InAppBrowser[0-9]{1,10}$" options:0 error:&err];
|
||||
if (err != nil) {
|
||||
// Couldn't initialize Regex; No is safer than Yes.
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
if ([self.callbackIdPattern firstMatchInString:callbackId options:0 range:NSMakeRange(0, [callbackId length])]) {
|
||||
return YES;
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
/**
|
||||
* The iframe bridge provided for the InAppBrowser is capable of executing any oustanding callback belonging
|
||||
* to the InAppBrowser plugin. Care has been taken that other callbacks cannot be triggered, and that no
|
||||
@@ -323,7 +364,7 @@
|
||||
NSString* scriptCallbackId = [url host];
|
||||
CDVPluginResult* pluginResult = nil;
|
||||
|
||||
if ([scriptCallbackId hasPrefix:@"InAppBrowser"]) {
|
||||
if ([self isValidCallbackId:scriptCallbackId]) {
|
||||
NSString* scriptResult = [url path];
|
||||
NSError* __autoreleasing error = nil;
|
||||
|
||||
@@ -377,7 +418,7 @@
|
||||
if (self.callbackId != nil) {
|
||||
NSString* url = [self.inAppBrowserViewController.currentURL absoluteString];
|
||||
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR
|
||||
messageAsDictionary:@{@"type":@"loaderror", @"url":url, @"code": [NSNumber numberWithInt:error.code], @"message": error.localizedDescription}];
|
||||
messageAsDictionary:@{@"type":@"loaderror", @"url":url, @"code": [NSNumber numberWithInteger:error.code], @"message": error.localizedDescription}];
|
||||
[pluginResult setKeepCallback:[NSNumber numberWithBool:YES]];
|
||||
|
||||
[self.commandDelegate sendPluginResult:pluginResult callbackId:self.callbackId];
|
||||
@@ -510,14 +551,18 @@
|
||||
self.addressLabel.contentStretch = CGRectFromString(@"{{0, 0}, {1, 1}}");
|
||||
self.addressLabel.enabled = YES;
|
||||
self.addressLabel.hidden = NO;
|
||||
self.addressLabel.lineBreakMode = UILineBreakModeTailTruncation;
|
||||
self.addressLabel.minimumFontSize = 10.000;
|
||||
self.addressLabel.lineBreakMode = NSLineBreakByTruncatingTail;
|
||||
if (IsAtLeastiOSVersion(@"6.0")) {
|
||||
self.addressLabel.minimumScaleFactor = 10.0/[UIFont labelFontSize];
|
||||
} else {
|
||||
self.addressLabel.minimumFontSize = 10.000;
|
||||
}
|
||||
self.addressLabel.multipleTouchEnabled = NO;
|
||||
self.addressLabel.numberOfLines = 1;
|
||||
self.addressLabel.opaque = NO;
|
||||
self.addressLabel.shadowOffset = CGSizeMake(0.0, -1.0);
|
||||
self.addressLabel.text = NSLocalizedString(@"Loading...", nil);
|
||||
self.addressLabel.textAlignment = UITextAlignmentLeft;
|
||||
self.addressLabel.textAlignment = NSTextAlignmentLeft;
|
||||
self.addressLabel.textColor = [UIColor colorWithWhite:1.000 alpha:1.000];
|
||||
self.addressLabel.userInteractionEnabled = NO;
|
||||
|
||||
@@ -816,7 +861,7 @@
|
||||
- (void)webView:(UIWebView*)theWebView didFailLoadWithError:(NSError*)error
|
||||
{
|
||||
// log fail message, stop spinner, update back/forward
|
||||
NSLog(@"webView:didFailLoadWithError - %i: %@", error.code, [error localizedDescription]);
|
||||
NSLog(@"webView:didFailLoadWithError - %ld: %@", (long)error.code, [error localizedDescription]);
|
||||
|
||||
self.backButton.enabled = theWebView.canGoBack;
|
||||
self.forwardButton.enabled = theWebView.canGoForward;
|
||||
@@ -867,6 +912,8 @@
|
||||
self.toolbar = YES;
|
||||
self.closebuttoncaption = nil;
|
||||
self.toolbarposition = kInAppBrowserToolbarBarPositionBottom;
|
||||
self.clearcache = NO;
|
||||
self.clearsessioncache = NO;
|
||||
|
||||
self.enableviewportscale = NO;
|
||||
self.mediaplaybackrequiresuseraction = NO;
|
||||
|
||||
@@ -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.Controls;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Ink;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Animation;
|
||||
using System.Windows.Shapes;
|
||||
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;
|
||||
|
||||
#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;
|
||||
#endif
|
||||
|
||||
namespace WPCordovaClassLib.Cordova.Commands
|
||||
{
|
||||
@@ -53,27 +70,29 @@ namespace WPCordovaClassLib.Cordova.Commands
|
||||
string target = args[1];
|
||||
string featString = args[2];
|
||||
|
||||
string[] features = featString.Split(',');
|
||||
foreach (string str in features)
|
||||
if (!string.IsNullOrEmpty(featString))
|
||||
{
|
||||
try
|
||||
string[] features = featString.Split(',');
|
||||
foreach (string str in features)
|
||||
{
|
||||
string[] split = str.Split('=');
|
||||
switch (split[0])
|
||||
try
|
||||
{
|
||||
case "location":
|
||||
ShowLocation = split[1].ToLower().StartsWith("yes");
|
||||
break;
|
||||
case "hidden":
|
||||
StartHidden = split[1].ToLower().StartsWith("yes");
|
||||
break;
|
||||
string[] split = str.Split('=');
|
||||
switch (split[0])
|
||||
{
|
||||
case "location":
|
||||
ShowLocation = split[1].StartsWith("yes", StringComparison.OrdinalIgnoreCase);
|
||||
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
|
||||
@@ -184,7 +203,6 @@ namespace WPCordovaClassLib.Cordova.Commands
|
||||
//throw new NotImplementedException("Windows Phone does not currently support 'insertCSS'");
|
||||
}
|
||||
|
||||
|
||||
private void ShowCordovaBrowser(string url)
|
||||
{
|
||||
Uri loc = new Uri(url, UriKind.RelativeOrAbsolute);
|
||||
@@ -208,13 +226,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)
|
||||
{
|
||||
WebBrowserTask webBrowserTask = new WebBrowserTask();
|
||||
webBrowserTask.Uri = new Uri(url, UriKind.Absolute);
|
||||
webBrowserTask.Show();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
private void ShowInAppBrowser(string url)
|
||||
{
|
||||
@@ -287,6 +345,8 @@ namespace WPCordovaClassLib.Cordova.Commands
|
||||
bar.IsVisible = !StartHidden;
|
||||
AppBar = bar;
|
||||
|
||||
page.BackKeyPress += page_BackKeyPress;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -294,6 +354,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)
|
||||
{
|
||||
|
||||
@@ -326,7 +403,7 @@ namespace WPCordovaClassLib.Cordova.Commands
|
||||
{
|
||||
#if WP8
|
||||
browser.GoBack();
|
||||
#else
|
||||
#else
|
||||
browser.InvokeScript("execScript", "history.back();");
|
||||
#endif
|
||||
}
|
||||
@@ -361,8 +438,10 @@ namespace WPCordovaClassLib.Cordova.Commands
|
||||
grid.Children.Remove(browser);
|
||||
}
|
||||
page.ApplicationBar = null;
|
||||
page.BackKeyPress -= page_BackKeyPress;
|
||||
}
|
||||
}
|
||||
|
||||
browser = null;
|
||||
string message = "{\"type\":\"exit\"}";
|
||||
PluginResult result = new PluginResult(PluginResult.Status.OK, message);
|
||||
@@ -405,4 +484,4 @@ namespace WPCordovaClassLib.Cordova.Commands
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -90,6 +90,8 @@ module.exports = function(strUrl, strWindowName, strWindowFeatures) {
|
||||
iab._eventHandler(eventname);
|
||||
};
|
||||
|
||||
strWindowFeatures = strWindowFeatures || "";
|
||||
|
||||
exec(cb, cb, "InAppBrowser", "open", [strUrl, strWindowName, strWindowFeatures]);
|
||||
return iab;
|
||||
};
|
||||
@@ -108,4 +108,4 @@ var IAB = {
|
||||
module.exports = IAB;
|
||||
|
||||
|
||||
require("cordova/windows8/commandProxy").add("InAppBrowser", module.exports);
|
||||
require("cordova/exec/proxy").add("InAppBrowser", module.exports);
|
||||
|
||||
Reference in New Issue
Block a user