-
Notifications
You must be signed in to change notification settings - Fork 229
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added swift and kotlin logic for tabs
- Loading branch information
1 parent
7fc8368
commit d235d7c
Showing
2 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
components/tabs/android/src/main/java/mozilla/appservices/tabs/DeviceType.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
) | ||
} | ||
} | ||
} |