Skip to content

[webview_flutter] Adds NavigationDelegate.onCreateWindow for target=_blank / window.open - #12312

Open
mateusz-ramp wants to merge 4 commits into
flutter:mainfrom
mateusz-ramp:webview-target-blank
Open

[webview_flutter] Adds NavigationDelegate.onCreateWindow for target=_blank / window.open#12312
mateusz-ramp wants to merge 4 commits into
flutter:mainfrom
mateusz-ramp:webview-target-blank

Conversation

@mateusz-ramp

@mateusz-ramp mateusz-ramp commented Jul 29, 2026

Copy link
Copy Markdown

Adds an optional NavigationDelegate.onCreateWindow callback so hosts can
handle target=_blank / window.open (e.g. open in an external browser)
instead of only loading in the same WebView.

Behavior

  • If onCreateWindow is set: Android (WebChromeClient.onCreateWindow
    pigeon) and iOS/macOS (WKUIDelegate.createWebViewWith) invoke the callback
    with the requested URL.
  • If unset: preserves existing same-WebView load behavior.

Packages (federated review PR)

  • webview_flutter_platform_interface 2.16.0
  • webview_flutter_android 4.14.0
  • webview_flutter_wkwebview 3.27.0
  • webview_flutter 4.15.0

Path dependency_overrides are present for combined review only
(make-deps-path-based). This PR is not intended to land as-is; after
approval we will land/publish in the usual federated order (platform
interface → implementations → app-facing).

Related issues

Related to:

Background (prior same-window _blank handling):

Pre-Review Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [AI contribution guidelines] and understand my responsibilities, or I am not using AI tools.
  • I read the [Tree Hygiene] page, which explains my responsibilities.
  • I read and followed the [relevant style guides] and ran [the auto-formatter].
  • I signed the [CLA].
  • The title of the PR starts with the name of the package surrounded by square brackets, e.g. [shared_preferences]
  • I [linked to at least one issue that this PR fixes] in the description above.
  • I followed [the version and CHANGELOG instructions], using [semantic versioning] and the [repository CHANGELOG style], or I have commented below to indicate which documented exception this PR falls under1.
  • I updated/added any relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or I have commented below to indicate which [test exemption] this PR falls under1.
  • All existing and new tests are passing.

Footnotes

  1. Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. 2

@google-cla

google-cla Bot commented Jul 29, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request adds the NavigationDelegate.onCreateWindow callback to the webview_flutter packages to support handling new-window requests, such as target=_blank and window.open, on Android and iOS. The implementation spans the platform interface, Android, and iOS implementations, alongside corresponding tests and version bumps. Feedback on the iOS implementation recommends avoiding an asynchronous IPC call to retrieve the URL when onCreateWindow is not set, and ensuring that empty or null URLs fall back to the default loading behavior instead of being silently dropped.

@mateusz-ramp

mateusz-ramp commented Aug 10, 2026

Copy link
Copy Markdown
Author

@bparrishMines hello, this is my first contribution to Flutter Packages repo, I'm not sure how things work here. Seems like cicd label needs to be added for the PR to move forward, and I can't do that myself. Could you help me with that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant