Closes #270: Integrate browser-storage-sync for history storage and toolbar autocompletion
parent
0ac3cd9e08
commit
0e3965632a
|
@ -90,6 +90,7 @@ dependencies {
|
|||
implementation Deps.mozilla_browser_domains
|
||||
implementation Deps.mozilla_browser_engine_gecko_nightly
|
||||
implementation Deps.mozilla_browser_session
|
||||
implementation Deps.mozilla_browser_storage_sync
|
||||
implementation Deps.mozilla_browser_toolbar
|
||||
|
||||
implementation Deps.mozilla_feature_awesomebar
|
||||
|
|
|
@ -52,7 +52,8 @@ class BrowserFragment : Fragment() {
|
|||
ToolbarIntegration(
|
||||
requireContext(),
|
||||
toolbar,
|
||||
requireComponents.toolbar.shippedDomainsProvider
|
||||
requireComponents.toolbar.shippedDomainsProvider,
|
||||
requireComponents.core.historyStorage
|
||||
)
|
||||
)
|
||||
|
||||
|
|
|
@ -11,9 +11,11 @@ import mozilla.components.browser.engine.gecko.GeckoEngine
|
|||
import mozilla.components.browser.session.Session
|
||||
import mozilla.components.browser.session.SessionManager
|
||||
import mozilla.components.browser.session.storage.SessionStorage
|
||||
import mozilla.components.browser.storage.sync.PlacesHistoryStorage
|
||||
import mozilla.components.concept.engine.DefaultSettings
|
||||
import mozilla.components.concept.engine.Engine
|
||||
import mozilla.components.concept.engine.EngineSession.TrackingProtectionPolicy
|
||||
import mozilla.components.feature.session.HistoryDelegate
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
/**
|
||||
|
@ -31,7 +33,8 @@ class Core(private val context: Context) {
|
|||
val defaultSettings = DefaultSettings(
|
||||
remoteDebuggingEnabled = false,
|
||||
testingModeEnabled = false,
|
||||
trackingProtectionPolicy = createTrackingProtectionPolicy(prefs)
|
||||
trackingProtectionPolicy = createTrackingProtectionPolicy(prefs),
|
||||
historyTrackingDelegate = HistoryDelegate(historyStorage)
|
||||
)
|
||||
GeckoEngine(context, defaultSettings)
|
||||
}
|
||||
|
@ -60,6 +63,12 @@ class Core(private val context: Context) {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The storage component to persist browsing history (with the exception of
|
||||
* private sessions).
|
||||
*/
|
||||
val historyStorage by lazy { PlacesHistoryStorage(context) }
|
||||
|
||||
/**
|
||||
* Constructs a [TrackingProtectionPolicy] based on current preferences.
|
||||
*
|
||||
|
|
|
@ -13,6 +13,7 @@ import androidx.navigation.Navigation
|
|||
import androidx.navigation.fragment.FragmentNavigator
|
||||
import mozilla.components.browser.domains.autocomplete.DomainAutocompleteProvider
|
||||
import mozilla.components.browser.toolbar.BrowserToolbar
|
||||
import mozilla.components.concept.storage.HistoryStorage
|
||||
import mozilla.components.feature.toolbar.ToolbarAutocompleteFeature
|
||||
import mozilla.components.feature.toolbar.ToolbarFeature
|
||||
import org.mozilla.fenix.R
|
||||
|
@ -23,6 +24,7 @@ class ToolbarIntegration(
|
|||
context: Context,
|
||||
toolbar: BrowserToolbar,
|
||||
domainAutocompleteProvider: DomainAutocompleteProvider,
|
||||
historyStorage: HistoryStorage,
|
||||
sessionId: String? = null
|
||||
) : LifecycleObserver {
|
||||
init {
|
||||
|
@ -50,6 +52,7 @@ class ToolbarIntegration(
|
|||
|
||||
ToolbarAutocompleteFeature(toolbar).apply {
|
||||
addDomainProvider(domainAutocompleteProvider)
|
||||
addHistoryStorageProvider(historyStorage)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -48,7 +48,9 @@ class SearchFragment : Fragment() {
|
|||
ToolbarIntegration(
|
||||
requireContext(),
|
||||
toolbar,
|
||||
ShippedDomainsProvider().also { it.initialize(requireContext()) })
|
||||
ShippedDomainsProvider().also { it.initialize(requireContext()) },
|
||||
requireComponents.core.historyStorage
|
||||
)
|
||||
)
|
||||
|
||||
awesomeBarFeature = AwesomeBarFeature(awesomeBar, toolbar, null, onEditComplete = ::userDidSearch)
|
||||
|
|
Loading…
Reference in New Issue