Pass concept-fetch Client implementation to SearchSuggestionProvider.
parent
ee229c9709
commit
4a66c60548
|
@ -12,12 +12,14 @@ import kotlinx.coroutines.GlobalScope
|
||||||
import kotlinx.coroutines.async
|
import kotlinx.coroutines.async
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import mozilla.components.browser.engine.gecko.GeckoEngine
|
import mozilla.components.browser.engine.gecko.GeckoEngine
|
||||||
|
import mozilla.components.browser.engine.gecko.fetch.GeckoViewFetchClient
|
||||||
import mozilla.components.browser.session.SessionManager
|
import mozilla.components.browser.session.SessionManager
|
||||||
import mozilla.components.browser.session.storage.SessionStorage
|
import mozilla.components.browser.session.storage.SessionStorage
|
||||||
import mozilla.components.browser.storage.sync.PlacesHistoryStorage
|
import mozilla.components.browser.storage.sync.PlacesHistoryStorage
|
||||||
import mozilla.components.concept.engine.DefaultSettings
|
import mozilla.components.concept.engine.DefaultSettings
|
||||||
import mozilla.components.concept.engine.Engine
|
import mozilla.components.concept.engine.Engine
|
||||||
import mozilla.components.concept.engine.EngineSession.TrackingProtectionPolicy
|
import mozilla.components.concept.engine.EngineSession.TrackingProtectionPolicy
|
||||||
|
import mozilla.components.concept.fetch.Client
|
||||||
import mozilla.components.feature.session.HistoryDelegate
|
import mozilla.components.feature.session.HistoryDelegate
|
||||||
import mozilla.components.feature.session.bundling.SessionBundleStorage
|
import mozilla.components.feature.session.bundling.SessionBundleStorage
|
||||||
import mozilla.components.lib.crash.handler.CrashHandlerService
|
import mozilla.components.lib.crash.handler.CrashHandlerService
|
||||||
|
@ -31,6 +33,14 @@ import java.util.concurrent.TimeUnit
|
||||||
*/
|
*/
|
||||||
class Core(private val context: Context) {
|
class Core(private val context: Context) {
|
||||||
|
|
||||||
|
private val runtime by lazy {
|
||||||
|
val runtimeSettings = GeckoRuntimeSettings.Builder()
|
||||||
|
.crashHandler(CrashHandlerService::class.java)
|
||||||
|
.build()
|
||||||
|
|
||||||
|
GeckoRuntime.create(context, runtimeSettings)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The browser engine component initialized based on the build
|
* The browser engine component initialized based on the build
|
||||||
* configuration (see build variants).
|
* configuration (see build variants).
|
||||||
|
@ -46,15 +56,16 @@ class Core(private val context: Context) {
|
||||||
historyTrackingDelegate = HistoryDelegate(historyStorage)
|
historyTrackingDelegate = HistoryDelegate(historyStorage)
|
||||||
)
|
)
|
||||||
|
|
||||||
val runtimeSettings = GeckoRuntimeSettings.Builder()
|
|
||||||
.crashHandler(CrashHandlerService::class.java)
|
|
||||||
.build()
|
|
||||||
|
|
||||||
val runtime = GeckoRuntime.create(context, runtimeSettings)
|
|
||||||
|
|
||||||
GeckoEngine(context, defaultSettings, runtime)
|
GeckoEngine(context, defaultSettings, runtime)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [Client] implementation to be used for code depending on `concept-fetch``
|
||||||
|
*/
|
||||||
|
val client: Client by lazy {
|
||||||
|
GeckoViewFetchClient(context, runtime)
|
||||||
|
}
|
||||||
|
|
||||||
val sessionStorage by lazy {
|
val sessionStorage by lazy {
|
||||||
SessionBundleStorage(context, bundleLifetime = Pair(1, TimeUnit.HOURS))
|
SessionBundleStorage(context, bundleLifetime = Pair(1, TimeUnit.HOURS))
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,6 +59,7 @@ class AwesomeBarUIView(
|
||||||
if (useNewTab) {
|
if (useNewTab) {
|
||||||
components.useCases.searchUseCases.newTabSearch
|
components.useCases.searchUseCases.newTabSearch
|
||||||
} else components.useCases.searchUseCases.defaultSearch,
|
} else components.useCases.searchUseCases.defaultSearch,
|
||||||
|
components.core.client,
|
||||||
SearchSuggestionProvider.Mode.MULTIPLE_SUGGESTIONS
|
SearchSuggestionProvider.Mode.MULTIPLE_SUGGESTIONS
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue