Skip to content

Commit

Permalink
For mozilla-mobile#12894 Canceling the "Open in app?" displays an emp…
Browse files Browse the repository at this point in the history
…ty page
  • Loading branch information
iorgamgabriel committed Oct 5, 2022
1 parent d581fcc commit 7c6387d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -674,8 +674,10 @@ class GeckoEngineSession(

if (interceptionResponse !is InterceptionResponse.AppIntent) {
appRedirectUrl = ""
lastLoadRequestUri = request.uri
}

lastLoadRequestUri = request.uri

return interceptionResponse
}
}
Expand All @@ -690,7 +692,7 @@ class GeckoEngineSession(

override fun onSecurityChange(
session: GeckoSession,
securityInfo: GeckoSession.ProgressDelegate.SecurityInformation
securityInfo: GeckoSession.ProgressDelegate.SecurityInformation,
) {
// Ignore initial load of about:blank (see https://github.com/mozilla-mobile/android-components/issues/403)
if (initialLoad && securityInfo.origin?.startsWith(MOZ_NULL_PRINCIPAL) == true) {
Expand Down Expand Up @@ -754,7 +756,7 @@ class GeckoEngineSession(
session: GeckoSession,
url: String,
lastVisitedURL: String?,
flags: Int
flags: Int,
): GeckoResult<Boolean>? {
// Don't track:
// - private visits
Expand Down Expand Up @@ -819,7 +821,7 @@ class GeckoEngineSession(

override fun getVisited(
session: GeckoSession,
urls: Array<out String>
urls: Array<out String>,
): GeckoResult<BooleanArray>? {
if (privateMode) {
return GeckoResult.fromValue(null)
Expand All @@ -835,15 +837,15 @@ class GeckoEngineSession(

override fun onHistoryStateChange(
session: GeckoSession,
historyList: GeckoSession.HistoryDelegate.HistoryList
historyList: GeckoSession.HistoryDelegate.HistoryList,
) {
val items = historyList.map {
// title is sometimes null despite the @NotNull annotation
// https://bugzilla.mozilla.org/show_bug.cgi?id=1660286
val title: String? = it.title
HistoryItem(
title = title ?: it.uri,
uri = it.uri
uri = it.uri,
)
}
notifyObservers { onHistoryStateChanged(items, historyList.currentIndex) }
Expand All @@ -866,7 +868,7 @@ class GeckoEngineSession(
session: GeckoSession,
screenX: Int,
screenY: Int,
element: GeckoSession.ContentDelegate.ContextElement
element: GeckoSession.ContentDelegate.ContextElement,
) {
val hitResult = handleLongClick(element.srcUri, element.type, element.linkUri, element.title)
hitResult?.let {
Expand Down Expand Up @@ -898,7 +900,7 @@ class GeckoEngineSession(
contentDisposition,
destinationDirectory = null,
url = url,
mimeType = contentType
mimeType = contentType,
)
val response = webResponse.toResponse()

Expand All @@ -909,7 +911,7 @@ class GeckoEngineSession(
contentType = DownloadUtils.sanitizeMimeType(contentType),
fileName = fileName.sanitizeFileName(),
response = response,
isPrivate = privateMode
isPrivate = privateMode,
)
}
}
Expand All @@ -920,8 +922,8 @@ class GeckoEngineSession(
onWindowRequest(
GeckoWindowRequest(
engineSession = this@GeckoEngineSession,
type = WindowRequest.Type.CLOSE
)
type = WindowRequest.Type.CLOSE,
),
)
}
}
Expand Down Expand Up @@ -1037,7 +1039,7 @@ class GeckoEngineSession(
return Tracker(
url = uri,
trackingCategories = blockedContentCategories,
cookiePolicies = getCookiePolicies()
cookiePolicies = getCookiePolicies(),
)
}

Expand Down Expand Up @@ -1078,7 +1080,7 @@ class GeckoEngineSession(
private fun createPermissionDelegate() = object : GeckoSession.PermissionDelegate {
override fun onContentPermissionRequest(
session: GeckoSession,
geckoContentPermission: ContentPermission
geckoContentPermission: ContentPermission,
): GeckoResult<Int> {
val geckoResult = GeckoResult<Int>()
val uri = geckoContentPermission.uri
Expand All @@ -1093,25 +1095,25 @@ class GeckoEngineSession(
uri: String,
video: Array<out GeckoSession.PermissionDelegate.MediaSource>?,
audio: Array<out GeckoSession.PermissionDelegate.MediaSource>?,
callback: GeckoSession.PermissionDelegate.MediaCallback
callback: GeckoSession.PermissionDelegate.MediaCallback,
) {
val request = GeckoPermissionRequest.Media(
uri,
video?.toList() ?: emptyList(),
audio?.toList() ?: emptyList(),
callback
callback,
)
notifyObservers { onContentPermissionRequest(request) }
}

override fun onAndroidPermissionsRequest(
session: GeckoSession,
permissions: Array<out String>?,
callback: GeckoSession.PermissionDelegate.Callback
callback: GeckoSession.PermissionDelegate.Callback,
) {
val request = GeckoPermissionRequest.App(
permissions?.toList() ?: emptyList(),
callback
callback,
)
notifyObservers { onAppPermissionRequest(request) }
}
Expand Down
3 changes: 3 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ permalink: /changelog/
* **nimbus-gradle-plugin**:
* Updated the plugin to use the version of application services defined in the buildSrc Dependencies.

* **browser-engine-gecko**:
* Canceling the "Open in app?" displays an empty page [#12894](https://github.com/mozilla-mobile/android-components/issues/12894)

# 106.0.0
* [Commits](https://github.com/mozilla-mobile/android-components/compare/v105.0.0..v106.0.0)
* [Milestone](https://github.com/mozilla-mobile/android-components/milestone/153?closed=1)
Expand Down

0 comments on commit 7c6387d

Please sign in to comment.