updated context menu item and options to settings

This commit is contained in:
Lorenzo Pichilli 2022-04-23 14:00:47 +02:00
parent 68305a365b
commit b881909957
27 changed files with 279 additions and 225 deletions

View File

@ -2,8 +2,8 @@ package com.pichillilorenzo.flutter_inappwebview;
import java.util.Map;
public interface IWebViewSettings<T> {
public IWebViewSettings parse(Map<String, Object> settings);
public interface ISettings<T> {
public ISettings parse(Map<String, Object> settings);
public Map<String, Object> toMap();
public Map<String, Object> getRealSettings(T obj);
}

View File

@ -7,14 +7,14 @@ import androidx.browser.customtabs.CustomTabsIntent;
import androidx.browser.trusted.ScreenOrientation;
import androidx.browser.trusted.TrustedWebActivityDisplayMode;
import com.pichillilorenzo.flutter_inappwebview.IWebViewSettings;
import com.pichillilorenzo.flutter_inappwebview.ISettings;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class ChromeCustomTabsSettings implements IWebViewSettings<ChromeCustomTabsActivity> {
public class ChromeCustomTabsSettings implements ISettings<ChromeCustomTabsActivity> {
final static String LOG_TAG = "ChromeCustomTabsSettings";

View File

@ -2,13 +2,13 @@ package com.pichillilorenzo.flutter_inappwebview.in_app_browser;
import androidx.annotation.Nullable;
import com.pichillilorenzo.flutter_inappwebview.IWebViewSettings;
import com.pichillilorenzo.flutter_inappwebview.ISettings;
import com.pichillilorenzo.flutter_inappwebview.R;
import java.util.HashMap;
import java.util.Map;
public class InAppBrowserSettings implements IWebViewSettings<InAppBrowserActivity> {
public class InAppBrowserSettings implements ISettings<InAppBrowserActivity> {
public static final String LOG_TAG = "InAppBrowserSettings";

View File

@ -1,16 +1,16 @@
package com.pichillilorenzo.flutter_inappwebview.in_app_webview;
import com.pichillilorenzo.flutter_inappwebview.IWebViewSettings;
import com.pichillilorenzo.flutter_inappwebview.ISettings;
import java.util.HashMap;
import java.util.Map;
public class ContextMenuOptions implements IWebViewSettings<Object> {
public class ContextMenuSettings implements ISettings<Object> {
public static final String LOG_TAG = "ContextMenuOptions";
public Boolean hideDefaultSystemContextMenuItems = false;
public ContextMenuOptions parse(Map<String, Object> options) {
public ContextMenuSettings parse(Map<String, Object> options) {
for (Map.Entry<String, Object> pair : options.entrySet()) {
String key = pair.getKey();
Object value = pair.getValue();

View File

@ -55,6 +55,7 @@ import androidx.webkit.WebViewFeature;
import com.pichillilorenzo.flutter_inappwebview.InAppWebViewFlutterPlugin;
import com.pichillilorenzo.flutter_inappwebview.types.DownloadStartRequest;
import com.pichillilorenzo.flutter_inappwebview.types.HitTestResult;
import com.pichillilorenzo.flutter_inappwebview.types.InAppWebViewInterface;
import com.pichillilorenzo.flutter_inappwebview.JavaScriptBridgeInterface;
import com.pichillilorenzo.flutter_inappwebview.R;
@ -1367,17 +1368,17 @@ final public class InAppWebView extends InputAwareWebView implements InAppWebVie
LinearLayout menuItemListLayout = (LinearLayout) horizontalScrollView.getChildAt(0);
List<Map<String, Object>> customMenuItems = new ArrayList<>();
ContextMenuOptions contextMenuOptions = new ContextMenuOptions();
ContextMenuSettings contextMenuSettings = new ContextMenuSettings();
if (contextMenu != null) {
customMenuItems = (List<Map<String, Object>>) contextMenu.get("menuItems");
Map<String, Object> contextMenuOptionsMap = (Map<String, Object>) contextMenu.get("options");
Map<String, Object> contextMenuOptionsMap = (Map<String, Object>) contextMenu.get("settings");
if (contextMenuOptionsMap != null) {
contextMenuOptions.parse(contextMenuOptionsMap);
contextMenuSettings.parse(contextMenuOptionsMap);
}
}
customMenuItems = customMenuItems == null ? new ArrayList<Map<String, Object>>() : customMenuItems;
if (contextMenuOptions.hideDefaultSystemContextMenuItems == null || !contextMenuOptions.hideDefaultSystemContextMenuItems) {
if (contextMenuSettings.hideDefaultSystemContextMenuItems == null || !contextMenuSettings.hideDefaultSystemContextMenuItems) {
for (int i = 0; i < actionMenu.size(); i++) {
final MenuItem menuItem = actionMenu.getItem(i);
final int itemId = menuItem.getItemId();
@ -1393,6 +1394,7 @@ final public class InAppWebView extends InputAwareWebView implements InAppWebVie
callback.onActionItemClicked(actionMode, menuItem);
Map<String, Object> obj = new HashMap<>();
obj.put("id", itemId);
obj.put("androidId", itemId);
obj.put("iosId", null);
obj.put("title", itemTitle);
@ -1406,7 +1408,7 @@ final public class InAppWebView extends InputAwareWebView implements InAppWebVie
}
for (final Map<String, Object> menuItem : customMenuItems) {
final int itemId = (int) menuItem.get("androidId");
final int itemId = (int) menuItem.get("id");
final String itemTitle = (String) menuItem.get("title");
TextView text = (TextView) LayoutInflater.from(this.getContext())
.inflate(R.layout.floating_action_mode_item, this, false);
@ -1417,6 +1419,7 @@ final public class InAppWebView extends InputAwareWebView implements InAppWebVie
hideContextMenu();
Map<String, Object> obj = new HashMap<>();
obj.put("id", itemId);
obj.put("androidId", itemId);
obj.put("iosId", null);
obj.put("title", itemTitle);

View File

@ -6,7 +6,7 @@ import android.webkit.WebSettings;
import androidx.annotation.Nullable;
import com.pichillilorenzo.flutter_inappwebview.IWebViewSettings;
import com.pichillilorenzo.flutter_inappwebview.ISettings;
import com.pichillilorenzo.flutter_inappwebview.types.InAppWebViewInterface;
import com.pichillilorenzo.flutter_inappwebview.types.PreferredContentModeOptionType;
@ -18,7 +18,7 @@ import java.util.Map;
import static android.webkit.WebSettings.LayoutAlgorithm.NARROW_COLUMNS;
import static android.webkit.WebSettings.LayoutAlgorithm.NORMAL;
public class InAppWebViewSettings implements IWebViewSettings<InAppWebViewInterface> {
public class InAppWebViewSettings implements ISettings<InAppWebViewInterface> {
public static final String LOG_TAG = "InAppWebViewSettings";

View File

@ -2,12 +2,12 @@ package com.pichillilorenzo.flutter_inappwebview.pull_to_refresh;
import androidx.annotation.Nullable;
import com.pichillilorenzo.flutter_inappwebview.IWebViewSettings;
import com.pichillilorenzo.flutter_inappwebview.ISettings;
import java.util.HashMap;
import java.util.Map;
public class PullToRefreshSettings implements IWebViewSettings<PullToRefreshLayout> {
public class PullToRefreshSettings implements ISettings<PullToRefreshLayout> {
public static final String LOG_TAG = "PullToRefreshSettings";
public Boolean enabled = true;

View File

@ -71,8 +71,7 @@ class _ChromeSafariBrowserExampleScreenState
keepAliveEnabled: true,
dismissButtonStyle: DismissButtonStyle.CLOSE,
presentationStyle:
ModalPresentationStyle.OVER_FULL_SCREEN
));
ModalPresentationStyle.OVER_FULL_SCREEN));
},
child: Text("Open Chrome Safari Browser")),
));

View File

@ -1,11 +1,7 @@
import 'dart:collection';
// import 'dart:convert';
import 'dart:io';
// import 'dart:typed_data';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
// import 'package:path_provider/path_provider.dart';
import 'package:url_launcher/url_launcher.dart';
import 'main.dart';
@ -17,7 +13,6 @@ class InAppWebViewExampleScreen extends StatefulWidget {
}
class _InAppWebViewExampleScreenState extends State<InAppWebViewExampleScreen> {
final GlobalKey webViewKey = GlobalKey();
InAppWebViewController? webViewController;
@ -25,8 +20,7 @@ class _InAppWebViewExampleScreenState extends State<InAppWebViewExampleScreen> {
useShouldOverrideUrlLoading: true,
mediaPlaybackRequiresUserGesture: false,
useHybridComposition: true,
allowsInlineMediaPlayback: true
);
allowsInlineMediaPlayback: true);
late PullToRefreshController pullToRefreshController;
late ContextMenu contextMenu;
@ -41,8 +35,7 @@ class _InAppWebViewExampleScreenState extends State<InAppWebViewExampleScreen> {
contextMenu = ContextMenu(
menuItems: [
ContextMenuItem(
androidId: 1,
iosId: "1",
id: 1,
title: "Special",
action: () async {
print("Menu item Special clicked!");
@ -50,7 +43,7 @@ class _InAppWebViewExampleScreenState extends State<InAppWebViewExampleScreen> {
await webViewController?.clearFocus();
})
],
options: ContextMenuOptions(hideDefaultSystemContextMenuItems: false),
settings: ContextMenuSettings(hideDefaultSystemContextMenuItems: false),
onCreateContextMenu: (hitTestResult) async {
print("onCreateContextMenu");
print(hitTestResult.extra);
@ -60,9 +53,7 @@ class _InAppWebViewExampleScreenState extends State<InAppWebViewExampleScreen> {
print("onHideContextMenu");
},
onContextMenuActionItemClicked: (contextMenuItemClicked) async {
var id = (Platform.isAndroid)
? contextMenuItemClicked.androidId
: contextMenuItemClicked.iosId;
var id = contextMenuItemClicked.id;
print("onContextMenuActionItemClicked: " +
id.toString() +
" " +
@ -74,9 +65,9 @@ class _InAppWebViewExampleScreenState extends State<InAppWebViewExampleScreen> {
color: Colors.blue,
),
onRefresh: () async {
if (Platform.isAndroid) {
if (defaultTargetPlatform == TargetPlatform.android) {
webViewController?.reload();
} else if (Platform.isIOS) {
} else if (defaultTargetPlatform == TargetPlatform.iOS || defaultTargetPlatform == TargetPlatform.macOS) {
webViewController?.loadUrl(
urlRequest: URLRequest(url: await webViewController?.getUrl()));
}
@ -97,9 +88,7 @@ class _InAppWebViewExampleScreenState extends State<InAppWebViewExampleScreen> {
body: SafeArea(
child: Column(children: <Widget>[
TextField(
decoration: InputDecoration(
prefixIcon: Icon(Icons.search)
),
decoration: InputDecoration(prefixIcon: Icon(Icons.search)),
controller: urlController,
keyboardType: TextInputType.url,
onSubmitted: (value) {
@ -107,8 +96,7 @@ class _InAppWebViewExampleScreenState extends State<InAppWebViewExampleScreen> {
if (url.scheme.isEmpty) {
url = Uri.parse("https://www.google.com/search?q=" + value);
}
webViewController?.loadUrl(
urlRequest: URLRequest(url: url));
webViewController?.loadUrl(urlRequest: URLRequest(url: url));
},
),
Expanded(
@ -122,6 +110,7 @@ class _InAppWebViewExampleScreenState extends State<InAppWebViewExampleScreen> {
// initialFile: "assets/index.html",
initialUserScripts: UnmodifiableListView<UserScript>([]),
initialSettings: settings,
// contextMenu: contextMenu,
pullToRefreshController: pullToRefreshController,
onWebViewCreated: (controller) {
webViewController = controller;
@ -137,7 +126,8 @@ class _InAppWebViewExampleScreenState extends State<InAppWebViewExampleScreen> {
resources: request.resources,
action: PermissionResponseAction.GRANT);
},
shouldOverrideUrlLoading: (controller, navigationAction) async {
shouldOverrideUrlLoading:
(controller, navigationAction) async {
var uri = navigationAction.request.url!;
if (![

View File

@ -31,8 +31,7 @@ Future main() async {
ServiceWorkerController serviceWorkerController =
ServiceWorkerController.instance();
await serviceWorkerController
.setServiceWorkerClient(ServiceWorkerClient(
await serviceWorkerController.setServiceWorkerClient(ServiceWorkerClient(
shouldInterceptRequest: (request) async {
print(request);
return null;

View File

@ -7,7 +7,7 @@
import Foundation
class ContextMenuOptions: IWebViewSettings<NSObject> {
class ContextMenuSettings: ISettings<NSObject> {
var hideDefaultSystemContextMenuItems = false;

View File

@ -8,13 +8,13 @@
import Foundation
@objcMembers
public class IWebViewSettings<T>: NSObject {
public class ISettings<T>: NSObject {
override init(){
super.init()
}
func parse(settings: [String: Any?]) -> IWebViewSettings {
func parse(settings: [String: Any?]) -> ISettings {
for (key, value) in settings {
if !(value is NSNull), value != nil, self.responds(to: Selector(key)) {
self.setValue(value, forKey: key)

View File

@ -8,7 +8,7 @@
import Foundation
@objcMembers
public class InAppBrowserSettings: IWebViewSettings<InAppBrowserWebViewController> {
public class InAppBrowserSettings: ISettings<InAppBrowserWebViewController> {
var hidden = false
var hideToolbarTop = true

View File

@ -203,13 +203,15 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate, WKNavi
if let menu = self.contextMenu {
if let menuItems = menu["menuItems"] as? [[String : Any]] {
for menuItem in menuItems {
let id = menuItem["iosId"] as! String
let id = menuItem["id"]!
let title = menuItem["title"] as! String
let targetMethodName = "onContextMenuActionItemClicked-" + String(self.hash) + "-" + id
let targetMethodName = "onContextMenuActionItemClicked-" + String(self.hash) + "-" +
(id is Int64 ? String(id as! Int64) : id as! String)
if !self.responds(to: Selector(targetMethodName)) {
let customAction: () -> Void = {
let arguments: [String: Any?] = [
"iosId": id,
"id": id,
"iosId": id is Int64 ? String(id as! Int64) : id as! String,
"androidId": nil,
"title": title
]
@ -244,10 +246,10 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate, WKNavi
}
if let menu = contextMenu {
let contextMenuOptions = ContextMenuOptions()
if let contextMenuOptionsMap = menu["options"] as? [String: Any?] {
let _ = contextMenuOptions.parse(settings: contextMenuOptionsMap)
if !action.description.starts(with: "onContextMenuActionItemClicked-") && contextMenuOptions.hideDefaultSystemContextMenuItems {
let contextMenuSettings = ContextMenuSettings()
if let contextMenuSettingsMap = menu["settings"] as? [String: Any?] {
let _ = contextMenuSettings.parse(settings: contextMenuSettingsMap)
if !action.description.starts(with: "onContextMenuActionItemClicked-") && contextMenuSettings.hideDefaultSystemContextMenuItems {
return false
}
}
@ -256,6 +258,7 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate, WKNavi
if contextMenuIsShowing, !action.description.starts(with: "onContextMenuActionItemClicked-") {
let id = action.description.compactMap({ $0.asciiValue?.description }).joined()
let arguments: [String: Any?] = [
"id": id,
"iosId": id,
"androidId": nil,
"title": action.description

View File

@ -9,7 +9,7 @@ import Foundation
import WebKit
@objcMembers
public class InAppWebViewSettings: IWebViewSettings<InAppWebView> {
public class InAppWebViewSettings: ISettings<InAppWebView> {
var useShouldOverrideUrlLoading = false
var useOnLoadResource = false

View File

@ -7,7 +7,7 @@
import Foundation
public class PullToRefreshSettings : IWebViewSettings<PullToRefreshControl> {
public class PullToRefreshSettings : ISettings<PullToRefreshControl> {
var enabled = true
var color: String?

View File

@ -9,7 +9,7 @@ import Foundation
@available(iOS 9.0, *)
@objcMembers
public class SafariBrowserSettings: IWebViewSettings<SafariViewController> {
public class SafariBrowserSettings: ISettings<SafariViewController> {
var entersReaderIfAvailable = false
var barCollapsingEnabled = false

View File

@ -242,8 +242,8 @@ class ChromeSafariBrowserSettings implements ChromeSafariBrowserOptions {
settings.additionalTrustedOrigins = map["additionalTrustedOrigins"];
switch (map["displayMode"]["type"]) {
case "IMMERSIVE_MODE":
settings.displayMode =
TrustedWebActivityImmersiveDisplayMode.fromMap(map["displayMode"]);
settings.displayMode = TrustedWebActivityImmersiveDisplayMode.fromMap(
map["displayMode"]);
break;
case "DEFAULT_MODE":
default:

View File

@ -1,3 +1,5 @@
import 'package:flutter/foundation.dart';
import 'in_app_webview/webview.dart';
import 'types.dart';
@ -20,9 +22,13 @@ class ContextMenu {
final void Function(ContextMenuItem contextMenuItemClicked)?
onContextMenuActionItemClicked;
///Context menu options.
///Use [settings] instead
@Deprecated("Use settings instead")
final ContextMenuOptions? options;
///Context menu settings.
final ContextMenuSettings? settings;
///List of the custom [ContextMenuItem].
final List<ContextMenuItem> menuItems;
@ -31,12 +37,14 @@ class ContextMenu {
this.onCreateContextMenu,
this.onHideContextMenu,
this.options,
this.settings,
this.onContextMenuActionItemClicked});
Map<String, dynamic> toMap() {
return {
"menuItems": menuItems.map((menuItem) => menuItem.toMap()).toList(),
"options": options?.toMap()
// ignore: deprecated_member_use_from_same_package
"settings": settings?.toMap() ?? options?.toMap()
};
}
@ -52,12 +60,19 @@ class ContextMenu {
///Class that represent an item of the [ContextMenu].
class ContextMenuItem {
///Android menu item ID.
///Use [id] instead.
@Deprecated("Use id instead")
int? androidId;
///iOS menu item ID.
///Use [id] instead.
@Deprecated("Use id instead")
String? iosId;
///Menu item ID. It cannot be `null` and it can be a [String] or an [int].
///
///**NOTE for Android**: it must be an [int] value.
dynamic id;
///Menu item title.
String title;
@ -65,10 +80,31 @@ class ContextMenuItem {
Function()? action;
ContextMenuItem(
{this.androidId, this.iosId, required this.title, this.action});
{this.id,
this.androidId,
this.iosId,
required this.title,
this.action}) {
if (defaultTargetPlatform == TargetPlatform.android) {
// ignore: deprecated_member_use_from_same_package
this.id = this.id ?? this.androidId;
assert(this.id is int);
} else if (defaultTargetPlatform == TargetPlatform.iOS) {
// ignore: deprecated_member_use_from_same_package
this.id = this.id ?? this.iosId;
}
assert(this.id != null && (this.id is int || this.id is String));
}
Map<String, dynamic> toMap() {
return {"androidId": androidId, "iosId": iosId, "title": title};
return {
"id": id,
// ignore: deprecated_member_use_from_same_package
"androidId": androidId,
// ignore: deprecated_member_use_from_same_package
"iosId": iosId,
"title": title
};
}
Map<String, dynamic> toJson() {
@ -81,7 +117,31 @@ class ContextMenuItem {
}
}
///Class that represents available options used by [ContextMenu].
///Class that represents available settings used by [ContextMenu].
class ContextMenuSettings {
///Whether all the default system context menu items should be hidden or not. The default value is `false`.
bool hideDefaultSystemContextMenuItems;
ContextMenuSettings({this.hideDefaultSystemContextMenuItems = false});
Map<String, dynamic> toMap() {
return {
"hideDefaultSystemContextMenuItems": hideDefaultSystemContextMenuItems
};
}
Map<String, dynamic> toJson() {
return this.toMap();
}
@override
String toString() {
return toMap().toString();
}
}
///Use [ContextMenuSettings] instead.
@Deprecated("Use ContextMenuSettings instead")
class ContextMenuOptions {
///Whether all the default system context menu items should be hidden or not. The default value is `false`.
bool hideDefaultSystemContextMenuItems;

View File

@ -107,7 +107,8 @@ abstract class AppleInAppWebViewControllerMixin {
///- iOS ([Official API - WKWebView.requestMediaPlaybackState](https://developer.apple.com/documentation/webkit/wkwebview/3752241-requestmediaplaybackstate)).
Future<MediaPlaybackState?> requestMediaPlaybackState() async {
Map<String, dynamic> args = <String, dynamic>{};
return MediaPlaybackState.fromValue(await _channel.invokeMethod('requestMediaPlaybackState', args));
return MediaPlaybackState.fromValue(
await _channel.invokeMethod('requestMediaPlaybackState', args));
}
}

View File

@ -469,8 +469,7 @@ class InAppWebView extends StatefulWidget implements WebView {
NavigationResponse navigationResponse)? onNavigationResponse;
@override
final Future<PermissionResponse?> Function(
InAppWebViewController controller,
final Future<PermissionResponse?> Function(InAppWebViewController controller,
PermissionRequest permissionRequest)? onPermissionRequest;
@override

View File

@ -748,11 +748,12 @@ class InAppWebViewController
?.toMap();
}
} else {
return (await _inAppBrowser!
.onPermissionRequest(permissionRequest))?.toMap() ??
return (await _inAppBrowser!.onPermissionRequest(permissionRequest))
?.toMap() ??
(await _inAppBrowser!
// ignore: deprecated_member_use_from_same_package
.androidOnPermissionRequest(origin, resources))?.toMap();
.androidOnPermissionRequest(origin, resources))
?.toMap();
}
}
break;
@ -945,16 +946,18 @@ class InAppWebViewController
if (contextMenu != null) {
int? androidId = call.arguments["androidId"];
String? iosId = call.arguments["iosId"];
dynamic id = call.arguments["id"];
String title = call.arguments["title"];
ContextMenuItem menuItemClicked = ContextMenuItem(
androidId: androidId, iosId: iosId, title: title, action: null);
id: id,
androidId: androidId,
iosId: iosId,
title: title,
action: null);
for (var menuItem in contextMenu.menuItems) {
if ((defaultTargetPlatform == TargetPlatform.android &&
menuItem.androidId == androidId) ||
(defaultTargetPlatform == TargetPlatform.iOS &&
menuItem.iosId == iosId)) {
if (menuItem.id == id) {
menuItemClicked = menuItem;
if (menuItem.action != null) {
menuItem.action!();
@ -1847,7 +1850,8 @@ class InAppWebViewController
///Use [setSettings] instead.
@Deprecated('Use setSettings instead')
Future<void> setOptions({required InAppWebViewGroupOptions options}) async {
InAppWebViewSettings settings = InAppWebViewSettings.fromMap(options.toMap());
InAppWebViewSettings settings =
InAppWebViewSettings.fromMap(options.toMap());
await setSettings(settings: settings);
}
@ -2306,7 +2310,8 @@ class InAppWebViewController
try {
Map<String, dynamic> args = <String, dynamic>{};
themeColor = UtilColor.fromStringRepresentation(await _channel.invokeMethod('getMetaThemeColor', args));
themeColor = UtilColor.fromStringRepresentation(
await _channel.invokeMethod('getMetaThemeColor', args));
} catch (e) {
// not implemented
}

View File

@ -1430,9 +1430,11 @@ class InAppWebViewSettings
settings.disableLongPressContextMenuOnLinks =
map["disableLongPressContextMenuOnLinks"];
settings.disableInputAccessoryView = map["disableInputAccessoryView"];
settings.underPageBackgroundColor = UtilColor.fromHex(map["underPageBackgroundColor"]);
settings.underPageBackgroundColor =
UtilColor.fromHex(map["underPageBackgroundColor"]);
settings.isTextInteractionEnabled = map["isTextInteractionEnabled"];
settings.isSiteSpecificQuirksModeEnabled = map["isSiteSpecificQuirksModeEnabled"];
settings.isSiteSpecificQuirksModeEnabled =
map["isSiteSpecificQuirksModeEnabled"];
settings.upgradeKnownHostsToHTTPS = map["upgradeKnownHostsToHTTPS"];
}
return settings;

View File

@ -510,8 +510,7 @@ abstract class WebView {
///
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebChromeClient.onPermissionRequest](https://developer.android.com/reference/android/webkit/WebChromeClient#onPermissionRequest(android.webkit.PermissionRequest)))
final Future<PermissionResponse?> Function(
InAppWebViewController controller,
final Future<PermissionResponse?> Function(InAppWebViewController controller,
PermissionRequest permissionRequest)? onPermissionRequest;
///Use [onGeolocationPermissionsShowPrompt] instead.

View File

@ -4769,7 +4769,8 @@ class PermissionResourceType {
PermissionResourceType.RESOURCE_VIDEO_CAPTURE,
].toSet();
static final Set<PermissionResourceType> _appleValues = <PermissionResourceType>[
static final Set<PermissionResourceType> _appleValues =
<PermissionResourceType>[
PermissionResourceType.CAMERA,
PermissionResourceType.MICROPHONE,
PermissionResourceType.CAMERA_AND_MICROPHONE,
@ -4779,7 +4780,8 @@ class PermissionResourceType {
static PermissionResourceType? fromValue(dynamic? value) {
if (value != null) {
try {
Set<PermissionResourceType> valueList = <PermissionResourceType>[].toSet();
Set<PermissionResourceType> valueList =
<PermissionResourceType>[].toSet();
if (Platform.isAndroid) {
valueList = PermissionResourceType._androidValues;
} else if (Platform.isIOS || Platform.isMacOS) {
@ -4815,40 +4817,39 @@ class PermissionResourceType {
///Resource belongs to audio capture device, like microphone.
///
///**NOTE**: available only on Android.
static const RESOURCE_AUDIO_CAPTURE = const PermissionResourceType._internal('android.webkit.resource.AUDIO_CAPTURE');
static const RESOURCE_AUDIO_CAPTURE = const PermissionResourceType._internal(
'android.webkit.resource.AUDIO_CAPTURE');
///Resource will allow sysex messages to be sent to or received from MIDI devices.
///These messages are privileged operations, e.g. modifying sound libraries and sampling data, or even updating the MIDI device's firmware.
///Permission may be requested for this resource in API levels 21 and above, if the Android device has been updated to WebView 45 or above.
///
///**NOTE**: available only on Android.
static const RESOURCE_MIDI_SYSEX =
const PermissionResourceType._internal('android.webkit.resource.MIDI_SYSEX');
static const RESOURCE_MIDI_SYSEX = const PermissionResourceType._internal(
'android.webkit.resource.MIDI_SYSEX');
///Resource belongs to protected media identifier. After the user grants this resource, the origin can use EME APIs to generate the license requests.
///
///**NOTE**: available only on Android.
static const RESOURCE_PROTECTED_MEDIA_ID =
const PermissionResourceType._internal('android.webkit.resource.PROTECTED_MEDIA_ID');
const PermissionResourceType._internal(
'android.webkit.resource.PROTECTED_MEDIA_ID');
///Resource belongs to video capture device, like camera.
///
///**NOTE**: available only on Android.
static const RESOURCE_VIDEO_CAPTURE =
const PermissionResourceType._internal('android.webkit.resource.VIDEO_CAPTURE');
static const RESOURCE_VIDEO_CAPTURE = const PermissionResourceType._internal(
'android.webkit.resource.VIDEO_CAPTURE');
///A media device that can capture video.
///
///**NOTE**: available only on iOS.
static const CAMERA =
const PermissionResourceType._internal(0);
static const CAMERA = const PermissionResourceType._internal(0);
///A media device that can capture audio.
///
///**NOTE**: available only on iOS.
static const MICROPHONE =
const PermissionResourceType._internal(1);
static const MICROPHONE = const PermissionResourceType._internal(1);
///A media device or devices that can capture audio and video.
///
@ -4880,9 +4881,7 @@ class PermissionRequest {
FrameInfo? frame;
PermissionRequest(
{required this.origin,
this.resources = const [],
this.frame});
{required this.origin, this.resources = const [], this.frame});
static PermissionRequest? fromMap(Map<String, dynamic>? map) {
if (map == null) {
@ -4891,8 +4890,7 @@ class PermissionRequest {
List<PermissionResourceType> resources = [];
if (map["resources"] != null) {
(map["resources"].cast<dynamic>() as List<dynamic>)
.forEach((element) {
(map["resources"].cast<dynamic>() as List<dynamic>).forEach((element) {
var resource = PermissionResourceType.fromValue(element);
if (resource != null) {
resources.add(resource);
@ -4933,8 +4931,7 @@ class PermissionResponse {
PermissionResponseAction? action;
PermissionResponse(
{this.resources = const [],
this.action = PermissionResponseAction.DENY});
{this.resources = const [], this.action = PermissionResponseAction.DENY});
Map<String, dynamic> toMap() {
return {
@ -10688,16 +10685,13 @@ class MediaPlaybackState {
static const NONE = const MediaPlaybackState._internal(0);
///The media is playing.
static const PLAYING =
const MediaPlaybackState._internal(1);
static const PLAYING = const MediaPlaybackState._internal(1);
///The media playback is paused.
static const PAUSED =
const MediaPlaybackState._internal(2);
static const PAUSED = const MediaPlaybackState._internal(2);
///The media is not playing, and cannot be resumed until the user revokes the suspension.
static const SUSPENDED =
const MediaPlaybackState._internal(3);
static const SUSPENDED = const MediaPlaybackState._internal(3);
bool operator ==(value) => value == _value;