Closes #3728: Add secret menu switch for allowing third party root certificates (#19398)

This commit is contained in:
Roger Yang 2021-05-06 21:52:55 -04:00 committed by GitHub
parent 9bfb31519a
commit a9e0557d83
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 31 additions and 0 deletions

View File

@ -108,6 +108,7 @@ class Core(
suspendMediaWhenInactive = false,
forceUserScalableContent = context.settings().forceEnableZoom,
loginAutofillEnabled = context.settings().shouldAutofillLogins,
enterpriseRootsEnabled = context.settings().allowThirdPartyRootCerts,
clearColor = ContextCompat.getColor(
context,
R.color.foundation_normal_theme

View File

@ -5,10 +5,12 @@
package org.mozilla.fenix.settings
import android.os.Bundle
import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat
import androidx.preference.SwitchPreference
import org.mozilla.fenix.FeatureFlags
import org.mozilla.fenix.R
import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.ext.showToolbar
@ -39,5 +41,17 @@ class SecretSettingsFragment : PreferenceFragmentCompat() {
isChecked = context.settings().tabsTrayRewrite
onPreferenceChangeListener = SharedPreferenceUpdater()
}
requirePreference<SwitchPreference>(R.string.pref_key_allow_third_party_root_certs).apply {
isVisible = true
isChecked = context.settings().allowThirdPartyRootCerts
onPreferenceChangeListener = object : SharedPreferenceUpdater() {
override fun onPreferenceChange(preference: Preference, newValue: Any?): Boolean {
context.components.core.engine.settings.enterpriseRootsEnabled =
newValue as Boolean
return super.onPreferenceChange(preference, newValue)
}
}
}
}
}

View File

@ -357,6 +357,11 @@ class Settings(private val appContext: Context) : PreferencesHolder {
featureFlag = FeatureFlags.tabsTrayRewrite
)
var allowThirdPartyRootCerts by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_allow_third_party_root_certs),
default = false
)
fun getTabTimeout(): Long = when {
closeTabsAfterOneDay -> ONE_DAY_MS
closeTabsAfterOneWeek -> ONE_WEEK_MS

View File

@ -255,6 +255,7 @@
<string name="pref_key_close_tabs_after_one_week" translatable="false">pref_key_close_tabs_after_one_week</string>
<string name="pref_key_close_tabs_after_one_month" translatable="false">pref_key_close_tabs_after_one_month</string>
<string name="pref_key_new_tabs_tray" translatable="false">pref_key_new_tabs_tray</string>
<string name="pref_key_allow_third_party_root_certs" translatable="false">pref_key_allow_third_party_cert_roots</string>
<string name="pref_key_camera_permissions_needed" translatable="false">pref_key_camera_permissions_needed</string>

View File

@ -43,6 +43,10 @@
<string name="preferences_debug_settings_tabs_tray_rewrite">Use new Tabs Tray</string>
<!-- Label for a longer description of the new tabs tray preference -->
<string name="preferences_debug_settings_tabs_tray_rewrite_summary">A refactored tabs tray that will include Synced Tabs.</string>
<!-- Label for allowing third party root certificates from the Android OS CA store preference -->
<string name="preferences_debug_settings_allow_third_party_root_certs">Use third party CA certificates</string>
<!-- Label for a longer description of allowing third party root certificates from the Android OS CA store preference -->
<string name="preferences_debug_settings_allow_third_party_root_certs_summary">Allows the use of third party certificates from the Android CA store</string>
<!-- Label for the Nimbus experiments preference -->
<string name="preferences_nimbus_experiments">Nimbus Experiments</string>

View File

@ -20,4 +20,10 @@
android:title="@string/preferences_debug_settings_tabs_tray_rewrite"
android:summary="@string/preferences_debug_settings_tabs_tray_rewrite_summary"
app:iconSpaceReserved="false" />
<SwitchPreference
android:defaultValue="false"
android:key="@string/pref_key_allow_third_party_root_certs"
android:title="@string/preferences_debug_settings_allow_third_party_root_certs"
android:summary="@string/preferences_debug_settings_allow_third_party_root_certs_summary"
app:iconSpaceReserved="false" />
</PreferenceScreen>