Skip to content

Commit

Permalink
Merge branch 'v6.2.0-beta.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
pichillilorenzo committed Nov 5, 2024
2 parents c7de95b + e92723a commit f9353d6
Show file tree
Hide file tree
Showing 38 changed files with 69 additions and 90 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class CredentialDatabase: ChannelDelegate {
private var plugin: SwiftFlutterPlugin?

init(plugin: SwiftFlutterPlugin) {
super.init(channel: FlutterMethodChannel(name: CredentialDatabase.METHOD_CHANNEL_NAME, binaryMessenger: plugin.registrar!.messenger()))
super.init(channel: FlutterMethodChannel(name: CredentialDatabase.METHOD_CHANNEL_NAME, binaryMessenger: plugin.registrar.messenger()))
self.plugin = plugin
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,9 @@ public class FindInteractionController: NSObject, Disposable {
self.plugin = plugin
self.webView = webView
self.settings = settings
if let registrar = plugin.registrar {
let channel = FlutterMethodChannel(name: FindInteractionController.METHOD_CHANNEL_NAME_PREFIX + String(describing: id),
binaryMessenger: registrar.messenger())
self.channelDelegate = FindInteractionChannelDelegate(findInteractionController: self, channel: channel)
}
let channel = FlutterMethodChannel(name: FindInteractionController.METHOD_CHANNEL_NAME_PREFIX + String(describing: id),
binaryMessenger: plugin.registrar.messenger())
self.channelDelegate = FindInteractionChannelDelegate(findInteractionController: self, channel: channel)
}

public func prepare() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class HeadlessInAppWebView: Disposable {
self.flutterWebView = flutterWebView
self.plugin = plugin
let channel = FlutterMethodChannel(name: HeadlessInAppWebView.METHOD_CHANNEL_NAME_PREFIX + id,
binaryMessenger: plugin.registrar!.messenger())
binaryMessenger: plugin.registrar.messenger())
self.channelDelegate = HeadlessWebViewChannelDelegate(headlessWebView: self, channel: channel)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class HeadlessInAppWebViewManager: ChannelDelegate {
var webViews: [String: HeadlessInAppWebView?] = [:]

init(plugin: SwiftFlutterPlugin) {
super.init(channel: FlutterMethodChannel(name: HeadlessInAppWebViewManager.METHOD_CHANNEL_NAME, binaryMessenger: plugin.registrar!.messenger()))
super.init(channel: FlutterMethodChannel(name: HeadlessInAppWebViewManager.METHOD_CHANNEL_NAME, binaryMessenger: plugin.registrar.messenger()))
self.plugin = plugin
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class InAppBrowserManager: ChannelDelegate {
var navControllers: [String: InAppBrowserNavigationController?] = [:]

init(plugin: SwiftFlutterPlugin) {
super.init(channel: FlutterMethodChannel(name: InAppBrowserManager.METHOD_CHANNEL_NAME, binaryMessenger: plugin.registrar!.messenger()))
super.init(channel: FlutterMethodChannel(name: InAppBrowserManager.METHOD_CHANNEL_NAME, binaryMessenger: plugin.registrar.messenger()))
self.plugin = plugin
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ public class InAppBrowserWebViewController: UIViewController, InAppBrowserDelega
var menuItems: [InAppBrowserMenuItem] = []

public override func loadView() {
guard let plugin = plugin, let registrar = plugin.registrar else {
guard let plugin = plugin else {
return
}

let channel = FlutterMethodChannel(name: InAppBrowserWebViewController.METHOD_CHANNEL_NAME_PREFIX + id, binaryMessenger: registrar.messenger())
let channel = FlutterMethodChannel(name: InAppBrowserWebViewController.METHOD_CHANNEL_NAME_PREFIX + id, binaryMessenger: plugin.registrar.messenger())
channelDelegate = InAppBrowserChannelDelegate(channel: channel)

var userScripts: [UserScript] = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,9 @@ public class FlutterWebViewController: NSObject, FlutterPlatformView, Disposable
webView = webViewTransport.webView
webView!.id = viewId
webView!.plugin = plugin
if let registrar = plugin.registrar {
let channel = FlutterMethodChannel(name: InAppWebView.METHOD_CHANNEL_NAME_PREFIX + String(describing: viewId),
binaryMessenger: registrar.messenger())
webView!.channelDelegate = WebViewChannelDelegate(webView: webView!, channel: channel)
}
let channel = FlutterMethodChannel(name: InAppWebView.METHOD_CHANNEL_NAME_PREFIX + String(describing: viewId),
binaryMessenger: plugin.registrar.messenger())
webView!.channelDelegate = WebViewChannelDelegate(webView: webView!, channel: channel)
webView!.frame = myView!.bounds
webView!.contextMenu = contextMenu
webView!.initialUserScripts = userScripts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class InAppWebViewManager: ChannelDelegate {
var windowAutoincrementId: Int64 = 0

init(plugin: SwiftFlutterPlugin) {
super.init(channel: FlutterMethodChannel(name: InAppWebViewManager.METHOD_CHANNEL_NAME, binaryMessenger: plugin.registrar!.messenger()))
super.init(channel: FlutterMethodChannel(name: InAppWebViewManager.METHOD_CHANNEL_NAME, binaryMessenger: plugin.registrar.messenger()))
self.plugin = plugin
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,9 @@ public class WebMessageChannel: FlutterMethodCallDelegate {
self.id = id
self.plugin = plugin
super.init()
if let registrar = plugin.registrar {
let channel = FlutterMethodChannel(name: WebMessageChannel.METHOD_CHANNEL_NAME_PREFIX + id,
binaryMessenger: registrar.messenger())
self.channelDelegate = WebMessageChannelChannelDelegate(webMessageChannel: self, channel: channel)
}
let channel = FlutterMethodChannel(name: WebMessageChannel.METHOD_CHANNEL_NAME_PREFIX + id,
binaryMessenger: plugin.registrar.messenger())
self.channelDelegate = WebMessageChannelChannelDelegate(webMessageChannel: self, channel: channel)
self.ports = [
WebMessagePort(name: "port1", index: 0, webMessageChannelId: self.id, webMessageChannel: self),
WebMessagePort(name: "port2", index: 1, webMessageChannelId: self.id, webMessageChannel: self)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,9 @@ public class WebMessageListener: FlutterMethodCallDelegate {
self.jsObjectName = jsObjectName
self.allowedOriginRules = allowedOriginRules
super.init()
if let registrar = plugin.registrar {
let channel = FlutterMethodChannel(name: WebMessageListener.METHOD_CHANNEL_NAME_PREFIX + self.id + "_" + self.jsObjectName,
binaryMessenger: registrar.messenger())
self.channelDelegate = WebMessageListenerChannelDelegate(webMessageListener: self, channel: channel)
}
let channel = FlutterMethodChannel(name: WebMessageListener.METHOD_CHANNEL_NAME_PREFIX + self.id + "_" + self.jsObjectName,
binaryMessenger: plugin.registrar.messenger())
self.channelDelegate = WebMessageListenerChannelDelegate(webMessageListener: self, channel: channel)
}

public func assertOriginRulesValid() throws {
Expand Down
2 changes: 1 addition & 1 deletion flutter_inappwebview_ios/ios/Classes/MyCookieManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class MyCookieManager: ChannelDelegate {
private var plugin: SwiftFlutterPlugin?

init(plugin: SwiftFlutterPlugin) {
super.init(channel: FlutterMethodChannel(name: MyCookieManager.METHOD_CHANNEL_NAME, binaryMessenger: plugin.registrar!.messenger()))
super.init(channel: FlutterMethodChannel(name: MyCookieManager.METHOD_CHANNEL_NAME, binaryMessenger: plugin.registrar.messenger()))
self.plugin = plugin
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class MyWebStorageManager: ChannelDelegate {
private var plugin: SwiftFlutterPlugin?

init(plugin: SwiftFlutterPlugin) {
super.init(channel: FlutterMethodChannel(name: MyWebStorageManager.METHOD_CHANNEL_NAME, binaryMessenger: plugin.registrar!.messenger()))
super.init(channel: FlutterMethodChannel(name: MyWebStorageManager.METHOD_CHANNEL_NAME, binaryMessenger: plugin.registrar.messenger()))
self.plugin = plugin
}

Expand Down
2 changes: 1 addition & 1 deletion flutter_inappwebview_ios/ios/Classes/PlatformUtil.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class PlatformUtil: ChannelDelegate {
var plugin: SwiftFlutterPlugin?

init(plugin: SwiftFlutterPlugin) {
super.init(channel: FlutterMethodChannel(name: PlatformUtil.METHOD_CHANNEL_NAME, binaryMessenger: plugin.registrar!.messenger()))
super.init(channel: FlutterMethodChannel(name: PlatformUtil.METHOD_CHANNEL_NAME, binaryMessenger: plugin.registrar.messenger()))
self.plugin = plugin
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,9 @@ public class PrintJobController: NSObject, Disposable, UIPrintInteractionControl
self.printFormatter = job?.printFormatter
self.printPageRenderer = job?.printPageRenderer
self.job?.delegate = self
if let registrar = plugin.registrar {
let channel = FlutterMethodChannel(name: PrintJobController.METHOD_CHANNEL_NAME_PREFIX + id,
binaryMessenger: registrar.messenger())
self.channelDelegate = PrintJobChannelDelegate(printJobController: self, channel: channel)
}
let channel = FlutterMethodChannel(name: PrintJobController.METHOD_CHANNEL_NAME_PREFIX + id,
binaryMessenger: plugin.registrar.messenger())
self.channelDelegate = PrintJobChannelDelegate(printJobController: self, channel: channel)
}

public func printInteractionControllerWillStartJob(_ printInteractionController: UIPrintInteractionController) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,9 @@ public class PullToRefreshControl: UIRefreshControl, Disposable {
super.init()
self.plugin = plugin
self.settings = settings
if let registrar = plugin.registrar {
let channel = FlutterMethodChannel(name: PullToRefreshControl.METHOD_CHANNEL_NAME_PREFIX + String(describing: id),
binaryMessenger: registrar.messenger())
self.channelDelegate = PullToRefreshChannelDelegate(pullToRefreshControl: self, channel: channel)
}
let channel = FlutterMethodChannel(name: PullToRefreshControl.METHOD_CHANNEL_NAME_PREFIX + String(describing: id),
binaryMessenger: plugin.registrar.messenger())
self.channelDelegate = PullToRefreshChannelDelegate(pullToRefreshControl: self, channel: channel)
}

required init?(coder: NSCoder) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class ChromeSafariBrowserManager: ChannelDelegate {
var prewarmingTokens: [String: Any?] = [:]

init(plugin: SwiftFlutterPlugin) {
super.init(channel: FlutterMethodChannel(name: ChromeSafariBrowserManager.METHOD_CHANNEL_NAME, binaryMessenger: plugin.registrar!.messenger()))
super.init(channel: FlutterMethodChannel(name: ChromeSafariBrowserManager.METHOD_CHANNEL_NAME, binaryMessenger: plugin.registrar.messenger()))
self.plugin = plugin
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class SafariViewController: SFSafariViewController, SFSafariViewControlle
SafariViewController.prepareConfig(configuration: configuration, safariSettings: safariSettings)
super.init(url: url, configuration: configuration)
let channel = FlutterMethodChannel(name: SafariViewController.METHOD_CHANNEL_NAME_PREFIX + id,
binaryMessenger: plugin.registrar!.messenger())
binaryMessenger: plugin.registrar.messenger())
self.channelDelegate = SafariViewControllerChannelDelegate(safariViewController: self, channel: channel)
self.delegate = self
}
Expand All @@ -38,7 +38,7 @@ public class SafariViewController: SFSafariViewController, SFSafariViewControlle
self.safariSettings = safariSettings
super.init(url: url, entersReaderIfAvailable: entersReaderIfAvailable)
let channel = FlutterMethodChannel(name: SafariViewController.METHOD_CHANNEL_NAME_PREFIX + id,
binaryMessenger: plugin.registrar!.messenger())
binaryMessenger: plugin.registrar.messenger())
self.channelDelegate = SafariViewControllerChannelDelegate(safariViewController: self, channel: channel)
self.delegate = self
}
Expand Down
5 changes: 3 additions & 2 deletions flutter_inappwebview_ios/ios/Classes/SwiftFlutterPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import SafariServices

public class SwiftFlutterPlugin: NSObject, FlutterPlugin {

var registrar: FlutterPluginRegistrar?
var registrar: FlutterPluginRegistrar
var platformUtil: PlatformUtil?
var inAppWebViewManager: InAppWebViewManager?
var myCookieManager: Any?
Expand All @@ -40,9 +40,10 @@ public class SwiftFlutterPlugin: NSObject, FlutterPlugin {
var safariViewControllers: [String: Any?] = [:]

public init(with registrar: FlutterPluginRegistrar) {
self.registrar = registrar

super.init()

self.registrar = registrar
registrar.register(FlutterWebViewFactory(plugin: self) as FlutterPlatformViewFactory, withId: FlutterWebViewFactory.VIEW_TYPE_ID)

platformUtil = PlatformUtil(plugin: self)
Expand Down
8 changes: 4 additions & 4 deletions flutter_inappwebview_ios/ios/Classes/Util.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ var SharedLastTouchPointTimestamp: [InAppWebView: Int64] = [:]

public class Util {
public static func getUrlAsset(plugin: SwiftFlutterPlugin, assetFilePath: String) throws -> URL {
guard let key = plugin.registrar?.lookupKey(forAsset: assetFilePath),
let assetURL = Bundle.main.url(forResource: key, withExtension: nil) else {
let key = plugin.registrar.lookupKey(forAsset: assetFilePath)
guard let assetURL = Bundle.main.url(forResource: key, withExtension: nil) else {
throw NSError(domain: assetFilePath + " asset file cannot be found!", code: 0)
}
return assetURL
}

public static func getAbsPathAsset(plugin: SwiftFlutterPlugin, assetFilePath: String) throws -> String {
guard let key = plugin.registrar?.lookupKey(forAsset: assetFilePath),
let assetAbsPath = Bundle.main.path(forResource: key, ofType: nil) else {
let key = plugin.registrar.lookupKey(forAsset: assetFilePath)
guard let assetAbsPath = Bundle.main.path(forResource: key, ofType: nil) else {
throw NSError(domain: assetFilePath + " asset file cannot be found!", code: 0)
}
return assetAbsPath
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class WebAuthenticationSession: NSObject, ASWebAuthenticationPresentation
self.session = SFAuthenticationSession(url: self.url, callbackURLScheme: self.callbackURLScheme, completionHandler: self.completionHandler)
}
let channel = FlutterMethodChannel(name: WebAuthenticationSession.METHOD_CHANNEL_NAME_PREFIX + id,
binaryMessenger: plugin.registrar!.messenger())
binaryMessenger: plugin.registrar.messenger())
self.channelDelegate = WebAuthenticationSessionChannelDelegate(webAuthenticationSession: self, channel: channel)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class WebAuthenticationSessionManager: ChannelDelegate {
var sessions: [String: WebAuthenticationSession?] = [:]

init(plugin: SwiftFlutterPlugin) {
super.init(channel: FlutterMethodChannel(name: WebAuthenticationSessionManager.METHOD_CHANNEL_NAME, binaryMessenger: plugin.registrar!.messenger()))
super.init(channel: FlutterMethodChannel(name: WebAuthenticationSessionManager.METHOD_CHANNEL_NAME, binaryMessenger: plugin.registrar.messenger()))
self.plugin = plugin
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class CredentialDatabase: ChannelDelegate {
static var credentialStore = URLCredentialStorage.shared

init(plugin: InAppWebViewFlutterPlugin) {
super.init(channel: FlutterMethodChannel(name: CredentialDatabase.METHOD_CHANNEL_NAME, binaryMessenger: plugin.registrar!.messenger))
super.init(channel: FlutterMethodChannel(name: CredentialDatabase.METHOD_CHANNEL_NAME, binaryMessenger: plugin.registrar.messenger))
self.plugin = plugin
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,9 @@ public class FindInteractionController: NSObject, Disposable {
self.plugin = plugin
self.webView = webView
self.settings = settings
if let registrar = plugin.registrar {
let channel = FlutterMethodChannel(name: FindInteractionController.METHOD_CHANNEL_NAME_PREFIX + String(describing: id),
binaryMessenger: registrar.messenger)
self.channelDelegate = FindInteractionChannelDelegate(findInteractionController: self, channel: channel)
}
let channel = FlutterMethodChannel(name: FindInteractionController.METHOD_CHANNEL_NAME_PREFIX + String(describing: id),
binaryMessenger: plugin.registrar.messenger)
self.channelDelegate = FindInteractionChannelDelegate(findInteractionController: self, channel: channel)
}

public func prepare() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class HeadlessInAppWebView: Disposable {
self.flutterWebView = flutterWebView
self.plugin = plugin
let channel = FlutterMethodChannel(name: HeadlessInAppWebView.METHOD_CHANNEL_NAME_PREFIX + id,
binaryMessenger: plugin.registrar!.messenger)
binaryMessenger: plugin.registrar.messenger)
self.channelDelegate = HeadlessWebViewChannelDelegate(headlessWebView: self, channel: channel)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class HeadlessInAppWebViewManager: ChannelDelegate {
var webViews: [String: HeadlessInAppWebView?] = [:]

init(plugin: InAppWebViewFlutterPlugin) {
super.init(channel: FlutterMethodChannel(name: HeadlessInAppWebViewManager.METHOD_CHANNEL_NAME, binaryMessenger: plugin.registrar!.messenger))
super.init(channel: FlutterMethodChannel(name: HeadlessInAppWebViewManager.METHOD_CHANNEL_NAME, binaryMessenger: plugin.registrar.messenger))
self.plugin = plugin
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class InAppBrowserManager: ChannelDelegate {
var plugin: InAppWebViewFlutterPlugin?

init(plugin: InAppWebViewFlutterPlugin) {
super.init(channel: FlutterMethodChannel(name: InAppBrowserManager.METHOD_CHANNEL_NAME, binaryMessenger: plugin.registrar!.messenger))
super.init(channel: FlutterMethodChannel(name: InAppBrowserManager.METHOD_CHANNEL_NAME, binaryMessenger: plugin.registrar.messenger))
self.plugin = plugin
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ public class InAppBrowserWebViewController: NSViewController, InAppBrowserDelega
var isHidden = false

public override func loadView() {
guard let plugin = plugin, let registrar = plugin.registrar else {
guard let plugin = plugin else {
return
}

let channel = FlutterMethodChannel(name: InAppBrowserWebViewController.METHOD_CHANNEL_NAME_PREFIX + id, binaryMessenger: registrar.messenger)
let channel = FlutterMethodChannel(name: InAppBrowserWebViewController.METHOD_CHANNEL_NAME_PREFIX + id, binaryMessenger: plugin.registrar.messenger)
channelDelegate = InAppBrowserChannelDelegate(channel: channel)

var userScripts: [UserScript] = []
Expand Down
Loading

0 comments on commit f9353d6

Please sign in to comment.