Commit Graph

71 Commits

Author SHA1 Message Date
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
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
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
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
Bentley O'Kane-Chase
65a825a193 Add customisation of the navigation buttons for iOS 2018-03-21 21:50:25 +10:00
Bentley O'Kane-Chase
a3fca87ee5
Fix navigation buttons on iOS 2018-02-22 15:09:09 +10:00
Niklas Merz
695e1b0f02
CB-13659 (iOS) Add hidespinner option
Signed-off-by: Niklas Merz <NiklasMerz@gmx.net>
2017-12-13 22:22:57 +01:00
Landsbankinn
4af420c592 CB-13409: change hidetoolbarnavigationbuttons to hidenavigationbuttons in iso 2017-10-09 16:17:52 +00:00
Landsbankinn
e691212c96 CB-13409: Android works well now, all changes are now documented 2017-10-09 16:17:44 +00:00
Landsbankinn
8711ee3f21 CB-13409: Lets user adjust color of toolbar, hide navigation buttons and set custom text on close button 2017-10-09 16:17:14 +00:00
Julio César
32d867f8e4 CB-12586 (iOS) fix method hide doesn't work
This closes #229
2017-07-23 19:02:19 +02:00
Reid Beels
c6ffd69e9c CB-12366: (ios) Reduce tmpWindow level to prevent overlapping statusbar
This closes #209
2017-02-21 21:08:45 +01:00
Manu Mtz.-Almeida
f32917df31 CB-11136: (ios) Fix InAppBrowser when closing with WKWebView
This closes #187
2017-01-03 15:28:43 -08:00
Julio César
d735649fcd CB-10799 (ios) fix toolbar is shown in incorrect position when in-call status bar
This closes #203
2016-12-22 23:51:51 +01:00
Frank Stingl
20c21f39df removed duplicate hide method in ios source and add jasmine test cases 2016-10-19 11:36:20 +02:00
ekidder3
df8bcaf751 CB-8467
Added support for hiding the web view container.  This maintains the browser
session without closing it.  The browser window can be repeatedly hidden and
shown.

** This has only been tested on android and ios **

amazon/android:
An additional `hide` action was added to `InAppBrowser#execute`.  It is
identical to `show`, except that it calls `dialog.hide()` instead.

blackberry10:
no changes

firefoxos:
Added a `hide` method that is identical to `show`, indicating it is not
supported.

ios:
Added a `hide` method that is identical to `show`, except that it uses
`dismissViewControllerAnimated`.  It checks the value of
`_previousStatusBarStyle`.  If it is `-1`, the method returns with no
action performed.  If it is not, it is set to `-1.`

ubuntu:
Added a `hide` method that sets `CordovaWrapper.global.inappbrowser.visible` to
`false`.

windows:
Added a `hide` method that sets `browserWrap.style.display` to `none`.

wp:
Added a `hide` method that is identical to `show`, except that it sets
`browser.Visibility` to `Visibility.Collapsed` and sets `AppBar.IsVisible` to
`false`.
2016-10-18 10:41:26 -04:00
Julio César
3f63aaee58 CB-11178 allow to open other apps on iOS 9
This closes #177
2016-07-28 00:04:00 +02:00
Julio César
e9734667c6 CB-2063: (ios) Fixed presentation style
This closes #176
2016-07-17 20:35:38 +02:00
Connor Pearson
4ef6106259
CB-3360: Set custom inappbrowser user agent for ios
This closes #94

Signed-off-by: Shazron Abdullah <shazron@gmail.com>
2016-07-01 13:17:23 -07:00
Birge Clark
c6ff803113 CB-7679 add fix for iOS upload. This closes #139 2016-03-25 15:44:25 +01:00
Julio César
555d55ac8a Fixes CB-10607
When the device is in portrait upside down the toolbar appears at the
bottom. This fix set the origin to the 0,0 point
2016-02-13 19:33:21 +01:00
Julio César
80c8e56fb0 CB-10305 Gray bar appears in the wrong place on iOS
This closes #137
2016-02-04 18:32:52 +03:00
PC Dreams (Paulo Cristo)
fa7c46a316 handle app store urls in system browser 2016-01-05 12:32:47 +00:00
sgrebnov
65821f907d CB-9445 Improves executeScript callbacks on iOS
This closes #125

Signed-off-by: Shazron Abdullah <shazron@apache.org>
2015-12-10 14:47:43 -08:00
Shazron Abdullah
542536f790 CB-10040 - re-fix: backwards compatible with cordova-ios < 4.0 2015-11-20 10:53:36 -08:00
Connor Pearson
52cfd3216a CB-3750: Fixes spinner on iOS. This closes #89 2015-11-20 18:40:16 +03:00
Shazron Abdullah
bc9036d90a CB-10040 - Compile Error in InAppBrowser Plugin for iOS - No known instance method for selector 'URLIsWhitelisted:' 2015-11-19 15:22:30 -08:00
Jesse MacFadyen
682703aa24 weak ref type was wrong 2015-11-18 14:22:42 -08:00
Jesse MacFadyen
1bc51f9381 fix async self usage 2015-11-17 11:50:40 -08:00
Jesse MacFadyen
1912d12697 Merge branch 'fix_status_bar_negative' of https://github.com/vinnyrose/cordova-plugin-inappbrowser 2015-11-16 17:54:08 -08:00
David Weber
2279aee4ff Fix crash on browser window close (https://issues.apache.org/jira/browse/CB-9167) 2015-07-20 13:09:58 +02:00
Shazron Abdullah
dfd0999581 CB-4930 - (prefix) InAppBrowser should take into account the status bar 2015-04-03 12:34:11 -07:00
Shazron Abdullah
ed1227f61a CB-8659 - Update InAppBrowser to support both cordova-ios 4.0.x and 3.x (closes #93) 2015-03-16 09:42:16 -07:00
Andrew Grieve
bfff56aef4 CB-8270 Remove usage of [arr JSONString], since it's been renamed to cdv_JSONString
Just updating to the new name would make the plugin incompatible with
previous cordova-ios versions.
2015-01-21 11:48:08 -05:00
Mario Rosa
d9900ba783 InAppBrowser, iOS: Setting setStatusBarStyle to -1 causes CGContextSaveGState.
Simple if statement to ensure -1 is not submitted to setStatusBarStyle.
2014-12-05 09:21:01 -05:00
bwin
91b84579e8 CB-6769 ios: Fix statusbar color reset wasn't working on iOS7+
close #45
2014-06-27 14:33:33 -04:00
Andrew Grieve
eb704f8212 Clean up whitespace (mainly due to no newline at eof warning) 2014-06-04 14:25:50 -04:00
Shazron Abdullah
40778ba239 Fixed use of iOS 6 deprecated methods 2014-04-17 17:02:59 -07:00
Shazron Abdullah
c25bc30d7d CB-6360 - improvement: feature detection instead of iOS version detection 2014-04-17 16:52:21 -07:00