Skip to content
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

Add support allowUniversalAccessFromFileURLs iOS #655

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ios/Classes/InAppWebView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1371,6 +1371,8 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate, WKNavi
configuration.dataDetectorTypes = dataDetectorTypes

configuration.mediaTypesRequiringUserActionForPlayback = options.mediaPlaybackRequiresUserGesture ? .all : []

configuration.setValue(options.allowUniversalAccessFromFileURLs, forKey: "allowUniversalAccessFromFileURLs")
} else {
// Fallback on earlier versions
configuration.mediaPlaybackRequiresUserAction = options.mediaPlaybackRequiresUserGesture
Expand Down
2 changes: 2 additions & 0 deletions ios/Classes/InAppWebViewOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ public class InAppWebViewOptions: Options<InAppWebView> {
var minimumZoomScale = 1.0
var contentInsetAdjustmentBehavior = 2 // UIScrollView.ContentInsetAdjustmentBehavior.never

var allowUniversalAccessFromFileURLs = false;

override init(){
super.init()
}
Expand Down
12 changes: 10 additions & 2 deletions lib/src/webview_options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -832,6 +832,9 @@ class IOSInAppWebViewOptions
///The default value is [IOSUIScrollViewContentInsetAdjustmentBehavior.NEVER].
IOSUIScrollViewContentInsetAdjustmentBehavior contentInsetAdjustmentBehavior;

///Set to true to support cross-domain. The default value is `false`.
bool allowUniversalAccessFromFileURLs;

IOSInAppWebViewOptions(
{this.disallowOverScroll = false,
this.enableViewportScale = false,
Expand All @@ -856,7 +859,8 @@ class IOSInAppWebViewOptions
this.maximumZoomScale = 1.0,
this.minimumZoomScale = 1.0,
this.contentInsetAdjustmentBehavior =
IOSUIScrollViewContentInsetAdjustmentBehavior.NEVER});
IOSUIScrollViewContentInsetAdjustmentBehavior.NEVER,
this.allowUniversalAccessFromFileURLs = false});

@override
Map<String, dynamic> toMap() {
Expand Down Expand Up @@ -891,7 +895,9 @@ class IOSInAppWebViewOptions
"isPagingEnabled": isPagingEnabled,
"maximumZoomScale": maximumZoomScale,
"minimumZoomScale": minimumZoomScale,
"contentInsetAdjustmentBehavior": contentInsetAdjustmentBehavior.toValue()
"contentInsetAdjustmentBehavior":
contentInsetAdjustmentBehavior.toValue(),
"allowUniversalAccessFromFileURLs": allowUniversalAccessFromFileURLs
};
}

Expand Down Expand Up @@ -938,6 +944,8 @@ class IOSInAppWebViewOptions
options.contentInsetAdjustmentBehavior =
IOSUIScrollViewContentInsetAdjustmentBehavior.fromValue(
map["contentInsetAdjustmentBehavior"]);
options.allowUniversalAccessFromFileURLs =
map["allowUniversalAccessFromFileURLs"];
return options;
}

Expand Down