Loading mobile/android/components/geckoview/GeckoViewStartup.jsm +2 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ ChromeUtils.defineESModuleGetters(lazy, { PdfJs: "resource://pdf.js/PdfJs.sys.mjs", Preferences: "resource://gre/modules/Preferences.sys.mjs", RFPHelper: "resource://gre/modules/RFPHelper.sys.mjs", TorAndroidIntegration: "resource://gre/modules/TorAndroidIntegration.sys.mjs", TorDomainIsolator: "resource://gre/modules/TorDomainIsolator.sys.mjs", }); Loading Loading @@ -259,6 +260,7 @@ class GeckoViewStartup { "GeckoView:SetLocale", ]); lazy.TorAndroidIntegration.init(); lazy.TorDomainIsolator.init(); Services.obs.addObserver(this, "browser-idle-startup-tasks-finished"); Loading mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoRuntimeSettings.java +16 −0 Original line number Diff line number Diff line Loading @@ -476,6 +476,11 @@ public final class GeckoRuntimeSettings extends RuntimeSettings { getSettings().mSecurityLevel.set(level); return this; } public @NonNull Builder useNewBootstrap(final boolean flag) { getSettings().mUseNewBootstrap.set(flag); return this; } } private GeckoRuntime mRuntime; Loading Loading @@ -527,6 +532,8 @@ public final class GeckoRuntimeSettings extends RuntimeSettings { /* package */ final Pref<Integer> mSpoofEnglish = new Pref<>("privacy.spoof_english", 0); /* package */ final Pref<Integer> mSecurityLevel = new Pref<>("browser.security_level.security_slider", 4); /* package */ final Pref<Boolean> mUseNewBootstrap = new Pref<>("browser.tor_android.use_new_bootstrap", false); /* package */ int mPreferredColorScheme = COLOR_SCHEME_SYSTEM; Loading Loading @@ -1319,6 +1326,15 @@ public final class GeckoRuntimeSettings extends RuntimeSettings { return this; } public boolean getUseNewBootstrap() { return mUseNewBootstrap.get(); } public @NonNull GeckoRuntimeSettings setUseNewBootstrap(final boolean flag) { mUseNewBootstrap.commit(flag); return this; } @Override // Parcelable public void writeToParcel(final Parcel out, final int flags) { super.writeToParcel(out, flags); Loading toolkit/modules/TorAndroidIntegration.sys.mjs 0 → 100644 +108 −0 Original line number Diff line number Diff line /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ import { ConsoleAPI } from "resource://gre/modules/Console.sys.mjs"; const lazy = {}; ChromeUtils.defineESModuleGetters(lazy, { EventDispatcher: "resource://gre/modules/Messaging.sys.mjs", TorConnect: "resource://gre/modules/TorConnect.sys.mjs", TorProviderBuilder: "resource://gre/modules/TorProviderBuilder.sys.mjs", TorSettings: "resource://gre/modules/TorSettings.sys.mjs", }); const Prefs = Object.freeze({ useNewBootstrap: "browser.tor_android.use_new_bootstrap", logLevel: "browser.tor_android.log_level", }); const logger = new ConsoleAPI({ maxLogLevel: "info", maxLogLevelPref: Prefs.logLevel, prefix: "TorAndroidIntegration", }); const ListenedEvents = Object.freeze({ settingsGet: "GeckoView:Tor:SettingsGet", settingsSet: "GeckoView:Tor:SettingsSet", settingsApply: "GeckoView:Tor:SettingsApply", settingsSave: "GeckoView:Tor:SettingsSave", }); class TorAndroidIntegrationImpl { #initialized = false; init() { lazy.EventDispatcher.instance.registerListener( this, Object.values(ListenedEvents) ); this.#bootstrapMethodReset(); Services.prefs.addObserver(Prefs.useNewBootstrap, this); } async #initNewBootstrap() { if (this.#initialized) { return; } this.#initialized = true; lazy.TorProviderBuilder.init().finally(() => { lazy.TorProviderBuilder.firstWindowLoaded(); }); try { await lazy.TorSettings.init(); await lazy.TorConnect.init(); } catch (e) { logger.error("Cannot initialize TorSettings or TorConnect", e); } } observe(subj, topic, data) { switch (topic) { case "nsPref:changed": if (data === Prefs.useNewBootstrap) { this.#bootstrapMethodReset(); } break; } } async onEvent(event, data, callback) { logger.debug(`Received event ${event}`, data); try { switch (event) { case settingsGet: callback?.onSuccess(lazy.TorSettings.getSettings()); return; case settingsSet: // This does not throw, so we do not have any way to report the error! lazy.TorSettings.setSettings(data); break; case settingsApply: await lazy.TorSettings.applySettings(); break; case settingsSave: await lazy.TorSettings.saveSettings(); break; } callback?.onSuccess(); } catch (e) { logger.error(); callback?.sendError(e); } } #bootstrapMethodReset() { if (Services.prefs.getBoolPref(Prefs.useNewBootstrap, false)) { this.#initNewBootstrap(); } else { Services.prefs.clearUserPref("network.proxy.socks"); Services.prefs.clearUserPref("network.proxy.socks_port"); } } } export const TorAndroidIntegration = new TorAndroidIntegrationImpl(); toolkit/modules/moz.build +1 −0 Original line number Diff line number Diff line Loading @@ -213,6 +213,7 @@ EXTRA_JS_MODULES += [ "Sqlite.sys.mjs", "SubDialog.sys.mjs", "Timer.sys.mjs", "TorAndroidIntegration.sys.mjs", "TorConnect.sys.mjs", "TorSettings.sys.mjs", "TorStrings.sys.mjs", Loading Loading
mobile/android/components/geckoview/GeckoViewStartup.jsm +2 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ ChromeUtils.defineESModuleGetters(lazy, { PdfJs: "resource://pdf.js/PdfJs.sys.mjs", Preferences: "resource://gre/modules/Preferences.sys.mjs", RFPHelper: "resource://gre/modules/RFPHelper.sys.mjs", TorAndroidIntegration: "resource://gre/modules/TorAndroidIntegration.sys.mjs", TorDomainIsolator: "resource://gre/modules/TorDomainIsolator.sys.mjs", }); Loading Loading @@ -259,6 +260,7 @@ class GeckoViewStartup { "GeckoView:SetLocale", ]); lazy.TorAndroidIntegration.init(); lazy.TorDomainIsolator.init(); Services.obs.addObserver(this, "browser-idle-startup-tasks-finished"); Loading
mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoRuntimeSettings.java +16 −0 Original line number Diff line number Diff line Loading @@ -476,6 +476,11 @@ public final class GeckoRuntimeSettings extends RuntimeSettings { getSettings().mSecurityLevel.set(level); return this; } public @NonNull Builder useNewBootstrap(final boolean flag) { getSettings().mUseNewBootstrap.set(flag); return this; } } private GeckoRuntime mRuntime; Loading Loading @@ -527,6 +532,8 @@ public final class GeckoRuntimeSettings extends RuntimeSettings { /* package */ final Pref<Integer> mSpoofEnglish = new Pref<>("privacy.spoof_english", 0); /* package */ final Pref<Integer> mSecurityLevel = new Pref<>("browser.security_level.security_slider", 4); /* package */ final Pref<Boolean> mUseNewBootstrap = new Pref<>("browser.tor_android.use_new_bootstrap", false); /* package */ int mPreferredColorScheme = COLOR_SCHEME_SYSTEM; Loading Loading @@ -1319,6 +1326,15 @@ public final class GeckoRuntimeSettings extends RuntimeSettings { return this; } public boolean getUseNewBootstrap() { return mUseNewBootstrap.get(); } public @NonNull GeckoRuntimeSettings setUseNewBootstrap(final boolean flag) { mUseNewBootstrap.commit(flag); return this; } @Override // Parcelable public void writeToParcel(final Parcel out, final int flags) { super.writeToParcel(out, flags); Loading
toolkit/modules/TorAndroidIntegration.sys.mjs 0 → 100644 +108 −0 Original line number Diff line number Diff line /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ import { ConsoleAPI } from "resource://gre/modules/Console.sys.mjs"; const lazy = {}; ChromeUtils.defineESModuleGetters(lazy, { EventDispatcher: "resource://gre/modules/Messaging.sys.mjs", TorConnect: "resource://gre/modules/TorConnect.sys.mjs", TorProviderBuilder: "resource://gre/modules/TorProviderBuilder.sys.mjs", TorSettings: "resource://gre/modules/TorSettings.sys.mjs", }); const Prefs = Object.freeze({ useNewBootstrap: "browser.tor_android.use_new_bootstrap", logLevel: "browser.tor_android.log_level", }); const logger = new ConsoleAPI({ maxLogLevel: "info", maxLogLevelPref: Prefs.logLevel, prefix: "TorAndroidIntegration", }); const ListenedEvents = Object.freeze({ settingsGet: "GeckoView:Tor:SettingsGet", settingsSet: "GeckoView:Tor:SettingsSet", settingsApply: "GeckoView:Tor:SettingsApply", settingsSave: "GeckoView:Tor:SettingsSave", }); class TorAndroidIntegrationImpl { #initialized = false; init() { lazy.EventDispatcher.instance.registerListener( this, Object.values(ListenedEvents) ); this.#bootstrapMethodReset(); Services.prefs.addObserver(Prefs.useNewBootstrap, this); } async #initNewBootstrap() { if (this.#initialized) { return; } this.#initialized = true; lazy.TorProviderBuilder.init().finally(() => { lazy.TorProviderBuilder.firstWindowLoaded(); }); try { await lazy.TorSettings.init(); await lazy.TorConnect.init(); } catch (e) { logger.error("Cannot initialize TorSettings or TorConnect", e); } } observe(subj, topic, data) { switch (topic) { case "nsPref:changed": if (data === Prefs.useNewBootstrap) { this.#bootstrapMethodReset(); } break; } } async onEvent(event, data, callback) { logger.debug(`Received event ${event}`, data); try { switch (event) { case settingsGet: callback?.onSuccess(lazy.TorSettings.getSettings()); return; case settingsSet: // This does not throw, so we do not have any way to report the error! lazy.TorSettings.setSettings(data); break; case settingsApply: await lazy.TorSettings.applySettings(); break; case settingsSave: await lazy.TorSettings.saveSettings(); break; } callback?.onSuccess(); } catch (e) { logger.error(); callback?.sendError(e); } } #bootstrapMethodReset() { if (Services.prefs.getBoolPref(Prefs.useNewBootstrap, false)) { this.#initNewBootstrap(); } else { Services.prefs.clearUserPref("network.proxy.socks"); Services.prefs.clearUserPref("network.proxy.socks_port"); } } } export const TorAndroidIntegration = new TorAndroidIntegrationImpl();
toolkit/modules/moz.build +1 −0 Original line number Diff line number Diff line Loading @@ -213,6 +213,7 @@ EXTRA_JS_MODULES += [ "Sqlite.sys.mjs", "SubDialog.sys.mjs", "Timer.sys.mjs", "TorAndroidIntegration.sys.mjs", "TorConnect.sys.mjs", "TorSettings.sys.mjs", "TorStrings.sys.mjs", Loading