Skip to content
Snippets Groups Projects
Verified Commit cac51024 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 0b0bae79
No related branches found
No related tags found
1 merge request!609Bug 41687: Rebased alpha to 102.10
......@@ -17,6 +17,7 @@ XPCOMUtils.defineLazyModuleGetters(this, {
EventDispatcher: "resource://gre/modules/Messaging.jsm",
Preferences: "resource://gre/modules/Preferences.jsm",
Services: "resource://gre/modules/Services.jsm",
RFPHelper: "resource://gre/modules/RFPHelper.jsm",
});
const { debug, warn } = GeckoViewUtils.initLogging("Startup");
......@@ -253,6 +254,10 @@ class GeckoViewStartup {
if (aData.requestedLocales) {
Services.locale.requestedLocales = aData.requestedLocales;
}
RFPHelper._handleSpoofEnglishChanged();
if (Services.prefs.getIntPref("privacy.spoof_english", 0) === 2) {
break;
}
const pls = Cc["@mozilla.org/pref-localizedstring;1"].createInstance(
Ci.nsIPrefLocalizedString
);
......
......@@ -810,6 +810,7 @@ package org.mozilla.geckoview {
method public boolean getRemoteDebuggingEnabled();
method @Nullable public GeckoRuntime getRuntime();
method @Nullable public Rect getScreenSizeOverride();
method public boolean getSpoofEnglish();
method @Nullable public RuntimeTelemetry.Delegate getTelemetryDelegate();
method public boolean getUseMaxScreenDepth();
method public boolean getWebFontsEnabled();
......@@ -831,6 +832,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 setWebFontsEnabled(boolean);
method @NonNull public GeckoRuntimeSettings setWebManifestEnabled(boolean);
field public static final int ALLOW_ALL = 0;
......@@ -870,6 +872,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 telemetryDelegate(@NonNull RuntimeTelemetry.Delegate);
method @NonNull public GeckoRuntimeSettings.Builder useMaxScreenDepth(boolean);
method @NonNull public GeckoRuntimeSettings.Builder webFontsEnabled(boolean);
......
......@@ -453,6 +453,17 @@ public final class GeckoRuntimeSettings extends RuntimeSettings {
getSettings().setAllowInsecureConnections(level);
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;
......@@ -501,6 +512,7 @@ public final class GeckoRuntimeSettings extends RuntimeSettings {
/* package */ final Pref<Boolean> mHttpsOnlyPrivateMode =
new Pref<Boolean>("dom.security.https_only_mode_pbm", false);
/* package */ final Pref<Integer> mProcessCount = new Pref<>("dom.ipc.processCount", 2);
/* package */ final Pref<Integer> mSpoofEnglish = new Pref<>("privacy.spoof_english", 0);
/* package */ int mPreferredColorScheme = COLOR_SCHEME_SYSTEM;
......@@ -1239,6 +1251,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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment