Commit 7c19ba4c authored by ma1's avatar ma1 Committed by Pier Angelo Vendrame
Browse files

[android] Modify add-on support

Bug 41160: One-time ultimate switch Tor Browser Android to HTTPS-Only.
Bug 41159: Remove HTTPS-Everywhere extension from Tor Browser Android.

Bug 41094: Enable HTTPS-Only Mode by default in Tor Browser Android.

Turn shouldUseHttpsOnly's default to true.

Bug 40225: Bundled extensions don't get updated with Android Tor
           Browser updates.

Bug 40030: Install NoScript addon on startup.

Also 40070: Consider storing the list of recommended addons

This implements our own AddonsProvider, which loads the list of
available addons from assets instead of fetching it from an
endpoint.

Also, we hide the uninstall button for builtin addons.

Bug 40058: Hide option for disallowing addon in private mode
parent 98ac373e
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -396,6 +396,7 @@ class GeckoWebExtension(

    override fun isAllowedInPrivateBrowsing(): Boolean {
        return isBuiltIn() || nativeExtension.metaData.allowedInPrivateBrowsing
            || isBundled()
    }

    override suspend fun loadIcon(size: Int): Bitmap? {
+8 −0
Original line number Diff line number Diff line
@@ -164,6 +164,14 @@ abstract class WebExtension(
     */
    open fun isBuiltIn(): Boolean = url.toUri().scheme == "resource"

    /**
     * Checks whether or not this extension is bundled with this browser,
     * but otherwise behaves as an unprivileged (non built-in) extension,
     * except it cannot be disabled or uninstalled from the UI (e.g.
     * NoScript in the Tor Browser).
     */
    open fun isBundled(): Boolean = id == "{73a6fe31-595d-460b-a920-fcc0f8843232}"

    /**
     * Checks whether or not this extension is enabled.
     */
+1 −0
Original line number Diff line number Diff line
@@ -248,6 +248,7 @@ object WebExtensionSupport {
                    // when the add-on has already been installed, we don't need to show anything
                    // either.
                    val shouldDispatchAction = !installedExtensions.containsKey(extension.id) && !extension.isBuiltIn()
                        && !extension.isBundled()
                    registerInstalledExtension(store, extension)
                    if (shouldDispatchAction) {
                        store.dispatch(
+1 −1
Original line number Diff line number Diff line
@@ -167,7 +167,7 @@ class BrowserRobot {
            verifyUrl("/releaseNotes")
        } catch (e: AssertionError) {
            Log.i(TAG, "verifyWhatsNewURL: AssertionError caught, checking redirect URL")
            verifyUrl(SupportUtils.WHATS_NEW_URL)
            verifyUrl(SupportUtils.getTorWhatsNewUrl())
        }
    }

+9 −2
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import mozilla.components.support.ktx.android.content.appName
import mozilla.components.support.ktx.android.content.appVersionName
import org.mozilla.fenix.BrowserDirection
import org.mozilla.fenix.BuildConfig
import mozilla.components.support.webextensions.WebExtensionSupport.installedExtensions
import org.mozilla.fenix.HomeActivity
import org.mozilla.fenix.databinding.FragmentInstalledAddOnDetailsBinding
import org.mozilla.fenix.ext.components
@@ -53,6 +54,8 @@ class InstalledAddonDetailsFragment : Fragment() {
    @Suppress("VariableNaming")
    internal var _binding: FragmentInstalledAddOnDetailsBinding? = null

    private var isBundledAddon = false;

    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
@@ -60,6 +63,7 @@ class InstalledAddonDetailsFragment : Fragment() {
    ): View {
        if (!::addon.isInitialized) {
            addon = AddonDetailsFragmentArgs.fromBundle(requireNotNull(arguments)).addon
            isBundledAddon = installedExtensions[addon.id]?.isBundled() ?: false
        }

        setBindingAndBindUI(
@@ -198,6 +202,7 @@ class InstalledAddonDetailsFragment : Fragment() {
        // When the ad-on is blocklisted or not correctly signed, we do not want to enable the toggle switch
        // because users shouldn't be able to re-enable an add-on in this state.
        if (
            isBundledAddon ||
            addon.isDisabledAsBlocklisted() ||
            addon.isDisabledAsNotCorrectlySigned() ||
            addon.isDisabledAsIncompatible()
@@ -216,7 +221,7 @@ class InstalledAddonDetailsFragment : Fragment() {
                        runIfFragmentIsAttached {
                            this.addon = it
                            switch.isClickable = true
                            privateBrowsingSwitch.isVisible = it.isEnabled()
                            privateBrowsingSwitch.isVisible = false
                            privateBrowsingSwitch.isChecked =
                                it.incognito != Addon.Incognito.NOT_ALLOWED && it.isAllowedInPrivateBrowsing()
                            binding.settings.isVisible = shouldSettingsBeVisible()
@@ -298,7 +303,7 @@ class InstalledAddonDetailsFragment : Fragment() {
    @VisibleForTesting
    internal fun bindAllowInPrivateBrowsingSwitch() {
        val switch = providePrivateBrowsingSwitch()
        switch.isVisible = addon.isEnabled()
        switch.isVisible = false

        if (addon.incognito == Addon.Incognito.NOT_ALLOWED) {
            switch.isChecked = false
@@ -337,6 +342,7 @@ class InstalledAddonDetailsFragment : Fragment() {
    }

    private fun bindReportButton() {
        binding.reportAddOn.isVisible = !isBundledAddon
        binding.reportAddOn.setOnClickListener {
            val shouldCreatePrivateSession = (activity as HomeActivity).browsingModeManager.mode.isPrivate

@@ -401,6 +407,7 @@ class InstalledAddonDetailsFragment : Fragment() {
    }

    private fun bindRemoveButton() {
        binding.removeAddOn.isVisible = !isBundledAddon
        binding.removeAddOn.setOnClickListener {
            setAllInteractiveViewsClickable(binding, false)
            requireContext().components.addonManager.uninstallAddon(
Loading