-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[webview_flutter_android] Adds internal wrapper methods for native WebViewClient
.
#8964
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
Merged
auto-submit
merged 15 commits into
flutter:main
from
bparrishMines:webviewclient_methods
Apr 14, 2025
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
0587870
update pigeon file
bparrishMines b225666
dart side finished
bparrishMines 7049840
webviewclient methods
bparrishMines 37f9b8b
Merge branch 'main' of github.com:flutter/packages into webviewclient…
bparrishMines 1607966
fix codegen
bparrishMines 83b77da
add suppress
bparrishMines 8b9258f
fix conditional debug log
bparrishMines 8455d87
Merge branch 'main' of github.com:flutter/packages into webviewclient…
bparrishMines 0fdbd38
trivial string.format lint
bparrishMines d9abd42
improve docs
bparrishMines cb15cf1
Merge branch 'main' of github.com:flutter/packages into webviewclient…
bparrishMines 7db29ae
add default impl
bparrishMines 253819c
formatting
bparrishMines 6563ae6
update legacy
bparrishMines 3972ad6
add java versions
bparrishMines File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
packages/webview_flutter/webview_flutter_android/CHANGELOG.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2,180 changes: 1,689 additions & 491 deletions
2,180
...android/android/src/main/java/io/flutter/plugins/webviewflutter/AndroidWebkitLibrary.g.kt
Large diffs are not rendered by default.
Oops, something went wrong.
40 changes: 40 additions & 0 deletions
40
...id/android/src/main/java/io/flutter/plugins/webviewflutter/ClientCertRequestProxyApi.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
package io.flutter.plugins.webviewflutter; | ||
|
||
import android.webkit.ClientCertRequest; | ||
import androidx.annotation.NonNull; | ||
import java.security.PrivateKey; | ||
import java.security.cert.X509Certificate; | ||
import java.util.List; | ||
|
||
/** | ||
* ProxyApi implementation for {@link ClientCertRequest}. This class may handle instantiating native | ||
* object instances that are attached to a Dart instance or handle method calls on the associated | ||
* native class or an instance of that class. | ||
*/ | ||
class ClientCertRequestProxyApi extends PigeonApiClientCertRequest { | ||
ClientCertRequestProxyApi(@NonNull ProxyApiRegistrar pigeonRegistrar) { | ||
super(pigeonRegistrar); | ||
} | ||
|
||
@Override | ||
public void cancel(@NonNull ClientCertRequest pigeon_instance) { | ||
pigeon_instance.cancel(); | ||
} | ||
|
||
@Override | ||
public void ignore(@NonNull ClientCertRequest pigeon_instance) { | ||
pigeon_instance.ignore(); | ||
} | ||
|
||
@Override | ||
public void proceed( | ||
@NonNull ClientCertRequest pigeon_instance, | ||
@NonNull PrivateKey privateKey, | ||
@NonNull List<? extends X509Certificate> chain) { | ||
pigeon_instance.proceed(privateKey, chain.toArray(new X509Certificate[0])); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...tter_android/android/src/main/java/io/flutter/plugins/webviewflutter/MessageProxyApi.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
package io.flutter.plugins.webviewflutter; | ||
|
||
import android.os.Message; | ||
import androidx.annotation.NonNull; | ||
|
||
/** | ||
* Proxy API implementation for `Message`. | ||
* | ||
* <p>This class may handle instantiating and adding native object instances that are attached to a | ||
* Dart instance or handle method calls on the associated native class or an instance of the class. | ||
*/ | ||
public class MessageProxyApi extends PigeonApiAndroidMessage { | ||
public MessageProxyApi(@NonNull AndroidWebkitLibraryPigeonProxyApiRegistrar pigeonRegistrar) { | ||
super(pigeonRegistrar); | ||
} | ||
|
||
@Override | ||
public void sendToTarget(@NonNull Message pigeon_instance) { | ||
pigeon_instance.sendToTarget(); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
.../android/src/main/java/io/flutter/plugins/webviewflutter/SslCertificateDNameProxyApi.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
package io.flutter.plugins.webviewflutter; | ||
|
||
import android.net.http.SslCertificate; | ||
import androidx.annotation.NonNull; | ||
|
||
/** | ||
* ProxyApi implementation for {@link SslCertificate.DName}. This class may handle instantiating | ||
* native object instances that are attached to a Dart instance or handle method calls on the | ||
* associated native class or an instance of that class. | ||
*/ | ||
class SslCertificateDNameProxyApi extends PigeonApiSslCertificateDName { | ||
SslCertificateDNameProxyApi(@NonNull ProxyApiRegistrar pigeonRegistrar) { | ||
super(pigeonRegistrar); | ||
} | ||
|
||
@NonNull | ||
@Override | ||
public String getCName(@NonNull SslCertificate.DName pigeon_instance) { | ||
return pigeon_instance.getCName(); | ||
} | ||
|
||
@NonNull | ||
@Override | ||
public String getDName(@NonNull SslCertificate.DName pigeon_instance) { | ||
return pigeon_instance.getDName(); | ||
} | ||
|
||
@NonNull | ||
@Override | ||
public String getOName(@NonNull SslCertificate.DName pigeon_instance) { | ||
return pigeon_instance.getOName(); | ||
} | ||
|
||
@NonNull | ||
@Override | ||
public String getUName(@NonNull SslCertificate.DName pigeon_instance) { | ||
return pigeon_instance.getUName(); | ||
} | ||
} |
79 changes: 79 additions & 0 deletions
79
...droid/android/src/main/java/io/flutter/plugins/webviewflutter/SslCertificateProxyApi.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
package io.flutter.plugins.webviewflutter; | ||
|
||
import android.net.http.SslCertificate; | ||
import android.os.Build; | ||
import android.util.Log; | ||
import androidx.annotation.NonNull; | ||
import androidx.annotation.Nullable; | ||
import java.util.Date; | ||
|
||
/** | ||
* ProxyApi implementation for {@link SslCertificate}. This class may handle instantiating native | ||
* object instances that are attached to a Dart instance or handle method calls on the associated | ||
* native class or an instance of that class. | ||
*/ | ||
class SslCertificateProxyApi extends PigeonApiSslCertificate { | ||
SslCertificateProxyApi(@NonNull ProxyApiRegistrar pigeonRegistrar) { | ||
super(pigeonRegistrar); | ||
} | ||
|
||
@NonNull | ||
@Override | ||
public ProxyApiRegistrar getPigeonRegistrar() { | ||
return (ProxyApiRegistrar) super.getPigeonRegistrar(); | ||
} | ||
|
||
@Nullable | ||
@Override | ||
public android.net.http.SslCertificate.DName getIssuedBy( | ||
@NonNull SslCertificate pigeon_instance) { | ||
return pigeon_instance.getIssuedBy(); | ||
} | ||
|
||
@Nullable | ||
@Override | ||
public android.net.http.SslCertificate.DName getIssuedTo( | ||
@NonNull SslCertificate pigeon_instance) { | ||
return pigeon_instance.getIssuedTo(); | ||
} | ||
|
||
@Nullable | ||
@Override | ||
public Long getValidNotAfterMsSinceEpoch(@NonNull SslCertificate pigeon_instance) { | ||
final Date date = pigeon_instance.getValidNotAfterDate(); | ||
if (date != null) { | ||
return date.getTime(); | ||
} | ||
return null; | ||
} | ||
|
||
@Nullable | ||
@Override | ||
public Long getValidNotBeforeMsSinceEpoch(@NonNull SslCertificate pigeon_instance) { | ||
final Date date = pigeon_instance.getValidNotBeforeDate(); | ||
if (date != null) { | ||
return date.getTime(); | ||
} | ||
return null; | ||
} | ||
|
||
@Nullable | ||
@Override | ||
public java.security.cert.X509Certificate getX509Certificate( | ||
@NonNull SslCertificate pigeon_instance) { | ||
if (getPigeonRegistrar().sdkIsAtLeast(Build.VERSION_CODES.Q)) { | ||
return pigeon_instance.getX509Certificate(); | ||
} else { | ||
Log.d( | ||
"SslCertificateProxyApi", | ||
getPigeonRegistrar() | ||
.createUnsupportedVersionMessage( | ||
"SslCertificate.getX509Certificate", "Build.VERSION_CODES.Q")); | ||
return null; | ||
} | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
...roid/android/src/main/java/io/flutter/plugins/webviewflutter/SslErrorHandlerProxyApi.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
package io.flutter.plugins.webviewflutter; | ||
|
||
import android.webkit.SslErrorHandler; | ||
import androidx.annotation.NonNull; | ||
|
||
/** | ||
* ProxyApi implementation for {@link SslErrorHandler}. This class may handle instantiating native | ||
* object instances that are attached to a Dart instance or handle method calls on the associated | ||
* native class or an instance of that class. | ||
*/ | ||
class SslErrorHandlerProxyApi extends PigeonApiSslErrorHandler { | ||
SslErrorHandlerProxyApi(@NonNull ProxyApiRegistrar pigeonRegistrar) { | ||
super(pigeonRegistrar); | ||
} | ||
|
||
@Override | ||
public void cancel(@NonNull SslErrorHandler pigeon_instance) { | ||
pigeon_instance.cancel(); | ||
} | ||
|
||
@Override | ||
public void proceed(@NonNull SslErrorHandler pigeon_instance) { | ||
pigeon_instance.proceed(); | ||
} | ||
} |
86 changes: 86 additions & 0 deletions
86
...ter_android/android/src/main/java/io/flutter/plugins/webviewflutter/SslErrorProxyApi.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
package io.flutter.plugins.webviewflutter; | ||
|
||
import android.net.http.SslError; | ||
import androidx.annotation.NonNull; | ||
|
||
/** | ||
* ProxyApi implementation for {@link SslError}. This class may handle instantiating native object | ||
* instances that are attached to a Dart instance or handle method calls on the associated native | ||
* class or an instance of that class. | ||
*/ | ||
class SslErrorProxyApi extends PigeonApiSslError { | ||
SslErrorProxyApi(@NonNull ProxyApiRegistrar pigeonRegistrar) { | ||
super(pigeonRegistrar); | ||
} | ||
|
||
@NonNull | ||
@Override | ||
public ProxyApiRegistrar getPigeonRegistrar() { | ||
return (ProxyApiRegistrar) super.getPigeonRegistrar(); | ||
} | ||
|
||
@NonNull | ||
@Override | ||
public android.net.http.SslCertificate certificate(@NonNull SslError pigeon_instance) { | ||
return pigeon_instance.getCertificate(); | ||
} | ||
|
||
@NonNull | ||
@Override | ||
public String url(@NonNull SslError pigeon_instance) { | ||
return pigeon_instance.getUrl(); | ||
} | ||
|
||
@NonNull | ||
@Override | ||
public SslErrorType getPrimaryError(@NonNull SslError pigeon_instance) { | ||
switch (pigeon_instance.getPrimaryError()) { | ||
case SslError.SSL_DATE_INVALID: | ||
return SslErrorType.DATE_INVALID; | ||
case SslError.SSL_EXPIRED: | ||
return SslErrorType.EXPIRED; | ||
case SslError.SSL_IDMISMATCH: | ||
return SslErrorType.ID_MISMATCH; | ||
case SslError.SSL_INVALID: | ||
return SslErrorType.INVALID; | ||
case SslError.SSL_NOTYETVALID: | ||
return SslErrorType.NOT_YET_VALID; | ||
case SslError.SSL_UNTRUSTED: | ||
return SslErrorType.UNTRUSTED; | ||
default: | ||
return SslErrorType.UNKNOWN; | ||
} | ||
} | ||
|
||
@Override | ||
public boolean hasError(@NonNull SslError pigeon_instance, @NonNull SslErrorType error) { | ||
int nativeError = -1; | ||
switch (error) { | ||
case DATE_INVALID: | ||
nativeError = SslError.SSL_DATE_INVALID; | ||
break; | ||
case EXPIRED: | ||
nativeError = SslError.SSL_EXPIRED; | ||
break; | ||
case ID_MISMATCH: | ||
nativeError = SslError.SSL_IDMISMATCH; | ||
break; | ||
case INVALID: | ||
nativeError = SslError.SSL_INVALID; | ||
break; | ||
case NOT_YET_VALID: | ||
nativeError = SslError.SSL_NOTYETVALID; | ||
break; | ||
case UNTRUSTED: | ||
nativeError = SslError.SSL_UNTRUSTED; | ||
break; | ||
case UNKNOWN: | ||
throw getPigeonRegistrar().createUnknownEnumException(error); | ||
} | ||
return pigeon_instance.hasError(nativeError); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This was required for me to run tests locally. I'm not sure if this is just me or not.