2019-01-24 22:07:52 +01:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
2019-07-12 20:38:15 +02: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
|
2020-02-04 07:41:52 +01:00
|
|
|
import mozilla.components.feature.addons.AddonManager
|
|
|
|
import mozilla.components.feature.addons.amo.AddonCollectionProvider
|
|
|
|
import mozilla.components.feature.addons.update.AddonUpdater
|
|
|
|
import mozilla.components.feature.addons.update.DefaultAddonUpdater
|
|
|
|
import mozilla.components.feature.tabs.TabsUseCases
|
2019-08-01 01:20:34 +02:00
|
|
|
import mozilla.components.lib.publicsuffixlist.PublicSuffixList
|
2020-01-15 06:59:08 +01:00
|
|
|
import mozilla.components.support.migration.state.MigrationStore
|
2020-02-10 22:57:29 +01:00
|
|
|
import org.mozilla.fenix.browser.browsingmode.DefaultBrowsingModeManager
|
2019-05-07 23:36:37 +02:00
|
|
|
import org.mozilla.fenix.test.Mockable
|
2019-09-18 20:23:32 +02:00
|
|
|
import org.mozilla.fenix.utils.ClipboardHandler
|
2020-02-04 07:41:52 +01:00
|
|
|
import java.util.concurrent.TimeUnit
|
|
|
|
|
|
|
|
private const val DAY_IN_MINUTES = 24 * 60L
|
2019-01-23 22:39:53 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Provides access to all components.
|
|
|
|
*/
|
2019-05-07 23:36:37 +02:00
|
|
|
@Mockable
|
2019-01-23 22:39:53 +01:00
|
|
|
class Components(private val context: Context) {
|
2019-05-23 22:13:27 +02:00
|
|
|
val backgroundServices by lazy {
|
2019-11-04 23:02:16 +01:00
|
|
|
BackgroundServices(
|
|
|
|
context,
|
|
|
|
analytics.crashReporter,
|
|
|
|
core.historyStorage,
|
|
|
|
core.bookmarksStorage,
|
2020-01-14 01:18:41 +01:00
|
|
|
core.syncablePasswordsStorage,
|
2019-11-14 17:23:15 +01:00
|
|
|
core.getSecureAbove22Preferences()
|
2019-11-04 23:02:16 +01:00
|
|
|
)
|
2019-05-23 22:13:27 +02:00
|
|
|
}
|
2019-08-23 01:56:13 +02:00
|
|
|
val services by lazy { Services(context, backgroundServices.accountManager) }
|
2019-01-23 22:39:53 +01:00
|
|
|
val core by lazy { Core(context) }
|
|
|
|
val search by lazy { Search(context) }
|
2019-08-29 21:45:11 +02:00
|
|
|
val useCases by lazy {
|
2019-09-26 21:50:50 +02:00
|
|
|
UseCases(
|
|
|
|
context,
|
|
|
|
core.sessionManager,
|
|
|
|
core.store,
|
|
|
|
core.engine.settings,
|
|
|
|
search.searchEngineManager,
|
2019-11-07 20:30:03 +01:00
|
|
|
core.webAppShortcutManager
|
2019-09-26 21:50:50 +02:00
|
|
|
)
|
2019-08-29 21:45:11 +02:00
|
|
|
}
|
2019-09-18 20:23:32 +02:00
|
|
|
val intentProcessors by lazy {
|
2019-10-09 18:17:49 +02:00
|
|
|
IntentProcessors(
|
|
|
|
context,
|
|
|
|
core.sessionManager,
|
|
|
|
useCases.sessionUseCases,
|
|
|
|
useCases.searchUseCases,
|
|
|
|
core.client,
|
2020-01-15 06:59:08 +01:00
|
|
|
core.customTabsStore,
|
2020-02-06 15:23:11 +01:00
|
|
|
migrationStore,
|
|
|
|
core.webAppManifestStorage
|
2019-10-09 18:17:49 +02:00
|
|
|
)
|
2019-09-18 20:23:32 +02:00
|
|
|
}
|
2020-02-04 07:41:52 +01:00
|
|
|
|
|
|
|
val addonCollectionProvider by lazy {
|
|
|
|
AddonCollectionProvider(context, core.client, maxCacheAgeInMinutes = DAY_IN_MINUTES)
|
|
|
|
}
|
|
|
|
|
|
|
|
val addonUpdater by lazy {
|
|
|
|
DefaultAddonUpdater(context, AddonUpdater.Frequency(1, TimeUnit.DAYS))
|
|
|
|
}
|
|
|
|
|
|
|
|
val addonManager by lazy {
|
|
|
|
AddonManager(core.store, core.engine, addonCollectionProvider, addonUpdater)
|
|
|
|
}
|
|
|
|
|
2020-02-10 22:57:29 +01:00
|
|
|
val browsingModeManager by lazy { DefaultBrowsingModeManager() }
|
|
|
|
|
2020-02-04 07:41:52 +01:00
|
|
|
val tabsUseCases: TabsUseCases by lazy { TabsUseCases(core.sessionManager) }
|
|
|
|
|
2019-01-29 17:42:10 +01:00
|
|
|
val analytics by lazy { Analytics(context) }
|
2019-08-01 01:20:34 +02:00
|
|
|
val publicSuffixList by lazy { PublicSuffixList(context) }
|
2019-09-18 20:23:32 +02:00
|
|
|
val clipboardHandler by lazy { ClipboardHandler(context) }
|
2020-01-15 06:59:08 +01:00
|
|
|
val migrationStore by lazy { MigrationStore() }
|
2019-01-29 17:42:10 +01:00
|
|
|
}
|