mirror of
https://github.com/shuto-cn/cordova-plugin-inappbrowser.git
synced 2026-01-26 00:00:04 +08:00
Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
56bb457c5e | ||
|
|
c6ff803113 | ||
|
|
21f4de0e2a | ||
|
|
68054819d8 | ||
|
|
0db344327c | ||
|
|
ea1253963b | ||
|
|
555d55ac8a | ||
|
|
2d836eea0f | ||
|
|
5cbd28edb0 | ||
|
|
98b63cc37e | ||
|
|
4f3b4df7d1 | ||
|
|
234cca4e5b | ||
|
|
bb69b79ca3 | ||
|
|
80c8e56fb0 | ||
|
|
b51a4dc54e | ||
|
|
be1f6076c2 | ||
|
|
f04f37a617 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -12,6 +12,7 @@ Thumbs.db
|
||||
*.swp
|
||||
*.user
|
||||
|
||||
node_modules
|
||||
|
||||
|
||||
|
||||
|
||||
16
.jshintrc
Normal file
16
.jshintrc
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"browser": true
|
||||
, "devel": true
|
||||
, "bitwise": true
|
||||
, "undef": true
|
||||
, "trailing": true
|
||||
, "quotmark": false
|
||||
, "indent": 4
|
||||
, "unused": "vars"
|
||||
, "latedef": "nofunc"
|
||||
, "globals": {
|
||||
"module": false,
|
||||
"exports": false,
|
||||
"require": false
|
||||
}
|
||||
}
|
||||
4
.travis.yml
Normal file
4
.travis.yml
Normal file
@@ -0,0 +1,4 @@
|
||||
language: node_js
|
||||
sudo: false
|
||||
node_js:
|
||||
- "4.2"
|
||||
@@ -26,7 +26,7 @@ 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
|
||||
For instructions on this, start with the
|
||||
[contribution overview](http://cordova.apache.org/contribute/).
|
||||
|
||||
The details are explained there, but the important items are:
|
||||
@@ -35,3 +35,30 @@ The details are explained there, but the important items are:
|
||||
- Run the tests so your patch doesn't break existing functionality.
|
||||
|
||||
We look forward to your contributions!
|
||||
|
||||
The notes on [Commit Workflow](https://github.com/apache/cordova-coho/blob/master/docs/committer-workflow.md#commit-workflow) can be helpful even if you are not a committer.
|
||||
|
||||
## Running plugin tests
|
||||
|
||||
* clone and install [cordova-plugin-test-framework](https://github.com/apache/cordova-plugin-test-framework)
|
||||
```
|
||||
git clone git@github.com:apache/cordova-plugin-test-framework.git
|
||||
```
|
||||
* edit ```cordova-plugin-test-framework/www/assets/index.html``` and add the following line
|
||||
```
|
||||
<meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com http://cordova.apache.org http://google.co.uk https://google.co.uk 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *">
|
||||
```
|
||||
* create test project
|
||||
```
|
||||
cordova create plugintest
|
||||
cd plugintest
|
||||
cordova platform add android
|
||||
cordova plugin add ../cordova-plugin-inappbrowser
|
||||
cordova plugin add ../cordova-plugin-inappbrowser/tests
|
||||
cordova plugin add ../cordova-plugin-test-framework
|
||||
```
|
||||
* edit ```config.xml``` and replace ```<content src="index.html" />``` with ```<content src="cdvtests/index.html" />```
|
||||
* run application
|
||||
```
|
||||
cordova run
|
||||
```
|
||||
|
||||
21
README.md
21
README.md
@@ -17,6 +17,8 @@
|
||||
# under the License.
|
||||
-->
|
||||
|
||||
[](https://travis-ci.org/apache/cordova-plugin-inappbrowser)
|
||||
|
||||
# cordova-plugin-inappbrowser
|
||||
|
||||
This plugin provides a web browser view that displays when calling `cordova.InAppBrowser.open()`.
|
||||
@@ -54,7 +56,7 @@ Although `window.open` is in the global scope, InAppBrowser is not available unt
|
||||
console.log("window.open works well");
|
||||
}
|
||||
|
||||
:warning: Report issues on the [Apache Cordova issue tracker](https://issues.apache.org/jira/issues/?jql=project%20%3D%20CB%20AND%20status%20in%20%28Open%2C%20%22In%20Progress%22%2C%20Reopened%29%20AND%20resolution%20%3D%20Unresolved%20AND%20component%20%3D%20%22Plugin%20InAppBrowser%22%20ORDER%20BY%20priority%20DESC%2C%20summary%20ASC%2C%20updatedDate%20DESC)
|
||||
Report issues with this plugin on the [Apache Cordova issue tracker](https://issues.apache.org/jira/issues/?jql=project%20%3D%20CB%20AND%20status%20in%20%28Open%2C%20%22In%20Progress%22%2C%20Reopened%29%20AND%20resolution%20%3D%20Unresolved%20AND%20component%20%3D%20%22Plugin%20InAppBrowser%22%20ORDER%20BY%20priority%20DESC%2C%20summary%20ASC%2C%20updatedDate%20DESC)
|
||||
|
||||
|
||||
|
||||
@@ -100,6 +102,7 @@ instance, or the system browser.
|
||||
- __clearsessioncache__: set to `yes` to have the session cookie cache cleared before the new window is opened
|
||||
- __zoom__: set to `yes` to show Android browser's zoom controls, set to `no` to hide them. Default value is `yes`.
|
||||
- __hardwareback__: set to `yes` to use the hardware back button to navigate backwards through the `InAppBrowser`'s history. If there is no previous page, the `InAppBrowser` will close. The default value is `yes`, so you must set it to `no` if you want the back button to simply close the InAppBrowser.
|
||||
- __mediaPlaybackRequiresUserAction__: Set to `yes` to prevent HTML5 audio or video from autoplaying (defaults to `no`).
|
||||
|
||||
iOS only:
|
||||
|
||||
@@ -110,7 +113,7 @@ instance, or the system browser.
|
||||
- __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`).
|
||||
- __mediaPlaybackRequiresUserAction__: Set to `yes` to prevent HTML5 audio or video from autoplaying (defaults to `no`).
|
||||
- __allowInlineMediaPlayback__: Set to `yes` or `no` to allow in-line HTML5 media playback, displaying within the browser window rather than a device-specific playback interface. The HTML's `video` element must also include the `webkit-playsinline` attribute (defaults to `no`)
|
||||
- __keyboardDisplayRequiresUserAction__: Set to `yes` or `no` to open the keyboard when form elements receive focus via JavaScript's `focus()` call (defaults to `yes`).
|
||||
- __suppressesIncrementalRendering__: Set to `yes` or `no` to wait until all new view content is received before being rendered (defaults to `no`).
|
||||
@@ -174,7 +177,7 @@ opened with `target='_blank'`. The rules might look like these
|
||||
|
||||
Windows 8.0, 8.1 and Windows Phone 8.1 don't support remote urls to be opened in the Cordova WebView so remote urls are always showed in the system's web browser if opened with `target='_self'`.
|
||||
|
||||
On Windows 10 if the URL is NOT in the white list and is opened with `target='_self'` it will be showed in the system's web browser instead of InAppBrowser popup.
|
||||
On Windows 10 if the URL is NOT in the white list and is opened with `target='_self'` it will be showed in the system's web browser instead of InAppBrowser popup.
|
||||
|
||||
Similar to Firefox OS IAB window visual behaviour can be overridden via `inAppBrowserWrap`/`inAppBrowserWrapFullscreen` CSS classes
|
||||
|
||||
@@ -197,7 +200,7 @@ The object returned from a call to `cordova.InAppBrowser.open`.
|
||||
- executeScript
|
||||
- insertCSS
|
||||
|
||||
## addEventListener
|
||||
## InAppBrowser.addEventListener
|
||||
|
||||
> Adds a listener for an event from the `InAppBrowser`.
|
||||
|
||||
@@ -243,7 +246,7 @@ The object returned from a call to `cordova.InAppBrowser.open`.
|
||||
var ref = cordova.InAppBrowser.open('http://apache.org', '_blank', 'location=yes');
|
||||
ref.addEventListener('loadstart', function(event) { alert(event.url); });
|
||||
|
||||
## removeEventListener
|
||||
## InAppBrowser.removeEventListener
|
||||
|
||||
> Removes a listener for an event from the `InAppBrowser`.
|
||||
|
||||
@@ -277,7 +280,7 @@ The function is passed an `InAppBrowserEvent` object.
|
||||
ref.addEventListener('loadstart', myCallback);
|
||||
ref.removeEventListener('loadstart', myCallback);
|
||||
|
||||
## close
|
||||
## InAppBrowser.close
|
||||
|
||||
> Closes the `InAppBrowser` window.
|
||||
|
||||
@@ -300,7 +303,7 @@ The function is passed an `InAppBrowserEvent` object.
|
||||
var ref = cordova.InAppBrowser.open('http://apache.org', '_blank', 'location=yes');
|
||||
ref.close();
|
||||
|
||||
## show
|
||||
## InAppBrowser.show
|
||||
|
||||
> Displays an InAppBrowser window that was opened hidden. Calling this has no effect if the InAppBrowser was already visible.
|
||||
|
||||
@@ -322,7 +325,7 @@ The function is passed an `InAppBrowserEvent` object.
|
||||
// some time later...
|
||||
ref.show();
|
||||
|
||||
## executeScript
|
||||
## InAppBrowser.executeScript
|
||||
|
||||
> Injects JavaScript code into the `InAppBrowser` window
|
||||
|
||||
@@ -364,7 +367,7 @@ The function is passed an `InAppBrowserEvent` object.
|
||||
|
||||
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]`.
|
||||
|
||||
## insertCSS
|
||||
## InAppBrowser.insertCSS
|
||||
|
||||
> Injects CSS into the `InAppBrowser` window.
|
||||
|
||||
|
||||
@@ -20,6 +20,22 @@
|
||||
-->
|
||||
# Release Notes
|
||||
|
||||
### 1.4.0 (Apr 15, 2016)
|
||||
* CB-7679 add fix for **iOS** upload.
|
||||
* CB-10944 `NoSuchMethodError` in `InAppBrowser` plugin
|
||||
* CB-10937 fix stretched icons
|
||||
* CB-10760 Fixing README for display on Cordova website
|
||||
* CB-10636 Add `JSHint` for plugins
|
||||
|
||||
### 1.3.0 (Feb 09, 2016)
|
||||
* [CB-3360](https://issues.apache.org/jira/browse/CB-3360) Set custom inappbrowser user agent for android
|
||||
* [CB-10538](https://issues.apache.org/jira/browse/CB-10538) cordova-plugin-inappbrowser timeout issue
|
||||
* [CB-10395](https://issues.apache.org/jira/browse/CB-10395) InAppBrowser's WebView not storing cookies reliable on Android
|
||||
* Edit package.json license to match SPDX id
|
||||
* [CB-10305](https://issues.apache.org/jira/browse/CB-10305) Gray bar appears in the wrong place on iOS
|
||||
* [CB-7786](https://issues.apache.org/jira/browse/CB-7786) Support mediaPlaybackRequiresUserAction on Android
|
||||
* [CB-7500](https://issues.apache.org/jira/browse/CB-7500) executeScript with callback kills/blurs inAppBrowser window on Android
|
||||
|
||||
### 1.2.1 (Feb 02, 2016)
|
||||
* [CB-10407](https://issues.apache.org/jira/browse/CB-10407) InAppBrowser not firing loadstart event on android
|
||||
* [CB-10428](https://issues.apache.org/jira/browse/CB-10428) Fix syntax error when browserifying inAppBrowser plugin
|
||||
|
||||
11
package.json
11
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "cordova-plugin-inappbrowser",
|
||||
"version": "1.2.1",
|
||||
"version": "1.4.0",
|
||||
"description": "Cordova InAppBrowser Plugin",
|
||||
"cordova": {
|
||||
"id": "cordova-plugin-inappbrowser",
|
||||
@@ -37,6 +37,10 @@
|
||||
"cordova-windows",
|
||||
"cordova-firefoxos"
|
||||
],
|
||||
"scripts": {
|
||||
"test": "npm run jshint",
|
||||
"jshint": "node node_modules/jshint/bin/jshint www && node node_modules/jshint/bin/jshint src && node node_modules/jshint/bin/jshint tests"
|
||||
},
|
||||
"engines": [
|
||||
{
|
||||
"name": "cordova",
|
||||
@@ -44,5 +48,8 @@
|
||||
}
|
||||
],
|
||||
"author": "Apache Software Foundation",
|
||||
"license": "Apache 2.0"
|
||||
"license": "Apache-2.0",
|
||||
"devDependencies": {
|
||||
"jshint": "^2.6.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
||||
id="cordova-plugin-inappbrowser"
|
||||
version="1.2.1">
|
||||
version="1.4.0">
|
||||
|
||||
<name>InAppBrowser</name>
|
||||
<description>Cordova InAppBrowser Plugin</description>
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
package org.apache.cordova.inappbrowser;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import org.apache.cordova.inappbrowser.InAppBrowserDialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.provider.Browser;
|
||||
@@ -41,12 +40,14 @@ import android.view.WindowManager.LayoutParams;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.webkit.CookieManager;
|
||||
import android.webkit.CookieSyncManager;
|
||||
import android.webkit.HttpAuthHandler;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
@@ -85,6 +86,7 @@ public class InAppBrowser extends CordovaPlugin {
|
||||
private static final String CLEAR_ALL_CACHE = "clearcache";
|
||||
private static final String CLEAR_SESSION_CACHE = "clearsessioncache";
|
||||
private static final String HARDWARE_BACK_BUTTON = "hardwareback";
|
||||
private static final String MEDIA_PLAYBACK_REQUIRES_USER_ACTION = "mediaPlaybackRequiresUserAction";
|
||||
|
||||
private InAppBrowserDialog dialog;
|
||||
private WebView inAppWebView;
|
||||
@@ -96,6 +98,7 @@ public class InAppBrowser extends CordovaPlugin {
|
||||
private boolean clearAllCache = false;
|
||||
private boolean clearSessionCache = false;
|
||||
private boolean hadwareBackButton = true;
|
||||
private boolean mediaPlaybackRequiresUserGesture = false;
|
||||
|
||||
/**
|
||||
* Executes the request and returns PluginResult.
|
||||
@@ -200,7 +203,7 @@ public class InAppBrowser extends CordovaPlugin {
|
||||
else if (action.equals("injectScriptCode")) {
|
||||
String jsWrapper = null;
|
||||
if (args.getBoolean(1)) {
|
||||
jsWrapper = String.format("prompt(JSON.stringify([eval(%%s)]), 'gap-iab://%s')", callbackContext.getCallbackId());
|
||||
jsWrapper = String.format("(function(){prompt(JSON.stringify([eval(%%s)]), 'gap-iab://%s')})()", callbackContext.getCallbackId());
|
||||
}
|
||||
injectDeferredObject(args.getString(0), jsWrapper);
|
||||
}
|
||||
@@ -473,6 +476,8 @@ public class InAppBrowser extends CordovaPlugin {
|
||||
showLocationBar = true;
|
||||
showZoomControls = true;
|
||||
openWindowHidden = false;
|
||||
mediaPlaybackRequiresUserGesture = false;
|
||||
|
||||
if (features != null) {
|
||||
Boolean show = features.get(LOCATION);
|
||||
if (show != null) {
|
||||
@@ -490,6 +495,10 @@ public class InAppBrowser extends CordovaPlugin {
|
||||
if (hardwareBack != null) {
|
||||
hadwareBackButton = hardwareBack.booleanValue();
|
||||
}
|
||||
Boolean mediaPlayback = features.get(MEDIA_PLAYBACK_REQUIRES_USER_ACTION);
|
||||
if (mediaPlayback != null) {
|
||||
mediaPlaybackRequiresUserGesture = mediaPlayback.booleanValue();
|
||||
}
|
||||
Boolean cache = features.get(CLEAR_ALL_CACHE);
|
||||
if (cache != null) {
|
||||
clearAllCache = cache.booleanValue();
|
||||
@@ -555,7 +564,7 @@ public class InAppBrowser extends CordovaPlugin {
|
||||
actionButtonContainer.setId(Integer.valueOf(1));
|
||||
|
||||
// Back button
|
||||
Button back = new Button(cordova.getActivity());
|
||||
ImageButton back = new ImageButton(cordova.getActivity());
|
||||
RelativeLayout.LayoutParams backLayoutParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
|
||||
backLayoutParams.addRule(RelativeLayout.ALIGN_LEFT);
|
||||
back.setLayoutParams(backLayoutParams);
|
||||
@@ -564,14 +573,12 @@ public class InAppBrowser extends CordovaPlugin {
|
||||
Resources activityRes = cordova.getActivity().getResources();
|
||||
int backResId = activityRes.getIdentifier("ic_action_previous_item", "drawable", cordova.getActivity().getPackageName());
|
||||
Drawable backIcon = activityRes.getDrawable(backResId);
|
||||
if(android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN)
|
||||
{
|
||||
back.setBackgroundDrawable(backIcon);
|
||||
}
|
||||
else
|
||||
{
|
||||
back.setBackground(backIcon);
|
||||
}
|
||||
back.setBackground(null);
|
||||
back.setImageDrawable(backIcon);
|
||||
back.setScaleType(ImageView.ScaleType.FIT_CENTER);
|
||||
back.setPadding(0, this.dpToPixels(10), 0, this.dpToPixels(10));
|
||||
back.getAdjustViewBounds();
|
||||
|
||||
back.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
goBack();
|
||||
@@ -579,7 +586,7 @@ public class InAppBrowser extends CordovaPlugin {
|
||||
});
|
||||
|
||||
// Forward button
|
||||
Button forward = new Button(cordova.getActivity());
|
||||
ImageButton forward = new ImageButton(cordova.getActivity());
|
||||
RelativeLayout.LayoutParams forwardLayoutParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
|
||||
forwardLayoutParams.addRule(RelativeLayout.RIGHT_OF, 2);
|
||||
forward.setLayoutParams(forwardLayoutParams);
|
||||
@@ -587,14 +594,12 @@ public class InAppBrowser extends CordovaPlugin {
|
||||
forward.setId(Integer.valueOf(3));
|
||||
int fwdResId = activityRes.getIdentifier("ic_action_next_item", "drawable", cordova.getActivity().getPackageName());
|
||||
Drawable fwdIcon = activityRes.getDrawable(fwdResId);
|
||||
if(android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN)
|
||||
{
|
||||
forward.setBackgroundDrawable(fwdIcon);
|
||||
}
|
||||
else
|
||||
{
|
||||
forward.setBackground(fwdIcon);
|
||||
}
|
||||
forward.setBackground(null);
|
||||
forward.setImageDrawable(fwdIcon);
|
||||
forward.setScaleType(ImageView.ScaleType.FIT_CENTER);
|
||||
forward.setPadding(0, this.dpToPixels(10), 0, this.dpToPixels(10));
|
||||
forward.getAdjustViewBounds();
|
||||
|
||||
forward.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
goForward();
|
||||
@@ -625,7 +630,7 @@ public class InAppBrowser extends CordovaPlugin {
|
||||
});
|
||||
|
||||
// Close/Done button
|
||||
Button close = new Button(cordova.getActivity());
|
||||
ImageButton close = new ImageButton(cordova.getActivity());
|
||||
RelativeLayout.LayoutParams closeLayoutParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
|
||||
closeLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
|
||||
close.setLayoutParams(closeLayoutParams);
|
||||
@@ -633,14 +638,12 @@ public class InAppBrowser extends CordovaPlugin {
|
||||
close.setId(Integer.valueOf(5));
|
||||
int closeResId = activityRes.getIdentifier("ic_action_remove", "drawable", cordova.getActivity().getPackageName());
|
||||
Drawable closeIcon = activityRes.getDrawable(closeResId);
|
||||
if(android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN)
|
||||
{
|
||||
close.setBackgroundDrawable(closeIcon);
|
||||
}
|
||||
else
|
||||
{
|
||||
close.setBackground(closeIcon);
|
||||
}
|
||||
close.setBackground(null);
|
||||
close.setImageDrawable(closeIcon);
|
||||
close.setScaleType(ImageView.ScaleType.FIT_CENTER);
|
||||
back.setPadding(0, this.dpToPixels(10), 0, this.dpToPixels(10));
|
||||
close.getAdjustViewBounds();
|
||||
|
||||
close.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
closeDialog();
|
||||
@@ -660,6 +663,20 @@ public class InAppBrowser extends CordovaPlugin {
|
||||
settings.setBuiltInZoomControls(showZoomControls);
|
||||
settings.setPluginState(android.webkit.WebSettings.PluginState.ON);
|
||||
|
||||
if(android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
||||
settings.setMediaPlaybackRequiresUserGesture(mediaPlaybackRequiresUserGesture);
|
||||
}
|
||||
|
||||
String overrideUserAgent = preferences.getString("OverrideUserAgent", null);
|
||||
String appendUserAgent = preferences.getString("AppendUserAgent", null);
|
||||
|
||||
if (overrideUserAgent != null) {
|
||||
settings.setUserAgentString(overrideUserAgent);
|
||||
}
|
||||
if (appendUserAgent != null) {
|
||||
settings.setUserAgentString(settings.getUserAgentString() + appendUserAgent);
|
||||
}
|
||||
|
||||
//Toggle whether this is enabled or not!
|
||||
Bundle appSettings = cordova.getActivity().getIntent().getExtras();
|
||||
boolean enableDatabase = appSettings == null ? true : appSettings.getBoolean("InAppBrowserStorageEnabled", true);
|
||||
@@ -870,6 +887,13 @@ public class InAppBrowser extends CordovaPlugin {
|
||||
public void onPageFinished(WebView view, String url) {
|
||||
super.onPageFinished(view, url);
|
||||
|
||||
// CB-10395 InAppBrowser's WebView not storing cookies reliable to local device storage
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
|
||||
CookieManager.getInstance().flush();
|
||||
} else {
|
||||
CookieSyncManager.getInstance().sync();
|
||||
}
|
||||
|
||||
try {
|
||||
JSONObject obj = new JSONObject();
|
||||
obj.put("type", LOAD_STOP_EVENT);
|
||||
@@ -896,7 +920,7 @@ public class InAppBrowser extends CordovaPlugin {
|
||||
Log.d(LOG_TAG, "Should never happen");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* On received http auth request.
|
||||
*/
|
||||
@@ -912,7 +936,7 @@ public class InAppBrowser extends CordovaPlugin {
|
||||
} catch (IllegalAccessException e) {
|
||||
} catch (InvocationTargetException e) {
|
||||
}
|
||||
|
||||
|
||||
if (pluginManager == null) {
|
||||
try {
|
||||
Field pmf = webView.getClass().getField("pluginManager");
|
||||
@@ -921,14 +945,13 @@ public class InAppBrowser extends CordovaPlugin {
|
||||
} catch (IllegalAccessException e) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (pluginManager != null && pluginManager.onReceivedHttpAuthRequest(webView, new CordovaHttpAuthHandler(handler), host, realm)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// By default handle 401 like we'd normally do!
|
||||
super.onReceivedHttpAuthRequest(view, handler, host, realm);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,10 +19,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
var cordova = require('cordova'),
|
||||
channel = require('cordova/channel'),
|
||||
modulemapper = require('cordova/modulemapper'),
|
||||
urlutil = require('cordova/urlutil');
|
||||
var modulemapper = require('cordova/modulemapper');
|
||||
|
||||
var browserWrap,
|
||||
popup,
|
||||
@@ -69,8 +66,7 @@ var IAB = {
|
||||
open: function (win, lose, args) {
|
||||
var strUrl = args[0],
|
||||
target = args[1],
|
||||
features = args[2],
|
||||
url;
|
||||
features = args[2];
|
||||
|
||||
if (target === "_self" || !target) {
|
||||
window.location = strUrl;
|
||||
@@ -193,7 +189,9 @@ var IAB = {
|
||||
if (browserWrap && popup) {
|
||||
try {
|
||||
popup.contentWindow.eval(code);
|
||||
hasCallback && win([]);
|
||||
if (hasCallback) {
|
||||
win([]);
|
||||
}
|
||||
} catch(e) {
|
||||
console.error('Error occured while trying to injectScriptCode: ' + JSON.stringify(e));
|
||||
}
|
||||
@@ -203,19 +201,25 @@ var IAB = {
|
||||
injectScriptFile: function (win, fail, args) {
|
||||
var msg = 'Browser cordova-plugin-inappbrowser injectScriptFile is not yet implemented';
|
||||
console.warn(msg);
|
||||
fail && fail(msg);
|
||||
if (fail) {
|
||||
fail(msg);
|
||||
}
|
||||
},
|
||||
|
||||
injectStyleCode: function (win, fail, args) {
|
||||
var msg = 'Browser cordova-plugin-inappbrowser injectStyleCode is not yet implemented';
|
||||
console.warn(msg);
|
||||
fail && fail(msg);
|
||||
if (fail) {
|
||||
fail(msg);
|
||||
}
|
||||
},
|
||||
|
||||
injectStyleFile: function (win, fail, args) {
|
||||
var msg = 'Browser cordova-plugin-inappbrowser injectStyleFile is not yet implemented';
|
||||
console.warn(msg);
|
||||
fail && fail(msg);
|
||||
if (fail) {
|
||||
fail(msg);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -21,9 +21,7 @@
|
||||
|
||||
// https://developer.mozilla.org/en-US/docs/WebAPI/Browser
|
||||
|
||||
var cordova = require('cordova'),
|
||||
channel = require('cordova/channel'),
|
||||
modulemapper = require('cordova/modulemapper');
|
||||
var modulemapper = require('cordova/modulemapper');
|
||||
|
||||
var origOpenFunc = modulemapper.getOriginalSymbol(window, 'window.open');
|
||||
var browserWrap;
|
||||
@@ -49,9 +47,7 @@ var IABExecs = {
|
||||
var strUrl = args[0],
|
||||
target = args[1],
|
||||
features_string = args[2] || "location=yes", //location=yes is default
|
||||
features = {},
|
||||
url,
|
||||
elem;
|
||||
features = {};
|
||||
|
||||
var features_list = features_string.split(',');
|
||||
features_list.forEach(function(feature) {
|
||||
@@ -61,7 +57,7 @@ var IABExecs = {
|
||||
} else if (tup[1] == 'no') {
|
||||
tup[1] = false;
|
||||
} else {
|
||||
var number = parseInt(tup[1]);
|
||||
var number = parseInt(tup[1]);
|
||||
if (!isNaN(number)) {
|
||||
tup[1] = number;
|
||||
}
|
||||
@@ -115,7 +111,7 @@ var IABExecs = {
|
||||
back.classList.add('inAppBrowserBack');
|
||||
forward.classList.add('inAppBrowserForward');
|
||||
|
||||
function checkForwardBackward() {
|
||||
var checkForwardBackward = function () {
|
||||
var backReq = browserElem.getCanGoBack();
|
||||
backReq.onsuccess = function() {
|
||||
if (this.result) {
|
||||
@@ -123,7 +119,7 @@ var IABExecs = {
|
||||
} else {
|
||||
back.classList.add('disabled');
|
||||
}
|
||||
}
|
||||
};
|
||||
var forwardReq = browserElem.getCanGoForward();
|
||||
forwardReq.onsuccess = function() {
|
||||
if (this.result) {
|
||||
@@ -131,7 +127,7 @@ var IABExecs = {
|
||||
} else {
|
||||
forward.classList.add('disabled');
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
browserElem.addEventListener('mozbrowserloadend', checkForwardBackward);
|
||||
@@ -163,16 +159,16 @@ var IABExecs = {
|
||||
win({
|
||||
type:'loadstart',
|
||||
url : e.detail
|
||||
})
|
||||
});
|
||||
}, false);
|
||||
browserElem.addEventListener('mozbrowserloadend', function(e){
|
||||
win({type:'loadstop'})
|
||||
win({type:'loadstop'});
|
||||
}, false);
|
||||
browserElem.addEventListener('mozbrowsererror', function(e){
|
||||
win({type:'loaderror'})
|
||||
win({type:'loaderror'});
|
||||
}, false);
|
||||
browserElem.addEventListener('mozbrowserclose', function(e){
|
||||
win({type:'exit'})
|
||||
win({type:'exit'});
|
||||
}, false);
|
||||
} else {
|
||||
window.location = strUrl;
|
||||
|
||||
@@ -755,6 +755,10 @@
|
||||
return UIStatusBarStyleDefault;
|
||||
}
|
||||
|
||||
- (BOOL)prefersStatusBarHidden {
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (void)close
|
||||
{
|
||||
[CDVUserAgentUtil releaseLock:&_userAgentLockToken];
|
||||
@@ -994,19 +998,38 @@
|
||||
|
||||
@implementation CDVInAppBrowserNavigationController : UINavigationController
|
||||
|
||||
- (void) dismissViewControllerAnimated:(BOOL)flag completion:(void (^)(void))completion {
|
||||
if ( self.presentedViewController) {
|
||||
[super dismissViewControllerAnimated:flag completion:completion];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) viewDidLoad {
|
||||
|
||||
CGRect frame = [UIApplication sharedApplication].statusBarFrame;
|
||||
|
||||
// simplified from: http://stackoverflow.com/a/25669695/219684
|
||||
|
||||
UIToolbar* bgToolbar = [[UIToolbar alloc] initWithFrame:frame];
|
||||
UIToolbar* bgToolbar = [[UIToolbar alloc] initWithFrame:[self invertFrameIfNeeded:frame]];
|
||||
bgToolbar.barStyle = UIBarStyleDefault;
|
||||
[bgToolbar setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
|
||||
[self.view addSubview:bgToolbar];
|
||||
|
||||
[super viewDidLoad];
|
||||
}
|
||||
|
||||
- (CGRect) invertFrameIfNeeded:(CGRect)rect {
|
||||
// We need to invert since on iOS 7 frames are always in Portrait context
|
||||
if (!IsAtLeastiOSVersion(@"8.0")) {
|
||||
if (UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation])) {
|
||||
CGFloat temp = rect.size.width;
|
||||
rect.size.width = rect.size.height;
|
||||
rect.size.height = temp;
|
||||
}
|
||||
rect.origin = CGPointZero;
|
||||
}
|
||||
return rect;
|
||||
}
|
||||
|
||||
#pragma mark CDVScreenOrientationDelegate
|
||||
|
||||
|
||||
@@ -19,6 +19,9 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/* jshint -W061 */
|
||||
/* global oxide */
|
||||
|
||||
oxide.addMessageHandler("EXECUTE", function(msg) {
|
||||
var code = msg.args.code;
|
||||
try {
|
||||
|
||||
@@ -19,10 +19,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/*jslint sloppy:true */
|
||||
/*global Windows:true, require, document, setTimeout, window, module */
|
||||
|
||||
|
||||
/* jslint sloppy:true */
|
||||
/* global Windows:true, setImmediate */
|
||||
|
||||
var cordova = require('cordova'),
|
||||
urlutil = require('cordova/urlutil');
|
||||
@@ -188,7 +186,7 @@ var IAB = {
|
||||
};
|
||||
|
||||
navigationButtonsDivInner = document.createElement("div");
|
||||
navigationButtonsDivInner.className = "inappbrowser-app-bar-inner"
|
||||
navigationButtonsDivInner.className = "inappbrowser-app-bar-inner";
|
||||
navigationButtonsDivInner.onclick = function (e) {
|
||||
e.cancelBubble = true;
|
||||
};
|
||||
@@ -253,9 +251,11 @@ var IAB = {
|
||||
if (isWebViewAvailable && browserWrap && popup) {
|
||||
var op = popup.invokeScriptAsync("eval", code);
|
||||
op.oncomplete = function (e) {
|
||||
// return null if event target is unavailable by some reason
|
||||
var result = (e && e.target) ? [e.target.result] : [null];
|
||||
hasCallback && win(result);
|
||||
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();
|
||||
@@ -278,8 +278,10 @@ var IAB = {
|
||||
Windows.Storage.FileIO.readTextAsync(file).done(function (code) {
|
||||
var op = popup.invokeScriptAsync("eval", code);
|
||||
op.oncomplete = function(e) {
|
||||
var result = [e.target.result];
|
||||
hasCallback && win(result);
|
||||
if (hasCallback) {
|
||||
var result = [e.target.result];
|
||||
win(result);
|
||||
}
|
||||
};
|
||||
op.onerror = function () { };
|
||||
op.start();
|
||||
@@ -329,7 +331,9 @@ function injectCSS (webView, cssCode, callback) {
|
||||
|
||||
var op = webView.invokeScriptAsync("eval", evalWrapper);
|
||||
op.oncomplete = function() {
|
||||
callback && callback([]);
|
||||
if (callback) {
|
||||
callback([]);
|
||||
}
|
||||
};
|
||||
op.onerror = function () { };
|
||||
op.start();
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
||||
id="cordova-plugin-inappbrowser-tests"
|
||||
version="1.2.1">
|
||||
version="1.4.0">
|
||||
<name>Cordova InAppBrowser Plugin Tests</name>
|
||||
<license>Apache 2.0</license>
|
||||
|
||||
|
||||
@@ -16,5 +16,5 @@
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
var d = document.getElementById("header")
|
||||
var d = document.getElementById("header");
|
||||
d.innerHTML = "Script file successfully injected";
|
||||
|
||||
@@ -38,5 +38,8 @@
|
||||
<button onclick="document.getElementById('player').play()"> play </button>
|
||||
<button onclick="document.getElementById('player').pause()"> pause </button>
|
||||
</div>
|
||||
<script>
|
||||
document.getElementById('player').play();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -19,6 +19,9 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/* jshint jasmine: true */
|
||||
/* global MSApp */
|
||||
|
||||
var cordova = require('cordova');
|
||||
var isWindows = cordova.platformId == 'windows';
|
||||
|
||||
@@ -42,13 +45,13 @@ exports.defineAutoTests = function () {
|
||||
|
||||
var iabInstance;
|
||||
var originalTimeout;
|
||||
var url = 'http://apache.org/';
|
||||
var url = 'https://dist.apache.org/repos/dist/dev/cordova/';
|
||||
var badUrl = 'http://bad-uri/';
|
||||
|
||||
beforeEach(function () {
|
||||
// increase timeout to ensure test url could be loaded within test time
|
||||
originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 15000;
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 30000;
|
||||
|
||||
iabInstance = null;
|
||||
});
|
||||
@@ -183,13 +186,13 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
||||
if (e.url != lastLoadStartURL) {
|
||||
alert('Unexpected: ' + e.type + ' event.url != loadstart\'s event.url');
|
||||
}
|
||||
if (numExpectedRedirects === 0 && counts['loadstart'] !== 1) {
|
||||
if (numExpectedRedirects === 0 && counts.loadstart !== 1) {
|
||||
// Do allow a loaderror without a loadstart (e.g. in the case of an invalid URL).
|
||||
if (!(e.type == 'loaderror' && counts['loadstart'] === 0)) {
|
||||
alert('Unexpected: got multiple loadstart events. (' + counts['loadstart'] + ')');
|
||||
if (!(e.type == 'loaderror' && counts.loadstart === 0)) {
|
||||
alert('Unexpected: got multiple loadstart events. (' + counts.loadstart + ')');
|
||||
}
|
||||
} else if (numExpectedRedirects > 0 && counts['loadstart'] < (numExpectedRedirects + 1)) {
|
||||
alert('Unexpected: should have got at least ' + (numExpectedRedirects + 1) + ' loadstart events, but got ' + counts['loadstart']);
|
||||
} else if (numExpectedRedirects > 0 && counts.loadstart < (numExpectedRedirects + 1)) {
|
||||
alert('Unexpected: should have got at least ' + (numExpectedRedirects + 1) + ' loadstart events, but got ' + counts.loadstart);
|
||||
}
|
||||
wasReset = true;
|
||||
numExpectedRedirects = 0;
|
||||
@@ -197,7 +200,7 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
||||
}
|
||||
// Verify that loadend / loaderror was called.
|
||||
if (e.type == 'exit') {
|
||||
var numStopEvents = counts['loadstop'] + counts['loaderror'];
|
||||
var numStopEvents = counts.loadstop + counts.loaderror;
|
||||
if (numStopEvents === 0 && !wasReset) {
|
||||
alert('Unexpected: browser closed without a loadstop or loaderror.');
|
||||
} else if (numStopEvents > 1) {
|
||||
@@ -423,7 +426,11 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
||||
|
||||
var video_tag_tests = '<h1>Video tag</h1>' +
|
||||
'<div id="openRemoteVideo"></div>' +
|
||||
'Expected result: open successfully in InAppBrowser with an embedded video that works after clicking the "play" button.';
|
||||
'Expected result: open successfully in InAppBrowser with an embedded video plays automatically on iOS and Android.' +
|
||||
'<div id="openRemoteNeedUserNoVideo"></div>' +
|
||||
'Expected result: open successfully in InAppBrowser with an embedded video plays automatically on iOS and Android.' +
|
||||
'<div id="openRemoteNeedUserYesVideo"></div>' +
|
||||
'Expected result: open successfully in InAppBrowser with an embedded video does not play automatically on iOS and Android but rather works after clicking the "play" button.';
|
||||
|
||||
var local_with_anchor_tag_tests = '<h1>Local with anchor tag</h1>' +
|
||||
'<div id="openAnchor1"></div>' +
|
||||
@@ -611,6 +618,12 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
||||
createActionButton('Remote Video', function () {
|
||||
doOpen(videohtml, '_blank');
|
||||
}, 'openRemoteVideo');
|
||||
createActionButton('Remote Need User No Video', function () {
|
||||
doOpen(videohtml, '_blank', 'mediaPlaybackRequiresUserAction=no');
|
||||
}, 'openRemoteNeedUserNoVideo');
|
||||
createActionButton('Remote Need User Yes Video', function () {
|
||||
doOpen(videohtml, '_blank', 'mediaPlaybackRequiresUserAction=yes');
|
||||
}, 'openRemoteNeedUserYesVideo');
|
||||
|
||||
//Local With Anchor Tag
|
||||
createActionButton('Anchor1', function () {
|
||||
@@ -620,4 +633,3 @@ exports.defineManualTests = function (contentEl, createActionButton) {
|
||||
doOpen(localhtml + '#anchor2', '_blank');
|
||||
}, 'openAnchor2');
|
||||
};
|
||||
|
||||
|
||||
@@ -22,10 +22,6 @@
|
||||
/*jslint sloppy:true */
|
||||
/*global Windows:true, require, document, setTimeout, window, module */
|
||||
|
||||
|
||||
var cordova = require('cordova'),
|
||||
channel = require('cordova/channel');
|
||||
|
||||
var browserWrap;
|
||||
|
||||
var IAB = {
|
||||
@@ -45,7 +41,6 @@ var IAB = {
|
||||
open: function (win, lose, args) {
|
||||
var strUrl = args[0],
|
||||
target = args[1],
|
||||
features = args[2],
|
||||
url,
|
||||
elem;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user