Skip to content

Commit c91a47c

Browse files
committed
Update GeckoView (release) to 80.0.20200818235255
1 parent 4a9f8e6 commit c91a47c

File tree

11 files changed

+475
-92
lines changed

11 files changed

+475
-92
lines changed

buildSrc/src/main/java/Gecko.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ internal object GeckoVersions {
1616
/**
1717
* GeckoView Release Version.
1818
*/
19-
const val release_version = "79.0.20200720193547"
19+
const val release_version = "80.0.20200818235255"
2020
}
2121

2222
@Suppress("Unused", "MaxLineLength")

components/browser/engine-gecko/src/androidTest/java/mozilla/components/browser/engine/gecko/fetch/geckoview/GeckoViewFetchTestCases.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@
22
* License, v. 2.0. If a copy of the MPL was not distributed with this
33
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
44

5-
package mozilla.components.lib.fetch.geckoview
5+
package mozilla.components.browser.engine.gecko.fetch.geckoview
66

77
import androidx.test.annotation.UiThreadTest
88
import androidx.test.core.app.ApplicationProvider
99
import androidx.test.filters.MediumTest
1010
import mozilla.components.browser.engine.gecko.fetch.GeckoViewFetchClient
1111
import mozilla.components.concept.fetch.Client
1212
import org.junit.Assert.assertTrue
13-
import org.junit.Ignore
1413
import org.junit.Test
1514

1615
@MediumTest
@@ -110,7 +109,6 @@ class GeckoViewFetchTestCases : mozilla.components.tooling.fetch.tests.FetchTest
110109

111110
@Test
112111
@UiThreadTest
113-
@Ignore("https://bugzilla.mozilla.org/show_bug.cgi?id=1626335")
114112
override fun get200WithCookiePolicy() {
115113
super.get200WithCookiePolicy()
116114
}

components/browser/engine-gecko/src/main/java/mozilla/components/browser/engine/gecko/GeckoEngine.kt

Lines changed: 22 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,13 @@ package mozilla.components.browser.engine.gecko
77
import android.content.Context
88
import android.util.AttributeSet
99
import androidx.annotation.VisibleForTesting
10+
import mozilla.components.browser.engine.gecko.ext.getAntiTrackingPolicy
11+
import mozilla.components.browser.engine.gecko.ext.getEtpLevel
12+
import mozilla.components.browser.engine.gecko.ext.getStrictSocialTrackingProtection
1013
import mozilla.components.browser.engine.gecko.integration.LocaleSettingUpdater
1114
import mozilla.components.browser.engine.gecko.mediaquery.from
1215
import mozilla.components.browser.engine.gecko.mediaquery.toGeckoValue
16+
import mozilla.components.browser.engine.gecko.profiler.Profiler
1317
import mozilla.components.browser.engine.gecko.webextension.GeckoWebExtension
1418
import mozilla.components.browser.engine.gecko.webnotifications.GeckoWebNotificationDelegate
1519
import mozilla.components.browser.engine.gecko.webpush.GeckoWebPushDelegate
@@ -27,7 +31,6 @@ import mozilla.components.concept.engine.content.blocking.TrackerLog
2731
import mozilla.components.concept.engine.content.blocking.TrackingProtectionExceptionStorage
2832
import mozilla.components.concept.engine.history.HistoryTrackingDelegate
2933
import mozilla.components.concept.engine.mediaquery.PreferredColorScheme
30-
import mozilla.components.concept.engine.profiler.Profiler
3134
import mozilla.components.concept.engine.utils.EngineVersion
3235
import mozilla.components.concept.engine.webextension.Action
3336
import mozilla.components.concept.engine.webextension.ActionHandler
@@ -478,7 +481,7 @@ class GeckoEngine(
478481
/**
479482
* See [Engine.profiler].
480483
*/
481-
override val profiler: Profiler? = null
484+
override val profiler: Profiler? = Profiler(runtime)
482485

483486
override fun name(): String = "Gecko"
484487

@@ -527,42 +530,29 @@ class GeckoEngine(
527530
override var trackingProtectionPolicy: TrackingProtectionPolicy? = null
528531
set(value) {
529532
value?.let { policy ->
530-
val activateStrictSocialTracking =
531-
policy.strictSocialTrackingProtection ?: policy.trackingCategories.contains(
532-
TrackingCategory.STRICT
533-
)
534-
val etpLevel =
535-
when {
536-
policy.trackingCategories.contains(TrackingCategory.NONE) ->
537-
ContentBlocking.EtpLevel.NONE
538-
else -> ContentBlocking.EtpLevel.STRICT
533+
with(runtime.settings.contentBlocking) {
534+
if (enhancedTrackingProtectionLevel != value.getEtpLevel()) {
535+
enhancedTrackingProtectionLevel = value.getEtpLevel()
539536
}
540-
runtime.settings.contentBlocking.setEnhancedTrackingProtectionLevel(etpLevel)
541-
runtime.settings.contentBlocking.setStrictSocialTrackingProtection(
542-
activateStrictSocialTracking
543-
)
544-
runtime.settings.contentBlocking.setAntiTracking(policy.getAntiTrackingPolicy())
545-
runtime.settings.contentBlocking.setCookieBehavior(policy.cookiePolicy.id)
537+
538+
if (strictSocialTrackingProtection != value.getStrictSocialTrackingProtection()) {
539+
strictSocialTrackingProtection = policy.getStrictSocialTrackingProtection()
540+
}
541+
542+
if (antiTrackingCategories != value.getAntiTrackingPolicy()) {
543+
setAntiTracking(policy.getAntiTrackingPolicy())
544+
}
545+
546+
if (cookieBehavior != value.cookiePolicy.id) {
547+
cookieBehavior = value.cookiePolicy.id
548+
}
549+
}
550+
546551
defaultSettings?.trackingProtectionPolicy = value
547552
field = value
548553
}
549554
}
550555

551-
private fun TrackingProtectionPolicy.getAntiTrackingPolicy(): Int {
552-
/**
553-
* The [TrackingProtectionPolicy.TrackingCategory.SCRIPTS_AND_SUB_RESOURCES] is an
554-
* artificial category, created with the sole purpose of going around this bug
555-
* https://bugzilla.mozilla.org/show_bug.cgi?id=1579264, for this reason we have to
556-
* remove its value from the valid anti tracking categories, when is present.
557-
*/
558-
val total = trackingCategories.sumBy { it.id }
559-
return if (contains(TrackingCategory.SCRIPTS_AND_SUB_RESOURCES)) {
560-
total - TrackingProtectionPolicy.TrackingCategory.SCRIPTS_AND_SUB_RESOURCES.id
561-
} else {
562-
total
563-
}
564-
}
565-
566556
override var remoteDebuggingEnabled: Boolean
567557
get() = runtime.settings.remoteDebuggingEnabled
568558
set(value) { runtime.settings.remoteDebuggingEnabled = value }

components/browser/engine-gecko/src/main/java/mozilla/components/browser/engine/gecko/GeckoEngineSession.kt

Lines changed: 44 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,24 @@ class GeckoEngineSession(
104104
createGeckoSession(shouldOpen = openGeckoSession)
105105
}
106106

107+
/**
108+
* Represents a request to load a [url].
109+
*
110+
* @param url the url to load.
111+
* @param parent the parent (referring) [EngineSession] i.e. the session that
112+
* triggered creating this one.
113+
* @param flags the [LoadUrlFlags] to use when loading the provided url.
114+
* @param additionalHeaders the extra headers to use when loading the provided url.
115+
**/
116+
data class LoadRequest(
117+
val url: String,
118+
val parent: EngineSession?,
119+
val flags: LoadUrlFlags,
120+
val additionalHeaders: Map<String, String>?
121+
)
122+
@VisibleForTesting
123+
internal var initialLoadRequest: LoadRequest? = null
124+
107125
/**
108126
* See [EngineSession.loadUrl]
109127
*/
@@ -113,6 +131,9 @@ class GeckoEngineSession(
113131
flags: LoadUrlFlags,
114132
additionalHeaders: Map<String, String>?
115133
) {
134+
if (initialLoad) {
135+
initialLoadRequest = LoadRequest(url, parent, flags, additionalHeaders)
136+
}
116137
geckoSession.loadUri(url, (parent as? GeckoEngineSession)?.geckoSession, flags.value, additionalHeaders)
117138
}
118139

@@ -137,7 +158,12 @@ class GeckoEngineSession(
137158
* See [EngineSession.reload]
138159
*/
139160
override fun reload(flags: LoadUrlFlags) {
140-
geckoSession.reload(flags.value)
161+
initialLoadRequest?.let {
162+
// We have a pending initial load request, which means we never
163+
// successfully loaded a page. Calling reload now would just reload
164+
// about:blank. To prevent that we trigger the initial load again.
165+
loadUrl(it.url, it.parent, it.flags, it.additionalHeaders)
166+
} ?: geckoSession.reload(flags.value)
141167
}
142168

143169
/**
@@ -388,6 +414,8 @@ class GeckoEngineSession(
388414

389415
currentUrl = url
390416
initialLoad = false
417+
initialLoadRequest = null
418+
391419
isIgnoredForTrackingProtection { ignored ->
392420
notifyObservers {
393421
onExcludedOnTrackingProtectionChange(ignored)
@@ -400,10 +428,6 @@ class GeckoEngineSession(
400428
session: GeckoSession,
401429
request: NavigationDelegate.LoadRequest
402430
): GeckoResult<AllowOrDeny> {
403-
if (request.target == NavigationDelegate.TARGET_WINDOW_NEW) {
404-
return GeckoResult.fromValue(AllowOrDeny.ALLOW)
405-
}
406-
407431
// The process switch involved when loading extension pages will
408432
// trigger an initial load of about:blank which we want to
409433
// avoid:
@@ -413,18 +437,22 @@ class GeckoEngineSession(
413437
initialLoad = true
414438
}
415439

416-
return if (maybeInterceptRequest(request, false) != null) {
417-
GeckoResult.fromValue(AllowOrDeny.DENY)
418-
} else {
419-
notifyObservers {
420-
onLoadRequest(
421-
url = request.uri,
422-
triggeredByRedirect = request.isRedirect,
423-
triggeredByWebContent = request.hasUserGesture
424-
)
425-
}
440+
return when {
441+
maybeInterceptRequest(request, false) != null ->
442+
GeckoResult.fromValue(AllowOrDeny.DENY)
443+
request.target == NavigationDelegate.TARGET_WINDOW_NEW ->
444+
GeckoResult.fromValue(AllowOrDeny.ALLOW)
445+
else -> {
446+
notifyObservers {
447+
onLoadRequest(
448+
url = request.uri,
449+
triggeredByRedirect = request.isRedirect,
450+
triggeredByWebContent = request.hasUserGesture
451+
)
452+
}
426453

427-
GeckoResult.fromValue(AllowOrDeny.ALLOW)
454+
GeckoResult.fromValue(AllowOrDeny.ALLOW)
455+
}
428456
}
429457
}
430458

components/browser/engine-gecko/src/main/java/mozilla/components/browser/engine/gecko/GeckoEngineView.kt

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,14 @@ class GeckoEngineView @JvmOverloads constructor(
3838
} catch (e: IllegalStateException) {
3939
// This is to debug "display already acquired" crashes
4040
val otherActivityClassName =
41-
this.session?.accessibility?.view?.context?.javaClass?.simpleName
41+
this.session?.accessibility?.view?.context?.javaClass?.simpleName
42+
val otherActivityClassHashcode =
43+
this.session?.accessibility?.view?.context?.hashCode()
4244
val activityClassName = context.javaClass.simpleName
43-
val msg = "ATTACH VIEW: Current activity: $activityClassName Other activity: $otherActivityClassName"
45+
val activityClassHashCode = context.hashCode()
46+
val msg = "ATTACH VIEW: Current activity: $activityClassName hashcode " +
47+
"$activityClassHashCode Other activity: $otherActivityClassName " +
48+
"hashcode $otherActivityClassHashcode"
4449
throw IllegalStateException(msg, e)
4550
}
4651
}
@@ -118,9 +123,13 @@ class GeckoEngineView @JvmOverloads constructor(
118123
// This is to debug "display already acquired" crashes
119124
val otherActivityClassName =
120125
internalSession.geckoSession.accessibility.view?.context?.javaClass?.simpleName
126+
val otherActivityClassHashcode =
127+
internalSession.geckoSession.accessibility.view?.context?.hashCode()
121128
val activityClassName = context.javaClass.simpleName
122-
val msg =
123-
"SET SESSION: Current activity: $activityClassName Other activity: $otherActivityClassName"
129+
val activityClassHashCode = context.hashCode()
130+
val msg = "SET SESSION: Current activity: $activityClassName hashcode " +
131+
"$activityClassHashCode Other activity: $otherActivityClassName " +
132+
"hashcode $otherActivityClassHashcode"
124133
throw IllegalStateException(msg, e)
125134
}
126135
}

components/browser/engine-gecko/src/main/java/mozilla/components/browser/engine/gecko/ext/TrackingProtectionPolicy.kt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,16 @@ fun TrackingProtectionPolicy.toContentBlockingSetting(
2020
antiTracking(getAntiTrackingPolicy())
2121
cookieBehavior(cookiePolicy.id)
2222
safeBrowsing(safeBrowsingPolicy.sumBy { it.id })
23-
// This will be fixed on merge day when strictSocialTrackingProtection will be available on beta
24-
// strictSocialTrackingProtection(getStrictSocialTrackingProtection())
23+
strictSocialTrackingProtection(getStrictSocialTrackingProtection())
2524
}.build()
2625

26+
/**
27+
* Returns whether [TrackingCategory.STRICT] is enabled in the [TrackingProtectionPolicy].
28+
*/
29+
internal fun TrackingProtectionPolicy.getStrictSocialTrackingProtection(): Boolean {
30+
return strictSocialTrackingProtection ?: trackingCategories.contains(TrackingCategory.STRICT)
31+
}
32+
2733
/**
2834
* Returns the [TrackingProtectionPolicy] categories as an Enhanced Tracking Protection level for GeckoView.
2935
*/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/* This Source Code Form is subject to the terms of the Mozilla Public
2+
* License, v. 2.0. If a copy of the MPL was not distributed with this
3+
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4+
5+
package mozilla.components.browser.engine.gecko.profiler
6+
7+
import mozilla.components.concept.engine.profiler.Profiler
8+
import org.mozilla.geckoview.GeckoRuntime
9+
10+
/**
11+
* Gecko-based implementation of [Profiler], wrapping the
12+
* ProfilerController object provided by GeckoView.
13+
*/
14+
class Profiler(
15+
private val runtime: GeckoRuntime
16+
) : Profiler {
17+
18+
/**
19+
* See [Profiler.isProfilerActive].
20+
*/
21+
override fun isProfilerActive(): Boolean {
22+
return runtime.profilerController.isProfilerActive
23+
}
24+
25+
/**
26+
* See [Profiler.getProfilerTime].
27+
*/
28+
override fun getProfilerTime(): Double? {
29+
return runtime.profilerController.profilerTime
30+
}
31+
32+
/**
33+
* See [Profiler.addMarker].
34+
*/
35+
override fun addMarker(markerName: String, startTime: Double?, endTime: Double?, text: String?) {
36+
runtime.profilerController.addMarker(markerName, startTime, endTime, text)
37+
}
38+
39+
/**
40+
* See [Profiler.addMarker].
41+
*/
42+
override fun addMarker(markerName: String, startTime: Double?, text: String?) {
43+
runtime.profilerController.addMarker(markerName, startTime, text)
44+
}
45+
46+
/**
47+
* See [Profiler.addMarker].
48+
*/
49+
override fun addMarker(markerName: String, startTime: Double?) {
50+
runtime.profilerController.addMarker(markerName, startTime)
51+
}
52+
53+
/**
54+
* See [Profiler.addMarker].
55+
*/
56+
override fun addMarker(markerName: String, text: String?) {
57+
runtime.profilerController.addMarker(markerName, text)
58+
}
59+
60+
/**
61+
* See [Profiler.addMarker].
62+
*/
63+
override fun addMarker(markerName: String) {
64+
runtime.profilerController.addMarker(markerName)
65+
}
66+
}

components/browser/engine-gecko/src/main/java/mozilla/components/browser/engine/gecko/selection/GeckoSelectionActionDelegate.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ open class GeckoSelectionActionDelegate(
4444
val selectedText = mSelection?.text
4545

4646
val customActionIsAvailable = !selectedText.isNullOrEmpty() &&
47-
customDelegate.isActionAvailable(id, selectedText)
47+
customDelegate.isActionAvailable(id, selectedText)
4848

4949
return customActionIsAvailable ||
5050
super.isActionAvailable(id)

0 commit comments

Comments
 (0)