Skip to content

Commit

Permalink
Merge branch 'main' into sparaipan/fxios-8468-Firefox-Suggest-Setting…
Browse files Browse the repository at this point in the history
…s-Part-2
  • Loading branch information
PARAIPAN9 committed Feb 22, 2024
2 parents c44af0c + d57cd4f commit 2d37537
Show file tree
Hide file tree
Showing 19 changed files with 308 additions and 174 deletions.
14 changes: 13 additions & 1 deletion firefox-ios/Client.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,9 @@
8AFCE50729DE0CD500B1B253 /* LaunchCoordinatorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8AFCE50629DE0CD500B1B253 /* LaunchCoordinatorTests.swift */; };
8AFCE50929DE136300B1B253 /* MockLaunchFinishedLoadingDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8AFCE50829DE136300B1B253 /* MockLaunchFinishedLoadingDelegate.swift */; };
8AFE4C2127480D0C00B97C65 /* LegacyTabTrayViewControllerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8AFE4C2027480D0B00B97C65 /* LegacyTabTrayViewControllerTests.swift */; };
8C19532E2B85E7AE00761B20 /* SelfSizingHostingController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8C19532D2B85E7AE00761B20 /* SelfSizingHostingController.swift */; };
8C1953302B85E7EC00761B20 /* AutoFillFooterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8C19532F2B85E7EC00761B20 /* AutoFillFooterView.swift */; };
8C1953322B85EAB500761B20 /* AutoFillHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8C1953312B85EAB500761B20 /* AutoFillHeaderView.swift */; };
8C29627C2B1F473800571655 /* AdEventsResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8C29627B2B1F473800571655 /* AdEventsResponse.swift */; };
8C44A9D22A6A99FE009A1AA7 /* ShoppingProduct.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8C44A9D12A6A99FE009A1AA7 /* ShoppingProduct.swift */; };
8C46E1B72B2209F000F56521 /* FakespotAdsEvent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8C46E1B62B2209F000F56521 /* FakespotAdsEvent.swift */; };
Expand Down Expand Up @@ -5913,6 +5916,9 @@
8BF7415AADE68847B78B376B /* mr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = mr; path = mr.lproj/3DTouchActions.strings; sourceTree = "<group>"; };
8BFA4413BB71963DB0E69F82 /* ses */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ses; path = ses.lproj/AuthenticationManager.strings; sourceTree = "<group>"; };
8BFD47109E07F897D604AEBE /* uz */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = uz; path = uz.lproj/ClearPrivateData.strings; sourceTree = "<group>"; };
8C19532D2B85E7AE00761B20 /* SelfSizingHostingController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SelfSizingHostingController.swift; sourceTree = "<group>"; };
8C19532F2B85E7EC00761B20 /* AutoFillFooterView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AutoFillFooterView.swift; sourceTree = "<group>"; };
8C1953312B85EAB500761B20 /* AutoFillHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AutoFillHeaderView.swift; sourceTree = "<group>"; };
8C264BF5A1C7B2B6378D4DFF /* fa */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fa; path = fa.lproj/Today.strings; sourceTree = "<group>"; };
8C29627B2B1F473800571655 /* AdEventsResponse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdEventsResponse.swift; sourceTree = "<group>"; };
8C44A9D12A6A99FE009A1AA7 /* ShoppingProduct.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShoppingProduct.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -8812,6 +8818,9 @@
isa = PBXGroup;
children = (
B2981F892B71AD7A00132C1B /* AutofillAccessoryViewButtonItem.swift */,
8C19532D2B85E7AE00761B20 /* SelfSizingHostingController.swift */,
8C19532F2B85E7EC00761B20 /* AutoFillFooterView.swift */,
8C1953312B85EAB500761B20 /* AutoFillHeaderView.swift */,
B2FEA6892B460CEC0058E616 /* Address */,
43D00491296FC46E00CB0F31 /* CreditCard */,
);
Expand Down Expand Up @@ -13489,6 +13498,8 @@
8C46E1B72B2209F000F56521 /* FakespotAdsEvent.swift in Sources */,
396E38F11EE0C8EC00CC180F /* FxAPushMessageHandler.swift in Sources */,
8A76B01629F6EB3900A82607 /* ScreenshotService.swift in Sources */,
8C1953322B85EAB500761B20 /* AutoFillHeaderView.swift in Sources */,
8C19532E2B85E7AE00761B20 /* SelfSizingHostingController.swift in Sources */,
E4CD9F6D1A77DD2800318571 /* ReaderModeStyleViewController.swift in Sources */,
E13E9AB52AAB0FB5001A0E9D /* FakespotViewModel.swift in Sources */,
8A5D1CBD2A30DC4E005AD35C /* AccountStatusSetting.swift in Sources */,
Expand Down Expand Up @@ -13986,6 +13997,7 @@
43F7952525795F69005AEE40 /* SearchTelemetry.swift in Sources */,
E65075541E37F6FC006961AC /* LegacyDynamicFontHelper.swift in Sources */,
8ADAE4242A33A126007BF926 /* StudiesToggleSetting.swift in Sources */,
8C1953302B85E7EC00761B20 /* AutoFillFooterView.swift in Sources */,
C82CDD47233E8996002E2743 /* Tab+ChangeUserAgent.swift in Sources */,
81122E212B221AC0003DD9F8 /* SearchScreenState.swift in Sources */,
1DA6F6512B48B42900BB5AD6 /* WindowEventCoordinator.swift in Sources */,
Expand Down Expand Up @@ -21211,7 +21223,7 @@
repositoryURL = "https://github.com/mozilla/rust-components-swift.git";
requirement = {
kind = exactVersion;
version = 125.0.20240216050339;
version = 125.0.20240221050347;
};
};
435C85EE2788F4D00072B526 /* XCRemoteSwiftPackageReference "glean-swift" */ = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/mozilla/rust-components-swift.git",
"state" : {
"revision" : "8d6e0c0d2e65e9bddf9e3430162ce570789ea158",
"version" : "125.0.20240216050339"
"revision" : "cf71878bed115ba1fcdf91b24e8cdc181045d4a6",
"version" : "125.0.20240221050347"
}
},
{
Expand Down
4 changes: 4 additions & 0 deletions firefox-ios/Client/Application/AccessibilityIdentifiers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -617,5 +617,9 @@ public struct AccessibilityIdentifiers {
static let manageCardsButton = "RememberCreditCard.manageCardsButton"
static let notNowButton = "RememberCreditCard.notNowButton"
}

enum Autofill {
static let footerPrimaryAction = "Autofill.footerPrimaryAction"
}
}
// swiftlint:enable line_length
3 changes: 2 additions & 1 deletion firefox-ios/Client/Application/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
.profileInitialized,
.preLaunchDependenciesComplete,
.postLaunchDependenciesComplete,
.accountManagerInitialized
.accountManagerInitialized,
.browserIsReady
])

// Then setup dependency container as it's needed for everything else
Expand Down
21 changes: 14 additions & 7 deletions firefox-ios/Client/Application/LaunchSessionProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,23 @@ protocol LaunchSessionProviderProtocol {
var openedFromExternalSource: Bool { get set }
}

class LaunchSessionProvider: LaunchSessionProviderProtocol {
init() {
addObservers()
class LaunchSessionProvider: LaunchSessionProviderProtocol, Notifiable {
private var logger: Logger
var notificationCenter: NotificationProtocol
var openedFromExternalSource = false {
didSet {
guard openedFromExternalSource else { return }
logger.log("openedFromExternalSource was set to true", level: .debug, category: .tabs)
}
}

var notificationCenter: NotificationProtocol = NotificationCenter.default
var openedFromExternalSource = false
}
init(notificationCenter: NotificationProtocol = NotificationCenter.default,
logger: Logger = DefaultLogger.shared) {
self.notificationCenter = notificationCenter
self.logger = logger
addObservers()
}

extension LaunchSessionProvider: Notifiable {
func addObservers() {
setupNotifications(forObserver: self, observing: [UIApplication.willResignActiveNotification,
UIScene.willDeactivateNotification])
Expand Down
36 changes: 23 additions & 13 deletions firefox-ios/Client/Application/SceneDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {

var sceneCoordinator: SceneCoordinator?
var routeBuilder = RouteBuilder()
var logger: Logger = DefaultLogger.shared

// MARK: - Connecting / Disconnecting Scenes

Expand All @@ -47,10 +48,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
let sceneCoordinator = SceneCoordinator(scene: scene)
self.sceneCoordinator = sceneCoordinator
sceneCoordinator.start()

AppEventQueue.wait(for: [.startupFlowComplete, .tabRestoration(sceneCoordinator.windowUUID)]) { [weak self] in
self?.handle(connectionOptions: connectionOptions)
}
handle(connectionOptions: connectionOptions)
}

func sceneDidDisconnect(_ scene: UIScene) {
Expand Down Expand Up @@ -96,17 +94,15 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
) {
guard let url = URLContexts.first?.url,
let route = routeBuilder.makeRoute(url: url) else { return }
sceneCoordinator?.findAndHandle(route: route)

sessionManager.launchSessionProvider.openedFromExternalSource = true
handle(route: route)
}

// MARK: - Continuing User Activities

/// Use this method to handle Handoff-related data or other activities.
func scene(_ scene: UIScene, continue userActivity: NSUserActivity) {
guard let route = routeBuilder.makeRoute(userActivity: userActivity) else { return }
sceneCoordinator?.findAndHandle(route: route)
handle(route: route)
}

// MARK: - Performing Tasks
Expand All @@ -124,26 +120,26 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
guard let route = routeBuilder.makeRoute(shortcutItem: shortcutItem,
tabSetting: NewTabAccessors.getNewTabPage(profile.prefs))
else { return }
sceneCoordinator?.findAndHandle(route: route)
handle(route: route)
}

// MARK: - Misc. Helpers

private func handle(connectionOptions: UIScene.ConnectionOptions) {
if let context = connectionOptions.urlContexts.first,
let route = routeBuilder.makeRoute(url: context.url) {
sceneCoordinator?.findAndHandle(route: route)
handle(route: route)
}

if let activity = connectionOptions.userActivities.first,
let route = routeBuilder.makeRoute(userActivity: activity) {
sceneCoordinator?.findAndHandle(route: route)
handle(route: route)
}

if let shortcut = connectionOptions.shortcutItem,
let route = routeBuilder.makeRoute(shortcutItem: shortcut,
tabSetting: NewTabAccessors.getNewTabPage(profile.prefs)) {
sceneCoordinator?.findAndHandle(route: route)
handle(route: route)
}

// Check if our connection options include a user response to a push
Expand All @@ -162,7 +158,21 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
guard let urlString = tab["url"] as? String,
let url = URL(string: urlString),
let route = routeBuilder.makeRoute(url: url) else { continue }
sceneCoordinator?.findAndHandle(route: route)
handle(route: route)
}
}

private func handle(route: Route) {
guard let sceneCoordinator = sceneCoordinator else {
logger.log("Scene coordinator should exist", level: .fatal, category: .coordinator)
return
}

logger.log("Scene coordinator will handle a route", level: .info, category: .coordinator)
sessionManager.launchSessionProvider.openedFromExternalSource = true

AppEventQueue.wait(for: [.startupFlowComplete, .tabRestoration(sceneCoordinator.windowUUID)]) {
sceneCoordinator.findAndHandle(route: route)
}
}
}
16 changes: 15 additions & 1 deletion firefox-ios/Client/Coordinators/Browser/BrowserCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ class BrowserCoordinator: BaseCoordinator,

// Once launch is done, we check for any saved Route
if let savedRoute {
logger.log("Find and handle route called after didFinishLaunch after onboarding",
level: .info,
category: .coordinator)
findAndHandle(route: savedRoute)
}
}
Expand Down Expand Up @@ -145,13 +148,15 @@ class BrowserCoordinator: BaseCoordinator,
if let webviewController = webviewController {
webviewController.update(webView: webView, isPrivate: tabManager.selectedTab?.isPrivate ?? false)
browserViewController.frontEmbeddedContent(webviewController)
logger.log("Webview content was updated", level: .info, category: .coordinator)
} else {
let webviewViewController = WebviewViewController(
webView: webView,
isPrivate: tabManager.selectedTab?.isPrivate ?? false
)
webviewController = webviewViewController
_ = browserViewController.embedContent(webviewViewController)
let isEmbedded = browserViewController.embedContent(webviewViewController)
logger.log("Webview controller was created and embedded \(isEmbedded)", level: .info, category: .coordinator)
}

screenshotService.screenshotableView = webviewController
Expand All @@ -162,6 +167,9 @@ class BrowserCoordinator: BaseCoordinator,
logger.log("Browser has loaded", level: .info, category: .coordinator)

if let savedRoute {
logger.log("Find and handle route called after browserHasLoaded",
level: .info,
category: .coordinator)
findAndHandle(route: savedRoute)
}
}
Expand Down Expand Up @@ -213,6 +221,9 @@ class BrowserCoordinator: BaseCoordinator,

override func handle(route: Route) {
guard browserIsReady, !tabManager.isRestoringTabs else {
logger.log("Not handling route. Ready? \(browserIsReady), restoring? \(tabManager.isRestoringTabs)",
level: .info,
category: .coordinator)
return
}

Expand Down Expand Up @@ -636,6 +647,9 @@ class BrowserCoordinator: BaseCoordinator,
func tabManagerDidRestoreTabs(_ tabManager: TabManager) {
// Once tab restore is made, if there's any saved route we make sure to call it
if let savedRoute {
logger.log("Find and handle route called after tabManagerDidRestoreTabs",
level: .info,
category: .coordinator)
findAndHandle(route: savedRoute)
}
}
Expand Down
Loading

0 comments on commit 2d37537

Please sign in to comment.