             completionHandler(.performDefaultHandling, nil)
         }
     }
-}
+
+    public func webView(_ webView: WKWebView, runJavaScriptConfirmPanelWithMessage message: String, initiatedByFrame frame: WKFrameInfo, completionHandler: @escaping (Bool) -> Void) {
+
+        let alertController = UIAlertController(title: nil, message: message, preferredStyle: .actionSheet)
+
+        alertController.addAction(UIAlertAction(title: Strings.ok, style: .default, handler: { (action) in
+            completionHandler(true)
+        }))
+
+        alertController.addAction(UIAlertAction(title: Strings.cancel, style: .cancel, handler: { (action) in
+            completionHandler(false)
+        }))
+
+        if let presenter = alertController.popoverPresentationController {
+            presenter.sourceView = view
+            presenter.sourceRect = CGRect(x: view.bounds.midX, y: view.bounds.midY, width: 0, height: 0)
+        }
+
+        present(alertController, animated: true, completion: nil)
+    }
+
+}


// Allows access to course content that requires authentication.
// Forwarding our oauth token to the server so we can get a web based cookie
public class AuthenticatedWebViewController: UIViewController, WKNavigationDelegate {
    
    fileprivate enum State {
        case CreatingSession

    private lazy var webController : WebContentController = {
        let controller = WKWebViewContentController()
        controller.webView.navigationDelegate = self
        controller.webView.uiDelegate = self
        return controller
    
    }()
