Skip to content

Commit

Permalink
Added swift and kotlin logic for tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
lougeniaC64 committed Apr 18, 2022
1 parent 7fc8368 commit d235d7c
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/* 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/. */

package mozilla.appservices.remotetabs

// Originally `TabsDeviceType` was named `DeviceType`, but this created a namespace clash for iOS with
// the `DeviceType` created for FxA. This conflict is not an issue for android so to avoid created a
// breaking change we are aliasing `TabsDeviceType` back to `DeviceType`.
typealias DeviceType = TabsDeviceType
48 changes: 48 additions & 0 deletions components/tabs/ios/Tabs/Tabs.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/* 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 Foundation

open class TabsStorage {
private var store: TabsStore
private let queue = DispatchQueue(label: "com.mozilla.tabs-storage")

public init(databasePath: String) throws {
store = try TabsStore(path: databasePath)
}

/// Get all tabs by client.
open func getAll() throws -> [ClientRemoteTabs] {
return queue.sync {
return self.store.getAll()
}
}

/// Set the local tabs.
open func setLocalTabs(remoteTabs: [RemoteTab]) throws {
try queue.sync {
self.store.setLocalTabs(remoteTabs: remoteTabs)
}
}

/// Register with the sync manager
open func registerWithSyncManager() throws {
return queue.sync {
return self.store.registerWithSyncManager()
}
}

open func sync(unlockInfo: SyncUnlockInfo, localId: String) throws -> String {
return try queue.sync {
return try self.store
.sync(
keyId: unlockInfo.kid,
accessToken: unlockInfo.fxaAccessToken,
syncKey: unlockInfo.syncKey,
tokenserverUrl: unlockInfo.tokenserverURL,
localId: localId
)
}
}
}

0 comments on commit d235d7c

Please sign in to comment.