diff --git a/components/feature/sitepermissions/src/main/java/mozilla/components/feature/sitepermissions/SitePermissionsRules.kt b/components/feature/sitepermissions/src/main/java/mozilla/components/feature/sitepermissions/SitePermissionsRules.kt index 1d5ca18ab34..c89733e54a6 100644 --- a/components/feature/sitepermissions/src/main/java/mozilla/components/feature/sitepermissions/SitePermissionsRules.kt +++ b/components/feature/sitepermissions/src/main/java/mozilla/components/feature/sitepermissions/SitePermissionsRules.kt @@ -19,7 +19,8 @@ data class SitePermissionsRules internal constructor( val microphone: Action, val autoplayAudible: Action, val autoplayInaudible: Action, - val persistentStorage: Action + val persistentStorage: Action, + val mediaKeySystemAccess: Action ) { constructor( @@ -29,7 +30,8 @@ data class SitePermissionsRules internal constructor( microphone: Action, autoplayAudible: AutoplayAction, autoplayInaudible: AutoplayAction, - persistentStorage: Action + persistentStorage: Action, + mediaKeySystemAccess: Action ) : this( camera = camera, location = location, @@ -37,7 +39,8 @@ data class SitePermissionsRules internal constructor( microphone = microphone, autoplayAudible = autoplayAudible.toAction(), autoplayInaudible = autoplayInaudible.toAction(), - persistentStorage = persistentStorage + persistentStorage = persistentStorage, + mediaKeySystemAccess = mediaKeySystemAccess ) enum class Action { @@ -93,6 +96,9 @@ data class SitePermissionsRules internal constructor( is Permission.ContentAutoPlayInaudible -> { autoplayInaudible } + is Permission.ContentMediaKeySystemAccess -> { + mediaKeySystemAccess + } else -> ASK_TO_ALLOW } } @@ -118,6 +124,7 @@ data class SitePermissionsRules internal constructor( autoplayAudible = autoplayAudible.toStatus(), autoplayInaudible = autoplayInaudible.toStatus(), localStorage = persistentStorage.toStatus(), + mediaKeySystemAccess = mediaKeySystemAccess.toStatus(), savedAt = savedAt ) } diff --git a/components/feature/sitepermissions/src/test/java/mozilla/components/feature/sitepermissions/SitePermissionsFeatureTest.kt b/components/feature/sitepermissions/src/test/java/mozilla/components/feature/sitepermissions/SitePermissionsFeatureTest.kt index 2075f58edbb..f188098a102 100644 --- a/components/feature/sitepermissions/src/test/java/mozilla/components/feature/sitepermissions/SitePermissionsFeatureTest.kt +++ b/components/feature/sitepermissions/src/test/java/mozilla/components/feature/sitepermissions/SitePermissionsFeatureTest.kt @@ -772,7 +772,8 @@ class SitePermissionsFeatureTest { microphone = SitePermissionsRules.Action.BLOCKED, autoplayAudible = SitePermissionsRules.Action.BLOCKED, autoplayInaudible = SitePermissionsRules.Action.ALLOWED, - persistentStorage = SitePermissionsRules.Action.BLOCKED + persistentStorage = SitePermissionsRules.Action.BLOCKED, + mediaKeySystemAccess = SitePermissionsRules.Action.ASK_TO_ALLOW ) sitePermissionFeature.sitePermissionsRules = rules @@ -787,6 +788,7 @@ class SitePermissionsFeatureTest { assertEquals(BLOCKED, sitePermissions.autoplayAudible) assertEquals(ALLOWED, sitePermissions.autoplayInaudible) assertEquals(BLOCKED, sitePermissions.localStorage) + assertEquals(NO_DECISION, sitePermissions.mediaKeySystemAccess) } @Test diff --git a/components/feature/sitepermissions/src/test/java/mozilla/components/feature/sitepermissions/SitePermissionsRulesTest.kt b/components/feature/sitepermissions/src/test/java/mozilla/components/feature/sitepermissions/SitePermissionsRulesTest.kt index 962b3fd9987..ed30e26d45f 100644 --- a/components/feature/sitepermissions/src/test/java/mozilla/components/feature/sitepermissions/SitePermissionsRulesTest.kt +++ b/components/feature/sitepermissions/src/test/java/mozilla/components/feature/sitepermissions/SitePermissionsRulesTest.kt @@ -65,7 +65,8 @@ class SitePermissionsRulesTest { microphone = BLOCKED, autoplayAudible = ASK_TO_ALLOW, autoplayInaudible = BLOCKED, - persistentStorage = BLOCKED + persistentStorage = BLOCKED, + mediaKeySystemAccess = ASK_TO_ALLOW ) val mockRequest: PermissionRequest = mock() @@ -101,6 +102,10 @@ class SitePermissionsRulesTest { doReturn(listOf(Permission.ContentPersistentStorage())).`when`(mockRequest).permissions action = rules.getActionFrom(mockRequest) assertEquals(action, rules.persistentStorage) + + doReturn(listOf(Permission.ContentMediaKeySystemAccess())).`when`(mockRequest).permissions + action = rules.getActionFrom(mockRequest) + assertEquals(action, rules.mediaKeySystemAccess) } @Test @@ -112,7 +117,8 @@ class SitePermissionsRulesTest { notification = ASK_TO_ALLOW, microphone = BLOCKED, autoplayInaudible = ASK_TO_ALLOW, - autoplayAudible = ASK_TO_ALLOW + autoplayAudible = ASK_TO_ALLOW, + mediaKeySystemAccess = ASK_TO_ALLOW ) val mockRequest: PermissionRequest = mock() @@ -128,7 +134,8 @@ class SitePermissionsRulesTest { microphone = ASK_TO_ALLOW, autoplayInaudible = BLOCKED, autoplayAudible = BLOCKED, - persistentStorage = BLOCKED + persistentStorage = BLOCKED, + mediaKeySystemAccess = ASK_TO_ALLOW ) action = rules.getActionFrom(mockRequest) @@ -146,6 +153,7 @@ class SitePermissionsRulesTest { microphone = Status.BLOCKED, autoplayInaudible = Status.NO_DECISION, autoplayAudible = Status.NO_DECISION, + mediaKeySystemAccess = Status.BLOCKED, savedAt = 1L ) @@ -156,7 +164,8 @@ class SitePermissionsRulesTest { microphone = BLOCKED, autoplayInaudible = ASK_TO_ALLOW, autoplayAudible = ASK_TO_ALLOW, - persistentStorage = BLOCKED + persistentStorage = BLOCKED, + mediaKeySystemAccess = BLOCKED ) val convertedSitePermissions = rules.toSitePermissions(origin = "origin", savedAt = 1L) @@ -169,6 +178,7 @@ class SitePermissionsRulesTest { assertEquals(expectedSitePermission.autoplayInaudible, convertedSitePermissions.autoplayInaudible) assertEquals(expectedSitePermission.autoplayAudible, convertedSitePermissions.autoplayAudible) assertEquals(expectedSitePermission.localStorage, convertedSitePermissions.localStorage) + assertEquals(expectedSitePermission.mediaKeySystemAccess, convertedSitePermissions.mediaKeySystemAccess) assertEquals(expectedSitePermission.savedAt, convertedSitePermissions.savedAt) } } diff --git a/components/feature/sitepermissions/src/test/java/mozilla/components/feature/sitepermissions/db/SitePermissionEntityTest.kt b/components/feature/sitepermissions/src/test/java/mozilla/components/feature/sitepermissions/db/SitePermissionEntityTest.kt index 25c9a37eb36..22de388a37a 100644 --- a/components/feature/sitepermissions/src/test/java/mozilla/components/feature/sitepermissions/db/SitePermissionEntityTest.kt +++ b/components/feature/sitepermissions/src/test/java/mozilla/components/feature/sitepermissions/db/SitePermissionEntityTest.kt @@ -41,6 +41,7 @@ class SitePermissionEntityTest { assertEquals(bluetooth, domainClass.bluetooth) assertEquals(autoplayAudible, domainClass.autoplayAudible) assertEquals(autoplayInaudible, domainClass.autoplayInaudible) + assertEquals(mediaKeySystemAccess, domainClass.mediaKeySystemAccess) assertEquals(savedAt, domainClass.savedAt) } } @@ -55,6 +56,9 @@ class SitePermissionEntityTest { microphone = NO_DECISION, camera = NO_DECISION, bluetooth = ALLOWED, + autoplayInaudible = BLOCKED, + autoplayAudible = NO_DECISION, + mediaKeySystemAccess = NO_DECISION, savedAt = 0 ) @@ -68,6 +72,9 @@ class SitePermissionEntityTest { assertEquals(microphone, domainClass.microphone) assertEquals(camera, domainClass.camera) assertEquals(bluetooth, domainClass.bluetooth) + assertEquals(autoplayAudible, domainClass.autoplayAudible) + assertEquals(autoplayInaudible, domainClass.autoplayInaudible) + assertEquals(mediaKeySystemAccess, domainClass.mediaKeySystemAccess) assertEquals(savedAt, domainClass.savedAt) } } diff --git a/docs/changelog.md b/docs/changelog.md index 2475a20ae9c..4629b2b04ae 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -15,6 +15,10 @@ permalink: /changelog/ * **feature-search** * ⚠️ **This is a breaking change**: Use cases in `SearchUseCases` now take the ID of s session/tab as parameter instead of a `Session` instance. +* **feature-sitepermissions** + * ⚠️ **This is a breaking change**: The `SitePermissionsRules` constructor, now requires a new parameter `mediaKeySystemAccess`. + * 🌟 Added support for EME permission prompts, see [#3153](https://github.com/mozilla-mobile/android-components/issues/7121). + # 68.0.0 * [Commits](https://github.com/mozilla-mobile/android-components/compare/v67.0.0...v68.0.0) diff --git a/samples/browser/src/main/java/org/mozilla/samples/browser/BaseBrowserFragment.kt b/samples/browser/src/main/java/org/mozilla/samples/browser/BaseBrowserFragment.kt index 113fc9a25b0..db1d61b8618 100644 --- a/samples/browser/src/main/java/org/mozilla/samples/browser/BaseBrowserFragment.kt +++ b/samples/browser/src/main/java/org/mozilla/samples/browser/BaseBrowserFragment.kt @@ -154,7 +154,8 @@ abstract class BaseBrowserFragment : Fragment(), UserInteractionHandler { location = SitePermissionsRules.Action.ASK_TO_ALLOW, notification = SitePermissionsRules.Action.ASK_TO_ALLOW, microphone = SitePermissionsRules.Action.ASK_TO_ALLOW, - persistentStorage = SitePermissionsRules.Action.ASK_TO_ALLOW + persistentStorage = SitePermissionsRules.Action.ASK_TO_ALLOW, + mediaKeySystemAccess = SitePermissionsRules.Action.ASK_TO_ALLOW ), onNeedToRequestPermissions = { permissions -> requestPermissions(permissions, REQUEST_CODE_APP_PERMISSIONS)