Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -76,21 +76,23 @@ dependencies {
implementation Deps.mozilla_concept_engine
implementation Deps.mozilla_concept_tabstray
implementation Deps.mozilla_concept_toolbar
implementation Deps.mozilla_concept_storage

implementation Deps.mozilla_browser_domains
implementation Deps.mozilla_browser_search
implementation Deps.mozilla_browser_session
implementation Deps.mozilla_browser_tabstray
implementation Deps.mozilla_browser_toolbar
implementation Deps.mozilla_browser_menu
implementation Deps.mozilla_browser_session
implementation Deps.mozilla_browser_storage_memory

implementation Deps.mozilla_feature_intent
implementation Deps.mozilla_feature_search
implementation Deps.mozilla_feature_session
implementation Deps.mozilla_feature_toolbar
implementation Deps.mozilla_feature_tabs
implementation Deps.mozilla_feature_downloads
implementation Deps.mozilla_feature_storage

implementation Deps.mozilla_ui_autocomplete

Expand Down
4 changes: 4 additions & 0 deletions app/src/main/java/org/mozilla/reference/browser/Components.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import mozilla.components.browser.search.SearchEngineManager
import mozilla.components.browser.session.Session
import mozilla.components.browser.session.SessionManager
import mozilla.components.browser.session.storage.DefaultSessionStorage
import mozilla.components.browser.storage.memory.InMemoryHistoryStorage
import mozilla.components.concept.engine.DefaultSettings
import mozilla.components.concept.engine.Engine
import mozilla.components.feature.intent.IntentProcessor
Expand All @@ -37,6 +38,9 @@ class Components(
EngineProvider.getEngine(applicationContext, defaultSettings)
}

// Storage
val historyStorage by lazy { InMemoryHistoryStorage() }

// Session
val sessionStorage by lazy { DefaultSessionStorage(applicationContext) }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import kotlinx.android.synthetic.main.fragment_browser.*
import mozilla.components.feature.downloads.DownloadsFeature
import mozilla.components.feature.downloads.SimpleDownloadDialogFragment.DownloadDialogListener
import mozilla.components.feature.session.SessionFeature
import mozilla.components.feature.storage.HistoryTrackingFeature
import mozilla.components.feature.tabs.toolbar.TabsToolbarFeature
import mozilla.components.support.ktx.android.content.isPermissionGranted
import org.mozilla.reference.browser.BackHandler
Expand All @@ -26,6 +27,7 @@ class BrowserFragment : Fragment(), BackHandler, DownloadDialogListener {
private lateinit var sessionFeature: SessionFeature
private lateinit var tabsToolbarFeature: TabsToolbarFeature
private lateinit var downloadsFeature: DownloadsFeature
private lateinit var historyTrackingFeature: HistoryTrackingFeature

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
return inflater.inflate(R.layout.fragment_browser, container, false)
Expand All @@ -36,6 +38,10 @@ class BrowserFragment : Fragment(), BackHandler, DownloadDialogListener {

val sessionId = arguments?.getString(SESSION_ID)

historyTrackingFeature = HistoryTrackingFeature(
requireComponents.engine,
requireComponents.historyStorage)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this is more like an "application level" feature and we would want to create this in BrowserApplication.onCreate() so that we track history even when there's no fragment/UI around. (cc @grigoryk)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what "tracking history without a browser fragment/ui around" means, but generally I agree, history tracking isn't conceptually tied to the UI, so moving this over to BrowserApplication makes sense.

Separately, we'd want to make that change in the sample-browser as well.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what "tracking history without a browser fragment/ui around" means

We are able to load URLs while the app is in the background and while there may not be any UI (but we still want to record history). Fragments come and go. There's no reason we want to re-register a new delegate whenever there's a new BrowserFragment getting created.


sessionFeature = SessionFeature(
requireComponents.sessionManager,
requireComponents.sessionUseCases,
Expand Down
3 changes: 3 additions & 0 deletions buildSrc/src/main/java/Dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ object Deps {
const val mozilla_concept_engine = "org.mozilla.components:concept-engine:${Versions.mozilla_android_components}"
const val mozilla_concept_tabstray = "org.mozilla.components:concept-tabstray:${Versions.mozilla_android_components}"
const val mozilla_concept_toolbar = "org.mozilla.components:concept-toolbar:${Versions.mozilla_android_components}"
const val mozilla_concept_storage = "org.mozilla.components:concept-storage:${Versions.mozilla_android_components}"
const val mozilla_browser_engine_system = "org.mozilla.components:browser-engine-system:${Versions.mozilla_android_components}"
const val mozilla_browser_engine_gecko = "org.mozilla.components:browser-engine-gecko:${Versions.mozilla_android_components}"
const val mozilla_browser_engine_gecko_beta = "org.mozilla.components:browser-engine-gecko-beta:${Versions.mozilla_android_components}"
Expand All @@ -39,12 +40,14 @@ object Deps {
const val mozilla_browser_toolbar = "org.mozilla.components:browser-toolbar:${Versions.mozilla_android_components}"
const val mozilla_browser_menu = "org.mozilla.components:browser-menu:${Versions.mozilla_android_components}"
const val mozilla_browser_errorpages = "org.mozilla.components:browser-errorpages:${Versions.mozilla_android_components}"
const val mozilla_browser_storage_memory = "org.mozilla.components:browser-storage-memory:${Versions.mozilla_android_components}"
const val mozilla_feature_intent = "org.mozilla.components:feature-intent:${Versions.mozilla_android_components}"
const val mozilla_feature_search = "org.mozilla.components:feature-search:${Versions.mozilla_android_components}"
const val mozilla_feature_session = "org.mozilla.components:feature-session:${Versions.mozilla_android_components}"
const val mozilla_feature_toolbar = "org.mozilla.components:feature-toolbar:${Versions.mozilla_android_components}"
const val mozilla_feature_tabs = "org.mozilla.components:feature-tabs:${Versions.mozilla_android_components}"
const val mozilla_feature_downloads = "org.mozilla.components:feature-downloads:${Versions.mozilla_android_components}"
const val mozilla_feature_storage = "org.mozilla.components:feature-storage:${Versions.mozilla_android_components}"
const val mozilla_ui_autocomplete = "org.mozilla.components:ui-autocomplete:${Versions.mozilla_android_components}"
const val mozilla_service_firefox_accounts = "org.mozilla.components:service-firefox-accounts:${Versions.mozilla_android_components}"
const val mozilla_support_utils = "org.mozilla.components:support-utils:${Versions.mozilla_android_components}"
Expand Down