Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

[webview_flutter_android] Fixes bug where a AndroidNavigationDelegate was required to load a request #6872

Merged
merged 5 commits into from
Dec 21, 2022

Conversation

bparrishMines
Copy link
Contributor

@bparrishMines bparrishMines commented Dec 21, 2022

The default WebChromeClient was being set to WebChromeClientImpl which would attempt to communicate with Dart in the onProgressChanged callback (viaWebChromeClientFlutterApi).

This moves the logic that ensures only secure url can attempt to open a window out of WebChromeClientImpl and into its own class (SecureWebChromeClient). The default WebView.webChromeClient is then set to SecureWebChromeClient which doesn't attempt to communicate with Dart.

Fixes flutter/flutter#117333

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the relevant style guides and ran the auto-formatter. (Unlike the flutter/flutter repo, the flutter/plugins repo does use dart format.)
  • I signed the CLA.
  • The title of the PR starts with the name of the plugin surrounded by square brackets, e.g. [shared_preferences]
  • I listed at least one issue that this PR fixes in the description above.
  • I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.
  • I updated CHANGELOG.md to add a description of the change, following repository CHANGELOG style.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@github-actions github-actions bot added p: webview_flutter Edits files for a webview_flutter plugin platform-android labels Dec 21, 2022
@bparrishMines bparrishMines changed the title fix bug [webview_flutter_android] Fixes bug where a AndroidNavigationDelegate was required to load a request Dec 21, 2022
Copy link
Contributor

@stuartmorgan-g stuartmorgan-g left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with nit

@@ -80,7 +79,7 @@ public void setWebContentsDebuggingEnabled(boolean enabled) {
/** Implementation of {@link WebView} that can be used as a Flutter {@link PlatformView}s. */
public static class WebViewPlatformView extends WebView implements PlatformView {
private WebViewClient currentWebViewClient;
private WebChromeClientImpl currentWebChromeClient;
private WebChromeClientHostApiImpl.SecureWebChromeClient currentWebChromeClient;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't the type here just be WebChromeClient since it's only being accessed via overridden methods?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be set to WebChromeClient, but then the overridden methods would have to cast this value.

@@ -135,7 +141,7 @@ public void setWebChromeClient(WebChromeClient client) {
public static class InputAwareWebViewPlatformView extends InputAwareWebView
implements PlatformView {
private WebViewClient currentWebViewClient;
private WebChromeClientImpl currentWebChromeClient;
private WebChromeClientHostApiImpl.SecureWebChromeClient currentWebChromeClient;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same.

@bparrishMines bparrishMines added the autosubmit Merge PR when tree becomes green via auto submit App label Dec 21, 2022
@auto-submit auto-submit bot merged commit 2dd85ec into flutter:main Dec 21, 2022
@bparrishMines bparrishMines deleted the nav_dev_fix branch December 22, 2022 03:25
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Dec 22, 2022
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Dec 22, 2022
* c61ac23fc [webview_flutter_wkwebview] Adds support for `WKNavigationAction.navigationType` (flutter/plugins#6863)

* 15cfe8aa2 [webview_flutter_android] Adds support for selecting Hybrid Composition (flutter/plugins#6864)

* 2dd85ec81 [webview_flutter_android] Fixes bug where a `AndroidNavigationDelegate` was required to load a request (flutter/plugins#6872)
loic-sharma pushed a commit to fluttergithubbot/flutter that referenced this pull request Jan 6, 2023
…#117535)

* c61ac23fc [webview_flutter_wkwebview] Adds support for `WKNavigationAction.navigationType` (flutter/plugins#6863)

* 15cfe8aa2 [webview_flutter_android] Adds support for selecting Hybrid Composition (flutter/plugins#6864)

* 2dd85ec81 [webview_flutter_android] Fixes bug where a `AndroidNavigationDelegate` was required to load a request (flutter/plugins#6872)
gspencergoog pushed a commit to gspencergoog/flutter that referenced this pull request Jan 19, 2023
…#117535)

* c61ac23fc [webview_flutter_wkwebview] Adds support for `WKNavigationAction.navigationType` (flutter/plugins#6863)

* 15cfe8aa2 [webview_flutter_android] Adds support for selecting Hybrid Composition (flutter/plugins#6864)

* 2dd85ec81 [webview_flutter_android] Fixes bug where a `AndroidNavigationDelegate` was required to load a request (flutter/plugins#6872)
mauricioluz pushed a commit to mauricioluz/plugins that referenced this pull request Jan 26, 2023
…e` was required to load a request (flutter#6872)

* fix bug

* comment

* another test

* fix spelling
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
autosubmit Merge PR when tree becomes green via auto submit App p: webview_flutter Edits files for a webview_flutter plugin platform-android
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[webview_flutter] 4.0.0 Android - Could not find identifier for WebChromeClient.
2 participants