-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[webview_flutter] Adds onHttpError callback to NavigationDelegate to catch HTTP error status codes #3278
Conversation
cc7b6ad
to
50559ae
Compare
1213e83
to
3f74300
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this! I made a first pass through.
packages/webview_flutter/webview_flutter/example/test/main_test.dart
Outdated
Show resolved
Hide resolved
...webview_flutter/webview_flutter_platform_interface/lib/src/platform_navigation_delegate.dart
Outdated
Show resolved
Hide resolved
packages/webview_flutter/webview_flutter/lib/src/navigation_delegate.dart
Outdated
Show resolved
Hide resolved
...ndroid/android/src/main/java/io/flutter/plugins/webviewflutter/WebViewClientHostApiImpl.java
Outdated
Show resolved
Hide resolved
packages/webview_flutter/webview_flutter_android/lib/src/android_webview.dart
Outdated
Show resolved
Hide resolved
packages/webview_flutter/webview_flutter_android/lib/src/android_webview.dart
Outdated
Show resolved
Hide resolved
packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFDataConverters.m
Show resolved
Hide resolved
...webview_flutter/webview_flutter_platform_interface/lib/src/platform_navigation_delegate.dart
Outdated
Show resolved
Hide resolved
...webview_flutter/webview_flutter_platform_interface/lib/src/platform_navigation_delegate.dart
Outdated
Show resolved
Hide resolved
db91fe9
to
3021c65
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the work on this! This looks mostly ready. I just had a few more comments about documentation.
This is also missing integration tests for Android, iOS, and the app-facing api. They're located at:
https://github.com/flutter/packages/blob/main/packages/webview_flutter/webview_flutter_android/example/integration_test/webview_flutter_test.dart
The test called onWebResourceError
should be a good example for each file. And you should be able to use '$prefixUrl/favicon.ico'
as the test url that returns a 404
status code.
I think this is ready for a secondary review since only documentation and integration tests are left.
@cyanglaz can you look over the webview_flutter_wkwebview
code as a secondary reviewer?
@stuartmorgan can you look over the platform interface/app-facing code as secondary reviewer?
...oid/android/src/main/java/io/flutter/plugins/webviewflutter/WebViewClientFlutterApiImpl.java
Outdated
Show resolved
Hide resolved
packages/webview_flutter/webview_flutter_android/lib/src/android_webview_controller.dart
Outdated
Show resolved
Hide resolved
...es/webview_flutter/webview_flutter_platform_interface/lib/src/types/http_response_error.dart
Outdated
Show resolved
Hide resolved
...es/webview_flutter/webview_flutter_platform_interface/lib/src/types/http_response_error.dart
Outdated
Show resolved
Hide resolved
...bview_flutter/webview_flutter_platform_interface/test/platform_navigation_delegate_test.dart
Outdated
Show resolved
Hide resolved
packages/webview_flutter/webview_flutter_wkwebview/CHANGELOG.md
Outdated
Show resolved
Hide resolved
packages/webview_flutter/webview_flutter_wkwebview/lib/src/webkit_webview_controller.dart
Show resolved
Hide resolved
packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit.dart
Outdated
Show resolved
Hide resolved
@HugoOlthof Are you planning on updating this based on the review feedback above? |
@stuartmorgan Yes, I will update the PR as soon as possible! |
c1153fb
to
390aee0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! with a handful of nits
After fixing the comments, you can go ahead and create the PR with just the code in webview_flutter_platform_interface
.
...es/webview_flutter/webview_flutter_platform_interface/lib/src/types/http_response_error.dart
Outdated
Show resolved
Hide resolved
...es/webview_flutter/webview_flutter_platform_interface/lib/src/types/http_response_error.dart
Outdated
Show resolved
Hide resolved
...es/webview_flutter/webview_flutter_platform_interface/lib/src/types/http_response_error.dart
Outdated
Show resolved
Hide resolved
packages/webview_flutter/webview_flutter_wkwebview/lib/src/foundation/foundation.dart
Outdated
Show resolved
Hide resolved
packages/webview_flutter/webview_flutter_wkwebview/lib/src/legacy/web_kit_webview_widget.dart
Outdated
Show resolved
Hide resolved
packages/webview_flutter/webview_flutter_wkwebview/lib/src/web_kit/web_kit.dart
Outdated
Show resolved
Hide resolved
packages/webview_flutter/webview_flutter_wkwebview/test/webkit_navigation_delegate_test.dart
Outdated
Show resolved
Hide resolved
This is the PR for |
Signed-off-by: Hugo Olthof <hugo@moneybird.com>
The PR for the platform implementations: #3695 |
Update from triage: this is waiting for the sub-PR to complete the review process. |
Update from triage: sub-PR is still in progress. |
Update from triage: Still waiting on #3695 |
Update from triage: #5790 has been created as a copy of the blocking PR, to try to start unwinding this stack. |
Update from triage: the last PR in the stack is resolved, and this is now blocked on getting the next PR over the line. |
Update from triage: implementation PR (referenced just above) is still in progress. |
…plementations for onHttpError (#6149) Copy of #3695 since it doesn't contain permission to edit from contributors. Part of flutter/flutter#39502 Full PR #3278
closing in favor of #6378 |
…catch HTTP error status codes (#6378) This is a copy of #3278 since it doesn't allow for contributor access. Fixes flutter/flutter#39502
…plementations for onHttpError (flutter#6149) Copy of flutter#3695 since it doesn't contain permission to edit from contributors. Part of flutter/flutter#39502 Full PR flutter#3278
…catch HTTP error status codes (flutter#6378) This is a copy of flutter#3278 since it doesn't allow for contributor access. Fixes flutter/flutter#39502
…plementations for onHttpError (#6149) Copy of flutter/packages#3695 since it doesn't contain permission to edit from contributors. Part of flutter/flutter#39502 Full PR flutter/packages#3278
This PR adds the onHttpError callback to NavigationDelegate to catch HTTP error status codes. In our app we need to catch the status codes to show native error pages/alerts or redirect users to the native login screen if the user is unauthenticated. The existing onWebResourceError is not sufficient.
The Android implementation uses the onReceiveHttpError callback from WebViewClient and the iOS implementation uses the decidePolicyForNavigationResponse delegate from WKWebView.
Fixes flutter/flutter#39502.
Pre-launch Checklist
dart format
.)[shared_preferences]
pubspec.yaml
with an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.CHANGELOG.md
to add a description of the change, following repository CHANGELOG style.///
).