For #19738 - Secure mode enabled in private tabs tray
Prevents screenshots while tabs tray with private tabs page is open.
This commit is contained in:
parent
3327fc508c
commit
0572cab97c
|
@ -0,0 +1,42 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
package org.mozilla.fenix.tabstray
|
||||
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.collect
|
||||
import kotlinx.coroutines.flow.map
|
||||
import mozilla.components.lib.state.helpers.AbstractBinding
|
||||
import mozilla.components.support.ktx.kotlinx.coroutines.flow.ifAnyChanged
|
||||
import org.mozilla.fenix.ext.removeSecure
|
||||
import org.mozilla.fenix.ext.secure
|
||||
import org.mozilla.fenix.utils.Settings
|
||||
|
||||
/**
|
||||
* Sets TabsTrayFragment flags to secure when private tabs list is selected.
|
||||
*/
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
class SecureTabsTrayBinding(
|
||||
store: TabsTrayStore,
|
||||
private val settings: Settings,
|
||||
private val tabsTrayFragment: TabsTrayFragment
|
||||
) : AbstractBinding<TabsTrayState>(store) {
|
||||
|
||||
override suspend fun onState(flow: Flow<TabsTrayState>) {
|
||||
flow.map { it }
|
||||
.ifAnyChanged { state ->
|
||||
arrayOf(
|
||||
state.selectedPage
|
||||
)
|
||||
}
|
||||
.collect { state ->
|
||||
if (state.selectedPage == Page.PrivateTabs) {
|
||||
tabsTrayFragment.secure()
|
||||
} else if (!settings.lastKnownMode.isPrivate) {
|
||||
tabsTrayFragment.removeSecure()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -72,6 +72,7 @@ class TabsTrayFragment : AppCompatDialogFragment() {
|
|||
private val selectionBannerBinding = ViewBoundFeatureWrapper<SelectionBannerBinding>()
|
||||
private val selectionHandleBinding = ViewBoundFeatureWrapper<SelectionHandleBinding>()
|
||||
private val tabsTrayCtaBinding = ViewBoundFeatureWrapper<TabsTrayInfoBannerBinding>()
|
||||
private val secureTabsTrayBinding = ViewBoundFeatureWrapper<SecureTabsTrayBinding>()
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
@ -267,6 +268,16 @@ class TabsTrayFragment : AppCompatDialogFragment() {
|
|||
owner = this,
|
||||
view = view
|
||||
)
|
||||
|
||||
secureTabsTrayBinding.set(
|
||||
feature = SecureTabsTrayBinding(
|
||||
store = tabsTrayStore,
|
||||
settings = requireComponents.settings,
|
||||
tabsTrayFragment = this
|
||||
),
|
||||
owner = this,
|
||||
view = view
|
||||
)
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
|
|
Loading…
Reference in New Issue
Block a user