Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasstrba committed Jan 11, 2022
2 parents a3c4a5c + b12a66b commit c030847
Show file tree
Hide file tree
Showing 12 changed files with 75 additions and 161 deletions.
30 changes: 11 additions & 19 deletions DuckDuckGo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
objects = {

/* Begin PBXBuildFile section */
0230C09F271F53000018F728 /* GPCUserScript.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0230C09E271F53000018F728 /* GPCUserScript.swift */; };
0230C0A1271F53670018F728 /* gpc.js in Resources */ = {isa = PBXBuildFile; fileRef = 0230C0A0271F53670018F728 /* gpc.js */; };
0230C0A3272080090018F728 /* KeyedCodingExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0230C0A2272080090018F728 /* KeyedCodingExtension.swift */; };
0230C0A52721F3750018F728 /* GPCRequestFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0230C0A42721F3750018F728 /* GPCRequestFactory.swift */; };
026ADE1426C3010C002518EE /* macos-config.json in Resources */ = {isa = PBXBuildFile; fileRef = 026ADE1326C3010C002518EE /* macos-config.json */; };
Expand Down Expand Up @@ -650,8 +648,6 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
0230C09E271F53000018F728 /* GPCUserScript.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GPCUserScript.swift; sourceTree = "<group>"; };
0230C0A0271F53670018F728 /* gpc.js */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.javascript; path = gpc.js; sourceTree = "<group>"; };
0230C0A2272080090018F728 /* KeyedCodingExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeyedCodingExtension.swift; sourceTree = "<group>"; };
0230C0A42721F3750018F728 /* GPCRequestFactory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GPCRequestFactory.swift; sourceTree = "<group>"; };
026ADE1326C3010C002518EE /* macos-config.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "macos-config.json"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1324,9 +1320,7 @@
0230C09D271F52D50018F728 /* GPC */ = {
isa = PBXGroup;
children = (
0230C09E271F53000018F728 /* GPCUserScript.swift */,
0230C0A42721F3750018F728 /* GPCRequestFactory.swift */,
0230C0A0271F53670018F728 /* gpc.js */,
);
path = GPC;
sourceTree = "<group>";
Expand Down Expand Up @@ -3564,7 +3558,6 @@
AA80EC6D256C469C007083E7 /* NavigationBar.storyboard in Resources */,
4B0511C6262CAA5A00F6079C /* DefaultBrowserTableCellView.xib in Resources */,
85B7185027677EA400B4277F /* Onboarding.xcassets in Resources */,
0230C0A1271F53670018F728 /* gpc.js in Resources */,
4B677433255DBEB800025BD8 /* httpsMobileV2Bloom.bin in Resources */,
AA34397B2754D55100B241FA /* trackers-3.json in Resources */,
026ADE1426C3010C002518EE /* macos-config.json in Resources */,
Expand Down Expand Up @@ -3986,7 +3979,6 @@
85378DA2274E7F25007C5CBF /* EmailManagerRequestDelegate.swift in Sources */,
B68172A9269C487D006D1092 /* PrivacyDashboardUserScript.swift in Sources */,
858A797F26A79EAA00A75A42 /* UserText+PasswordManager.swift in Sources */,
0230C09F271F53000018F728 /* GPCUserScript.swift in Sources */,
B693954E26F04BEB0015B914 /* ProgressView.swift in Sources */,
B69B503C2726A12500758A2B /* StatisticsStore.swift in Sources */,
B693955426F04BEC0015B914 /* ColorView.swift in Sources */,
Expand Down Expand Up @@ -4419,15 +4411,15 @@
CODE_SIGN_IDENTITY = "";
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 0.18.1;
CURRENT_PROJECT_VERSION = 0.18.2;
DEVELOPMENT_TEAM = "";
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = DuckDuckGo/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
);
MARKETING_VERSION = 0.18.1;
MARKETING_VERSION = 0.18.2;
PRODUCT_BUNDLE_IDENTIFIER = com.duckduckgo.macos.browser.debug;
PRODUCT_MODULE_NAME = "$(TARGET_NAME:c99extidentifier)";
PRODUCT_NAME = DuckDuckGo;
Expand Down Expand Up @@ -4691,15 +4683,15 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 0.18.1;
CURRENT_PROJECT_VERSION = 0.18.2;
DEVELOPMENT_TEAM = HKE973VLUW;
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = DuckDuckGo/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
);
MARKETING_VERSION = 0.18.1;
MARKETING_VERSION = 0.18.2;
PRODUCT_BUNDLE_IDENTIFIER = com.duckduckgo.macos.browser.debug;
PRODUCT_MODULE_NAME = "$(TARGET_NAME:c99extidentifier)";
PRODUCT_NAME = DuckDuckGo;
Expand All @@ -4719,15 +4711,15 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 0.18.1;
CURRENT_PROJECT_VERSION = 0.18.2;
DEVELOPMENT_TEAM = HKE973VLUW;
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = DuckDuckGo/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
);
MARKETING_VERSION = 0.18.1;
MARKETING_VERSION = 0.18.2;
PRODUCT_BUNDLE_IDENTIFIER = com.duckduckgo.macos.browser;
PRODUCT_MODULE_NAME = "$(TARGET_NAME:c99extidentifier)";
PRODUCT_NAME = DuckDuckGo;
Expand Down Expand Up @@ -4851,7 +4843,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 0.18.1;
CURRENT_PROJECT_VERSION = 0.18.2;
DEVELOPMENT_TEAM = HKE973VLUW;
ENABLE_HARDENED_RUNTIME = YES;
GCC_PREPROCESSOR_DEFINITIONS = "REVIEW=1";
Expand All @@ -4860,7 +4852,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MARKETING_VERSION = 0.18.1;
MARKETING_VERSION = 0.18.2;
PRODUCT_BUNDLE_IDENTIFIER = com.duckduckgo.macos.browser.review;
PRODUCT_MODULE_NAME = "$(TARGET_NAME:c99extidentifier)";
PRODUCT_NAME = "DuckDuckGo Review";
Expand Down Expand Up @@ -5000,7 +4992,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 0.18.1;
CURRENT_PROJECT_VERSION = 0.18.2;
DEVELOPMENT_TEAM = HKE973VLUW;
ENABLE_HARDENED_RUNTIME = YES;
GCC_PREPROCESSOR_DEFINITIONS = "BETA=1";
Expand All @@ -5009,7 +5001,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MARKETING_VERSION = 0.18.1;
MARKETING_VERSION = 0.18.2;
PRODUCT_BUNDLE_IDENTIFIER = com.duckduckgo.macos.browser;
PRODUCT_MODULE_NAME = "$(TARGET_NAME:c99extidentifier)";
PRODUCT_NAME = "DuckDuckGo Non-Production";
Expand Down Expand Up @@ -5144,7 +5136,7 @@
repositoryURL = "https://github.com/duckduckgo/BrowserServicesKit.git";
requirement = {
kind = revision;
revision = be84a3b281920cdd2805398960eff43fe9267607;
revision = d9ebd24d7c61c4b3025bd029577bfe6c06f3c2b9;
};
};
85FF55C625F82E4F00E2AB99 /* XCRemoteSwiftPackageReference "lottie-ios" */ = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"repositoryURL": "https://github.com/duckduckgo/BrowserServicesKit.git",
"state": {
"branch": null,
"revision": "be84a3b281920cdd2805398960eff43fe9267607",
"revision": "d9ebd24d7c61c4b3025bd029577bfe6c06f3c2b9",
"version": null
}
},
Expand Down
5 changes: 3 additions & 2 deletions DuckDuckGo/BrowserTab/Model/Tab.swift
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,7 @@ extension Tab: ContentBlockerRulesUserScriptDelegate {
func contentBlockerRulesUserScript(_ script: ContentBlockerRulesUserScript, detectedTracker tracker: DetectedTracker) {
trackerInfo?.add(detectedTracker: tracker)
}

}

extension Tab: SurrogatesUserScriptDelegate {
Expand Down Expand Up @@ -838,13 +839,13 @@ extension Tab: WKNavigationDelegate {
}
}

@available(macOS 12, *)
@available(macOS 11.3, *)
@objc(webView:navigationAction:didBecomeDownload:)
func webView(_ webView: WKWebView, navigationAction: WKNavigationAction, didBecome download: WKDownload) {
self.webView(webView, navigationAction: navigationAction, didBecomeDownload: download)
}

@available(macOS 12, *)
@available(macOS 11.3, *)
@objc(webView:navigationResponse:didBecomeDownload:)
func webView(_ webView: WKWebView, navigationResponse: WKNavigationResponse, didBecome download: WKDownload) {
self.webView(webView, navigationResponse: navigationResponse, didBecomeDownload: download)
Expand Down
9 changes: 6 additions & 3 deletions DuckDuckGo/BrowserTab/Model/UserScripts.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,17 @@ final class UserScripts {
let contentBlockerRulesScript: ContentBlockerRulesUserScript
let surrogatesScript: SurrogatesUserScript
let navigatorCredentialsUserScript: NavigatorCredentialsUserScript
let gpcScript: GPCUserScript
let contentScopeUserScript: ContentScopeUserScript

init(with sourceProvider: ScriptSourceProviding) {

contentBlockerRulesScript = ContentBlockerRulesUserScript(configuration: sourceProvider.contentBlockerRulesConfig!)
surrogatesScript = SurrogatesUserScript(configuration: sourceProvider.surrogatesConfig!)
navigatorCredentialsUserScript = NavigatorCredentialsUserScript(scriptSource: sourceProvider)
gpcScript = GPCUserScript(scriptSource: sourceProvider)
let privacySettings = PrivacySecurityPreferences()
let sessionKey = sourceProvider.sessionKey ?? ""
let prefs = ContentScopeProperties.init(gpcEnabled: privacySettings.gpcEnabled, sessionKey: sessionKey)
contentScopeUserScript = ContentScopeUserScript(sourceProvider.privacyConfigurationManager, properties: prefs)
}

lazy var userScripts: [UserScript] = [
Expand All @@ -54,8 +57,8 @@ final class UserScripts {
pageObserverScript,
printingUserScript,
hoverUserScript,
gpcScript,
navigatorCredentialsUserScript,
contentScopeUserScript,
autofillScript
]

Expand Down
5 changes: 5 additions & 0 deletions DuckDuckGo/BrowserTab/View/BrowserTabViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -885,6 +885,11 @@ extension BrowserTabViewController: OnboardingDelegate {
}

func onboardingDidRequestSetDefault(completion: @escaping () -> Void) {
if DefaultBrowserPreferences.isDefault {
completion()
return
}

DefaultBrowserPreferences.becomeDefault()

var observer: Any?
Expand Down
27 changes: 8 additions & 19 deletions DuckDuckGo/ContentBlocker/ScriptSourceProviding.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ protocol ScriptSourceProviding {
func reload(knownChanges: ContentBlockerRulesIdentifier.Difference?)
var contentBlockerRulesConfig: ContentBlockerUserScriptConfig? { get }
var surrogatesConfig: SurrogatesUserScriptConfig? { get }
var gpcSource: String { get }
var navigatorCredentialsSource: String { get }

var privacyConfigurationManager: PrivacyConfigurationManager { get }
var sessionKey: String? { get }
var sourceUpdatedPublisher: AnyPublisher<ContentBlockerRulesIdentifier.Difference?, Never> { get }

}
Expand All @@ -38,8 +38,8 @@ final class DefaultScriptSourceProvider: ScriptSourceProviding {

private(set) var contentBlockerRulesConfig: ContentBlockerUserScriptConfig?
private(set) var surrogatesConfig: SurrogatesUserScriptConfig?
private(set) var gpcSource: String = ""
private(set) var navigatorCredentialsSource: String = ""
private(set) var sessionKey: String?

private let sourceUpdatedSubject = PassthroughSubject<ContentBlockerRulesIdentifier.Difference?, Never>()
var sourceUpdatedPublisher: AnyPublisher<ContentBlockerRulesIdentifier.Difference?, Never> {
Expand Down Expand Up @@ -77,11 +77,15 @@ final class DefaultScriptSourceProvider: ScriptSourceProviding {
func reload(knownChanges: ContentBlockerRulesIdentifier.Difference?) {
contentBlockerRulesConfig = buildContentBlockerRulesConfig()
surrogatesConfig = buildSurrogatesConfig()
gpcSource = buildGPCSource()
navigatorCredentialsSource = buildNavigatorCredentialsSource()
sessionKey = generateSessionKey()
sourceUpdatedSubject.send( knownChanges )
}

private func generateSessionKey() -> String {
return UUID().uuidString
}

private func buildContentBlockerRulesConfig() -> ContentBlockerUserScriptConfig {
return DefaultContentBlockerUserScriptConfig(privacyConfiguration: privacyConfigurationManager.privacyConfig,
trackerData: contentBlockingManager.currentRules?.trackerData)
Expand All @@ -104,20 +108,6 @@ final class DefaultScriptSourceProvider: ScriptSourceProviding {
encodedSurrogateTrackerData: rules?.encodedTrackerData,
isDebugBuild: isDebugBuild)
}

private func buildGPCSource() -> String {
let privacyConfiguration = privacyConfigurationManager.privacyConfig
let exceptions = privacyConfiguration.tempUnprotectedDomains +
privacyConfiguration.exceptionsList(forFeature: .gpc)
let privSettings = PrivacySecurityPreferences()
let localUnprotectedDomains = privacyConfiguration.userUnprotectedDomains.joined(separator: "\n")

return GPCUserScript.loadJS("gpc", from: .main, withReplacements: [
"$GPC_ENABLED$": privacyConfiguration.isEnabled(featureKey: .gpc) && privSettings.gpcEnabled ? "true" : "false",
"$GPC_EXCEPTIONS$": exceptions.joined(separator: "\n"),
"$USER_UNPROTECTED_DOMAINS$": localUnprotectedDomains
])
}

private func buildNavigatorCredentialsSource() -> String {
let privacyConfiguration = privacyConfigurationManager.privacyConfig
Expand All @@ -131,5 +121,4 @@ final class DefaultScriptSourceProvider: ScriptSourceProviding {
"$CREDENTIALS_EXCEPTIONS$": (unprotectedDomains + contentBlockingExceptions).joined(separator: "\n")
])
}

}
35 changes: 0 additions & 35 deletions DuckDuckGo/GPC/GPCUserScript.swift

This file was deleted.

78 changes: 0 additions & 78 deletions DuckDuckGo/GPC/gpc.js

This file was deleted.

Loading

0 comments on commit c030847

Please sign in to comment.