Skip to content

Commit

Permalink
Temporary disable use of subscription cookie to share subscription ac…
Browse files Browse the repository at this point in the history
…cess token
  • Loading branch information
miasma13 committed Oct 30, 2024
1 parent c5aab0c commit 8f16ed6
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 48 deletions.
34 changes: 18 additions & 16 deletions DuckDuckGo/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ import os.log
private var autofillUsageMonitor = AutofillUsageMonitor()

private(set) var subscriptionFeatureAvailability: SubscriptionFeatureAvailability!
private var subscriptionCookieManager: SubscriptionCookieManaging!
// Temporary disable, see: https://app.asana.com/0/0/1208249142369975/1208659372053914/f
// private var subscriptionCookieManager: SubscriptionCookieManaging!
var privacyProDataReporter: PrivacyProDataReporting!

// MARK: - Feature specific app event handlers
Expand Down Expand Up @@ -314,16 +315,17 @@ import os.log
privacyConfigurationManager: ContentBlocking.shared.privacyConfigurationManager,
purchasePlatform: .appStore)

subscriptionCookieManager = SubscriptionCookieManager(subscriptionManager: AppDependencyProvider.shared.subscriptionManager,
currentCookieStore: { [weak self] in
guard self?.mainViewController?.tabManager.model.hasActiveTabs ?? false else {
// We shouldn't interact with WebKit's cookie store unless we have a WebView,
// eventually the subscription cookie will be refreshed on opening the first tab
return nil
}

return WKWebsiteDataStore.current().httpCookieStore
}, eventMapping: SubscriptionCookieManageEventPixelMapping())
// Temporary disable, see: https://app.asana.com/0/0/1208249142369975/1208659372053914/f
// subscriptionCookieManager = SubscriptionCookieManager(subscriptionManager: AppDependencyProvider.shared.subscriptionManager,
// currentCookieStore: { [weak self] in
// guard self?.mainViewController?.tabManager.model.hasActiveTabs ?? false else {
// // We shouldn't interact with WebKit's cookie store unless we have a WebView,
// // eventually the subscription cookie will be refreshed on opening the first tab
// return nil
// }
//
// return WKWebsiteDataStore.current().httpCookieStore
// }, eventMapping: SubscriptionCookieManageEventPixelMapping())

homePageConfiguration = HomePageConfiguration(variantManager: AppDependencyProvider.shared.variantManager,
remoteMessagingClient: remoteMessagingClient,
Expand Down Expand Up @@ -362,8 +364,7 @@ import os.log
contextualOnboardingLogic: daxDialogs,
contextualOnboardingPixelReporter: onboardingPixelReporter,
subscriptionFeatureAvailability: subscriptionFeatureAvailability,
voiceSearchHelper: voiceSearchHelper,
subscriptionCookieManager: subscriptionCookieManager)
voiceSearchHelper: voiceSearchHelper)

main.loadViewIfNeeded()
syncErrorHandler.alertPresenter = main
Expand Down Expand Up @@ -587,9 +588,10 @@ import os.log
}
}

Task { @MainActor in
await subscriptionCookieManager.refreshSubscriptionCookie()
}
// Temporary disable, see: https://app.asana.com/0/0/1208249142369975/1208659372053914/f
// Task { @MainActor in
// await subscriptionCookieManager.refreshSubscriptionCookie()
// }

let importPasswordsStatusHandler = ImportPasswordsStatusHandler(syncService: syncService)
importPasswordsStatusHandler.checkSyncSuccessStatus()
Expand Down
8 changes: 2 additions & 6 deletions DuckDuckGo/MainViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ class MainViewController: UIViewController {
private var feedbackCancellable: AnyCancellable?

let subscriptionFeatureAvailability: SubscriptionFeatureAvailability
private let subscriptionCookieManager: SubscriptionCookieManaging
let privacyProDataReporter: PrivacyProDataReporting

private lazy var featureFlagger = AppDependencyProvider.shared.featureFlagger
Expand Down Expand Up @@ -196,8 +195,7 @@ class MainViewController: UIViewController {
tutorialSettings: TutorialSettings = DefaultTutorialSettings(),
statisticsStore: StatisticsStore = StatisticsUserDefaults(),
subscriptionFeatureAvailability: SubscriptionFeatureAvailability,
voiceSearchHelper: VoiceSearchHelperProtocol,
subscriptionCookieManager: SubscriptionCookieManaging
voiceSearchHelper: VoiceSearchHelperProtocol
) {
self.bookmarksDatabase = bookmarksDatabase
self.bookmarksDatabaseCleaner = bookmarksDatabaseCleaner
Expand All @@ -219,8 +217,7 @@ class MainViewController: UIViewController {
privacyProDataReporter: privacyProDataReporter,
contextualOnboardingPresenter: contextualOnboardingPresenter,
contextualOnboardingLogic: contextualOnboardingLogic,
onboardingPixelReporter: contextualOnboardingPixelReporter,
subscriptionCookieManager: subscriptionCookieManager)
onboardingPixelReporter: contextualOnboardingPixelReporter)
self.syncPausedStateManager = syncPausedStateManager
self.privacyProDataReporter = privacyProDataReporter
self.homeTabManager = NewTabPageManager()
Expand All @@ -231,7 +228,6 @@ class MainViewController: UIViewController {
self.statisticsStore = statisticsStore
self.subscriptionFeatureAvailability = subscriptionFeatureAvailability
self.voiceSearchHelper = voiceSearchHelper
self.subscriptionCookieManager = subscriptionCookieManager

super.init(nibName: nil, bundle: nil)

Expand Down
11 changes: 3 additions & 8 deletions DuckDuckGo/TabManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ class TabManager {
private let contextualOnboardingPresenter: ContextualOnboardingPresenting
private let contextualOnboardingLogic: ContextualOnboardingLogic
private let onboardingPixelReporter: OnboardingPixelReporting
private let subscriptionCookieManager: SubscriptionCookieManaging

weak var delegate: TabDelegate?

Expand All @@ -59,8 +58,7 @@ class TabManager {
privacyProDataReporter: PrivacyProDataReporting,
contextualOnboardingPresenter: ContextualOnboardingPresenting,
contextualOnboardingLogic: ContextualOnboardingLogic,
onboardingPixelReporter: OnboardingPixelReporting,
subscriptionCookieManager: SubscriptionCookieManaging) {
onboardingPixelReporter: OnboardingPixelReporting) {
self.model = model
self.previewsSource = previewsSource
self.bookmarksDatabase = bookmarksDatabase
Expand All @@ -71,7 +69,6 @@ class TabManager {
self.contextualOnboardingPresenter = contextualOnboardingPresenter
self.contextualOnboardingLogic = contextualOnboardingLogic
self.onboardingPixelReporter = onboardingPixelReporter
self.subscriptionCookieManager = subscriptionCookieManager
registerForNotifications()
}

Expand All @@ -93,8 +90,7 @@ class TabManager {
contextualOnboardingPresenter: contextualOnboardingPresenter,
contextualOnboardingLogic: contextualOnboardingLogic,
onboardingPixelReporter: onboardingPixelReporter,
featureFlagger: AppDependencyProvider.shared.featureFlagger,
subscriptionCookieManager: subscriptionCookieManager)
featureFlagger: AppDependencyProvider.shared.featureFlagger)
controller.applyInheritedAttribution(inheritedAttribution)
controller.attachWebView(configuration: configuration,
andLoadRequest: url == nil ? nil : URLRequest.userInitiated(url!),
Expand Down Expand Up @@ -172,8 +168,7 @@ class TabManager {
contextualOnboardingPresenter: contextualOnboardingPresenter,
contextualOnboardingLogic: contextualOnboardingLogic,
onboardingPixelReporter: onboardingPixelReporter,
featureFlagger: AppDependencyProvider.shared.featureFlagger,
subscriptionCookieManager: subscriptionCookieManager)
featureFlagger: AppDependencyProvider.shared.featureFlagger)
controller.attachWebView(configuration: configCopy,
andLoadRequest: request,
consumeCookies: !model.hasActiveTabs,
Expand Down
16 changes: 6 additions & 10 deletions DuckDuckGo/TabViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ class TabViewController: UIViewController {
let appSettings: AppSettings

var featureFlagger: FeatureFlagger
let subscriptionCookieManager: SubscriptionCookieManaging
private lazy var internalUserDecider = AppDependencyProvider.shared.internalUserDecider

private lazy var autofillNeverPromptWebsitesManager = AppDependencyProvider.shared.autofillNeverPromptWebsitesManager
Expand Down Expand Up @@ -323,8 +322,7 @@ class TabViewController: UIViewController {
contextualOnboardingLogic: ContextualOnboardingLogic,
onboardingPixelReporter: OnboardingCustomInteractionPixelReporting,
urlCredentialCreator: URLCredentialCreating = URLCredentialCreator(),
featureFlagger: FeatureFlagger,
subscriptionCookieManager: SubscriptionCookieManaging) -> TabViewController {
featureFlagger: FeatureFlagger) -> TabViewController {
let storyboard = UIStoryboard(name: "Tab", bundle: nil)
let controller = storyboard.instantiateViewController(identifier: "TabViewController", creator: { coder in
TabViewController(coder: coder,
Expand All @@ -339,8 +337,7 @@ class TabViewController: UIViewController {
contextualOnboardingLogic: contextualOnboardingLogic,
onboardingPixelReporter: onboardingPixelReporter,
urlCredentialCreator: urlCredentialCreator,
featureFlagger: featureFlagger,
subscriptionCookieManager: subscriptionCookieManager
featureFlagger: featureFlagger
)
})
return controller
Expand Down Expand Up @@ -373,8 +370,7 @@ class TabViewController: UIViewController {
contextualOnboardingLogic: ContextualOnboardingLogic,
onboardingPixelReporter: OnboardingCustomInteractionPixelReporting,
urlCredentialCreator: URLCredentialCreating = URLCredentialCreator(),
featureFlagger: FeatureFlagger,
subscriptionCookieManager: SubscriptionCookieManaging) {
featureFlagger: FeatureFlagger) {
self.tabModel = tabModel
self.appSettings = appSettings
self.bookmarksDatabase = bookmarksDatabase
Expand All @@ -393,7 +389,6 @@ class TabViewController: UIViewController {
self.onboardingPixelReporter = onboardingPixelReporter
self.urlCredentialCreator = urlCredentialCreator
self.featureFlagger = featureFlagger
self.subscriptionCookieManager = subscriptionCookieManager
super.init(coder: aDecoder)
}

Expand Down Expand Up @@ -642,8 +637,9 @@ class TabViewController: UIViewController {
await webView.configuration.websiteDataStore.dataRecords(ofTypes: WKWebsiteDataStore.allWebsiteDataTypes())
let cookieStore = webView.configuration.websiteDataStore.httpCookieStore
await WebCacheManager.shared.consumeCookies(httpCookieStore: cookieStore)
subscriptionCookieManager.resetLastRefreshDate()
await subscriptionCookieManager.refreshSubscriptionCookie()
// Temporary disable, see: https://app.asana.com/0/0/1208249142369975/1208659372053914/f
// subscriptionCookieManager.resetLastRefreshDate()
// await subscriptionCookieManager.refreshSubscriptionCookie()
doLoad()
}
}
Expand Down
3 changes: 1 addition & 2 deletions DuckDuckGo/TabViewControllerLongPressMenuExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,7 @@ extension TabViewController {
contextualOnboardingPresenter: contextualOnboardingPresenter,
contextualOnboardingLogic: contextualOnboardingLogic,
onboardingPixelReporter: onboardingPixelReporter,
featureFlagger: AppDependencyProvider.shared.featureFlagger,
subscriptionCookieManager: subscriptionCookieManager)
featureFlagger: AppDependencyProvider.shared.featureFlagger)
tabController.isLinkPreview = true
let configuration = WKWebViewConfiguration.nonPersistent()
tabController.attachWebView(configuration: configuration, andLoadRequest: URLRequest.userInitiated(url), consumeCookies: false)
Expand Down
3 changes: 1 addition & 2 deletions DuckDuckGoTests/MockTabDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,7 @@ extension TabViewController {
contextualOnboardingLogic: contextualOnboardingLogic,
onboardingPixelReporter: contextualOnboardingPixelReporter,
urlCredentialCreator: MockCredentialCreator(),
featureFlagger: featureFlagger,
subscriptionCookieManager: SubscriptionCookieManagerMock()
featureFlagger: featureFlagger
)
tab.attachWebView(configuration: .nonPersistent(), andLoadRequest: nil, consumeCookies: false, customWebView: customWebView)
return tab
Expand Down
3 changes: 1 addition & 2 deletions DuckDuckGoTests/OnboardingDaxFavouritesTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@ final class OnboardingDaxFavouritesTests: XCTestCase {
contextualOnboardingPixelReporter: OnboardingPixelReporterMock(),
tutorialSettings: tutorialSettingsMock,
subscriptionFeatureAvailability: SubscriptionFeatureAvailabilityMock.enabled,
voiceSearchHelper: MockVoiceSearchHelper(isSpeechRecognizerAvailable: true, voiceSearchEnabled: true),
subscriptionCookieManager: SubscriptionCookieManagerMock()
voiceSearchHelper: MockVoiceSearchHelper(isSpeechRecognizerAvailable: true, voiceSearchEnabled: true)
)
let window = UIWindow(frame: UIScreen.main.bounds)
window.rootViewController = UIViewController()
Expand Down
3 changes: 1 addition & 2 deletions DuckDuckGoTests/OnboardingNavigationDelegateTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ final class OnboardingNavigationDelegateTests: XCTestCase {
contextualOnboardingLogic: ContextualOnboardingLogicMock(),
contextualOnboardingPixelReporter: onboardingPixelReporter,
subscriptionFeatureAvailability: SubscriptionFeatureAvailabilityMock.enabled,
voiceSearchHelper: MockVoiceSearchHelper(isSpeechRecognizerAvailable: true, voiceSearchEnabled: true),
subscriptionCookieManager: SubscriptionCookieManagerMock())
voiceSearchHelper: MockVoiceSearchHelper(isSpeechRecognizerAvailable: true, voiceSearchEnabled: true))
let window = UIWindow(frame: UIScreen.main.bounds)
window.rootViewController = UIViewController()
window.makeKeyAndVisible()
Expand Down

0 comments on commit 8f16ed6

Please sign in to comment.