Commit 48593938 authored by clairehurst's avatar clairehurst 🌱
Browse files

Enable the connect assist experiments on alpha

parent a61486e2
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -799,6 +799,11 @@ class GeckoEngine(
        override var prioritizeOnions: Boolean
            get() = runtime.settings.prioritizeOnions
            set(value) { runtime.settings.prioritizeOnions = value }
        override var useNewBootstrap: Boolean
            get() = runtime.settings.useNewBootstrap
            set(value) {
                runtime.settings.useNewBootstrap = value
            }
    }.apply {
        defaultSettings?.let {
            this.javascriptEnabled = it.javascriptEnabled
@@ -824,6 +829,7 @@ class GeckoEngine(
            this.torSecurityLevel = it.torSecurityLevel
            this.spoofEnglish = it.spoofEnglish
            this.prioritizeOnions = it.prioritizeOnions
            this.useNewBootstrap = it.useNewBootstrap
        }
    }

@@ -929,6 +935,8 @@ class GeckoEngine(
            unBlockedBySmartBlock = this.blockingData.any { it.unBlockedBySmartBlock() },
        )
    }

    fun getTorIntegrationController() = runtime.getTorIntegrationController()
}

internal fun ContentBlockingController.LogEntry.BlockingData.hasBlockedCookies(): Boolean {
+3 −0
Original line number Diff line number Diff line
@@ -214,6 +214,8 @@ abstract class Settings {
    open var spoofEnglish: Boolean by UnsupportedSetting()

    open var prioritizeOnions: Boolean by UnsupportedSetting()

    open var useNewBootstrap: Boolean by UnsupportedSetting()
}

/**
@@ -259,6 +261,7 @@ data class DefaultSettings(
    override var torSecurityLevel: Int = 4,
    override var spoofEnglish: Boolean = false,
    override var prioritizeOnions: Boolean = false,
    override var useNewBootstrap: Boolean = false,
) : Settings()

class UnsupportedSetting<T> {
+43 −2
Original line number Diff line number Diff line
@@ -164,6 +164,11 @@ import org.mozilla.fenix.utils.Settings
import java.lang.ref.WeakReference
import java.util.Locale

import androidx.navigation.fragment.findNavController
import mozilla.components.browser.engine.gecko.GeckoEngine
import mozilla.components.browser.state.selector.findCustomTab
import org.mozilla.geckoview.TorIntegrationAndroid

/**
 * The main activity of the application. The application is primarily a single Activity (this one)
 * with fragments switching out to display different views. The most important views shown here are the:
@@ -171,7 +176,7 @@ import java.util.Locale
 * - browser screen
 */
@SuppressWarnings("TooManyFunctions", "LargeClass", "LongParameterList", "LongMethod")
open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity {
open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity, TorIntegrationAndroid.BootstrapStateChangeListener {
    // DO NOT MOVE ANYTHING ABOVE THIS, GETTING INIT TIME IS CRITICAL
    // we need to store startup timestamp for warm startup. we cant directly store
    // inside AppStartupTelemetry since that class lives inside components and
@@ -201,7 +206,7 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity {

    private var inflater: LayoutInflater? = null

    private val navHost by lazy {
    val navHost by lazy {
        supportFragmentManager.findFragmentById(R.id.container) as NavHostFragment
    }

@@ -396,6 +401,12 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity {

        components.notificationsDelegate.bindToActivity(this)

        val engine = components.core.engine
        if (engine is GeckoEngine) {
            val torIntegration = engine.getTorIntegrationController()
            torIntegration.registerBootstrapStateChangeListener(this)
        }

        StartupTimeline.onActivityCreateEndHome(this) // DO NOT MOVE ANYTHING BELOW HERE.
    }

@@ -609,6 +620,12 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity {
            // underlying Application, as well.
            (application as FenixApplication).terminate()
        }

        val engine = components.core.engine
        if (engine is GeckoEngine) {
            val torIntegration = engine.getTorIntegrationController()
            torIntegration.unregisterBootstrapStateChangeListener(this)
        }
    }

    override fun onConfigurationChanged(newConfig: Configuration) {
@@ -1163,8 +1180,21 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity {
    }

    open fun navigateToHome() {
        if (settings().useNewBootstrap) {
            if (settings().useNewBootstrapNativeUi) {
                navHost.navController.navigate(NavGraphDirections.actionStartupTorConnectionAssist())
            } else {
                navHost.navController.navigate(NavGraphDirections.actionStartupHome())
                openToBrowserAndLoad(
                    searchTermOrURL = "about:torconnect",
                    newTab = true,
                    from = BrowserDirection.FromHome,
                )
            }
        } else {
            navHost.navController.navigate(NavGraphDirections.actionStartupTorbootstrap())
        }
    }

    override fun attachBaseContext(base: Context) {
        base.components.strictMode.resetAfter(StrictMode.allowThreadDiskReads()) {
@@ -1341,4 +1371,15 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity {
        // telemetry purposes.
        const val PWA_RECENTLY_USED_THRESHOLD = DateUtils.DAY_IN_MILLIS * 30L
    }

    override fun onBootstrapStateChange(state: String) = Unit
    override fun onBootstrapProgress(progress: Double, status: String, hasWarnings: Boolean) = Unit
    override fun onBootstrapComplete() {
        components.useCases.tabsUseCases.removeAllTabs()
        navHost.navController.navigate(NavGraphDirections.actionStartupHome())
    }
    override fun onBootstrapError(message: String, details: String) = Unit
    override fun onSettingsRequested() {
        navHost.navController.navigate(NavGraphDirections.actionGlobalSettingsFragment())
    }
}
+21 −0
Original line number Diff line number Diff line
@@ -1189,6 +1189,9 @@ abstract class BaseBrowserFragment :
                val context = requireContext()
                resumeDownloadDialogState(selectedTab.id, context.components.core.store, context, toolbarHeight)
                it.announceForAccessibility(selectedTab.toDisplayTitle())
                if (getCurrentTab()?.content?.url == "about:torconnect") {
                    browserToolbarView.view.visibility = View.GONE
                }
            }
        } else {
            view?.let { view -> initializeUI(view) }
@@ -1206,6 +1209,24 @@ abstract class BaseBrowserFragment :
            components.useCases.sessionUseCases.reload()
        }
        hideToolbar()
        handleBetaHtmlTorConnect()
    }

    private fun handleBetaHtmlTorConnect() {
        if (getCurrentTab()?.content?.url == "about:torconnect") {
            if (!requireActivity().settings().useNewBootstrap) {
                requireContext().components.useCases.tabsUseCases.removeAllTabs()
                (requireActivity() as HomeActivity).navHost.navController.navigate(
                    NavGraphDirections.actionStartupTorbootstrap(),
                )
            } else if (!requireActivity().settings().useNewBootstrapHtmlUi) {
                requireContext().components.useCases.tabsUseCases.removeAllTabs()
                (requireActivity() as HomeActivity).navigateToHome()
            } else {
                // This just makes it not flash (be visible for a split second) before handleTabSelected() hides it again
                browserToolbarView.view.visibility = View.GONE
            }
        }
    }

    @CallSuper
+1 −0
Original line number Diff line number Diff line
@@ -146,6 +146,7 @@ class Core(
            torSecurityLevel = context.settings().torSecurityLevel().intRepresentation,
            spoofEnglish = context.settings().spoofEnglish,
            prioritizeOnions = context.settings().prioritizeOnions,
            useNewBootstrap = context.settings().useNewBootstrap,
        )

        GeckoEngine(
Loading