Skip to content
Snippets Groups Projects
Verified Commit 9a8da4ec authored by Alex Catarineu's avatar Alex Catarineu Committed by Pier Angelo Vendrame
Browse files

Bug 30605: Honor privacy.spoof_english in Android

This checks `privacy.spoof_english` whenever `setLocales` is
called from Fenix side and sets `intl.accept_languages`
accordingly.

Bug 40198: Expose privacy.spoof_english pref in GeckoView
parent a72b7149
No related branches found
No related tags found
2 merge requests!1202Bug_43099: 2024 YEC Strings,!1136Bug 43085: Rebased alpha onto 128.2.0esr
......@@ -886,6 +886,7 @@ package org.mozilla.geckoview {
method public boolean getRemoteDebuggingEnabled();
method @Nullable public GeckoRuntime getRuntime();
method @Nullable public Rect getScreenSizeOverride();
method public boolean getSpoofEnglish();
method public boolean getTranslationsOfferPopup();
method @NonNull public String getTrustedRecursiveResolverUri();
method public int getTrustedRecusiveResolverMode();
......@@ -915,6 +916,7 @@ package org.mozilla.geckoview {
method @NonNull public GeckoRuntimeSettings setLoginAutofillEnabled(boolean);
method @NonNull public GeckoRuntimeSettings setPreferredColorScheme(int);
method @NonNull public GeckoRuntimeSettings setRemoteDebuggingEnabled(boolean);
method @NonNull public GeckoRuntimeSettings setSpoofEnglish(boolean);
method @NonNull public GeckoRuntimeSettings setTranslationsOfferPopup(boolean);
method @NonNull public GeckoRuntimeSettings setTrustedRecursiveResolverMode(int);
method @NonNull public GeckoRuntimeSettings setTrustedRecursiveResolverUri(@NonNull String);
......@@ -968,6 +970,7 @@ package org.mozilla.geckoview {
method @NonNull public GeckoRuntimeSettings.Builder preferredColorScheme(int);
method @NonNull public GeckoRuntimeSettings.Builder remoteDebuggingEnabled(boolean);
method @NonNull public GeckoRuntimeSettings.Builder screenSizeOverride(int, int);
method @NonNull public GeckoRuntimeSettings.Builder spoofEnglish(boolean);
method @NonNull public GeckoRuntimeSettings.Builder translationsOfferPopup(boolean);
method @NonNull public GeckoRuntimeSettings.Builder trustedRecursiveResolverMode(int);
method @NonNull public GeckoRuntimeSettings.Builder trustedRecursiveResolverUri(@NonNull String);
......
......@@ -565,6 +565,17 @@ public final class GeckoRuntimeSettings extends RuntimeSettings {
getSettings().setLargeKeepaliveFactor(factor);
return this;
}
/**
* Sets whether we should spoof locale to English for webpages.
*
* @param flag True if we should spoof locale to English for webpages, false otherwise.
* @return This Builder instance.
*/
public @NonNull Builder spoofEnglish(final boolean flag) {
getSettings().mSpoofEnglish.set(flag ? 2 : 1);
return this;
}
}
private GeckoRuntime mRuntime;
......@@ -634,6 +645,7 @@ public final class GeckoRuntimeSettings extends RuntimeSettings {
new Pref<Boolean>("privacy.globalprivacycontrol.pbmode.enabled", true);
/* package */ final Pref<Boolean> mGlobalPrivacyControlFunctionalityEnabled =
new Pref<Boolean>("privacy.globalprivacycontrol.functionality.enabled", true);
/* package */ final Pref<Integer> mSpoofEnglish = new Pref<>("privacy.spoof_english", 0);
/* package */ int mPreferredColorScheme = COLOR_SCHEME_SYSTEM;
......@@ -1625,6 +1637,26 @@ public final class GeckoRuntimeSettings extends RuntimeSettings {
return this;
}
/**
* Get whether we should spoof locale to English for webpages.
*
* @return Whether we should spoof locale to English for webpages.
*/
public boolean getSpoofEnglish() {
return mSpoofEnglish.get() == 2;
}
/**
* Set whether we should spoof locale to English for webpages.
*
* @param flag A flag determining whether we should locale to English for webpages.
* @return This GeckoRuntimeSettings instance.
*/
public @NonNull GeckoRuntimeSettings setSpoofEnglish(final boolean flag) {
mSpoofEnglish.commit(flag ? 2 : 1);
return this;
}
@Override // Parcelable
public void writeToParcel(final Parcel out, final int flags) {
super.writeToParcel(out, flags);
......
......@@ -11,6 +11,7 @@ ChromeUtils.defineESModuleGetters(lazy, {
ActorManagerParent: "resource://gre/modules/ActorManagerParent.sys.mjs",
EventDispatcher: "resource://gre/modules/Messaging.sys.mjs",
PdfJs: "resource://pdf.js/PdfJs.sys.mjs",
RFPHelper: "resource://gre/modules/RFPHelper.sys.mjs",
});
const { debug, warn } = GeckoViewUtils.initLogging("Startup");
......@@ -339,6 +340,10 @@ export class GeckoViewStartup {
if (aData.requestedLocales) {
Services.locale.requestedLocales = aData.requestedLocales;
}
lazy.RFPHelper._handleSpoofEnglishChanged();
if (Services.prefs.getIntPref("privacy.spoof_english", 0) === 2) {
break;
}
const pls = Cc["@mozilla.org/pref-localizedstring;1"].createInstance(
Ci.nsIPrefLocalizedString
);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment