Commit Graph

266 Commits

Author SHA1 Message Date
Niklas Merz
d4338bd64a (android) improve defensive code for NULL check 2020-01-02 19:53:36 +01:00
Alex Yaz
0411a287b8
(android) defensive code to prevent NULL reference exceptions for async
Signed-off-by: Niklas Merz <niklasmerz@apache.org>
2020-01-02 19:50:26 +01:00
Lorenzo B
416b05c1e5 Replace "beforeload" with BEFORELOAD (#524)
Improve code formatting
2019-12-30 10:47:37 +01:00
Dave Alden
80feff6cf8
Merge pull request #401 from GEDYSIntraWare/bridge
Move bridge creation to injectDeferredObject
2019-09-24 16:21:19 +01:00
Niklas Merz
855394628e Fix unresponsive main window after hide 2019-09-24 16:28:07 +02:00
Niklas Merz
79b1bb61a0 Move window hiding to 'browserExit'
Fixes close, hide and toolbar 'done' and makes cordova window responsive
2019-09-23 10:29:31 +02:00
Niklas Merz
4376ddabcd New fix attempt 2019-09-20 15:48:27 +02:00
Niklas Merz
82d496ae5c Use tmpWindow and hide on close 2019-09-20 13:43:57 +02:00
Niklas Merz
81bec09526 (ios) Fix iOS 13 show not working
Removed tmpWindow and controller.
This was introduced to fix IAB with WKWebView before WKIAB existed.
2019-09-06 14:14:51 +02:00
Niklas Merz
8805f5d46a Finish revert and correct Xcode warnings 2019-09-06 13:53:36 +02:00
Niklas Merz
8810c6a8a0 (ios) Fix inappbrowser not opening on iOS 13 by using reusable window
Closes #492
2019-09-06 13:49:44 +02:00
Ralph Gutkowski
94fec84d5c Fix beforeload for Android <= 7 (#427)
* Fix beforeload for Android <= 7
* Change Android version check conditional
2019-06-13 00:33:23 +05:30
Jesse MacFadyen
d01bd25a88
Merge pull request #262 from landsbankinn/CB-13969
Cb 13969 - Allow close button and navigation buttons positions to be swapped
2019-03-05 23:31:12 -08:00
Jesse MacFadyen
2f74d677b7
Revert "Add support for right to left direction languages" 2019-03-05 17:56:34 -08:00
Jesse MacFadyen
7b16ee88a4
Merge pull request #353 from transoceanic/patch-1
Add support for right to left direction languages
2019-03-05 17:34:19 -08:00
Jesse MacFadyen
686108484e Prevent malformed callbackId from reaching app cordova view 2019-02-28 14:52:01 -08:00
Steinar Ágúst
9c7c2f31d8 CB-13969 functionality extended to WKWebView 2019-02-28 14:39:26 +00:00
Steinar Ágúst
74ccef1226 Merge remote-tracking branch 'upstream/master' 2019-02-28 11:43:34 +00:00
Dave Alden
388e3f6ae7 (iOS) Fix iframes in iOS/WKWebView which were broken by #418. Fixes #424. (#425) 2019-02-12 00:14:18 +01:00
Dave Alden
9f4b72982a GH-417: Handle non-default target attribute values (e.g. target=on links in WKWebView implementation on iOS (#418) 2019-02-10 18:06:35 +01:00
Niklas Merz
e3db974080 (ios) Move createIframeBridge to injectDeferredObject
Avoid failed script injections for pages which did not finish loading.
2019-01-16 14:22:51 +01:00
Dave Alden
632a395b3d GH-359: Fix beforeload to work with POST requests (#367)
### Platforms affected
iOS and Android


### What does this PR do?
Fixes the behaviour of `beforeload` to resolve the problem with POST requests outlined in #359.

The `beforeload` parameter has been changed from taking only a boolean (`yes` or not defined) to a discrete string with possible values of `get`, `post`, or `yes` which correspond to request types of GET, POST or GET&POST respectively. The `README.md` has been updated to reflect this.

Note that use of `beforeload` to intercept POST requests is currently not supported on Android or iOS, so if `beforeload=yes` is specified and a POST request is detected as the HTTP request method, `beforeload` behaviour will not be applied. If `beforeload=post` is specified, a `loaderror` event will be dispatched which states that POST requests are not yet supported.

#### Notes for Android

The `shouldOverrideUrlLoading()` override method has been updated to support the [new method interface added in API 24 / Android 7][1] which receives the `WebResourceRequest` instead of just the `String url`, enabling the HTTP method of the request to be determined. The [deprecated method interface][2] has also been preserved for API <=23, but in this case the HTTP method cannot be determined so is passed as null.

Also note that due to a [Chromium bug](https://bugs.chromium.org/p/chromium/issues/detail?id=155250),  `shouldOverrideUrlLoading()` is currently not called for POST requests. It's possible this may be resolved in a future Chromium version in the Android System Webview (given that this is now self-updating and independent of Android version since Android 5.0) - in prospective anticipation of this, code to handle POST requests has been added to `shouldOverrideUrlLoading()`.

However, it seems more likely that this won't be resolved any time soon given that [a Chromium dev said](https://bugs.chromium.org/p/chromium/issues/detail?id=155250#c39):

 > We're looking at implementing a better way to handle request interception in a future OS version. There's no way to just "fix" this, the API doesn't accommodate this usage at all. This will not be something you can use any time soon.

Therefore if we want to go ahead and use `beforeload` to intercept request types other than GET, it's likely we'll instead need to use the `shouldInterceptRequest()` method override. As with `shouldOverrideUrlLoading()`, there are a two variants: the [new method interface][3] added in API 21 / Android 5.0 which  which receives the `WebResourceRequest` object and the [deprecated one][4] which receives only `String url`. If we want to determine the HTTP request method, we'll need to use the new implementation. This has been empirically tested and *is* called for POST requests so would allow the possibility to intercept, delay, modify and send the POST request and its data via `beforeload`.
Both `shouldInterceptRequest()` method interfaces have been exposed in the Android implentation for potential future use but they currently do nothing other than return the unadulterated request object.

### What testing has been done on this change?
Manual testing of POST and GET requests on both platforms using a test app container:
https://github.com/dpa99c/cordova-plugin-inappbrowser-test

[1]: https://developer.android.com/reference/android/webkit/WebViewClient.html#shouldOverrideUrlLoading(android.webkit.WebView,%20android.webkit.WebResourceRequest)
[2]: https://developer.android.com/reference/android/webkit/WebViewClient.html#shouldOverrideUrlLoading(android.webkit.WebView,%20java.lang.String)
[3]: https://developer.android.com/reference/android/webkit/WebViewClient.html#shouldInterceptRequest(android.webkit.WebView,%20android.webkit.WebResourceRequest)
[4]: https://developer.android.com/reference/android/webkit/WebViewClient.html#shouldInterceptRequest(android.webkit.WebView,%20java.lang.String)
2018-12-20 20:31:14 +01:00
Dave Alden
c54d10052a (iOS & Android) Add postMessage API support (#362)
<!--
Please make sure the checklist boxes are all checked before submitting the PR. The checklist
is intended as a quick reference, for complete details please see our Contributor Guidelines:

http://cordova.apache.org/contribute/contribute_guidelines.html

Thanks!
-->

### Platforms affected
Android
iOS (both UIWebView & WKWebView implementations)

### What does this PR do?
Adds support for [postMessage API](https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage) enabling pages loaded into the InappBrowser to post messages back to the parent Webview of the Cordova app.

For example, sending event messages associated with UI interactions such as button clicks from the wrapped page back to the parent app Webview.

### What testing has been done on this change?
Automated tests have been extended to cover the `message` event.

### Checklist
- [x ] Commit message follows the format: "GH-3232: (android) Fix bug with resolving file paths", where CB-xxxx is the JIRA ID & "android" is the platform affected.
- [ x] Added automated test coverage as appropriate for this change.
2018-12-13 17:21:45 +01:00
transoceanic
ba3a440491
Added to support android devices with right to left direction languages (issue #352) 2018-11-22 15:45:34 +02:00
Dave Alden
0fd43ae644 Fixes loadAfterBeforeload on iOS. Resolves #349. (#350)
For both UIWebView and WKWebView implementations on iOS.

<!--
Please make sure the checklist boxes are all checked before submitting the PR. The checklist
is intended as a quick reference, for complete details please see our Contributor Guidelines:

http://cordova.apache.org/contribute/contribute_guidelines.html

Thanks!
-->

### Platforms affected
iOS

### What does this PR do?
Fixes `beforeload` event (introduced by #276) for iOS

### What testing has been done on this change?
Tested both allow & deny loading of URL with both iOS implementations in [test container app](https://github.com/dpa99c/cordova-plugin-inappbrowser-wkwebview-test) (ignore its README).

- To test with UIWebView use options: `beforeload=yes,usewkwebview=no`
- To test with WKWebView use options: `beforeload=yes,usewkwebview=yes`

### Checklist
- [x] [Reported an issue](http://cordova.apache.org/contribute/issues.html) in the JIRA database
- [x] Commit message follows the format: "CB-3232: (android) Fix bug with resolving file paths", where CB-xxxx is the JIRA ID & "android" is the platform affected.
- [x] Added automated test coverage as appropriate for this change.

closes #349
2018-11-21 19:04:04 +01:00
Dave Alden
3b82c160d9 Fix crashes when using WKWebView implementation on iOS 9. (#337)
Fixes #323. Fixes #324.
2018-11-20 17:12:29 +01:00
Jonathan Li
978b147598 Fix iOS CDVWKInAppBrowser evaluateJavascript method randomly gets blocked on ios 12 (#341)
### Platforms affected
iOS

### What does this PR do?
fix issue[ #340](https://github.com/apache/cordova-plugin-inappbrowser/issues/340) iOS CDVWKInAppBrowser evaluateJavascript method randomly gets blocked on iOS 12

### What testing has been done on this change?
manual testing

### Checklist
- [x] [Reported an issue](http://cordova.apache.org/contribute/issues.html) in the JIRA database
- [x] Commit message follows the format: "CB-3232: (android) Fix bug with resolving file paths", where CB-xxxx is the JIRA ID & "android" is the platform affected.
- [ ] Added automated test coverage as appropriate for this change.
2018-11-19 18:28:25 +01:00
Jesse MacFadyen
c24bb46965 This lets the default window layering do it's thing. Fixes #334. Fixes #314. 2018-10-29 13:43:37 -07:00
Dave Alden
c41f5b5131 Fix merge error 2018-10-09 11:31:26 +01:00
Dave Alden
19c6dfe197 Merge branch 'master' into CB-7179 2018-10-09 11:15:23 +01:00
wvengen
228703a63b CB-14188: add beforeload event, catching navigation before it happens 2018-10-01 16:41:21 +02:00
Dave Alden
dc7fa34bbe CB-7179 (iOS): Add support to optionally use WKWebView for iOS 2018-09-30 10:05:46 +01:00
Dan Polivy
a0783378fc [CB-10795] Exclude current app from external intent list (#154)
On Android, if the app defines an intent-filter for a given URL, and
then tries to use inappbrowser to launch that URL via the _system
target, the default handler for that intent is the app itself.

That behavior can lead to circular loops, and ultimately is not what the
developer wants -- the link should be launched in a browser.

Because there is no easy way to find the "default" system browser on a
device, this solution will do two things:
1) Check if the app is one of the targets for this intent
2) If so, create a custom chooser with all other targets, excluding the
current app.

If the app is not a target, then the current (existing) behavior is
preserved.

The only real "downside" to this approach is that a default handler can no longer be set for these URLs within the app, and a chooser will be shown each time the user taps a link that opens in a new browser.

Fixes https://issues.apache.org/jira/browse/CB-10795
2018-09-20 22:43:52 +02:00
Dan Polivy
cf58b04097 CB-14234: Don't call handleOpenURL for system URLs (#278)
When calling `.open()` with a target of `_system`, the InAppBrowser on iOS is both launching the URL in the system browser AND also broadcasting to open the URL within the app (calling handleOpenURL). The latter behavior is problematic in many circumstances (e.g. when you want to explicitly open a link in a browser which is a universal link handled by the app).

This commit attempts to address this by checking the return value from openURL -- if it does not open the URL successfully, then (and only then) the code falls back to broadcasting the event within the app to handleOpenURL.
2018-08-22 23:43:06 +02:00
Malte Norström
dc5329d157 CB-12875: (iOS) Pushes the inappbrowser window to a higher ui level than the existing apps window. (#284) 2018-08-21 10:28:56 +02:00
Julio César
dac06aa3f3 CB-12922 (ios): fix In-app browser does not cede control 2018-07-01 18:09:47 +02:00
jcesarmobile
26cf6e488c
Merge pull request #269 from timbru31/fix/CB-14061-handle-more-url-schemes
CB-14061: (android) comply with RFC 3986 for custom URL scheme handling
2018-05-19 13:57:13 +02:00
Tim Brust
f57ede9be2
CB-14061: (android) comply with RFC 3986 for custom URL scheme handling 2018-05-02 20:18:34 +02:00
Wojciech Trocki
57eda786e0 CB-14048: (android) allowedSchemes check empty string fix 2018-04-27 00:07:57 +01:00
Fiffi
ec6af56fbd remove statusbar when inAppBrowser is open in andriod 2018-04-23 16:07:17 +00:00
Steve Gill
974ca3309a
Merge pull request #254 from NiklasMerz/loading-spinner
CB-13659 (iOS) Add hidespinner option
2018-04-12 12:04:06 -07:00
Joe Bowser
50db5c498c
Merge pull request #263 from SailingSteve/CB-14013-InAppBrowser-AllowCustomSchemes
CB-14013: (android) Change the InAppBrowser to allow custom schemes for oAuth
2018-04-12 12:01:59 -07:00
stevepodell
42df297724 In file AppBrowser.java: New code within shouldOverrideUrlLoading() to
check for whitelisting custom schemes via a new "AllowedSchemes"
preference configuration item.  Allows custom schemes like
"mycoolapp://" or "wevotetwitterscheme://"

In file inappbrowser.js: Added new "customscheme" channel.
2018-04-05 12:45:02 -07:00
stevepodell
27500c2990 In file AppBrowser.java: New code within shouldOverrideUrlLoading() to
check for whitelisting custom schemes via a new "AllowedSchemes"
preference configuration item.  Allows custom schemes like
"mycoolapp://" or "wevotetwitterscheme://"

In file inappbrowser.js: Added new "customscheme" channel.
2018-04-05 11:54:32 -07:00
stevepodell
4c4bee528e InAppBrowser.java: New method isURLWhileListed to check for whitelisting of
"AllowedSchemes" in a new preference configuration item.
There is a new check in shouldOverrideUrlLoading, to allow whitelisted
custom schemes like "mycoolapp://"

inappbrowser.js: Added "customscheme" channel.
2018-04-05 10:31:00 -07:00
stevepodell
019ec3963f InAppBrowser.java: New method isURLWhileListed to check for whitelisting of
"AllowedSchemes" in a new preference configuration item.
There is a new check in shouldOverrideUrlLoading, to allow whitelisted
custom schemes like "mycoolapp://"

inappbrowser.js: Added "customscheme" channel.
2018-04-05 10:14:54 -07:00
stevepodell
2d69afcd7c InAppBrowser.java: New method isURLWhileListed to check for whitelisting.
Newtest in shouldOverrideUrlLoading, to allow whitelisted custom schemes
like"mycoolapp://"

inappbrowser.js: Added "customscheme" channel.
2018-04-04 15:57:13 -07:00
stevepodell
a6c7b54998 InAppBrowser.java: New method isURLWhileListed to check for whitelisting.
Newtest in shouldOverrideUrlLoading, to allow whitelisted custom schemes
like"mycoolapp://"

inappbrowser.js: Added "customscheme" channel.
2018-04-04 08:42:00 -07:00
stevepodell
44d9bb0f6a InAppBrowser.java: New method isURLWhileListed to check for whitelisting.
Newtest in shouldOverrideUrlLoading, to allow whitelisted custom schemes
like"mycoolapp://"

inappbrowser.js: Added "customscheme" channel.
2018-04-04 08:22:23 -07:00
Bentley O'Kane-Chase
65a825a193 Add customisation of the navigation buttons for iOS 2018-03-21 21:50:25 +10:00