2018-08-08 09:28:00 +00:00
|
|
|
/*
|
|
|
|
Copyright 2018 New Vector Ltd
|
|
|
|
|
|
|
|
Licensed 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 Foundation
|
|
|
|
|
2021-07-09 16:05:43 +00:00
|
|
|
@objc protocol GDPRConsentViewControllerDelegate: AnyObject {
|
2018-08-09 16:56:40 +00:00
|
|
|
func gdprConsentViewControllerDidConsentToGDPRWithSuccess(_ gdprConsentViewController: GDPRConsentViewController)
|
2018-08-08 09:28:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// GPDR consent screen.
|
2018-08-08 09:30:50 +00:00
|
|
|
final public class GDPRConsentViewController: WebViewViewController {
|
2018-08-08 09:28:00 +00:00
|
|
|
|
|
|
|
// MARK: - Constants
|
|
|
|
|
2018-08-09 16:56:40 +00:00
|
|
|
private static let consentSuccessURLPath = "/_matrix/consent"
|
2018-08-08 09:28:00 +00:00
|
|
|
|
2018-08-09 16:56:40 +00:00
|
|
|
// MARK: - Properties
|
2018-08-08 09:28:00 +00:00
|
|
|
|
|
|
|
@objc weak var delegate: GDPRConsentViewControllerDelegate?
|
|
|
|
|
|
|
|
// MARK: - View life cycle
|
|
|
|
|
|
|
|
public override func viewDidLoad() {
|
|
|
|
super.viewDidLoad()
|
|
|
|
|
2021-09-28 05:40:01 +00:00
|
|
|
self.title = VectorL10n.settingsTermConditions
|
2018-08-08 09:28:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// MARK: - Superclass Overrides
|
|
|
|
|
|
|
|
override public func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
|
|
|
|
super.webView(webView, didFinish: navigation)
|
|
|
|
|
2018-08-09 16:56:40 +00:00
|
|
|
// When navigation finish on path `consentSuccessURLPath` with no query, it means that user consent to GDPR
|
|
|
|
if let url = webView.url, url.path == GDPRConsentViewController.consentSuccessURLPath, url.query == nil {
|
2021-06-03 08:30:07 +00:00
|
|
|
MXLog.debug("[GDPRConsentViewController] User consent to GDPR")
|
2018-08-09 16:56:40 +00:00
|
|
|
self.delegate?.gdprConsentViewControllerDidConsentToGDPRWithSuccess(self)
|
2018-08-08 09:28:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|