2019-08-28 21:55:24 +02:00
|
|
|
/* 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.home.intent
|
|
|
|
|
|
|
|
import android.content.Intent
|
|
|
|
import androidx.navigation.NavController
|
|
|
|
import org.mozilla.fenix.HomeActivity
|
2019-08-28 23:41:37 +02:00
|
|
|
import org.mozilla.fenix.components.metrics.Event
|
2019-08-28 21:55:24 +02:00
|
|
|
import org.mozilla.fenix.ext.components
|
|
|
|
import org.mozilla.fenix.ext.sessionsOfType
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The Private Browsing Mode notification has an "Delete and Open" button to let users delete all
|
|
|
|
* of their private tabs.
|
|
|
|
*/
|
|
|
|
class NotificationsIntentProcessor(
|
|
|
|
private val activity: HomeActivity
|
|
|
|
) : HomeIntentProcessor {
|
|
|
|
|
|
|
|
override fun process(intent: Intent, navController: NavController, out: Intent): Boolean {
|
|
|
|
return if (intent.extras?.getBoolean(HomeActivity.EXTRA_DELETE_PRIVATE_TABS) == true) {
|
|
|
|
out.putExtra(HomeActivity.EXTRA_DELETE_PRIVATE_TABS, false)
|
2019-08-28 23:41:37 +02:00
|
|
|
activity.components.analytics.metrics.track(Event.PrivateBrowsingNotificationDeleteAndOpenTapped)
|
2019-08-28 21:55:24 +02:00
|
|
|
activity.components.core.sessionManager.run {
|
|
|
|
sessionsOfType(private = true).forEach { remove(it) }
|
|
|
|
}
|
|
|
|
true
|
2019-08-28 23:41:37 +02:00
|
|
|
} else if (intent.extras?.getBoolean(HomeActivity.EXTRA_OPENED_FROM_NOTIFICATION) == true) {
|
|
|
|
activity.components.analytics.metrics.track(Event.PrivateBrowsingNotificationOpenTapped)
|
|
|
|
true
|
2019-08-28 21:55:24 +02:00
|
|
|
} else {
|
|
|
|
false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|