1
0
Fork 0

Pass concept-fetch Client implementation to SearchSuggestionProvider.

master
Sebastian Kaspari 2019-02-14 14:59:27 +01:00 committed by Colin Lee
parent ee229c9709
commit 4a66c60548
2 changed files with 18 additions and 6 deletions

View File

@ -12,12 +12,14 @@ import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.async
import kotlinx.coroutines.launch
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.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.concept.fetch.Client
import mozilla.components.feature.session.HistoryDelegate
import mozilla.components.feature.session.bundling.SessionBundleStorage
import mozilla.components.lib.crash.handler.CrashHandlerService
@ -31,6 +33,14 @@ import java.util.concurrent.TimeUnit
*/
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
* configuration (see build variants).
@ -46,15 +56,16 @@ class Core(private val context: Context) {
historyTrackingDelegate = HistoryDelegate(historyStorage)
)
val runtimeSettings = GeckoRuntimeSettings.Builder()
.crashHandler(CrashHandlerService::class.java)
.build()
val runtime = GeckoRuntime.create(context, runtimeSettings)
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 {
SessionBundleStorage(context, bundleLifetime = Pair(1, TimeUnit.HOURS))
}

View File

@ -59,6 +59,7 @@ class AwesomeBarUIView(
if (useNewTab) {
components.useCases.searchUseCases.newTabSearch
} else components.useCases.searchUseCases.defaultSearch,
components.core.client,
SearchSuggestionProvider.Mode.MULTIPLE_SUGGESTIONS
)
)