Skip to content

Commit

Permalink
[webview_flutter_web] Add support for the credentialless attribute. (…
Browse files Browse the repository at this point in the history
…#151557)
  • Loading branch information
uldall committed Jul 10, 2024
1 parent 57d42e4 commit d61c55d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class _WebViewExample extends StatefulWidget {

class _WebViewExampleState extends State<_WebViewExample> {
final PlatformWebViewController _controller = PlatformWebViewController(
const PlatformWebViewControllerCreationParams(),
WebWebViewControllerCreationParams(iFrameCredentialless: true),
)..loadRequest(
LoadRequestParams(
uri: Uri.parse('https://flutter.dev'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,18 @@ import 'http_request_factory.dart';
@immutable
class WebWebViewControllerCreationParams
extends PlatformWebViewControllerCreationParams {
/// Creates a new [AndroidWebViewControllerCreationParams] instance.
/// Creates a new [WebWebViewControllerCreationParams] instance.
WebWebViewControllerCreationParams({
@visibleForTesting this.httpRequestFactory = const HttpRequestFactory(),
}) : super();
bool iFrameCredentialless = false,
}) : iFrame = web.HTMLIFrameElement()
..id = 'webView${_nextIFrameId++}'
..style.width = '100%'
..style.height = '100%'
..style.border = 'none'
..setAttribute(
'credentialless', iFrameCredentialless ? 'true' : 'false'),
super();

/// Creates a [WebWebViewControllerCreationParams] instance based on [PlatformWebViewControllerCreationParams].
WebWebViewControllerCreationParams.fromPlatformWebViewControllerCreationParams(
Expand All @@ -30,7 +38,8 @@ class WebWebViewControllerCreationParams
PlatformWebViewControllerCreationParams params, {
@visibleForTesting
HttpRequestFactory httpRequestFactory = const HttpRequestFactory(),
}) : this(httpRequestFactory: httpRequestFactory);
bool iFrameCredentialless = false,
}) : this(httpRequestFactory: httpRequestFactory, iFrameCredentialless: iFrameCredentialless);

static int _nextIFrameId = 0;

Expand All @@ -39,11 +48,7 @@ class WebWebViewControllerCreationParams

/// The underlying element used as the WebView.
@visibleForTesting
final web.HTMLIFrameElement iFrame = web.HTMLIFrameElement()
..id = 'webView${_nextIFrameId++}'
..style.width = '100%'
..style.height = '100%'
..style.border = 'none';
final web.HTMLIFrameElement iFrame;
}

/// An implementation of [PlatformWebViewController] using Flutter for Web API.
Expand Down

0 comments on commit d61c55d

Please sign in to comment.