Skip to content

Commit

Permalink
Merge commit 'e5d390c8559fbe7b1ca67fd3982c91bcc0437d60' into smodi/co…
Browse files Browse the repository at this point in the history
…mpilation_time_tracking
  • Loading branch information
studiosutara committed Dec 5, 2024
2 parents 44ce600 + e5d390c commit 02702a6
Show file tree
Hide file tree
Showing 98 changed files with 4,068 additions and 2,139 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -491,9 +491,9 @@
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "PhishingDetection"
BuildableName = "PhishingDetection"
BlueprintName = "PhishingDetection"
BlueprintIdentifier = "MaliciousSiteProtection"
BuildableName = "MaliciousSiteProtection"
BlueprintName = "MaliciousSiteProtection"
ReferencedContainer = "container:">
</BuildableReference>
</BuildActionEntry>
Expand Down Expand Up @@ -553,6 +553,20 @@
ReferencedContainer = "container:">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "PixelExperimentKit"
BuildableName = "PixelExperimentKit"
BlueprintName = "PixelExperimentKit"
ReferencedContainer = "container:">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
Expand Down Expand Up @@ -796,9 +810,9 @@
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "PhishingDetectionTests"
BuildableName = "PhishingDetectionTests"
BlueprintName = "PhishingDetectionTests"
BlueprintIdentifier = "MaliciousSiteProtectionTests"
BuildableName = "MaliciousSiteProtectionTests"
BlueprintName = "MaliciousSiteProtectionTests"
ReferencedContainer = "container:">
</BuildableReference>
</TestableReference>
Expand Down Expand Up @@ -842,6 +856,16 @@
ReferencedContainer = "container:">
</BuildableReference>
</TestableReference>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "PixelExperimentKitTests"
BuildableName = "PixelExperimentKitTests"
BlueprintName = "PixelExperimentKitTests"
ReferencedContainer = "container:">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
Expand Down
27 changes: 27 additions & 0 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,24 @@
"version" : "3.0.0"
}
},
{
"identity" : "swift-clocks",
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/swift-clocks.git",
"state" : {
"revision" : "b9b24b69e2adda099a1fa381cda1eeec272d5b53",
"version" : "1.0.5"
}
},
{
"identity" : "swift-concurrency-extras",
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/swift-concurrency-extras",
"state" : {
"revision" : "163409ef7dae9d960b87f34b51587b6609a76c1f",
"version" : "1.3.0"
}
},
{
"identity" : "swifter",
"kind" : "remoteSourceControl",
Expand All @@ -89,6 +107,15 @@
"revision" : "5de0a610a7927b638a5fd463a53032c9934a2c3b",
"version" : "3.0.0"
}
},
{
"identity" : "xctest-dynamic-overlay",
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/xctest-dynamic-overlay",
"state" : {
"revision" : "a3f634d1a409c7979cabc0a71b3f26ffa9fc8af1",
"version" : "1.4.3"
}
}
],
"version" : 2
Expand Down
49 changes: 38 additions & 11 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ let package = Package(
.library(name: "PixelKitTestingUtilities", targets: ["PixelKitTestingUtilities"]),
.library(name: "SpecialErrorPages", targets: ["SpecialErrorPages"]),
.library(name: "DuckPlayer", targets: ["DuckPlayer"]),
.library(name: "PhishingDetection", targets: ["PhishingDetection"]),
.library(name: "MaliciousSiteProtection", targets: ["MaliciousSiteProtection"]),
.library(name: "Onboarding", targets: ["Onboarding"]),
.library(name: "PixelExperimentKit", targets: ["PixelExperimentKit"]),
.library(name: "BrokenSitePrompt", targets: ["BrokenSitePrompt"]),
.library(name: "PageRefreshMonitor", targets: ["PageRefreshMonitor"]),
.library(name: "PrivacyStats", targets: ["PrivacyStats"]),
Expand All @@ -58,7 +59,8 @@ let package = Package(
.package(url: "https://github.com/duckduckgo/privacy-dashboard", exact: "7.2.1"),
.package(url: "https://github.com/httpswift/swifter.git", exact: "1.5.0"),
.package(url: "https://github.com/duckduckgo/bloom_cpp.git", exact: "3.0.0"),
.package(url: "https://github.com/1024jp/GzipSwift.git", exact: "6.0.1")
.package(url: "https://github.com/1024jp/GzipSwift.git", exact: "6.0.1"),
.package(url: "https://github.com/pointfreeco/swift-clocks.git", exact: "1.0.5"),
],
targets: [
.target(
Expand Down Expand Up @@ -250,6 +252,7 @@ let package = Package(
"ContentBlocking",
"Persistence",
"BrowserServicesKit",
"MaliciousSiteProtection",
.product(name: "PrivacyDashboardResources", package: "privacy-dashboard")
],
path: "Sources/PrivacyDashboard",
Expand Down Expand Up @@ -391,7 +394,8 @@ let package = Package(
dependencies: [
"Common",
"UserScript",
"BrowserServicesKit"
"BrowserServicesKit",
"MaliciousSiteProtection",
],
swiftSettings: [
.define("DEBUG", .when(configuration: .debug))
Expand All @@ -408,9 +412,11 @@ let package = Package(
]
),
.target(
name: "PhishingDetection",
name: "MaliciousSiteProtection",
dependencies: [
"Common"
"Common",
"Networking",
"PixelKit",
],
swiftSettings: [
.define("DEBUG", .when(configuration: .debug))
Expand All @@ -428,6 +434,19 @@ let package = Package(
.define("DEBUG", .when(configuration: .debug))
]
),
.target(
name: "PixelExperimentKit",
dependencies: [
"PixelKit",
"BrowserServicesKit"
],
resources: [
.process("Resources")
],
swiftSettings: [
.define("DEBUG", .when(configuration: .debug))
]
),
.target(
name: "BrokenSitePrompt",
dependencies: [
Expand Down Expand Up @@ -655,19 +674,21 @@ let package = Package(
.testTarget(
name: "DuckPlayerTests",
dependencies: [
"DuckPlayer"
"DuckPlayer",
"BrowserServicesKitTestsUtils",
]
),

.testTarget(
name: "PhishingDetectionTests",
name: "MaliciousSiteProtectionTests",
dependencies: [
"PhishingDetection",
"PixelKit"
"TestUtils",
"MaliciousSiteProtection",
.product(name: "Clocks", package: "swift-clocks"),
],
resources: [
.copy("Resources/hashPrefixes.json"),
.copy("Resources/filterSet.json")
.copy("Resources/phishingHashPrefixes.json"),
.copy("Resources/phishingFilterSet.json"),
]
),
.testTarget(
Expand All @@ -676,6 +697,12 @@ let package = Package(
"Onboarding"
]
),
.testTarget(
name: "PixelExperimentKitTests",
dependencies: [
"PixelExperimentKit"
]
),
.testTarget(
name: "SpecialErrorPagesTests",
dependencies: [
Expand Down
4 changes: 2 additions & 2 deletions Sources/BrowserServicesKit/Autofill/AutofillUserScript.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
//

import Common
import WebKit
import UserScript
import os.log
import UserScript
@preconcurrency import WebKit

var previousIncontextSignupPermanentlyDismissedAt: Double?
var previousEmailSignedIn: Bool?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
// limitations under the License.
//

import WebKit
import Common
import ContentBlocking
import TrackerRadarKit
import UserScript
import ContentBlocking
import Common
@preconcurrency import WebKit

public protocol SurrogatesUserScriptDelegate: NSObjectProtocol {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ public final class SpecialPagesUserScript: NSObject, UserScript, UserScriptMessa
@available(macOS 11.0, iOS 14.0, *)
extension SpecialPagesUserScript: WKScriptMessageHandlerWithReply {
@MainActor
public func userContentController(_ userContentController: WKUserContentController,
didReceive message: WKScriptMessage) async -> (Any?, String?) {
public func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) async -> (Any?, String?) {
let action = broker.messageHandlerFor(message)
do {
let json = try await broker.execute(action: action, original: message)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@

import Combine
import Common
import UserScript
import WebKit
import QuartzCore
import os.log
import QuartzCore
import UserScript
@preconcurrency import WebKit

public protocol UserContentControllerDelegate: AnyObject {
@MainActor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public class ExperimentCohortsManager: ExperimentCohortsManaging {
private var store: ExperimentsDataStoring
private let randomizer: (Range<Double>) -> Double
private let queue = DispatchQueue(label: "com.ExperimentCohortsManager.queue")
private let fireCohortAssigned: (_ subfeatureID: SubfeatureID, _ experiment: ExperimentData) -> Void

public var experiments: Experiments? {
get {
Expand All @@ -81,9 +82,11 @@ public class ExperimentCohortsManager: ExperimentCohortsManaging {
}
}

public init(store: ExperimentsDataStoring = ExperimentsDataStore(), randomizer: @escaping (Range<Double>) -> Double = Double.random(in:)) {
public init(store: ExperimentsDataStoring = ExperimentsDataStore(), randomizer: @escaping (Range<Double>) -> Double = Double.random(in:),
fireCohortAssigned: @escaping (_ subfeatureID: SubfeatureID, _ experiment: ExperimentData) -> Void) {
self.store = store
self.randomizer = randomizer
self.fireCohortAssigned = fireCohortAssigned
}

public func resolveCohort(for experiment: ExperimentSubfeature, allowCohortReassignment: Bool) -> CohortID? {
Expand Down Expand Up @@ -113,6 +116,7 @@ extension ExperimentCohortsManager {
cumulativeWeight += Double(cohort.weight)
if randomValue < cumulativeWeight {
saveCohort(cohort.name, in: subfeature.subfeatureID, parentID: subfeature.parentID)
fireCohortAssigned(subfeature.subfeatureID, ExperimentData(parentID: subfeature.parentID, cohortID: cohort.name, enrollmentDate: Date()))
return cohort.name
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public enum PrivacyFeature: String {
case sslCertificates
case brokenSiteReportExperiment
case toggleReports
case phishingDetection
case maliciousSiteProtection
case brokenSitePrompt
case remoteMessaging
case additionalCampaignPixelParams
Expand Down Expand Up @@ -182,10 +182,9 @@ public enum DuckPlayerSubfeature: String, PrivacySubfeature {
case enableDuckPlayer // iOS DuckPlayer rollout feature
}

public enum PhishingDetectionSubfeature: String, PrivacySubfeature {
public var parent: PrivacyFeature { .phishingDetection }
public enum MaliciousSiteProtectionSubfeature: String, PrivacySubfeature {
public var parent: PrivacyFeature { .maliciousSiteProtection }
case allowErrorPage
case allowPreferencesToggle
}

public enum SyncPromotionSubfeature: String, PrivacySubfeature {
Expand Down
Loading

0 comments on commit 02702a6

Please sign in to comment.