Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
Move STWebpageController inside Tab
Browse files Browse the repository at this point in the history
  • Loading branch information
domcorvasce committed Jul 7, 2023
1 parent 34a90d9 commit ff9059c
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions Sources/Brave/Frontend/Browser/Tab.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import Data
import os.log
import BraveWallet
import Favicon
import ScreenTime

protocol TabContentScriptLoader {
static func loadUserScript(named: String) -> String?
Expand Down Expand Up @@ -65,6 +66,7 @@ enum TabSecureContentState {
class Tab: NSObject {
let id: UUID
let rewardsId: UInt32
let screenTimeViewController = STWebpageController()

var onScreenshotUpdated: (() -> Void)?
var rewardsEnabledCallback: ((Bool) -> Void)?
Expand All @@ -74,7 +76,6 @@ class Tab: NSObject {

private(set) var type: TabType = .regular


var redirectURLs = [URL]()

var isPrivate: Bool {
Expand Down Expand Up @@ -176,9 +177,10 @@ class Tab: NSObject {
willSet {
url = newValue
previousComittedURL = committedURL
screenTimeViewController.url = isPrivate ? nil : url
}
}

/// The previous url that was set before `comittedURL` was set again
private(set) var previousComittedURL: URL?

Expand Down Expand Up @@ -307,6 +309,7 @@ class Tab: NSObject {

super.init()
self.type = type
self.screenTimeViewController.suppressUsageRecording = type.isPrivate
}

weak var navigationDelegate: WKNavigationDelegate? {
Expand Down Expand Up @@ -343,6 +346,11 @@ class Tab: NSObject {
let webView = TabWebView(frame: .zero, tab: self, configuration: configuration!, isPrivate: isPrivate)
webView.delegate = self

webView.addSubview(screenTimeViewController.view)
screenTimeViewController.view.snp.makeConstraints {
$0.edges.equalToSuperview()
}

webView.accessibilityLabel = Strings.webContentAccessibilityLabel
webView.allowsBackForwardNavigationGestures = true
webView.allowsLinkPreview = true
Expand Down

0 comments on commit ff9059c

Please sign in to comment.