Skip to content

Commit

Permalink
Remove fixBlobDownloadWithIframes kill switch (#5184)
Browse files Browse the repository at this point in the history
Task/Issue URL: https://app.asana.com/0/1198194956794324/1208351041752901/f

### Description
Remove the `fixBlobDownloadWithIframes` kill switch and all the (deactivated) code behind it

### Steps to test this PR
Just code review, we're removing code that doesn't execute
  • Loading branch information
aitorvs authored Oct 24, 2024
1 parent ad99cff commit c8f8956
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 35 deletions.
36 changes: 10 additions & 26 deletions app/src/main/java/com/duckduckgo/app/browser/BrowserTabViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -438,8 +438,6 @@ class BrowserTabViewModel @Inject constructor(
private var hasUserSeenHistoryIAM = false
private var lastAutoCompleteState: AutoCompleteViewState? = null

private val replyProxyMap = mutableMapOf<String, JavaScriptReplyProxy>()

// Map<String, Map<String, JavaScriptReplyProxy>>() = Map<Origin, Map<location.href, JavaScriptReplyProxy>>()
private val fixedReplyProxyMap = mutableMapOf<String, Map<String, JavaScriptReplyProxy>>()

Expand Down Expand Up @@ -1494,7 +1492,6 @@ class BrowserTabViewModel @Inject constructor(

private fun cleanupBlobDownloadReplyProxyMaps() {
fixedReplyProxyMap.clear()
replyProxyMap.clear()
}

private fun setAdClickActiveTabData(url: String?) {
Expand Down Expand Up @@ -3048,21 +3045,12 @@ class BrowserTabViewModel @Inject constructor(
@SuppressLint("RequiresFeature") // it's already checked in isBlobDownloadWebViewFeatureEnabled
private fun postMessageToConvertBlobToDataUri(url: String) {
appCoroutineScope.launch(dispatchers.main()) { // main because postMessage is not always safe in another thread
if (withContext(dispatchers.io()) { androidBrowserConfig.fixBlobDownloadWithIframes().isEnabled() }) {
for ((key, proxies) in fixedReplyProxyMap) {
if (sameOrigin(url.removePrefix("blob:"), key)) {
for (replyProxy in proxies.values) {
replyProxy.postMessage(url)
}
return@launch
}
}
} else {
for ((key, value) in replyProxyMap) {
if (sameOrigin(url.removePrefix("blob:"), key)) {
value.postMessage(url)
return@launch
for ((key, proxies) in fixedReplyProxyMap) {
if (sameOrigin(url.removePrefix("blob:"), key)) {
for (replyProxy in proxies.values) {
replyProxy.postMessage(url)
}
return@launch
}
}
}
Expand Down Expand Up @@ -3742,15 +3730,11 @@ class BrowserTabViewModel @Inject constructor(
locationHref: String? = null,
) {
appCoroutineScope.launch(dispatchers.io()) { // FF check has disk IO
if (androidBrowserConfig.fixBlobDownloadWithIframes().isEnabled()) {
val frameProxies = fixedReplyProxyMap[originUrl]?.toMutableMap() ?: mutableMapOf()
// if location.href is not passed, we fall back to origin
val safeLocationHref = locationHref ?: originUrl
frameProxies[safeLocationHref] = replyProxy
fixedReplyProxyMap[originUrl] = frameProxies
} else {
replyProxyMap[originUrl] = replyProxy
}
val frameProxies = fixedReplyProxyMap[originUrl]?.toMutableMap() ?: mutableMapOf()
// if location.href is not passed, we fall back to origin
val safeLocationHref = locationHref ?: originUrl
frameProxies[safeLocationHref] = replyProxy
fixedReplyProxyMap[originUrl] = frameProxies
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,4 @@ interface AndroidBrowserConfigFeature {
*/
@Toggle.DefaultValue(false)
fun optimizeTrackerEvaluationV2(): Toggle

/**
* This feature flag guards a fix for blob downloads
*
* @return always returns `true` for internal builds
* @return `true` when the remote feature is enabled.
*/
@Toggle.DefaultValue(true)
fun fixBlobDownloadWithIframes(): Toggle
}

0 comments on commit c8f8956

Please sign in to comment.