Commit 6b4af383 authored by Matthew Finkel's avatar Matthew Finkel
Browse files

Bug 40026: Integrate Security Level settings

parent 1def5736
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -370,6 +370,8 @@ class DefaultSessionControlController(
    }

    override fun handleOpenSecurityLevelSettingsClicked() {
        val directions = HomeFragmentDirections.actionGlobalTorSecurityLevelFragment()
        navController.nav(R.id.homeFragment, directions)
    }

    override fun handleWhatsNewGetAnswersClicked() {
+9 −4
Original line number Diff line number Diff line
@@ -11,6 +11,8 @@ import org.mozilla.fenix.R
import org.mozilla.fenix.ext.components
import org.mozilla.fenix.home.sessioncontrol.OnboardingInteractor
import org.mozilla.fenix.onboarding.OnboardingRadioButton
import org.mozilla.fenix.tor.SecurityLevel
import org.mozilla.fenix.tor.SecurityLevelUtil
import org.mozilla.fenix.utils.view.addToRadioGroup

class TorOnboardingSecurityLevelViewHolder(
@@ -57,19 +59,22 @@ class TorOnboardingSecurityLevelViewHolder(
        saferSecurityLevel.isChecked = securityLevel == SecurityLevel.SAFER

        standardSecurityLevel.onClickListener {
            updateSecurityLevel()
            updateSecurityLevel(SecurityLevel.STANDARD)
        }

        saferSecurityLevel.onClickListener {
            updateSecurityLevel()
            updateSecurityLevel(SecurityLevel.SAFER)
        }

        safestSecurityLevel.onClickListener {
            updateSecurityLevel()
            updateSecurityLevel(SecurityLevel.SAFEST)
        }
    }

    private fun updateSecurityLevel() {
    private fun updateSecurityLevel(newLevel: SecurityLevel) {
        itemView.context.components.let {
            it.core.engine.settings.torSecurityLevel = newLevel.intRepresentation
        }
    }

    companion object {
+3 −0
Original line number Diff line number Diff line
@@ -218,6 +218,9 @@ class SettingsFragment : PreferenceFragmentCompat() {
            resources.getString(R.string.pref_key_tor_network_settings) -> {
                SettingsFragmentDirections.actionSettingsFragmentToTorNetworkSettingsFragment()
            }
            resources.getString(R.string.pref_key_tor_security_level_settings) -> {
                SettingsFragmentDirections.actionSettingsFragmentToTorSecurityLevelFragment()
            }
            resources.getString(R.string.pref_key_tracking_protection_settings) -> {
                requireContext().metrics.track(Event.TrackingProtectionSettings)
                SettingsFragmentDirections.actionSettingsFragmentToTrackingProtectionFragment()
+10 −0
Original line number Diff line number Diff line
@@ -62,6 +62,9 @@
    <action
        android:id="@+id/action_global_syncedTabsFragment"
        app:destination="@id/syncedTabsFragment" />
    <action
        android:id="@+id/action_global_torSecurityLevelFragment"
        app:destination="@id/torSecurityLevelFragment" />
    <action
        android:id="@+id/action_global_privateBrowsingFragment"
        app:destination="@id/privateBrowsingFragment" />
@@ -506,6 +509,13 @@
            app:exitAnim="@anim/slide_out_left"
            app:popEnterAnim="@anim/slide_in_left"
            app:popExitAnim="@anim/slide_out_right" />
        <action
            android:id="@+id/action_settingsFragment_to_torSecurityLevelFragment"
            app:destination="@id/torSecurityLevelFragment"
            app:enterAnim="@anim/slide_in_right"
            app:exitAnim="@anim/slide_out_left"
            app:popEnterAnim="@anim/slide_in_left"
            app:popExitAnim="@anim/slide_out_right" />
        <action
            android:id="@+id/action_settingsFragment_to_privateBrowsingFragment"
            app:destination="@id/privateBrowsingFragment"
+4 −3
Original line number Diff line number Diff line
@@ -54,6 +54,10 @@
    <string name="preferences_tor_network_settings_restarting">Restarting</string>
    <string name="preferences_tor_network_settings_bridges_enabled">Bridges are enabled: %s</string>

    <!-- Preference title for security level settings -->
    <string name="preferences_tor_security_level_settings">Security Settings</string>
    <string name="preferences_tor_security_level_options">Security Level</string>

    <!-- Description of security levels -->
    <string name="tor_security_level_standard_option">Standard</string>
    <string name="tor_security_level_standard_description">All Tor Browser and website features are enabled.</string>
@@ -62,7 +66,4 @@
    <string name="tor_security_level_safest_option">Safest</string>
    <string name="tor_security_level_safest_description">Only allow website features required for static sites and basic services. These changes affect images, media, and scripts.</string>

    <!-- Preference title for security level settings -->
    <string name="preferences_tor_security_level_settings">Security Settings</string>
    <string name="preferences_tor_security_level_options">Security Level</string>
</resources>
Loading