Update built-in extensions for new AC/GV API
New API (installBuiltIn/ensureBuiltin) requires - Gecko IDs and new permissions - Extension will only be re-installed if it has a new version This includes a gradle task to automatically generate a new version in manifest.json for every build so we don't forget to update the version and end up with changes that are never applied.master
parent
fab64229a5
commit
27c608d956
|
@ -100,3 +100,7 @@ test_artifacts/
|
||||||
/build/test-tools/google-cloud-sdk/
|
/build/test-tools/google-cloud-sdk/
|
||||||
/build/test-tools/*.jar
|
/build/test-tools/*.jar
|
||||||
/build/test-tools/*.gz
|
/build/test-tools/*.gz
|
||||||
|
|
||||||
|
|
||||||
|
# Web extensions: manifest.json files are generated
|
||||||
|
manifest.json
|
||||||
|
|
|
@ -186,6 +186,10 @@ android {
|
||||||
// GeckoView must uncompress it before it can do anything else which
|
// GeckoView must uncompress it before it can do anything else which
|
||||||
// causes a significant delay on startup.
|
// causes a significant delay on startup.
|
||||||
noCompress 'ja'
|
noCompress 'ja'
|
||||||
|
|
||||||
|
// manifest.template.json is converted to manifest.json at build time.
|
||||||
|
// No need to package the template in the APK.
|
||||||
|
ignoreAssetsPattern "manifest.template.json"
|
||||||
}
|
}
|
||||||
|
|
||||||
testOptions {
|
testOptions {
|
||||||
|
@ -755,3 +759,34 @@ if (gradle.hasProperty('localProperties.autoPublish.application-services.dir'))
|
||||||
ext.appServicesSrcDir = gradle."localProperties.autoPublish.application-services.dir"
|
ext.appServicesSrcDir = gradle."localProperties.autoPublish.application-services.dir"
|
||||||
apply from: "../${appServicesSrcDir}/build-scripts/substitute-local-appservices.gradle"
|
apply from: "../${appServicesSrcDir}/build-scripts/substitute-local-appservices.gradle"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Define a reusable task for updating the versions of our built-in web extensions. We automate this
|
||||||
|
// to make sure we never forget to update the version, either in local development or for releases.
|
||||||
|
// In both cases, we want to make sure the latest version of all extensions (including their latest
|
||||||
|
// changes) are installed on first start-up.
|
||||||
|
// We're using the A-C version here as we want to uplift all built-in extensions to A-C (Once that's
|
||||||
|
// done we can also remove the task below):
|
||||||
|
// https://github.com/mozilla-mobile/android-components/issues/7249
|
||||||
|
ext.updateExtensionVersion = { task, extDir ->
|
||||||
|
configure(task) {
|
||||||
|
from extDir
|
||||||
|
include 'manifest.template.json'
|
||||||
|
rename { 'manifest.json' }
|
||||||
|
into extDir
|
||||||
|
|
||||||
|
def values = ['version': AndroidComponents.VERSION + "." + new Date().format('MMddHHmmss')]
|
||||||
|
inputs.properties(values)
|
||||||
|
expand(values)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.register("updateAdsExtensionVersion", Copy) { task ->
|
||||||
|
updateExtensionVersion(task, 'src/main/assets/extensions/ads')
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.register("updateCookiesExtensionVersion", Copy) { task ->
|
||||||
|
updateExtensionVersion(task, 'src/main/assets/extensions/cookies')
|
||||||
|
}
|
||||||
|
|
||||||
|
preBuild.dependsOn updateAdsExtensionVersion
|
||||||
|
preBuild.dependsOn updateCookiesExtensionVersion
|
||||||
|
|
|
@ -1,7 +1,12 @@
|
||||||
{
|
{
|
||||||
"manifest_version": 2,
|
"manifest_version": 2,
|
||||||
|
"applications": {
|
||||||
|
"gecko": {
|
||||||
|
"id": "ads@mozac.org"
|
||||||
|
}
|
||||||
|
},
|
||||||
"name": "Mozilla Android Components - Ads",
|
"name": "Mozilla Android Components - Ads",
|
||||||
"version": "1.0",
|
"version": "${version}",
|
||||||
"content_scripts": [
|
"content_scripts": [
|
||||||
{
|
{
|
||||||
"matches": ["https://*/*"],
|
"matches": ["https://*/*"],
|
||||||
|
@ -16,6 +21,7 @@
|
||||||
],
|
],
|
||||||
"permissions": [
|
"permissions": [
|
||||||
"geckoViewAddons",
|
"geckoViewAddons",
|
||||||
"nativeMessaging"
|
"nativeMessaging",
|
||||||
|
"nativeMessagingFromContent"
|
||||||
]
|
]
|
||||||
}
|
}
|
|
@ -1,7 +1,12 @@
|
||||||
{
|
{
|
||||||
"manifest_version": 2,
|
"manifest_version": 2,
|
||||||
|
"applications": {
|
||||||
|
"gecko": {
|
||||||
|
"id": "cookies@mozac.org"
|
||||||
|
}
|
||||||
|
},
|
||||||
"name": "Mozilla Android Components - Cookies",
|
"name": "Mozilla Android Components - Cookies",
|
||||||
"version": "1.0",
|
"version": "${version}",
|
||||||
"content_scripts": [
|
"content_scripts": [
|
||||||
{
|
{
|
||||||
"matches": ["https://*/*"],
|
"matches": ["https://*/*"],
|
||||||
|
@ -23,6 +28,7 @@
|
||||||
"permissions": [
|
"permissions": [
|
||||||
"geckoViewAddons",
|
"geckoViewAddons",
|
||||||
"nativeMessaging",
|
"nativeMessaging",
|
||||||
|
"nativeMessagingFromContent",
|
||||||
"webNavigation",
|
"webNavigation",
|
||||||
"webRequest",
|
"webRequest",
|
||||||
"webRequestBlocking",
|
"webRequestBlocking",
|
|
@ -93,7 +93,6 @@ abstract class BaseSearchTelemetry {
|
||||||
engine.installWebExtension(
|
engine.installWebExtension(
|
||||||
id = extensionInfo.id,
|
id = extensionInfo.id,
|
||||||
url = extensionInfo.resourceUrl,
|
url = extensionInfo.resourceUrl,
|
||||||
allowContentMessaging = true,
|
|
||||||
onSuccess = { extension ->
|
onSuccess = { extension ->
|
||||||
store.flowScoped { flow -> subscribeToUpdates(flow, extension, extensionInfo) }
|
store.flowScoped { flow -> subscribeToUpdates(flow, extension, extensionInfo) }
|
||||||
},
|
},
|
||||||
|
|
|
@ -51,7 +51,7 @@ class AdsTelemetry(private val metrics: MetricController) : BaseSearchTelemetry(
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
internal const val ADS_EXTENSION_ID = "mozacBrowserAds"
|
internal const val ADS_EXTENSION_ID = "ads@mozac.org"
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
internal const val ADS_EXTENSION_RESOURCE_URL = "resource://android/assets/extensions/ads/"
|
internal const val ADS_EXTENSION_RESOURCE_URL = "resource://android/assets/extensions/ads/"
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
|
|
|
@ -131,7 +131,7 @@ class InContentTelemetry(private val metrics: MetricController) : BaseSearchTele
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
internal const val COOKIES_EXTENSION_ID = "BrowserCookiesExtension"
|
internal const val COOKIES_EXTENSION_ID = "cookies@mozac.org"
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
internal const val COOKIES_EXTENSION_RESOURCE_URL =
|
internal const val COOKIES_EXTENSION_RESOURCE_URL =
|
||||||
"resource://android/assets/extensions/cookies/"
|
"resource://android/assets/extensions/cookies/"
|
||||||
|
|
|
@ -44,7 +44,6 @@ class BaseSearchTelemetryTest {
|
||||||
engine.installWebExtension(
|
engine.installWebExtension(
|
||||||
id = id,
|
id = id,
|
||||||
url = resourceUrl,
|
url = resourceUrl,
|
||||||
allowContentMessaging = true,
|
|
||||||
onSuccess = any(),
|
onSuccess = any(),
|
||||||
onError = any()
|
onError = any()
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue