2019-01-24 22:07:52 +01:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
2019-01-23 23:48:15 +01:00
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2019-01-24 22:07:52 +01:00
|
|
|
|
2019-01-23 22:39:53 +01:00
|
|
|
package org.mozilla.fenix.components
|
|
|
|
|
|
|
|
import android.content.Context
|
|
|
|
import kotlinx.coroutines.GlobalScope
|
|
|
|
import kotlinx.coroutines.launch
|
|
|
|
import mozilla.components.browser.search.SearchEngineManager
|
2019-05-07 23:36:37 +02:00
|
|
|
import org.mozilla.fenix.test.Mockable
|
2019-03-12 18:17:15 +01:00
|
|
|
import org.mozilla.fenix.utils.Settings
|
2019-01-23 22:39:53 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Component group for all search engine integration related functionality.
|
|
|
|
*/
|
2019-05-07 23:36:37 +02:00
|
|
|
@Mockable
|
2019-01-23 22:39:53 +01:00
|
|
|
class Search(private val context: Context) {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This component provides access to a centralized registry of search engines.
|
|
|
|
*/
|
|
|
|
val searchEngineManager by lazy {
|
|
|
|
SearchEngineManager().apply {
|
2019-03-06 20:39:38 +01:00
|
|
|
registerForLocaleUpdates(context)
|
2019-01-23 22:39:53 +01:00
|
|
|
GlobalScope.launch {
|
|
|
|
load(context).await()
|
|
|
|
}
|
2019-03-12 18:17:15 +01:00
|
|
|
defaultSearchEngine = getDefaultSearchEngine(
|
|
|
|
context,
|
|
|
|
Settings.getInstance(context).defaultSearchEngineName
|
|
|
|
)
|
2019-01-23 22:39:53 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|