Commit 992d53f7 authored by aguestuser's avatar aguestuser
Browse files

Merge branch 'bug_40074_96.0.15' into 'android-components-96.0.15-11.5-1'

Resolve Bug 40074:  Rebase android-components patches for Fenix 96

See merge request !79
parents 0178a6fd 7112ccfc
......@@ -118,7 +118,13 @@ subprojects {
rename { 'manifest.json' }
into extDir
def values = ['version': rootProject.ext.config.componentsVersion + "." + new Date().format('MMddHHmmss')]
def systemEnvBuildDate = System.getenv('MOZ_BUILD_DATE')
// MOZ_BUILD_DATE is in the YYYYMMDDHHMMSS format. Thus, we only use a
// substring of it if it is available.
def values = ['version': rootProject.ext.config.componentsVersion + "." +
(systemEnvBuildDate != null ?
systemEnvBuildDate.substring(4) :
new Date().format('MMddHHmmss'))]
inputs.properties(values)
expand(values)
}
......
......@@ -687,6 +687,22 @@ class GeckoEngine(
Engine.HttpsOnlyMode.ENABLED -> GeckoRuntimeSettings.HTTPS_ONLY
}
}
override var torSecurityLevel: Int
get() = runtime.settings.torSecurityLevel
set(value) {
value.let {
runtime.settings.torSecurityLevel = it
}
}
override var spoofEnglish: Boolean
get() = runtime.settings.spoofEnglish
set(value) {
value.let {
runtime.settings.spoofEnglish = it
localeUpdater.updateValue()
}
}
}.apply {
defaultSettings?.let {
this.javascriptEnabled = it.javascriptEnabled
......@@ -706,6 +722,8 @@ class GeckoEngine(
this.loginAutofillEnabled = it.loginAutofillEnabled
this.enterpriseRootsEnabled = it.enterpriseRootsEnabled
this.httpsOnlyMode = it.httpsOnlyMode
this.torSecurityLevel = it.torSecurityLevel
this.spoofEnglish = it.spoofEnglish
}
}
......
......@@ -87,6 +87,7 @@ private fun Request.toWebRequest(): WebRequest = WebRequest.Builder(url)
.addHeadersFrom(this)
.addBodyFrom(this)
.cacheMode(if (useCaches) CACHE_MODE_DEFAULT else CACHE_MODE_RELOAD)
.origin(origin)
.build()
private fun WebRequest.Builder.addHeadersFrom(request: Request): WebRequest.Builder {
......
......@@ -57,7 +57,8 @@ open class HttpIconLoader(
readTimeout = Pair(READ_TIMEOUT, TimeUnit.SECONDS),
redirect = Request.Redirect.FOLLOW,
useCaches = true,
private = request.isPrivate
private = request.isPrivate,
origin = request.url
)
return try {
......
......@@ -9,7 +9,6 @@ import androidx.annotation.ColorRes
import androidx.annotation.DrawableRes
import mozilla.components.browser.menu.item.BackPressMenuItem
import mozilla.components.browser.menu.item.BrowserMenuDivider
import mozilla.components.browser.menu.item.BrowserMenuImageText
import mozilla.components.browser.menu.item.NO_ID
import mozilla.components.browser.menu.item.ParentBrowserMenuItem
import mozilla.components.browser.menu.item.WebExtensionBrowserMenuItem
......@@ -96,21 +95,11 @@ class WebExtensionBrowserMenuBuilder(
iconTintColorResource = style.webExtIconTintColorResource
)
val addonsManagerMenuItem = BrowserMenuImageText(
label = context.getString(R.string.mozac_browser_menu_addons_manager),
imageResource = style.addonsManagerMenuItemDrawableRes,
iconTintColorResource = style.webExtIconTintColorResource
) {
onAddonsManagerTapped.invoke()
}
val webExtSubMenuItems = if (appendExtensionSubMenuAtStart) {
listOf(backPressMenuItem) + BrowserMenuDivider() +
filteredExtensionMenuItems +
BrowserMenuDivider() + addonsManagerMenuItem
filteredExtensionMenuItems
} else {
listOf(addonsManagerMenuItem) + BrowserMenuDivider() +
filteredExtensionMenuItems +
filteredExtensionMenuItems +
BrowserMenuDivider() + backPressMenuItem
}
......@@ -125,25 +114,21 @@ class WebExtensionBrowserMenuBuilder(
endOfMenuAlwaysVisible = endOfMenuAlwaysVisible
)
} else {
BrowserMenuImageText(
label = context.getString(R.string.mozac_browser_menu_addons),
imageResource = style.addonsManagerMenuItemDrawableRes,
iconTintColorResource = style.webExtIconTintColorResource
) {
onAddonsManagerTapped.invoke()
}
null
}
val mainMenuIndex = items.indexOfFirst { browserMenuItem ->
(browserMenuItem as? WebExtensionPlaceholderMenuItem)?.id ==
WebExtensionPlaceholderMenuItem.MAIN_EXTENSIONS_MENU_ID
}
return if (mainMenuIndex != -1) {
return if (mainMenuIndex != -1 && addonsMenuItem != null) {
items[mainMenuIndex] = addonsMenuItem
items
// if we do not have a placeholder we should add the extension submenu at top or bottom
} else {
if (appendExtensionSubMenuAtStart) {
if (addonsMenuItem == null) {
items
} else if (appendExtensionSubMenuAtStart) {
listOf(addonsMenuItem) + items
} else {
items + addonsMenuItem
......
......@@ -499,6 +499,7 @@ class DisplayToolbar internal constructor(
@ColorInt val color = when (siteSecurity) {
Toolbar.SiteSecurity.INSECURE -> colors.securityIconInsecure
Toolbar.SiteSecurity.SECURE -> colors.securityIconSecure
Toolbar.SiteSecurity.ONION -> colors.securityIconSecure
}
if (color == Color.TRANSPARENT) {
views.securityIndicator.clearColorFilter()
......
......@@ -43,6 +43,11 @@ internal class SiteSecurityIconView @JvmOverloads constructor(
View.mergeDrawableStates(drawableState, intArrayOf(R.attr.state_site_secure))
drawableState
}
SiteSecurity.ONION -> {
val drawableState = super.onCreateDrawableState(extraSpace + 1)
View.mergeDrawableStates(drawableState, intArrayOf(R.attr.state_site_onion))
drawableState
}
}
}
}
......@@ -3,6 +3,9 @@
- 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/. -->
<selector xmlns:android="http://schemas.android.com/apk/res/android" xmlns:ac="http://schemas.android.com/apk/res-auto">
<item
android:drawable="@drawable/mozac_ic_onion"
ac:state_site_onion="true" />
<item
android:drawable="@drawable/mozac_ic_lock"
ac:state_site_secure="true" />
......
......@@ -27,6 +27,10 @@
<attr name="state_site_secure" format="boolean"/>
</declare-styleable>
<declare-styleable name="BrowserToolbarSiteOnionState">
<attr name="state_site_onion" format="boolean"/>
</declare-styleable>
<declare-styleable name="ActionContainer">
<attr name="actionContainerItemSize" format="dimension" />
</declare-styleable>
......
......@@ -9,6 +9,7 @@ import android.graphics.Bitmap
import androidx.annotation.CallSuper
import mozilla.components.concept.engine.EngineSession.TrackingProtectionPolicy.CookiePolicy.ACCEPT_ALL
import mozilla.components.concept.engine.EngineSession.TrackingProtectionPolicy.CookiePolicy.ACCEPT_NON_TRACKERS
import mozilla.components.concept.engine.EngineSession.TrackingProtectionPolicy.CookiePolicy.ACCEPT_ONLY_FIRST_PARTY
import mozilla.components.concept.engine.content.blocking.Tracker
import mozilla.components.concept.engine.history.HistoryItem
import mozilla.components.concept.engine.manifest.WebAppManifest
......@@ -405,7 +406,9 @@ abstract class EngineSession(
companion object {
fun none() = TrackingProtectionPolicy(
trackingCategories = arrayOf(TrackingCategory.NONE),
cookiePolicy = ACCEPT_ALL
useForPrivateSessions = false,
useForRegularSessions = false,
cookiePolicy = ACCEPT_ONLY_FIRST_PARTY
)
/**
......
......@@ -189,6 +189,13 @@ abstract class Settings {
* Setting the HTTPS-Only mode for upgrading connections to HTTPS.
*/
open var httpsOnlyMode: Engine.HttpsOnlyMode by UnsupportedSetting()
/**
* Setting to control the current security level
*/
open var torSecurityLevel: Int by UnsupportedSetting()
open var spoofEnglish: Boolean by UnsupportedSetting()
}
/**
......@@ -226,7 +233,9 @@ data class DefaultSettings(
override var loginAutofillEnabled: Boolean = false,
override var clearColor: Int? = null,
override var enterpriseRootsEnabled: Boolean = false,
override var httpsOnlyMode: Engine.HttpsOnlyMode = Engine.HttpsOnlyMode.DISABLED
override var httpsOnlyMode: Engine.HttpsOnlyMode = Engine.HttpsOnlyMode.DISABLED,
override var torSecurityLevel: Int = 4,
override var spoofEnglish: Boolean = false
) : Settings()
class UnsupportedSetting<T> {
......
......@@ -48,7 +48,8 @@ data class Request(
val redirect: Redirect = Redirect.FOLLOW,
val cookiePolicy: CookiePolicy = CookiePolicy.INCLUDE,
val useCaches: Boolean = true,
val private: Boolean = false
val private: Boolean = false,
val origin: String? = null
) {
/**
* A [Body] to be send with the [Request].
......
......@@ -437,6 +437,7 @@ interface Toolbar {
enum class SiteSecurity {
INSECURE,
SECURE,
ONION,
}
/**
......
......@@ -58,7 +58,7 @@ internal const val PAGE_SIZE = 50
* cache is being used by default
*/
@Suppress("LongParameterList")
class AddonCollectionProvider(
open class AddonCollectionProvider(
private val context: Context,
private val client: Client,
private val serverURL: String = DEFAULT_SERVER_URL,
......@@ -175,7 +175,7 @@ class AddonCollectionProvider(
* a connectivity problem or a timeout.
*/
@Throws(IOException::class)
suspend fun getAddonIconBitmap(addon: Addon): Bitmap? {
open suspend fun getAddonIconBitmap(addon: Addon): Bitmap? {
var bitmap: Bitmap? = null
if (addon.iconUrl != "") {
client.fetch(
......@@ -193,7 +193,7 @@ class AddonCollectionProvider(
}
@VisibleForTesting
internal fun writeToDiskCache(collectionResponse: String, language: String?) {
protected fun writeToDiskCache(collectionResponse: String, language: String?) {
synchronized(diskCacheLock) {
getCacheFile(context, language, useFallbackFile = false).writeString { collectionResponse }
}
......
......@@ -63,6 +63,7 @@
/>
<androidx.appcompat.widget.AppCompatCheckBox
android:visibility="gone"
android:id="@+id/allow_in_private_browsing"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
......
......@@ -42,6 +42,7 @@ dependencies {
implementation Dependencies.kotlin_stdlib
implementation Dependencies.kotlin_coroutines
implementation project(path: ':support-utils')
testImplementation project(':support-test')
testImplementation project(':support-test-libstate')
......
......@@ -103,7 +103,7 @@ class AppLinksFeature(
)
}
if (!tab.content.private || fragmentManager == null) {
if (true || !tab.content.private || fragmentManager == null) {
doOpenApp()
return
}
......
......@@ -22,6 +22,7 @@ import java.lang.Exception
import java.lang.NullPointerException
import java.lang.NumberFormatException
import java.net.URISyntaxException
import mozilla.components.support.utils.TorUtils
private const val EXTRA_BROWSER_FALLBACK_URL = "browser_fallback_url"
private const val MARKET_INTENT_URI_PACKAGE_PREFIX = "market://details?id="
......@@ -209,7 +210,7 @@ class AppLinksUseCases(
if (launchInNewTask) {
it.flags = it.flags or Intent.FLAG_ACTIVITY_NEW_TASK
}
context.startActivity(it)
TorUtils.startActivityPrompt(context, it)
} catch (e: Exception) {
when (e) {
is ActivityNotFoundException, is SecurityException, is NullPointerException -> {
......
......@@ -23,6 +23,7 @@ import mozilla.components.support.ktx.android.content.addContact
import mozilla.components.support.ktx.android.content.share
import mozilla.components.support.ktx.kotlin.stripMailToProtocol
import mozilla.components.support.ktx.kotlin.takeOrReplace
import mozilla.components.support.utils.TorUtils
/**
* A candidate for an item to be displayed in the context menu.
......@@ -360,7 +361,7 @@ data class ContextMenuCandidate(
context.getString(R.string.mozac_feature_contextmenu_share_link)
).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
context.startActivity(shareIntent)
TorUtils.startActivityPrompt(context, shareIntent)
}
)
......
......@@ -21,6 +21,8 @@ android {
arg("room.schemaLocation", "$projectDir/schemas".toString())
}
}
buildConfigField("boolean", "ANDROID_DOWNLOADS_INTEGRATION", "false")
}
buildTypes {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment