forked from flutter/flutter
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[webview_flutter] Support for handling basic authentication requests …
…(Platform Interface) (flutter#5362) Adds the platform interface implementation for basic http authentication. This PR is part of a series of PRs that aim to close flutter#83556. The PR that contains all changes can be found at flutter/packages#4140.
- Loading branch information
1 parent
2e010d8
commit c5443ad
Showing
9 changed files
with
134 additions
and
4 deletions.
There are no files selected for viewing
3 changes: 2 additions & 1 deletion
3
packages/webview_flutter/webview_flutter_platform_interface/CHANGELOG.md
This file contains 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 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 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
68 changes: 68 additions & 0 deletions
68
...s/webview_flutter/webview_flutter_platform_interface/lib/src/types/http_auth_request.dart
This file contains 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,68 @@ | ||
// 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. | ||
|
||
import 'package:flutter/foundation.dart'; | ||
import 'webview_credential.dart'; | ||
|
||
/// Defines the parameters of a pending HTTP authentication request received by | ||
/// the webview through a [HttpAuthRequestCallback]. | ||
/// | ||
/// Platform specific implementations can add additional fields by extending | ||
/// this class and providing a factory method that takes the [HttpAuthRequest] | ||
/// as a parameter. | ||
/// | ||
/// This example demonstrates how to extend the [HttpAuthRequest] to provide | ||
/// additional platform specific parameters. | ||
/// | ||
/// When extending [HttpAuthRequest], additional parameters should always accept | ||
/// `null` or have a default value to prevent breaking changes. | ||
/// | ||
/// ```dart | ||
/// @immutable | ||
/// class WKWebViewHttpAuthRequest extends HttpAuthRequest { | ||
/// WKWebViewHttpAuthRequest._( | ||
/// HttpAuthRequest authRequest, | ||
/// this.extraData, | ||
/// ) : super( | ||
/// onProceed: authRequest.onProceed, | ||
/// onCancel: authRequest.onCancel, | ||
/// host: authRequest.host, | ||
/// realm: authRequest.realm, | ||
/// ); | ||
/// | ||
/// factory WKWebViewHttpAuthRequest.fromHttpAuthRequest( | ||
/// HttpAuthRequest authRequest, { | ||
/// String? extraData, | ||
/// }) { | ||
/// return WKWebViewHttpAuthRequest._( | ||
/// authRequest, | ||
/// extraData: extraData, | ||
/// ); | ||
/// } | ||
/// | ||
/// final String? extraData; | ||
/// } | ||
/// ``` | ||
@immutable | ||
class HttpAuthRequest { | ||
/// Creates a [HttpAuthRequest]. | ||
const HttpAuthRequest({ | ||
required this.onProceed, | ||
required this.onCancel, | ||
required this.host, | ||
this.realm, | ||
}); | ||
|
||
/// The callback to authenticate. | ||
final void Function(WebViewCredential credential) onProceed; | ||
|
||
/// The callback to cancel authentication. | ||
final void Function() onCancel; | ||
|
||
/// The host requiring authentication. | ||
final String host; | ||
|
||
/// The realm requiring authentication. | ||
final String? realm; | ||
} |
This file contains 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
24 changes: 24 additions & 0 deletions
24
.../webview_flutter/webview_flutter_platform_interface/lib/src/types/webview_credential.dart
This file contains 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,24 @@ | ||
// 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. | ||
|
||
import 'package:meta/meta.dart'; | ||
|
||
import '../types/http_auth_request.dart'; | ||
|
||
/// Defines the response parameters of a pending [HttpAuthRequest] received by | ||
/// the webview. | ||
@immutable | ||
class WebViewCredential { | ||
/// Creates a [WebViewCredential]. | ||
const WebViewCredential({ | ||
required this.user, | ||
required this.password, | ||
}); | ||
|
||
/// The user name. | ||
final String user; | ||
|
||
/// The password. | ||
final String password; | ||
} |
This file contains 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 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 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