[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [Git][tpo/applications/fenix][tor-browser-81.1.2-10.0-2] 2 commits: Bug 40062: HTTPS Everywhere is not shown as installed



Title: GitLab

Matthew Finkel pushed to branch tor-browser-81.1.2-10.0-2 at The Tor Project / Applications / fenix

Commits:

4 changed files:

Changes:

  • app/src/main/assets/allowed_addons.json The diff for this file was not included because it is too large.
  • app/src/main/java/org/mozilla/fenix/addons/InstalledAddonDetailsFragment.kt
    ... ... @@ -21,6 +21,7 @@ import kotlinx.coroutines.launch
    21 21
     import mozilla.components.feature.addons.Addon
    
    22 22
     import mozilla.components.feature.addons.AddonManagerException
    
    23 23
     import mozilla.components.feature.addons.ui.translatedName
    
    24
    +import mozilla.components.support.webextensions.WebExtensionSupport.installedExtensions
    
    24 25
     import org.mozilla.fenix.HomeActivity
    
    25 26
     import org.mozilla.fenix.R
    
    26 27
     import org.mozilla.fenix.ext.components
    
    ... ... @@ -256,6 +257,8 @@ class InstalledAddonDetailsFragment : Fragment() {
    256 257
             }
    
    257 258
         }
    
    258 259
         private fun bindRemoveButton(view: View) {
    
    260
    +        val isBuiltin = installedExtensions[addon.id]?.isBuiltIn() ?: false
    
    261
    +        view.remove_add_on.isVisible = !isBuiltin
    
    259 262
             view.remove_add_on.setOnClickListener {
    
    260 263
                 setAllInteractiveViewsClickable(view, false)
    
    261 264
                 requireContext().components.addonManager.uninstallAddon(
    

  • app/src/main/java/org/mozilla/fenix/components/Components.kt
    ... ... @@ -9,7 +9,6 @@ import android.content.Context
    9 9
     import android.content.Intent
    
    10 10
     import androidx.core.net.toUri
    
    11 11
     import mozilla.components.feature.addons.AddonManager
    
    12
    -import mozilla.components.feature.addons.amo.AddonCollectionProvider
    
    13 12
     import mozilla.components.feature.addons.migration.DefaultSupportedAddonsChecker
    
    14 13
     import mozilla.components.feature.addons.migration.SupportedAddonsChecker
    
    15 14
     import mozilla.components.feature.addons.update.AddonUpdater
    
    ... ... @@ -71,18 +70,7 @@ class Components(private val context: Context) {
    71 70
             )
    
    72 71
         }
    
    73 72
     
    
    74
    -    val addonCollectionProvider by lazy {
    
    75
    -        if (!BuildConfig.AMO_COLLECTION.isNullOrEmpty()) {
    
    76
    -            AddonCollectionProvider(
    
    77
    -                context,
    
    78
    -                core.client,
    
    79
    -                collectionName = BuildConfig.AMO_COLLECTION,
    
    80
    -                maxCacheAgeInMinutes = DAY_IN_MINUTES
    
    81
    -            )
    
    82
    -        } else {
    
    83
    -            AddonCollectionProvider(context, core.client, maxCacheAgeInMinutes = DAY_IN_MINUTES)
    
    84
    -        }
    
    85
    -    }
    
    73
    +    val addonCollectionProvider by lazy { TorAddonCollectionProvider(context, core.client) }
    
    86 74
     
    
    87 75
         val appStartupTelemetry by lazy { AppStartupTelemetry(analytics.metrics) }
    
    88 76
     
    

  • app/src/main/java/org/mozilla/fenix/components/TorAddonCollectionProvider.kt
    1
    +/* This Source Code Form is subject to the terms of the Mozilla Public
    
    2
    + * License, v. 2.0. If a copy of the MPL was not distributed with this
    
    3
    + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
    
    4
    +
    
    5
    +// Copyright (c) 2020, The Tor Project, Inc.
    
    6
    +
    
    7
    +package org.mozilla.fenix.components
    
    8
    +
    
    9
    +import android.content.Context
    
    10
    +import android.graphics.Bitmap
    
    11
    +import kotlinx.coroutines.withContext
    
    12
    +import mozilla.components.concept.fetch.Client
    
    13
    +import mozilla.components.feature.addons.Addon
    
    14
    +import kotlinx.coroutines.Dispatchers
    
    15
    +import mozilla.components.feature.addons.amo.AddonCollectionProvider
    
    16
    +import java.io.IOException
    
    17
    +
    
    18
    +internal const val COLLECTION_NAME = "tor_browser_collection"
    
    19
    +internal const val ALLOWED_ADDONS_PATH = "allowed_addons.json"
    
    20
    +internal const val MAX_CACHE_AGE = 1000L * 365L * 24L * 60L // 1000 years
    
    21
    +
    
    22
    +class TorAddonCollectionProvider(
    
    23
    +    private val context: Context,
    
    24
    +    client: Client
    
    25
    +) : AddonCollectionProvider(
    
    26
    +    context, client, serverURL = "",
    
    27
    +    collectionName = COLLECTION_NAME,
    
    28
    +    maxCacheAgeInMinutes = MAX_CACHE_AGE
    
    29
    +) {
    
    30
    +    private var isCacheLoaded = false
    
    31
    +
    
    32
    +    @Throws(IOException::class)
    
    33
    +    override suspend fun getAvailableAddons(
    
    34
    +        allowCache: Boolean,
    
    35
    +        readTimeoutInSeconds: Long?
    
    36
    +    ): List<Addon> {
    
    37
    +        ensureCache()
    
    38
    +        return super.getAvailableAddons(true, readTimeoutInSeconds)
    
    39
    +    }
    
    40
    +
    
    41
    +    @Throws(IOException::class)
    
    42
    +    override suspend fun getAddonIconBitmap(addon: Addon): Bitmap? {
    
    43
    +        ensureCache()
    
    44
    +        return super.getAddonIconBitmap(addon)
    
    45
    +    }
    
    46
    +
    
    47
    +    @Throws(IOException::class)
    
    48
    +    private suspend fun ensureCache() {
    
    49
    +        if (isCacheLoaded) {
    
    50
    +            return
    
    51
    +        }
    
    52
    +        return withContext(Dispatchers.IO) {
    
    53
    +            val data = context.assets.open(ALLOWED_ADDONS_PATH).bufferedReader().use {
    
    54
    +                it.readText()
    
    55
    +            }
    
    56
    +            writeToDiskCache(data)
    
    57
    +            isCacheLoaded = true
    
    58
    +        }
    
    59
    +    }
    
    60
    +}

  • _______________________________________________
    tor-commits mailing list
    tor-commits@xxxxxxxxxxxxxxxxxxxx
    https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits