Skip to content
This repository has been archived by the owner on Feb 20, 2023. It is now read-only.

Closes #270: Integrate browser-storage-sync #294

Merged
merged 1 commit into from
Jan 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ class BrowserFragment : Fragment() {
ToolbarIntegration(
requireContext(),
toolbar,
requireComponents.toolbar.shippedDomainsProvider
requireComponents.toolbar.shippedDomainsProvider,
requireComponents.core.historyStorage
)
)

Expand Down
11 changes: 10 additions & 1 deletion app/src/main/java/org/mozilla/fenix/components/Core.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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

/**
Expand All @@ -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)
}
Expand Down Expand Up @@ -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.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -23,6 +24,7 @@ class ToolbarIntegration(
context: Context,
toolbar: BrowserToolbar,
domainAutocompleteProvider: DomainAutocompleteProvider,
historyStorage: HistoryStorage,
sessionId: String? = null
) : LifecycleObserver {
init {
Expand Down Expand Up @@ -50,6 +52,7 @@ class ToolbarIntegration(

ToolbarAutocompleteFeature(toolbar).apply {
addDomainProvider(domainAutocompleteProvider)
addHistoryStorageProvider(historyStorage)
}
}

Expand Down
4 changes: 3 additions & 1 deletion app/src/main/java/org/mozilla/fenix/search/SearchFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down