For #7996: Private mode doesn't play nicely with sites added to home screen
Site Controls Notification should reflect the browsing mode of the currernt web app session.fennec/production
parent
688c377197
commit
4a12f1b6aa
@ -0,0 +1,45 @@
|
||||
/* 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.customtabs
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.IntentFilter
|
||||
import androidx.core.app.NotificationCompat
|
||||
import mozilla.components.browser.session.Session
|
||||
import mozilla.components.browser.session.SessionManager
|
||||
import mozilla.components.concept.engine.manifest.WebAppManifest
|
||||
import mozilla.components.feature.pwa.feature.SiteControlsBuilder
|
||||
import mozilla.components.feature.session.SessionUseCases
|
||||
import org.mozilla.fenix.R
|
||||
|
||||
class WebAppSiteControlsBuilder(
|
||||
private val sessionManager: SessionManager,
|
||||
reloadUrlUseCase: SessionUseCases.ReloadUrlUseCase,
|
||||
private val sessionId: String,
|
||||
private val manifest: WebAppManifest
|
||||
) : SiteControlsBuilder {
|
||||
|
||||
private val inner = SiteControlsBuilder.CopyAndRefresh(reloadUrlUseCase)
|
||||
|
||||
override fun buildNotification(
|
||||
context: Context,
|
||||
builder: NotificationCompat.Builder,
|
||||
channelId: String
|
||||
) {
|
||||
inner.buildNotification(context, builder, channelId)
|
||||
|
||||
val isPrivateSession = sessionManager.findSessionById(sessionId)?.private ?: false
|
||||
|
||||
if (!isPrivateSession) { return }
|
||||
|
||||
builder.setSmallIcon(R.drawable.ic_pbm_notification)
|
||||
builder.setContentTitle(context.getString(R.string.pwa_site_controls_title_private, manifest.name))
|
||||
}
|
||||
|
||||
override fun getFilter() = inner.getFilter()
|
||||
|
||||
override fun onReceiveBroadcast(context: Context, session: Session, intent: Intent) = inner.onReceiveBroadcast(context, session, intent)
|
||||
}
|
Loading…
Reference in New Issue