Commit 44c17d1e authored by Lorenzo Pichilli's avatar Lorenzo Pichilli

updated code docs

parent bb0e7f70
This diff is collapsed.
......@@ -155,7 +155,7 @@ public class ContentBlockerHandler {
break;
case MAKE_HTTPS:
if (url.startsWith("http://")) {
if (scheme.equals("http") && (port == -1 || port == 80)) {
String urlHttps = url.replace("http://", "https://");
Request mRequest = new Request.Builder().url(urlHttps).build();
......
......@@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_inappbrowser/flutter_inappbrowser.dart';
class MyChromeSafariBrowser extends ChromeSafariBrowser {
MyChromeSafariBrowser(browserFallback) : super(browserFallback);
MyChromeSafariBrowser(browserFallback) : super(bFallback: browserFallback);
@override
void onOpened() {
print("ChromeSafari browser opened");
......@@ -36,7 +36,7 @@ class _ChromeSafariExampleScreenState extends State<ChromeSafariExampleScreen> {
return new Center(
child: new RaisedButton(
onPressed: () async {
await widget.browser.open("https://flutter.dev/",
await widget.browser.open(url: "https://flutter.dev/",
options: ChromeSafariBrowserClassOptions(
androidChromeCustomTabsOptions: AndroidChromeCustomTabsOptions(addShareButton: false),
iosSafariOptions: IosSafariOptions(barCollapsingEnabled: true)
......
......@@ -104,10 +104,11 @@ class _InlineExampleScreenState extends State<InlineExampleScreen> {
resourceCustomSchemes: ["my-special-custom-scheme"],
contentBlockers: [
ContentBlocker(
ContentBlockerTrigger(".*",
trigger: ContentBlockerTrigger(
urlFilter: ".*",
resourceType: [ContentBlockerTriggerResourceType.IMAGE, ContentBlockerTriggerResourceType.STYLE_SHEET],
ifTopUrl: ["https://getbootstrap.com/"]),
ContentBlockerAction(ContentBlockerActionType.BLOCK)
action: ContentBlockerAction(type: ContentBlockerActionType.BLOCK)
)
]
),
......@@ -125,11 +126,11 @@ class _InlineExampleScreenState extends State<InlineExampleScreen> {
if (Platform.isAndroid)
webView.startSafeBrowsing();
webView.addJavaScriptHandler('handlerFoo', (args) {
webView.addJavaScriptHandler(handlerName:'handlerFoo', callback: (args) {
return new Foo(bar: 'bar_value', baz: 'baz_value');
});
webView.addJavaScriptHandler('handlerFooWithArgs', (args) {
webView.addJavaScriptHandler(handlerName: 'handlerFooWithArgs', callback: (args) {
print(args);
return [args[0] + 5, !args[1], args[2][0], args[3]['foo']];
});
......@@ -155,20 +156,20 @@ class _InlineExampleScreenState extends State<InlineExampleScreen> {
var tRexHtml = await controller.getTRexRunnerHtml();
var tRexCss = await controller.getTRexRunnerCss();
controller.loadData("""
controller.loadData(data: """
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1.0, user-scalable=no">
<style>${tRexCss}</style>
<style>$tRexCss</style>
</head>
<body>
${tRexHtml}
$tRexHtml
<p>
URL ${url} failed to load.
URL $url failed to load.
</p>
<p>
Error: ${code}, ${message}
Error: $code, $message
</p>
</body>
</html>
......@@ -182,7 +183,7 @@ class _InlineExampleScreenState extends State<InlineExampleScreen> {
},
shouldOverrideUrlLoading: (InAppWebViewController controller, String url) {
print("override $url");
controller.loadUrl(url);
controller.loadUrl(url: url);
},
onLoadResource: (InAppWebViewController controller, LoadedResource response) {
print("Resource type: '"+response.initiatorType + "' started at: " +
......@@ -212,14 +213,14 @@ class _InlineExampleScreenState extends State<InlineExampleScreen> {
onLoadResourceCustomScheme: (InAppWebViewController controller, String scheme, String url) async {
if (scheme == "my-special-custom-scheme") {
var bytes = await rootBundle.load("assets/" + url.replaceFirst("my-special-custom-scheme://", "", 0));
var response = new CustomSchemeResponse(bytes.buffer.asUint8List(), "image/svg+xml", contentEnconding: "utf-8");
var response = new CustomSchemeResponse(data: bytes.buffer.asUint8List(), contentType: "image/svg+xml", contentEnconding: "utf-8");
return response;
}
return null;
},
onTargetBlank: (InAppWebViewController controller, String url) {
print("target _blank: " + url);
controller.loadUrl(url);
controller.loadUrl(url: url);
},
onGeolocationPermissionsShowPrompt: (InAppWebViewController controller, String origin) async {
GeolocationPermissionShowPromptResponse response;
......@@ -234,14 +235,14 @@ class _InlineExampleScreenState extends State<InlineExampleScreen> {
FlatButton(
child: Text("Close"),
onPressed: () {
response = new GeolocationPermissionShowPromptResponse(origin, false, false);
response = new GeolocationPermissionShowPromptResponse(origin: origin, allow: false, retain: false);
Navigator.of(context).pop();
},
),
FlatButton(
child: Text("Accept"),
onPressed: () {
response = new GeolocationPermissionShowPromptResponse(origin, true, true);
response = new GeolocationPermissionShowPromptResponse(origin: origin, allow: true, retain: true);
Navigator.of(context).pop();
},
),
......@@ -312,7 +313,7 @@ class _InlineExampleScreenState extends State<InlineExampleScreen> {
return fetchRequest;
},
onNavigationStateChange: (InAppWebViewController controller, String url) async {
print("NAVIGATION STATE CHANGE: ${url}");
print("NAVIGATION STATE CHANGE: $url");
setState(() {
this.url = url;
});
......
......@@ -3,7 +3,7 @@ import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter_inappbrowser/flutter_inappbrowser.dart';
class MyInappBrowser extends InAppBrowser {
class MyInAppBrowser extends InAppBrowser {
@override
Future onBrowserCreated() async {
......@@ -43,7 +43,7 @@ class MyInappBrowser extends InAppBrowser {
@override
void shouldOverrideUrlLoading(String url) {
print("\n\n override $url\n\n");
this.webViewController.loadUrl(url);
this.webViewController.loadUrl(url: url);
}
@override
......@@ -75,11 +75,13 @@ class MyInappBrowser extends InAppBrowser {
@override
Future<CustomSchemeResponse> onLoadResourceCustomScheme(String scheme, String url) async {
print("custom scheme: " + scheme);
return null;
}
@override
Future<GeolocationPermissionShowPromptResponse> onGeolocationPermissionsShowPrompt(String origin) async {
print("request Geolocation permission API");
return null;
}
@override
......@@ -89,18 +91,18 @@ class MyInappBrowser extends InAppBrowser {
@override
Future<JsConfirmResponse> onJsConfirm(String message) {
return null;
}
@override
Future<JsPromptResponse> onJsPrompt(String message, String defaultValue) {
return null;
}
}
class WebviewExampleScreen extends StatefulWidget {
final MyInappBrowser browser = new MyInappBrowser();
static BuildContext context = null;
final MyInAppBrowser browser = new MyInAppBrowser();
static BuildContext context;
@override
_WebviewExampleScreenState createState() => new _WebviewExampleScreenState();
......@@ -119,7 +121,7 @@ class _WebviewExampleScreenState extends State<WebviewExampleScreen> {
child: new RaisedButton(
onPressed: () {
widget.browser.openFile(
"assets/index.html",
assetFilePath: "assets/index.html",
//url: "https://www.google.com/",
options: InAppBrowserClassOptions(
inAppWebViewWidgetOptions: InAppWebViewWidgetOptions(
......
import 'dart:async';
import 'dart:io';
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
import 'types.dart';
......@@ -12,16 +13,16 @@ import 'in_app_browser.dart';
///This class uses native [Chrome Custom Tabs](https://developer.android.com/reference/android/support/customtabs/package-summary) on Android
///and [SFSafariViewController](https://developer.apple.com/documentation/safariservices/sfsafariviewcontroller) on iOS.
///
///[browserFallback] represents the [InAppBrowser] instance fallback in case [Chrome Custom Tabs]/[SFSafariViewController] is not available.
///[browserFallback] represents the [InAppBrowser] instance fallback in case `Chrome Custom Tabs`/`SFSafariViewController` is not available.
class ChromeSafariBrowser {
String uuid;
InAppBrowser browserFallback;
bool _isOpened = false;
///Initialize the [ChromeSafariBrowser] instance with an [InAppBrowser] fallback instance or `null`.
ChromeSafariBrowser (bf) {
ChromeSafariBrowser ({bFallback}) {
uuid = uuidGenerator.v4();
browserFallback = bf;
browserFallback = bFallback;
ChannelManager.addListener(uuid, handleMethod);
_isOpened = false;
}
......@@ -45,32 +46,14 @@ class ChromeSafariBrowser {
///Opens an [url] in a new [ChromeSafariBrowser] instance.
///
///- [url]: The [url] to load. Call [encodeUriComponent()] on this if the [url] contains Unicode characters.
///[url]: The [url] to load. Call [encodeUriComponent()] on this if the [url] contains Unicode characters.
///
///- [options]: Options for the [ChromeSafariBrowser].
///[options]: Options for the [ChromeSafariBrowser].
///
///- [headersFallback]: The additional header of the [InAppBrowser] instance fallback to be used in the HTTP request for this URL, specified as a map from name to value.
///[headersFallback]: The additional header of the [InAppBrowser] instance fallback to be used in the HTTP request for this URL, specified as a map from name to value.
///
///- [optionsFallback]: Options used by the [InAppBrowser] instance fallback.
///
///**Android** supports these options:
///
///- __addShareButton__: Set to `false` if you don't want the default share button. The default value is `true`.
///- __showTitle__: Set to `false` if the title shouldn't be shown in the custom tab. The default value is `true`.
///- __toolbarBackgroundColor__: Set the custom background color of the toolbar.
///- __enableUrlBarHiding__: Set to `true` to enable the url bar to hide as the user scrolls down on the page. The default value is `false`.
///- __instantAppsEnabled__: Set to `true` to enable Instant Apps. The default value is `false`.
///
///**iOS** supports these options:
///
///- __entersReaderIfAvailable__: Set to `true` if Reader mode should be entered automatically when it is available for the webpage. The default value is `false`.
///- __barCollapsingEnabled__: Set to `true` to enable bar collapsing. The default value is `false`.
///- __dismissButtonStyle__: Set the custom style for the dismiss button. The default value is `0 //done`. See [SFSafariViewController.DismissButtonStyle](https://developer.apple.com/documentation/safariservices/sfsafariviewcontroller/dismissbuttonstyle) for all the available styles.
///- __preferredBarTintColor__: Set the custom background color of the navigation bar and the toolbar.
///- __preferredControlTintColor__: Set the custom color of the control buttons on the navigation bar and the toolbar.
///- __presentationStyle__: Set the custom modal presentation style when presenting the WebView. The default value is `0 //fullscreen`. See [UIModalPresentationStyle](https://developer.apple.com/documentation/uikit/uimodalpresentationstyle) for all the available styles.
///- __transitionStyle__: Set to the custom transition style when presenting the WebView. The default value is `0 //crossDissolve`. See [UIModalTransitionStyle](https://developer.apple.com/documentation/uikit/uimodaltransitionStyle) for all the available styles.
Future<void> open(String url, {ChromeSafariBrowserClassOptions options, Map<String, String> headersFallback = const {}, InAppBrowserClassOptions optionsFallback}) async {
///[optionsFallback]: Options used by the [InAppBrowser] instance fallback.
Future<void> open({@required String url, ChromeSafariBrowserClassOptions options, Map<String, String> headersFallback = const {}, InAppBrowserClassOptions optionsFallback}) async {
assert(url != null && url.isNotEmpty);
this.throwIsAlreadyOpened(message: 'Cannot open $url!');
......
import 'package:flutter/foundation.dart';
///ContentBlocker class represents a set of rules to use block content in the browser window.
///
///On iOS, it uses [WKContentRuleListStore](https://developer.apple.com/documentation/webkit/wkcontentruleliststore).
///On Android, it uses a custom implementation because such functionality doesn't exist.
///
///In general, this [article](https://developer.apple.com/documentation/safariservices/creating_a_content_blocker) can be used to get an overview about this functionality
///but on Android there are two types of [action] that are unavailable: `block-cookies` and `ignore-previous-rules`.
class ContentBlocker {
///Trigger of the content blocker. The trigger tells to the WebView when to perform the corresponding action.
ContentBlockerTrigger trigger;
///Action associated to the trigger. The action tells to the WebView what to do when the trigger is matched.
ContentBlockerAction action;
ContentBlocker(this.trigger, this.action);
ContentBlocker({@required this.trigger,@required this.action});
Map<String, Map<String, dynamic>> toMap() {
return {
......@@ -14,22 +24,22 @@ class ContentBlocker {
static ContentBlocker fromMap(Map<dynamic, Map<dynamic, dynamic>> map) {
return ContentBlocker(
ContentBlockerTrigger.fromMap(
trigger: ContentBlockerTrigger.fromMap(
Map<String, dynamic>.from(map["trigger"])
),
ContentBlockerAction.fromMap(
action: ContentBlockerAction.fromMap(
Map<String, dynamic>.from(map["action"])
)
);
}
}
///
///ContentBlockerTriggerResourceType class represents the possible resource type defined for a [ContentBlockerTrigger].
class ContentBlockerTriggerResourceType {
final String _value;
const ContentBlockerTriggerResourceType._internal(this._value);
static ContentBlockerTriggerResourceType fromValue(String value) {
return (["document", "image", "LINK", "style-sheet", "script", "font",
return (["document", "image", "style-sheet", "script", "font",
"media", "svg-document", "raw"].contains(value)) ? ContentBlockerTriggerResourceType._internal(value) : null;
}
toValue() => _value;
......@@ -41,10 +51,11 @@ class ContentBlockerTriggerResourceType {
static const FONT = const ContentBlockerTriggerResourceType._internal('font');
static const MEDIA = const ContentBlockerTriggerResourceType._internal('media');
static const SVG_DOCUMENT = const ContentBlockerTriggerResourceType._internal('svg-document');
///Any untyped load
static const RAW = const ContentBlockerTriggerResourceType._internal('raw');
}
///
///ContentBlockerTriggerLoadType class represents the possible load type for a [ContentBlockerTrigger].
class ContentBlockerTriggerLoadType {
final String _value;
const ContentBlockerTriggerLoadType._internal(this._value);
......@@ -53,25 +64,44 @@ class ContentBlockerTriggerLoadType {
}
toValue() => _value;
///FIRST_PARTY is triggered only if the resource has the same scheme, domain, and port as the main page resource.
static const FIRST_PARTY = const ContentBlockerTriggerLoadType._internal('first-party');
///THIRD_PARTY is triggered if the resource is not from the same domain as the main page resource.
static const THIRD_PARTY = const ContentBlockerTriggerLoadType._internal('third-party');
}
///
///Trigger of the content blocker. The trigger tells to the WebView when to perform the corresponding action.
///A trigger dictionary must include an [ContentBlockerTrigger.urlFilter], which specifies a pattern to match the URL against.
///The remaining properties are optional and modify the behavior of the trigger.
///For example, you can limit the trigger to specific domains or have it not apply when a match is found on a specific domain.
class ContentBlockerTrigger {
///A regular expression pattern to match the URL against.
String urlFilter;
///Used only by iOS. A Boolean value. The default value is false.
bool urlFilterIsCaseSensitive;
///A list of [ContentBlockerTriggerResourceType] representing the resource types (how the browser intends to use the resource) that the rule should match.
///If not specified, the rule matches all resource types.
List<ContentBlockerTriggerResourceType> resourceType;
///A list of strings matched to a URL's domain; limits action to a list of specific domains.
///Values must be lowercase ASCII, or punycode for non-ASCII. Add * in front to match domain and subdomains. Can't be used with [ContentBlockerTrigger.unlessDomain].
List<String> ifDomain;
///A list of strings matched to a URL's domain; acts on any site except domains in a provided list.
///Values must be lowercase ASCII, or punycode for non-ASCII. Add * in front to match domain and subdomains. Can't be used with [ContentBlockerTrigger.ifDomain].
List<String> unlessDomain;
///A list of [ContentBlockerTriggerLoadType] that can include one of two mutually exclusive values. If not specified, the rule matches all load types.
List<ContentBlockerTriggerLoadType> loadType;
///A list of strings matched to the entire main document URL; limits the action to a specific list of URL patterns.
///Values must be lowercase ASCII, or punycode for non-ASCII. Can't be used with [ContentBlockerTrigger.unlessTopUrl].
List<String> ifTopUrl;
///An array of strings matched to the entire main document URL; acts on any site except URL patterns in provided list.
///Values must be lowercase ASCII, or punycode for non-ASCII. Can't be used with [ContentBlockerTrigger.ifTopUrl].
List<String> unlessTopUrl;
ContentBlockerTrigger(String urlFilter, {bool urlFilterIsCaseSensitive = false, List<ContentBlockerTriggerResourceType> resourceType = const [],
ContentBlockerTrigger({@required String urlFilter, bool urlFilterIsCaseSensitive = false, List<ContentBlockerTriggerResourceType> resourceType = const [],
List<String> ifDomain = const [], List<String> unlessDomain = const [], List<ContentBlockerTriggerLoadType> loadType = const [],
List<String> ifTopUrl = const [], List<String> unlessTopUrl = const []}) {
this.urlFilter = urlFilter;
assert(this.urlFilter != null);
this.resourceType = resourceType;
this.urlFilterIsCaseSensitive = urlFilterIsCaseSensitive;
this.ifDomain = ifDomain;
......@@ -128,7 +158,7 @@ class ContentBlockerTrigger {
});
return ContentBlockerTrigger(
map["url-filter"],
urlFilter: map["url-filter"],
urlFilterIsCaseSensitive: map["url-filter-is-case-sensitive"],
ifDomain: List<String>.from(map["if-domain"] ?? []),
unlessDomain: List<String>.from(map["unless-domain"] ?? []),
......@@ -140,7 +170,7 @@ class ContentBlockerTrigger {
}
}
///
///ContentBlockerActionType class represents the kind of action that can be used with a [ContentBlockerTrigger].
class ContentBlockerActionType {
final String _value;
const ContentBlockerActionType._internal(this._value);
......@@ -149,18 +179,31 @@ class ContentBlockerActionType {
}
toValue() => _value;
///Stops loading of the resource. If the resource was cached, the cache is ignored.
static const BLOCK = const ContentBlockerActionType._internal('block');
///Hides elements of the page based on a CSS selector. A selector field contains the selector list. Any matching element has its display property set to none, which hides it.
///
///**NOTE**: on Android, JavaScript must be enabled.
static const CSS_DISPLAY_NONE = const ContentBlockerActionType._internal('css-display-none');
///Changes a URL from http to https. URLs with a specified (nondefault) port and links using other protocols are unaffected.
static const MAKE_HTTPS = const ContentBlockerActionType._internal('make-https');
}
///
///Action associated to the trigger. The action tells to the WebView what to do when the trigger is matched.
///When a trigger matches a resource, the browser queues the associated action for execution.
///The WebView evaluates all the triggers, it executes the actions in order.
///When a domain matches a trigger, all rules after the triggered rule that specify the same action are skipped.
///Group the rules with similar actions together to improve performance.
class ContentBlockerAction {
///Type of the action.
ContentBlockerActionType type;
///If the action type is [ContentBlockerActionType.CSS_DISPLAY_NONE], then also the [selector] property is required, otherwise it is ignored.
///It specify a string that defines a selector list. Use CSS identifiers as the individual selector values, separated by commas.
String selector;
ContentBlockerAction(ContentBlockerActionType type, {String selector}) {
ContentBlockerAction({@required ContentBlockerActionType type, String selector}) {
this.type = type;
assert(this.type != null);
if (this.type == ContentBlockerActionType.CSS_DISPLAY_NONE) {
assert(selector != null);
}
......@@ -183,7 +226,7 @@ class ContentBlockerAction {
static ContentBlockerAction fromMap(Map<String, dynamic> map) {
return ContentBlockerAction(
ContentBlockerActionType.fromValue(map["type"]),
type: ContentBlockerActionType.fromValue(map["type"]),
selector: map["selector"]
);
}
......
import 'dart:async';
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
///Manages the cookies used by WebView instances.
......@@ -26,8 +27,8 @@ class CookieManager {
///
///The default value of [path] is `"/"`.
///If [domain] is `null`, its default value will be the domain name of [url].
Future<void> setCookie(String url, String name, String value,
{ String domain,
Future<void> setCookie({@required String url, @required String name, @required String value,
String domain,
String path = "/",
int expiresDate,
int maxAge,
......@@ -55,7 +56,7 @@ class CookieManager {
}
///Gets all the cookies for the given [url].
Future<List<Map<String, dynamic>>> getCookies(String url) async {
Future<List<Map<String, dynamic>>> getCookies({@required String url}) async {
assert(url != null && url.isNotEmpty);
Map<String, dynamic> args = <String, dynamic>{};
......@@ -70,7 +71,7 @@ class CookieManager {
}
///Gets a cookie by its [name] for the given [url].
Future<Map<String, dynamic>> getCookie(String url, String name) async {
Future<Map<String, dynamic>> getCookie({@required String url, @required String name}) async {
assert(url != null && url.isNotEmpty);
assert(name != null && name.isNotEmpty);
......@@ -90,7 +91,7 @@ class CookieManager {
///
///The default value of [path] is `"/"`.
///If [domain] is `null` or empty, its default value will be the domain name of [url].
Future<void> deleteCookie(String url, String name, {String domain = "", String path = "/"}) async {
Future<void> deleteCookie({@required String url, @required String name, String domain = "", String path = "/"}) async {
if (domain == null || domain.isEmpty)
domain = _getDomainName(url);
......@@ -111,7 +112,7 @@ class CookieManager {
///
///The default value of [path] is `"/"`.
///If [domain] is `null` or empty, its default value will be the domain name of [url].
Future<void> deleteCookies(String url, {String domain = "", String path = "/"}) async {
Future<void> deleteCookies({@required String url, String domain = "", String path = "/"}) async {
if (domain == null || domain.isEmpty)
domain = _getDomainName(url);
......
import 'dart:async';
import 'package:flutter/foundation.dart';
import 'types.dart';
import 'package:flutter/services.dart';
///
///HttpAuthCredentialDatabase class implements a singleton object (shared instance) which manages the shared HTTP auth credentials cache.
///On iOS, this class uses the [URLCredentialStorage](https://developer.apple.com/documentation/foundation/urlcredentialstorage) class.
///On Android, this class has a custom implementation using `android.database.sqlite.SQLiteDatabase` because [WebViewDatabase](https://developer.android.com/reference/android/webkit/WebViewDatabase)
///doesn't offer the same functionalities as iOS `URLCredentialStorage`.
class HttpAuthCredentialDatabase {
static HttpAuthCredentialDatabase _instance;
static const MethodChannel _channel = const MethodChannel('com.pichillilorenzo/flutter_inappbrowser_credential_database');
///
///Gets the database shared instance.
static HttpAuthCredentialDatabase instance() {
return (_instance != null) ? _instance : _init();
}
......@@ -22,7 +27,9 @@ class HttpAuthCredentialDatabase {
static Future<dynamic> _handleMethod(MethodCall call) async {
}
///
///Gets a map list of all HTTP auth credentials saved.
///Each map contains the key `protectionSpace` of type [ProtectionSpace]
///and the key `credentials` of type `List<HttpAuthCredential>` that contains all the HTTP auth credentials saved for that `protectionSpace`.
Future<List<Map<String, dynamic>>> getAllAuthCredentials() async {
Map<String, dynamic> args = <String, dynamic>{};
List<dynamic> allCredentials = await _channel.invokeMethod('getAllAuthCredentials', args);
......@@ -38,8 +45,8 @@ class HttpAuthCredentialDatabase {
return result;
}
///
Future<List<HttpAuthCredential>> getHttpAuthCredentials(ProtectionSpace protectionSpace) async {
///Gets all the HTTP auth credentials saved for that [protectionSpace].
Future<List<HttpAuthCredential>> getHttpAuthCredentials({@required ProtectionSpace protectionSpace}) async {
Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent("host", () => protectionSpace.host);
args.putIfAbsent("protocol", () => protectionSpace.protocol);
......@@ -53,8 +60,8 @@ class HttpAuthCredentialDatabase {
return credentials;
}
///
Future<void> setHttpAuthCredential(ProtectionSpace protectionSpace, HttpAuthCredential credential) async {
///Saves an HTTP auth [credential] for that [protectionSpace].
Future<void> setHttpAuthCredential({@required ProtectionSpace protectionSpace, @required HttpAuthCredential credential}) async {
Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent("host", () => protectionSpace.host);
args.putIfAbsent("protocol", () => protectionSpace.protocol);
......@@ -65,8 +72,8 @@ class HttpAuthCredentialDatabase {
await _channel.invokeMethod('setHttpAuthCredential', args);
}
///
Future<void> removeHttpAuthCredential(ProtectionSpace protectionSpace, HttpAuthCredential credential) async {
///Removes an HTTP auth [credential] for that [protectionSpace].
Future<void> removeHttpAuthCredential({@required ProtectionSpace protectionSpace, @required HttpAuthCredential credential}) async {
Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent("host", () => protectionSpace.host);
args.putIfAbsent("protocol", () => protectionSpace.protocol);
......@@ -77,8 +84,8 @@ class HttpAuthCredentialDatabase {
await _channel.invokeMethod('removeHttpAuthCredential', args);
}
///
Future<void> removeHttpAuthCredentials(ProtectionSpace protectionSpace) async {
///Removes all the HTTP auth credentials saved for that [protectionSpace].
Future<void> removeHttpAuthCredentials({@required ProtectionSpace protectionSpace}) async {
Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent("host", () => protectionSpace.host);
args.putIfAbsent("protocol", () => protectionSpace.protocol);
......@@ -87,7 +94,7 @@ class HttpAuthCredentialDatabase {
await _channel.invokeMethod('removeHttpAuthCredentials', args);
}
///
///Removes all the HTTP auth credentials saved in the database.
Future<void> clearAllAuthCredentials() async {
Map<String, dynamic> args = <String, dynamic>{};
await _channel.invokeMethod('clearAllAuthCredentials', args);
......
This diff is collapsed.
This diff is collapsed.
......@@ -3,7 +3,7 @@ import 'dart:typed_data';
import 'package:uuid/uuid.dart';
import 'package:flutter/services.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'webview_options.dart';
......@@ -54,7 +54,7 @@ class LoadedResource {
///Returns the [DOMHighResTimeStamp](https://developer.mozilla.org/en-US/docs/Web/API/DOMHighResTimeStamp) duration to fetch a resource.
double duration;
LoadedResource(this.initiatorType, this.url, this.startTime, this.duration);
LoadedResource({this.initiatorType, this.url, this.startTime, this.duration});
}
......@@ -67,7 +67,7 @@ class InAppWebViewInitialData {
String encoding;
String baseUrl;
InAppWebViewInitialData(this.data, {this.mimeType = "text/html", this.encoding = "utf8", this.baseUrl = "about:blank"});
InAppWebViewInitialData({@required this.data, this.mimeType = "text/html", this.encoding = "utf8", this.baseUrl = "about:blank"});
Map<String, String> toMap() {
return {
......@@ -120,7 +120,7 @@ class CustomSchemeResponse {
///Content-Enconding of the data, such as `utf-8`.
String contentEnconding;
CustomSchemeResponse(this.data, this.contentType, {this.contentEnconding = 'utf-8'});
CustomSchemeResponse({@required this.data, @required this.contentType, this.contentEnconding = 'utf-8'});
Map<String, dynamic> toJson() {
return {
......@@ -137,25 +137,24 @@ class CustomSchemeResponse {
///To receive notifications of these messages, use the [onConsoleMessage] event.
class ConsoleMessage {
String sourceURL = "";
int lineNumber = 1;
String message = "";
ConsoleMessageLevel messageLevel = ConsoleMessageLevel.LOG;
String sourceURL;
int lineNumber;
String message;
ConsoleMessageLevel messageLevel;
ConsoleMessage(this.sourceURL, this.lineNumber, this.message, this.messageLevel);
ConsoleMessage({this.sourceURL = "", this.lineNumber = 1, this.message = "", this.messageLevel = ConsoleMessageLevel.LOG});
}
///WebHistory class.
///
///This class contains a snapshot of the current back/forward list for a WebView.
class WebHistory {
List<WebHistoryItem> _list;
///List of all [WebHistoryItem]s.
List<WebHistoryItem> get list => _list;
List<WebHistoryItem> list;
///Index of the current [WebHistoryItem].
int currentIndex;
WebHistory(this._list, this.currentIndex);
WebHistory({this.list, this.currentIndex});
}
///WebHistoryItem class.
......@@ -173,7 +172,7 @@ class WebHistoryItem {
///Position offset respect to the currentIndex of the back-forward [WebHistory.list].
int offset;
WebHistoryItem(this.originalUrl, this.title, this.url, this.index, this.offset);
WebHistoryItem({this.originalUrl, this.title, this.url, this.index, this.offset});
}
///GeolocationPermissionPromptResponse class.
......@@ -187,7 +186,7 @@ class GeolocationPermissionShowPromptResponse {
///Whether the permission should be retained beyond the lifetime of a page currently being displayed by a WebView
bool retain;
GeolocationPermissionShowPromptResponse(this.origin, this.allow, this.retain);
GeolocationPermissionShowPromptResponse({this.origin, this.allow, this.retain});
Map<String, dynamic> toMap() {
return {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment