This is an automated email from the git hooks/post-receive script.
richard pushed a commit to branch tor-browser-91.9.0esr-11.5-1 in repository tor-browser.
commit ef9c0a301b640370f857681ac9c116e94b65b114 Author: Pier Angelo Vendrame pierov@torproject.org AuthorDate: Mon Apr 11 16:12:49 2022 +0200
fixup! squash! Bug 27476: Implement about:torconnect captive portal within Tor Browser
Bug 40891: started working on the You Are Offline panel (WIP). --- browser/components/torconnect/TorConnectParent.jsm | 12 ++-- .../torconnect/content/aboutTorConnect.css | 14 ++-- .../torconnect/content/aboutTorConnect.js | 76 +++++++++++++++------- .../torconnect/content/aboutTorConnect.xhtml | 4 +- 4 files changed, 73 insertions(+), 33 deletions(-)
diff --git a/browser/components/torconnect/TorConnectParent.jsm b/browser/components/torconnect/TorConnectParent.jsm index 479446898e115..f39b31a974a95 100644 --- a/browser/components/torconnect/TorConnectParent.jsm +++ b/browser/components/torconnect/TorConnectParent.jsm @@ -5,6 +5,7 @@ var EXPORTED_SYMBOLS = ["TorConnectParent"]; const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm"); const { TorStrings } = ChromeUtils.import("resource:///modules/TorStrings.jsm"); const { + InternetStatus, TorConnect, TorConnectTopics, TorConnectState, @@ -27,12 +28,13 @@ class TorConnectParent extends JSWindowActorParent {
this.state = { State: TorConnect.state, - DetectedCensorshipLevel: TorConnect.detectedCensorshipLevel, StateChanged: false, ErrorMessage: TorConnect.errorMessage, ErrorDetails: TorConnect.errorDetails, BootstrapProgress: TorConnect.bootstrapProgress, BootstrapStatus: TorConnect.bootstrapStatus, + DetectedCensorshipLevel: TorConnect.detectedCensorshipLevel, + InternetStatus: TorConnect.internetStatus, ShowViewLog: TorConnect.logHasWarningOrError, QuickStartEnabled: TorSettings.quickstart.enabled, CountryCodes: TorConnect.countryCodes, @@ -77,6 +79,7 @@ class TorConnectParent extends JSWindowActorParent { self.state.ErrorMessage = obj.message; self.state.ErrorDetails = obj.details; self.state.DetectedCensorshipLevel = obj.censorshipLevel; + self.state.InternetStatus = TorConnect.internetStatus;
// With severe censorshp, we offer user list of countries to try if ( @@ -142,9 +145,6 @@ class TorConnectParent extends JSWindowActorParent { case "torconnect:open-tor-preferences": TorConnect.openTorPreferences(); break; - case "torconnect:view-tor-logs": - TorConnect.viewTorLogs(); - break; case "torconnect:cancel-bootstrap": TorConnect.cancelBootstrap(); break; @@ -154,6 +154,9 @@ class TorConnectParent extends JSWindowActorParent { case "torconnect:begin-autobootstrap": TorConnect.beginAutoBootstrap(message.data); break; + case "torconnect:view-tor-logs": + TorConnect.viewTorLogs(); + break; case "torconnect:restart": Services.startup.quit( Ci.nsIAppStartup.eRestart | Ci.nsIAppStartup.eAttemptQuit @@ -169,6 +172,7 @@ class TorConnectParent extends JSWindowActorParent { TorStrings, TorConnectState, TorCensorshipLevel, + InternetStatus, Direction: Services.locale.isAppLocaleRTL ? "rtl" : "ltr", State: this.state, CountryNames: TorConnect.countryNames, diff --git a/browser/components/torconnect/content/aboutTorConnect.css b/browser/components/torconnect/content/aboutTorConnect.css index f2d8089a96326..926ff4927505a 100644 --- a/browser/components/torconnect/content/aboutTorConnect.css +++ b/browser/components/torconnect/content/aboutTorConnect.css @@ -69,27 +69,31 @@ margin-top: -1px; }
-#breadcrumbs .active { +.breadcrumb-item.active { color: var(--in-content-accent-color-active); }
-#breadcrumbs .disabled, #breadcrumbs .disabled:hover { +.breadcrumb-item.disabled, .breadcrumb-item.disabled:hover { color: var(--green-90-a40); cursor: default; }
-#breadcrumbs .error { +.breadcrumb-item.error { color: var(--in-content-danger-button-background); }
-#breadcrumbs .error:hover { +.breadcrumb-item.error:hover { color: var(--in-content-danger-button-background-hover); }
-#breadcrumbs .error:active { +.breadcrumb-item.error:active { color: var(--in-content-danger-button-background-active); }
+.breadcrumb-item.hidden, .breadcrumb-separator.hidden { + display: none; +} + #connection-assist { margin-left: 0; } diff --git a/browser/components/torconnect/content/aboutTorConnect.js b/browser/components/torconnect/content/aboutTorConnect.js index eb691444e4d26..30dfbd978315f 100644 --- a/browser/components/torconnect/content/aboutTorConnect.js +++ b/browser/components/torconnect/content/aboutTorConnect.js @@ -6,12 +6,14 @@ let TorStrings = {}; let TorConnectState = {}; let TorCensorshipLevel = {}; +let InternetStatus = {};
const BreadcrumbStatus = Object.freeze({ - Disabled: -1, - Default: 0, - Active: 1, - Error: 2, + Hidden: "hidden", + Disabled: "disabled", + Default: "default", + Active: "active", + Error: "error", });
class AboutTorConnect { @@ -32,10 +34,12 @@ class AboutTorConnect { label: "#connection-assist .breadcrumb-label", }, locationSettings: { + separator: "#location-settings-separator", link: "#location-settings", label: "#location-settings .breadcrumb-label", }, tryBridge: { + separator: "#try-bridge-separator", link: "#try-bridge", label: "#try-bridge .breadcrumb-label", }, @@ -81,12 +85,18 @@ class AboutTorConnect { connectionAssistLabel: document.querySelector( this.selectors.breadcrumbs.connectionAssist.label ), + locationSettingsSeparator: document.querySelector( + this.selectors.breadcrumbs.locationSettings.separator + ), locationSettingsLink: document.querySelector( this.selectors.breadcrumbs.locationSettings.link ), locationSettingsLabel: document.querySelector( this.selectors.breadcrumbs.locationSettings.label ), + tryBridgeSeparator: document.querySelector( + this.selectors.breadcrumbs.tryBridge.separator + ), tryBridgeLink: document.querySelector( this.selectors.breadcrumbs.tryBridge.link ), @@ -284,26 +294,28 @@ class AboutTorConnect {
setBreadcrumbsStatus(connectionAssist, locationSettings, tryBridge) { this.elements.breadcrumbContainer.classList.remove("hidden"); - let elems = [ - [this.elements.connectionAssistLink, connectionAssist], - [this.elements.locationSettingsLink, locationSettings], - [this.elements.tryBridgeLink, tryBridge], + const elems = [ + [this.elements.connectionAssistLink, connectionAssist, null], + [ + this.elements.locationSettingsLink, + locationSettings, + this.elements.locationSettingsSeparator, + ], + [ + this.elements.tryBridgeLink, + tryBridge, + this.elements.tryBridgeSeparator, + ], ]; - elems.forEach(([elem, status]) => { - elem.classList.remove("disabled"); - elem.classList.remove("active"); - elem.classList.remove("error"); - switch (status) { - case BreadcrumbStatus.Disabled: - elem.classList.add("disabled"); - break; - case BreadcrumbStatus.Active: - elem.classList.add("active"); - break; - case BreadcrumbStatus.Error: - elem.classList.add("error"); - break; + elems.forEach(([elem, status, separator]) => { + elem.classList.remove(BreadcrumbStatus.Hidden); + elem.classList.remove(BreadcrumbStatus.Disabled); + elem.classList.remove(BreadcrumbStatus.Active); + elem.classList.remove(BreadcrumbStatus.Error); + if (status !== "") { + elem.classList.add(status); } + separator?.classList.toggle("hidden", status === BreadcrumbStatus.Hidden); }); }
@@ -346,6 +358,10 @@ class AboutTorConnect { this.hideButtons();
if (hasError) { + if (state.InternetStatus === InternetStatus.Offline) { + this.showOffline(state.ErrorMessage); + return; + } switch (state.DetectedCensorshipLevel) { case TorCensorshipLevel.None: // we shouldn't be able to get here @@ -463,6 +479,21 @@ class AboutTorConnect { // it isn't in use (eg using tor-launcher or system tor) }
+ showOffline(error) { + this.setTitle(TorStrings.torConnect.noInternet, "error"); + this.setLongText("Some long text from 🍩️"); + this.setProgress(error, false); + this.setBreadcrumbsStatus( + BreadcrumbStatus.Default, + BreadcrumbStatus.Active, + BreadcrumbStatus.Hidden + ); + this.hideButtons(); + this.show(this.elements.configureButton); + this.show(this.elements.connectButton, true); + this.elements.connectButton.textContent = TorStrings.torConnect.tryAgain; + } + showConnectionAssistant(error) { const hasError = !!error; this.setTitle( @@ -662,6 +693,7 @@ class AboutTorConnect { TorStrings = Object.freeze(args.TorStrings); TorConnectState = Object.freeze(args.TorConnectState); TorCensorshipLevel = Object.freeze(args.TorCensorshipLevel); + InternetStatus = Object.freeze(args.InternetStatus); this.locations = args.CountryNames;
this.initElements(args.Direction); diff --git a/browser/components/torconnect/content/aboutTorConnect.xhtml b/browser/components/torconnect/content/aboutTorConnect.xhtml index 0591ed03a540c..4bb5b31949a67 100644 --- a/browser/components/torconnect/content/aboutTorConnect.xhtml +++ b/browser/components/torconnect/content/aboutTorConnect.xhtml @@ -14,12 +14,12 @@ <span id="connection-assist-icon" class="breadcrumb-icon" /> <span class="breadcrumb-label"/> </span> - <span class="breadcrumb-separator breadcrumb-icon" /> + <span id="location-settings-separator" class="breadcrumb-separator breadcrumb-icon" /> <span id="location-settings" class="breadcrumb-item"> <span id="location-settings-icon" class="breadcrumb-icon" /> <span class="breadcrumb-label"/> </span> - <span class="breadcrumb-separator breadcrumb-icon" /> + <span id="try-bridge-separator" class="breadcrumb-separator breadcrumb-icon" /> <span id="try-bridge" class="breadcrumb-item"> <span id="try-bridge-icon" class="breadcrumb-icon" /> <span class="breadcrumb-label"/>