From 9c347a31baf72191af7f4c692eb11e1b9af75df3 Mon Sep 17 00:00:00 2001 From: Grisha Kruglov Date: Tue, 23 Apr 2019 13:53:47 -0700 Subject: [PATCH] [fenix] Closes https://github.com/mozilla-mobile/fenix/issues/919: Enable bookmarks synchronization --- .../org/mozilla/fenix/components/BackgroundServices.kt | 8 ++++++-- .../main/java/org/mozilla/fenix/components/Components.kt | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/org/mozilla/fenix/components/BackgroundServices.kt b/app/src/main/java/org/mozilla/fenix/components/BackgroundServices.kt index 425e6161ec..218ebe2c08 100644 --- a/app/src/main/java/org/mozilla/fenix/components/BackgroundServices.kt +++ b/app/src/main/java/org/mozilla/fenix/components/BackgroundServices.kt @@ -8,6 +8,7 @@ import android.content.Context import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch +import mozilla.components.browser.storage.sync.PlacesBookmarksStorage import mozilla.components.browser.storage.sync.PlacesHistoryStorage import mozilla.components.feature.sync.BackgroundSyncManager import mozilla.components.feature.sync.GlobalSyncableStoreProvider @@ -20,7 +21,8 @@ import mozilla.components.service.fxa.FxaAccountManager */ class BackgroundServices( context: Context, - historyStorage: PlacesHistoryStorage + historyStorage: PlacesHistoryStorage, + bookmarkStorage: PlacesBookmarksStorage ) { companion object { const val CLIENT_ID = "a2270f727f45f648" @@ -35,12 +37,14 @@ class BackgroundServices( private val config = Config.release(CLIENT_ID, REDIRECT_URL) init { - // Make the "history" store accessible to workers spawned by the sync manager. + // Make the "history" and "bookmark" stores accessible to workers spawned by the sync manager. GlobalSyncableStoreProvider.configureStore("history" to historyStorage) + GlobalSyncableStoreProvider.configureStore("bookmarks" to bookmarkStorage) } val syncManager = BackgroundSyncManager("https://identity.mozilla.com/apps/oldsync").also { it.addStore("history") + it.addStore("bookmarks") } val accountManager = FxaAccountManager(context, config, scopes, syncManager).also { diff --git a/app/src/main/java/org/mozilla/fenix/components/Components.kt b/app/src/main/java/org/mozilla/fenix/components/Components.kt index c28cadb3fc..1c5c8a8432 100644 --- a/app/src/main/java/org/mozilla/fenix/components/Components.kt +++ b/app/src/main/java/org/mozilla/fenix/components/Components.kt @@ -10,7 +10,7 @@ import android.content.Context * Provides access to all components. */ class Components(private val context: Context) { - val backgroundServices by lazy { BackgroundServices(context, core.historyStorage) } + val backgroundServices by lazy { BackgroundServices(context, core.historyStorage, core.bookmarksStorage) } val services by lazy { Services(backgroundServices.accountManager, useCases.tabsUseCases) } val core by lazy { Core(context) } val search by lazy { Search(context) }