Commit 3c557139 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 c6f0d202
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -382,6 +382,7 @@ class GeckoWebExtension(
                temporary = it.temporary,
                detailUrl = it.amoListingUrl,
                incognito = Incognito.fromString(it.incognito),
                defaultPrivateBrowsingAllowed = it.allowedInPrivateBrowsing,
            )
        }
    }
@@ -396,6 +397,7 @@ class GeckoWebExtension(

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

    override suspend fun loadIcon(size: Int): Bitmap? {
+13 −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.
     */
@@ -486,6 +494,11 @@ data class Metadata(
     * https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/incognito
     */
    val incognito: Incognito,

    /**
     * Wether this extension should default to pbm-allowed because being installed in global PBM
     */
    val defaultPrivateBrowsingAllowed : Boolean = false,
)

/**
+3 −0
Original line number Diff line number Diff line
@@ -54,6 +54,7 @@ val logger = Logger("Addon")
 * @property ratingUrl The link to the ratings page (user reviews) for this [Addon].
 * @property detailUrl The link to the detail page for this [Addon].
 * @property incognito Indicates how the extension works with private browsing windows.
 * @property defaultPrivateBrowsingAllowed whether the extension should default to pbm-enabled.
 */
@SuppressLint("ParcelCreator")
@Parcelize
@@ -81,6 +82,7 @@ data class Addon(
    val ratingUrl: String = "",
    val detailUrl: String = "",
    val incognito: Incognito = Incognito.SPANNING,
    val defaultPrivateBrowsingAllowed: Boolean = false,
) : Parcelable {

    /**
@@ -660,6 +662,7 @@ data class Addon(
                detailUrl = detailUrl,
                incognito = incognito,
                installedState = installedState,
                defaultPrivateBrowsingAllowed = metadata?.defaultPrivateBrowsingAllowed == true,
            )
        }

+3 −0
Original line number Diff line number Diff line
@@ -287,6 +287,9 @@ class PermissionsDialogFragment : AddonDialogFragment() {
        ) {
            optionalsSettingsTitle.isVisible = false
            allowedInPrivateBrowsing.isVisible = false
        } else {
            allowedInPrivateBrowsing.isChecked = addon.defaultPrivateBrowsingAllowed
            allowedInPrivateBrowsing.isVisible = !addon.defaultPrivateBrowsingAllowed
        }

        if (dataCollectionPermissions.contains(TECHNICAL_AND_INTERACTION_PERM) && !forOptionalPermissions) {
+1 −0
Original line number Diff line number Diff line
@@ -252,6 +252,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(
Loading