//
//  WebClient.swift
//  Astro
//
//  Created by Justin Vaillancourt on 2015-05-27.
//  Copyright (c) 2015 Mobify Research & Development Inc. All rights reserved.
//

import Foundation
import UIKit
import WebKit

protocol WebClient: class {
    var webClientDelegate: WebClientDelegate? { get set }
    var currentURL: URL? { get }
    func load(_ request: URLRequest)
    func getCookie(named cookieName: String, completionHandler: @escaping (_ cookieValue: String?, _ error: String?) -> Void)
    func deleteCookie(named cookieName: String, completionHandler: @escaping () -> Void)
}

protocol WebClientDelegate: class {
    func handleNavigationRequest(_ request: URLRequest)
    func pageDidStartLoading(_ url: URL)
    func pageDidFinishLoading()
    func notifyAppStoreLinkOpened()
    func notifyNoInternetConnection(_ url: String)
    func showAlertPanelWithMessage(_ message: String, initiatedByFrame frame: WKFrameInfo, completionHandler: @escaping () -> Void)
    func showConfirmPanelWithMessage(_ message: String, initiatedByFrame frame: WKFrameInfo, completionHandler: @escaping (Bool) -> Void)
    func showTextInputPanelWithPrompt(_ prompt: String, defaultText: String?, initiatedByFrame frame: WKFrameInfo, completionHandler: @escaping (String?) -> Void)
    func pageDidFailLoadWithError(_ error: NSError)
}
