-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathOSIABEngine.swift
More file actions
36 lines (32 loc) · 1.93 KB
/
OSIABEngine.swift
File metadata and controls
36 lines (32 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import UIKit
/// Structure responsible for managing all InAppBrowser interactions.
public struct OSIABEngine<ExternalBrowser: OSIABRouter, SystemBrowser: OSIABRouter, WebView: OSIABRouter>
where ExternalBrowser.ReturnType == Bool, SystemBrowser.ReturnType == UIViewController, WebView.ReturnType == UIViewController {
/// Constructor method.
public init() {
// Empty constructor
// This is required for the library's callers.
}
/// Delegates opening the passed `url`to the External Browser.
/// - Parameter url: URL to be opened.
/// - Parameter routerDelegate: The External Browser that will open the url.`
/// - Parameter completionHandler: The callback with the result of opening the url using the External Browser.
public func openExternalBrowser(_ url: URL, routerDelegate: ExternalBrowser, _ completionHandler: @escaping (ExternalBrowser.ReturnType) -> Void) {
routerDelegate.handleOpen(url, completionHandler)
}
/// Delegates opening the passed `url`to the System Browser.
/// - Parameter url: URL to be opened.
/// - Parameter routerDelegate: The System Browser that will open the url.`
/// - Parameter completionHandler: The callback with the result of opening the url using the System Browser.
public func openSystemBrowser(_ url: URL, routerDelegate: SystemBrowser, _ completionHandler: @escaping (SystemBrowser.ReturnType) -> Void) {
routerDelegate.handleOpen(url, completionHandler)
}
/// Delegates opening the passed `url` to the Web View.
/// - Parameters:
/// - url: URL to be opened.
/// - routerDelegate: The Web View that will open the url.
/// - completionHandler: The callback with the result of opening the url using the Web View.
public func openWebView(_ url: URL, routerDelegate: WebView, _ completionHandler: @escaping (WebView.ReturnType) -> Void) {
routerDelegate.handleOpen(url, completionHandler)
}
}