Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Commit

Permalink
Closes issue #8367: Add SHIMMED TrackingCategory
Browse files Browse the repository at this point in the history
  • Loading branch information
Amejia481 committed Oct 7, 2020
1 parent 47ab747 commit e838ae8
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

package mozilla.components.browser.engine.gecko

import android.annotation.SuppressLint
import android.content.Context
import android.util.AttributeSet
import androidx.annotation.VisibleForTesting
Expand Down Expand Up @@ -684,12 +685,17 @@ internal fun ContentBlockingController.LogEntry.BlockingData.hasBlockedCookies()
category == Event.COOKIES_BLOCKED_SOCIALTRACKER
}

// There is going to be a patch from GV for adding [REPLACED_UNSAFE_CONTENT] as
// a valid option for [BlockingData.category]
// https://bugzilla.mozilla.org/show_bug.cgi?id=1669577
@SuppressLint("SwitchIntDef")
internal fun ContentBlockingController.LogEntry.BlockingData.getBlockedCategory(): TrackingCategory {
return when (category) {
Event.BLOCKED_FINGERPRINTING_CONTENT -> TrackingCategory.FINGERPRINTING
Event.BLOCKED_CRYPTOMINING_CONTENT -> TrackingCategory.CRYPTOMINING
Event.BLOCKED_SOCIALTRACKING_CONTENT, Event.COOKIES_BLOCKED_SOCIALTRACKER -> TrackingCategory.MOZILLA_SOCIAL
Event.BLOCKED_TRACKING_CONTENT -> TrackingCategory.SCRIPTS_AND_SUB_RESOURCES
Event.REPLACED_UNSAFE_CONTENT -> TrackingCategory.SHIMMED
else -> TrackingCategory.NONE
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1686,6 +1686,7 @@ class GeckoEngineTest {
assertTrue(trackerLog.blockedCategories.contains(TrackingCategory.FINGERPRINTING))
assertTrue(trackerLog.blockedCategories.contains(TrackingCategory.CRYPTOMINING))
assertTrue(trackerLog.blockedCategories.contains(TrackingCategory.MOZILLA_SOCIAL))
assertTrue(trackerLog.blockedCategories.contains(TrackingCategory.SHIMMED))

assertTrue(trackerLog.loadedCategories.contains(TrackingCategory.SCRIPTS_AND_SUB_RESOURCES))
assertTrue(trackerLog.loadedCategories.contains(TrackingCategory.FINGERPRINTING))
Expand Down Expand Up @@ -1863,6 +1864,7 @@ class GeckoEngineTest {
val blockedFingerprintingContent = createBlockingData(Event.BLOCKED_FINGERPRINTING_CONTENT)
val blockedCyptominingContent = createBlockingData(Event.BLOCKED_CRYPTOMINING_CONTENT)
val blockedSocialContent = createBlockingData(Event.BLOCKED_SOCIALTRACKING_CONTENT)
val shimmedContent = createBlockingData(Event.REPLACED_UNSAFE_CONTENT)

val loadedTrackingLevel1Content = createBlockingData(Event.LOADED_LEVEL_1_TRACKING_CONTENT)
val loadedTrackingLevel2Content = createBlockingData(Event.LOADED_LEVEL_2_TRACKING_CONTENT)
Expand All @@ -1882,7 +1884,8 @@ class GeckoEngineTest {
blockedSocialContent,
loadedSocialContent,
loadedCookieSocialTracker,
blockedCookieSocialTracker
blockedCookieSocialTracker,
shimmedContent
)

val addLogSecondEntry = object : ContentBlockingController.LogEntry() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,13 @@ abstract class EngineSession(
*/
SCRIPTS_AND_SUB_RESOURCES(1 shl 31),

/**
* Indicates that content that would have been blocked has instead been replaced with a shim.
* This category is only used for categorization purposes ie. for checking the state of blocked content.
* It can not be used to actively configure a tracking protection policy.
*/
SHIMMED(NONE.id),

RECOMMENDED(AD.id + ANALYTICS.id + SOCIAL.id + TEST.id + MOZILLA_SOCIAL.id +
CRYPTOMINING.id + FINGERPRINTING.id),

Expand Down
1 change: 1 addition & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ permalink: /changelog/

* **concept-engine**
* Added `MediaSession` for the media session API.
* 🌟 Added a new `TrackingCategory`.`SHIMMED` to indicate that content that would have been blocked has instead been replaced with a shimmed file. See more on [Fenix #14071](https://github.com/mozilla-mobile/fenix/issues/14071)

* **browser-engine-gecko(-nightly)**
* Added `GeckoMediaSessionController` and `GeckoMediaSessionDelegate` for the media session API.
Expand Down

0 comments on commit e838ae8

Please sign in to comment.