diff --git a/firefox-ios/Client.xcodeproj/project.pbxproj b/firefox-ios/Client.xcodeproj/project.pbxproj index 21b4e835e69a..efa45a5be3fb 100644 --- a/firefox-ios/Client.xcodeproj/project.pbxproj +++ b/firefox-ios/Client.xcodeproj/project.pbxproj @@ -761,6 +761,7 @@ 8A3345682BA499B7008C52AB /* disconnect-block-social.json in Resources */ = {isa = PBXBuildFile; fileRef = 8A33455E2BA499B7008C52AB /* disconnect-block-social.json */; }; 8A3345692BA499B7008C52AB /* disconnect-block-cookies-social.json in Resources */ = {isa = PBXBuildFile; fileRef = 8A33455F2BA499B7008C52AB /* disconnect-block-cookies-social.json */; }; 8A33456A2BA499B7008C52AB /* disconnect-block-cryptomining.json in Resources */ = {isa = PBXBuildFile; fileRef = 8A3345602BA499B7008C52AB /* disconnect-block-cryptomining.json */; }; + 8A34DD892CF6B31F00DC91FB /* UnifiedAdsNetwork.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A34DD882CF6B30F00DC91FB /* UnifiedAdsNetwork.swift */; }; 8A359EF32A1FD449004A5BB7 /* AdjustWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A359EF22A1FD449004A5BB7 /* AdjustWrapper.swift */; }; 8A359EF62A1FE840004A5BB7 /* MockAdjustWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A359EF52A1FE840004A5BB7 /* MockAdjustWrapper.swift */; }; 8A36AC2C2886F27F00CDC0AD /* MockTabManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A36AC2B2886F27F00CDC0AD /* MockTabManager.swift */; }; @@ -1040,6 +1041,7 @@ 8AE938192CD91D5A0020E6CF /* TopSiteState.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8AE938182CD91D5A0020E6CF /* TopSiteState.swift */; }; 8AE9381B2CD91FDB0020E6CF /* TopSitesSectionStateTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8AE9381A2CD91FDB0020E6CF /* TopSitesSectionStateTests.swift */; }; 8AE9381D2CD920310020E6CF /* TopSiteCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8AE9381C2CD920310020E6CF /* TopSiteCell.swift */; }; + 8AE9FD262CF66301001053EE /* UnifiedAdsProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8AE9FD252CF662FF001053EE /* UnifiedAdsProvider.swift */; }; 8AEAD9F32C3D7B3E001A2C5A /* FeatureFlagsSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8AEAD9F22C3D7B3E001A2C5A /* FeatureFlagsSettings.swift */; }; 8AEAD9F52C3D7BA9001A2C5A /* FeatureFlagsDebugViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8AEAD9F42C3D7BA9001A2C5A /* FeatureFlagsDebugViewController.swift */; }; 8AEAD9F92C3DB0CD001A2C5A /* MicrosurveyTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8AEAD9F62C3DB0BF001A2C5A /* MicrosurveyTests.swift */; }; @@ -7349,6 +7351,7 @@ 8A33455E2BA499B7008C52AB /* disconnect-block-social.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = "disconnect-block-social.json"; path = "../../../ContentBlockingLists/disconnect-block-social.json"; sourceTree = ""; }; 8A33455F2BA499B7008C52AB /* disconnect-block-cookies-social.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = "disconnect-block-cookies-social.json"; path = "../../../ContentBlockingLists/disconnect-block-cookies-social.json"; sourceTree = ""; }; 8A3345602BA499B7008C52AB /* disconnect-block-cryptomining.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = "disconnect-block-cryptomining.json"; path = "../../../ContentBlockingLists/disconnect-block-cryptomining.json"; sourceTree = ""; }; + 8A34DD882CF6B30F00DC91FB /* UnifiedAdsNetwork.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UnifiedAdsNetwork.swift; sourceTree = ""; }; 8A359EF22A1FD449004A5BB7 /* AdjustWrapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdjustWrapper.swift; sourceTree = ""; }; 8A359EF52A1FE840004A5BB7 /* MockAdjustWrapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockAdjustWrapper.swift; sourceTree = ""; }; 8A36AC2B2886F27F00CDC0AD /* MockTabManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockTabManager.swift; sourceTree = ""; }; @@ -7634,6 +7637,7 @@ 8AE938182CD91D5A0020E6CF /* TopSiteState.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TopSiteState.swift; sourceTree = ""; }; 8AE9381A2CD91FDB0020E6CF /* TopSitesSectionStateTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TopSitesSectionStateTests.swift; sourceTree = ""; }; 8AE9381C2CD920310020E6CF /* TopSiteCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TopSiteCell.swift; sourceTree = ""; }; + 8AE9FD252CF662FF001053EE /* UnifiedAdsProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UnifiedAdsProvider.swift; sourceTree = ""; }; 8AEAD9F22C3D7B3E001A2C5A /* FeatureFlagsSettings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeatureFlagsSettings.swift; sourceTree = ""; }; 8AEAD9F42C3D7BA9001A2C5A /* FeatureFlagsDebugViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeatureFlagsDebugViewController.swift; sourceTree = ""; }; 8AEAD9F62C3DB0BF001A2C5A /* MicrosurveyTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MicrosurveyTests.swift; sourceTree = ""; }; @@ -11804,6 +11808,7 @@ 8AB8572A27D944B70075C173 /* DataManagement */ = { isa = PBXGroup; children = ( + 8AE9FD272CF665C7001053EE /* UnifiedAds */, 96A5629F27D6D0E80045144A /* ContileProvider.swift */, 8AF6D4E02A856B4500B0474B /* ContileNetworking.swift */, 96A562A227D7B32A0045144A /* Contile.swift */, @@ -12032,6 +12037,15 @@ path = JumpBackIn; sourceTree = ""; }; + 8AE9FD272CF665C7001053EE /* UnifiedAds */ = { + isa = PBXGroup; + children = ( + 8A34DD882CF6B30F00DC91FB /* UnifiedAdsNetwork.swift */, + 8AE9FD252CF662FF001053EE /* UnifiedAdsProvider.swift */, + ); + path = UnifiedAds; + sourceTree = ""; + }; 8AED23C327AC1F8700DE7E97 /* Components */ = { isa = PBXGroup; children = ( @@ -16428,6 +16442,7 @@ ED9FD5DB2CEBB5EA00E906A3 /* SentFromFirefoxSetting.swift in Sources */, 8C92DE8B2A711ED60090BD28 /* FakespotClient.swift in Sources */, 8AC1065F28D0CD700013263A /* OpenQLPreviewHelper.swift in Sources */, + 8AE9FD262CF66301001053EE /* UnifiedAdsProvider.swift in Sources */, EBA3B2C32268F16300728BDB /* PhotonActionSheetView.swift in Sources */, E18EA56F28AD3279003F97FC /* UIDevice+Extension.swift in Sources */, 8A46F5AD2C9E4389005B6422 /* RemoteSettingsFetchConfig.swift in Sources */, @@ -16965,6 +16980,7 @@ 0BDDB3462CA6E43A00D501DF /* BookmarksSaver.swift in Sources */, EBB89506219398E500EB91A0 /* TabContentBlocker.swift in Sources */, E1B9A2C22CAD91EF00F6A0E9 /* ToolbarTelemetry.swift in Sources */, + 8A34DD892CF6B31F00DC91FB /* UnifiedAdsNetwork.swift in Sources */, 21F2A2D22B0BC85200626AEC /* InactiveTabsModel.swift in Sources */, 966206CD2698DE1E005C0A55 /* BookmarksViewModel.swift in Sources */, D3E8EF101B97BE69001900FB /* ClearPrivateDataTableViewController.swift in Sources */, diff --git a/firefox-ios/Client/Frontend/Home/TopSites/DataManagement/UnifiedAds/UnifiedAdsNetwork.swift b/firefox-ios/Client/Frontend/Home/TopSites/DataManagement/UnifiedAds/UnifiedAdsNetwork.swift new file mode 100644 index 000000000000..212f39300b48 --- /dev/null +++ b/firefox-ios/Client/Frontend/Home/TopSites/DataManagement/UnifiedAds/UnifiedAdsNetwork.swift @@ -0,0 +1,30 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/ + +import Common +import Foundation + +/// Used only for sponsored tiles content and telemetry. This is aiming to be a temporary API +/// as we'll migrate to using A-S for this at some point in 2025 +protocol UnifiedAdsNetwork { + func data(from request: URLRequest, completion: @escaping (NetworkingContileResult) -> Void) +} + +class DefaultUnifiedAdsNetwork: UnifiedAdsNetwork { + private var urlSession: URLSessionProtocol + private var logger: Logger + + init(with urlSession: URLSessionProtocol, + logger: Logger = DefaultLogger.shared) { + self.urlSession = urlSession + self.logger = logger + } + + func data(from request: URLRequest, completion: @escaping (NetworkingContileResult) -> Void) { + urlSession.dataTaskWith(request: request) { [weak self] data, response, error in + guard self != nil else { return } + // TODO: FXIOS-10715 + }.resume() + } +} diff --git a/firefox-ios/Client/Frontend/Home/TopSites/DataManagement/UnifiedAds/UnifiedAdsProvider.swift b/firefox-ios/Client/Frontend/Home/TopSites/DataManagement/UnifiedAds/UnifiedAdsProvider.swift new file mode 100644 index 000000000000..ece9834f8aec --- /dev/null +++ b/firefox-ios/Client/Frontend/Home/TopSites/DataManagement/UnifiedAds/UnifiedAdsProvider.swift @@ -0,0 +1,37 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/ + +import Common +import Foundation +import Shared + +/// Used only for sponsored tiles content and telemetry. This is aiming to be a temporary API +/// as we'll migrate to using A-S for this at some point in 2025 +protocol UnifiedAdsProviderInterface { + func fetchTiles(completion: @escaping (ContileResult) -> Void) +} + +class UnifiedAdsProvider: UnifiedAdsProviderInterface { + private static let resourceEndpoint = "https://ads.mozilla.org/v1/ads" + + var urlCache: URLCache + private var logger: Logger + private var networking: UnifiedAdsNetwork + + init( + networking: UnifiedAdsNetwork = DefaultUnifiedAdsNetwork( + with: makeURLSession(userAgent: UserAgent.mobileUserAgent(), + configuration: URLSessionConfiguration.defaultMPTCP)), + urlCache: URLCache = URLCache.shared, + logger: Logger = DefaultLogger.shared + ) { + self.logger = logger + self.networking = networking + self.urlCache = urlCache + } + + func fetchTiles(completion: @escaping (ContileResult) -> Void) { + // TODO: FXIOS-10715 + } +}