Commit a601fc73 authored by Alex Catarineu's avatar Alex Catarineu Committed by Pier Angelo Vendrame
Browse files

TB 21952: Implement Onion-Location

Whenever a valid Onion-Location HTTP header (or corresponding HTML
<meta> http-equiv attribute) is found in a document load, we either
redirect to it (if the user opted-in via preference) or notify the
presence of an onionsite alternative with a badge in the urlbar.
parent 1c607ce3
Loading
Loading
Loading
Loading
+3 −0
Changes for browser/base/content/browser-init.js: 3 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -250,6 +250,9 @@ var gBrowserInit = {
    // Init the OnionAuthPrompt
    OnionAuthPrompt.init();

    // Init the Onion Location pill
    OnionLocationParent.init(document);

    gTorCircuitPanel.init();

    // Certain kinds of automigration rely on this notification to complete
+12 −0
Changes for browser/base/content/browser.js: 12 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@ ChromeUtils.defineESModuleGetters(this, {
  NewTabUtils: "resource://gre/modules/NewTabUtils.sys.mjs",
  NimbusFeatures: "resource://nimbus/ExperimentAPI.sys.mjs",
  nsContextMenu: "chrome://browser/content/nsContextMenu.sys.mjs",
  OnionLocationParent: "resource:///modules/OnionLocationParent.sys.mjs",
  OpenInTabsUtils:
    "moz-src:///browser/components/tabbrowser/OpenInTabsUtils.sys.mjs",
  OpenSearchManager:
@@ -2330,6 +2331,7 @@ var XULBrowserWindow = {
    CFRPageActions.updatePageActions(gBrowser.selectedBrowser);

    AboutReaderParent.updateReaderButton(gBrowser.selectedBrowser);
    OnionLocationParent.updateOnionLocationBadge(gBrowser.selectedBrowser);
    TranslationsParent.onLocationChange(gBrowser.selectedBrowser);

    PictureInPicture.updateUrlbarToggle(gBrowser.selectedBrowser);
@@ -2907,6 +2909,16 @@ var CombinedStopReload = {

var TabsProgressListener = {
  onStateChange(aBrowser, aWebProgress, aRequest, aStateFlags, aStatus) {
    // Clear OnionLocation UI
    if (
      aStateFlags & Ci.nsIWebProgressListener.STATE_START &&
      aStateFlags & Ci.nsIWebProgressListener.STATE_IS_NETWORK &&
      aRequest &&
      aWebProgress.isTopLevel
    ) {
      OnionLocationParent.onStateChange(aBrowser);
    }

    // Collect telemetry data about tab load times.
    if (
      aWebProgress.isTopLevel &&
+2 −1
Changes for browser/base/content/browser.js.globals: 2 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -250,5 +250,6 @@
  "TorConnectParent",
  "gTorConnectUrlbarButton",
  "gTorConnectTitlebarStatus",
  "OnionAuthPrompt"
  "OnionAuthPrompt",
  "OnionLocationParent"
]
+2 −0
Changes for browser/base/content/navigator-toolbox.inc.xhtml: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -463,6 +463,8 @@
                  hidden="true">
              <label id="tor-connect-urlbar-button-label"/>
            </hbox>

#include ../../components/onionservices/content/onionlocation-urlbar.inc.xhtml
          </hbox>
          <vbox class="urlbarView"
                context=""
+9 −0
Changes for browser/base/content/popup-notifications.inc.xhtml: 9 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -13,6 +13,15 @@
           role="alert"
           remote="true"/>

    <!-- Shown when visiting first web page with an onion-available header.
       - This allows us to add some extra content to the popup.
       - See tor-browser#21952 and tor-browser#41341 -->
    <popupnotification id="onion-location-notification" hidden="true">
      <popupnotificationcontent orient="vertical">
        <description id="onion-location-body-text"/>
      </popupnotificationcontent>
    </popupnotification>

    <popupnotification id="webRTC-shareDevices-notification" hidden="true"
                       descriptionid="webRTC-shareDevices-notification-description">
      <popupnotificationcontent id="webRTC-selectCamera" orient="vertical">
Loading