2018-09-14 00:21:51 +00:00
|
|
|
/*
|
|
|
|
Licensed to the Apache Software Foundation (ASF) under one
|
|
|
|
or more contributor license agreements. See the NOTICE file
|
|
|
|
distributed with this work for additional information
|
|
|
|
regarding copyright ownership. The ASF licenses this file
|
|
|
|
to you under the Apache License, Version 2.0 (the
|
|
|
|
"License"); you may not use this file except in compliance
|
|
|
|
with the License. You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing,
|
|
|
|
software distributed under the License is distributed on an
|
|
|
|
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
|
|
KIND, either express or implied. See the License for the
|
|
|
|
specific language governing permissions and limitations
|
|
|
|
under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
import Flutter
|
|
|
|
import UIKit
|
|
|
|
import WebKit
|
|
|
|
import Foundation
|
|
|
|
import AVFoundation
|
2018-09-26 00:56:56 +00:00
|
|
|
import SafariServices
|
2018-09-14 00:21:51 +00:00
|
|
|
|
|
|
|
public class SwiftFlutterPlugin: NSObject, FlutterPlugin {
|
2018-10-15 23:27:58 +00:00
|
|
|
|
2019-10-26 02:42:50 +00:00
|
|
|
var registrar: FlutterPluginRegistrar?
|
2021-03-01 02:21:07 +00:00
|
|
|
var platformUtil: PlatformUtil?
|
2023-05-18 22:45:12 +00:00
|
|
|
var inAppWebViewManager: InAppWebViewManager?
|
2019-12-18 20:34:40 +00:00
|
|
|
var myCookieManager: Any?
|
|
|
|
var myWebStorageManager: Any?
|
|
|
|
var credentialDatabase: CredentialDatabase?
|
|
|
|
var inAppBrowserManager: InAppBrowserManager?
|
2020-05-11 00:48:41 +00:00
|
|
|
var headlessInAppWebViewManager: HeadlessInAppWebViewManager?
|
2019-12-18 20:34:40 +00:00
|
|
|
var chromeSafariBrowserManager: ChromeSafariBrowserManager?
|
2022-05-08 23:51:21 +00:00
|
|
|
var webAuthenticationSessionManager: WebAuthenticationSessionManager?
|
2022-05-11 22:19:43 +00:00
|
|
|
var printJobManager: PrintJobManager?
|
2018-10-15 23:27:58 +00:00
|
|
|
|
2018-09-30 19:52:56 +00:00
|
|
|
var webViewControllers: [String: InAppBrowserWebViewController?] = [:]
|
|
|
|
var safariViewControllers: [String: Any?] = [:]
|
2018-09-14 00:21:51 +00:00
|
|
|
|
|
|
|
public init(with registrar: FlutterPluginRegistrar) {
|
2019-10-26 02:42:50 +00:00
|
|
|
super.init()
|
2019-11-04 00:39:23 +00:00
|
|
|
|
2019-10-26 02:42:50 +00:00
|
|
|
self.registrar = registrar
|
2023-05-18 22:45:12 +00:00
|
|
|
registrar.register(FlutterWebViewFactory(plugin: self) as FlutterPlatformViewFactory, withId: FlutterWebViewFactory.VIEW_TYPE_ID)
|
2018-11-13 11:02:20 +00:00
|
|
|
|
2023-05-16 18:06:53 +00:00
|
|
|
platformUtil = PlatformUtil(plugin: self)
|
|
|
|
inAppBrowserManager = InAppBrowserManager(plugin: self)
|
|
|
|
headlessInAppWebViewManager = HeadlessInAppWebViewManager(plugin: self)
|
|
|
|
chromeSafariBrowserManager = ChromeSafariBrowserManager(plugin: self)
|
2023-05-18 22:45:12 +00:00
|
|
|
inAppWebViewManager = InAppWebViewManager(plugin: self)
|
2023-05-16 18:06:53 +00:00
|
|
|
credentialDatabase = CredentialDatabase(plugin: self)
|
2018-10-27 19:07:00 +00:00
|
|
|
if #available(iOS 11.0, *) {
|
2023-05-16 18:06:53 +00:00
|
|
|
myCookieManager = MyCookieManager(plugin: self)
|
2018-10-27 19:07:00 +00:00
|
|
|
}
|
2019-12-16 22:58:10 +00:00
|
|
|
if #available(iOS 9.0, *) {
|
2023-05-16 18:06:53 +00:00
|
|
|
myWebStorageManager = MyWebStorageManager(plugin: self)
|
2019-11-02 03:16:47 +00:00
|
|
|
}
|
2023-05-16 18:06:53 +00:00
|
|
|
webAuthenticationSessionManager = WebAuthenticationSessionManager(plugin: self)
|
2023-05-18 22:45:12 +00:00
|
|
|
printJobManager = PrintJobManager(plugin: self)
|
2019-11-02 03:16:47 +00:00
|
|
|
}
|
|
|
|
|
2019-12-18 20:34:40 +00:00
|
|
|
public static func register(with registrar: FlutterPluginRegistrar) {
|
2023-05-16 18:06:53 +00:00
|
|
|
let _ = SwiftFlutterPlugin(with: registrar)
|
2019-12-16 22:58:10 +00:00
|
|
|
}
|
2022-04-23 02:02:37 +00:00
|
|
|
|
|
|
|
public func detachFromEngine(for registrar: FlutterPluginRegistrar) {
|
|
|
|
platformUtil?.dispose()
|
|
|
|
platformUtil = nil
|
|
|
|
inAppBrowserManager?.dispose()
|
|
|
|
inAppBrowserManager = nil
|
|
|
|
headlessInAppWebViewManager?.dispose()
|
|
|
|
headlessInAppWebViewManager = nil
|
|
|
|
chromeSafariBrowserManager?.dispose()
|
|
|
|
chromeSafariBrowserManager = nil
|
2023-05-18 22:45:12 +00:00
|
|
|
inAppWebViewManager?.dispose()
|
|
|
|
inAppWebViewManager = nil
|
2022-04-23 02:02:37 +00:00
|
|
|
credentialDatabase?.dispose()
|
|
|
|
credentialDatabase = nil
|
|
|
|
if #available(iOS 11.0, *) {
|
|
|
|
(myCookieManager as! MyCookieManager?)?.dispose()
|
|
|
|
myCookieManager = nil
|
|
|
|
}
|
|
|
|
if #available(iOS 9.0, *) {
|
|
|
|
(myWebStorageManager as! MyWebStorageManager?)?.dispose()
|
|
|
|
myWebStorageManager = nil
|
|
|
|
}
|
2022-05-08 23:51:21 +00:00
|
|
|
webAuthenticationSessionManager?.dispose()
|
|
|
|
webAuthenticationSessionManager = nil
|
2022-05-11 22:19:43 +00:00
|
|
|
printJobManager?.dispose()
|
|
|
|
printJobManager = nil
|
2022-04-23 02:02:37 +00:00
|
|
|
}
|
2018-09-14 00:21:51 +00:00
|
|
|
}
|