mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-17 15:26:23 +00:00
[fenix] For https://github.com/mozilla-mobile/fenix/issues/25816: Have the previous autocomplete functionality work with the new API
The new API allows us to move from having just two autocomplete providers: a shipped list of domains and history result to any autocomplete providers.
This commit is contained in:
parent
556c741d4f
commit
12c8d94eeb
@ -8,13 +8,13 @@ import android.content.Context
|
|||||||
import androidx.annotation.VisibleForTesting
|
import androidx.annotation.VisibleForTesting
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.lifecycle.LifecycleOwner
|
import androidx.lifecycle.LifecycleOwner
|
||||||
import mozilla.components.browser.domains.autocomplete.DomainAutocompleteProvider
|
import mozilla.components.browser.domains.autocomplete.BaseDomainAutocompleteProvider
|
||||||
import mozilla.components.browser.state.selector.normalTabs
|
import mozilla.components.browser.state.selector.normalTabs
|
||||||
import mozilla.components.browser.state.selector.privateTabs
|
import mozilla.components.browser.state.selector.privateTabs
|
||||||
import mozilla.components.browser.toolbar.BrowserToolbar
|
import mozilla.components.browser.toolbar.BrowserToolbar
|
||||||
import mozilla.components.browser.toolbar.display.DisplayToolbar
|
import mozilla.components.browser.toolbar.display.DisplayToolbar
|
||||||
import mozilla.components.concept.engine.Engine
|
import mozilla.components.concept.engine.Engine
|
||||||
import mozilla.components.concept.storage.HistoryStorage
|
import mozilla.components.concept.toolbar.AutocompleteProvider
|
||||||
import mozilla.components.feature.tabs.toolbar.TabCounterToolbarButton
|
import mozilla.components.feature.tabs.toolbar.TabCounterToolbarButton
|
||||||
import mozilla.components.feature.toolbar.ToolbarAutocompleteFeature
|
import mozilla.components.feature.toolbar.ToolbarAutocompleteFeature
|
||||||
import mozilla.components.feature.toolbar.ToolbarBehaviorController
|
import mozilla.components.feature.toolbar.ToolbarBehaviorController
|
||||||
@ -77,12 +77,13 @@ abstract class ToolbarIntegration(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Suppress("LongParameterList")
|
||||||
class DefaultToolbarIntegration(
|
class DefaultToolbarIntegration(
|
||||||
context: Context,
|
context: Context,
|
||||||
toolbar: BrowserToolbar,
|
toolbar: BrowserToolbar,
|
||||||
toolbarMenu: ToolbarMenu,
|
toolbarMenu: ToolbarMenu,
|
||||||
domainAutocompleteProvider: DomainAutocompleteProvider,
|
domainAutocompleteProvider: BaseDomainAutocompleteProvider,
|
||||||
historyStorage: HistoryStorage,
|
historyStorage: AutocompleteProvider,
|
||||||
lifecycleOwner: LifecycleOwner,
|
lifecycleOwner: LifecycleOwner,
|
||||||
sessionId: String? = null,
|
sessionId: String? = null,
|
||||||
isPrivate: Boolean,
|
isPrivate: Boolean,
|
||||||
@ -155,10 +156,15 @@ class DefaultToolbarIntegration(
|
|||||||
toolbar,
|
toolbar,
|
||||||
engineForSpeculativeConnects,
|
engineForSpeculativeConnects,
|
||||||
).apply {
|
).apply {
|
||||||
addDomainProvider(domainAutocompleteProvider)
|
updateAutocompleteProviders(
|
||||||
if (context.settings().shouldShowHistorySuggestions) {
|
listOfNotNull(
|
||||||
addHistoryStorageProvider(historyStorage)
|
when (context.settings().shouldShowHistorySuggestions) {
|
||||||
}
|
true -> historyStorage
|
||||||
|
false -> null
|
||||||
|
},
|
||||||
|
domainAutocompleteProvider,
|
||||||
|
),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ class DefaultToolbarIntegrationTest {
|
|||||||
context = testContext,
|
context = testContext,
|
||||||
toolbar = mockk(relaxed = true),
|
toolbar = mockk(relaxed = true),
|
||||||
toolbarMenu = mockk(relaxed = true),
|
toolbarMenu = mockk(relaxed = true),
|
||||||
domainAutocompleteProvider = mockk(),
|
domainAutocompleteProvider = mockk(relaxed = true),
|
||||||
historyStorage = mockk(),
|
historyStorage = mockk(),
|
||||||
lifecycleOwner = mockk(),
|
lifecycleOwner = mockk(),
|
||||||
sessionId = null,
|
sessionId = null,
|
||||||
|
Loading…
Reference in New Issue
Block a user