[tbb-commits] [tor-browser] 27/72: Bug 40198: Expose privacy.spoof_english pref in GeckoView

gitolite role git at cupani.torproject.org
Wed Aug 3 13:05:17 UTC 2022


This is an automated email from the git hooks/post-receive script.

richard pushed a commit to branch tor-browser-91.12.0esr-12.0-1
in repository tor-browser.

commit 72b9b068ac4fc7c461d0d1f92dbaefff43ebe5db
Author: Alex Catarineu <acat at torproject.org>
AuthorDate: Sun Oct 18 17:06:04 2020 +0200

    Bug 40198: Expose privacy.spoof_english pref in GeckoView
---
 mobile/android/geckoview/api.txt                   |  3 ++
 .../mozilla/geckoview/GeckoRuntimeSettings.java    | 33 ++++++++++++++++++++++
 2 files changed, 36 insertions(+)

diff --git a/mobile/android/geckoview/api.txt b/mobile/android/geckoview/api.txt
index 5a04541ae57fd..8e024b646f94e 100644
--- a/mobile/android/geckoview/api.txt
+++ b/mobile/android/geckoview/api.txt
@@ -737,6 +737,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();
@@ -758,6 +759,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;
@@ -797,6 +799,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);
diff --git a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoRuntimeSettings.java b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoRuntimeSettings.java
index 3479af4313b20..6904750971396 100644
--- a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoRuntimeSettings.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoRuntimeSettings.java
@@ -472,6 +472,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;
@@ -528,6 +539,8 @@ public final class GeckoRuntimeSettings extends RuntimeSettings {
         "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;
 
@@ -1286,6 +1299,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);

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the tbb-commits mailing list