Commit 08e44ea2 authored by Alex Catarineu's avatar Alex Catarineu Committed by Matthew Finkel
Browse files

Bug 34196: Update site info URL with the onion name

parent fa3ed70d
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -464,13 +464,13 @@ var gIdentityHandler = {
   *        nsIURI for which the identity UI should be displayed, already
   *        processed by nsIURIFixup.createExposableURI.
   */
  updateIdentity(state, uri) {
  updateIdentity(state, uri, onionAliasURI) {
    let shouldHidePopup = this._uri && this._uri.spec != uri.spec;
    this._state = state;

    // Firstly, populate the state properties required to display the UI. See
    // the documentation of the individual properties for details.
    this.setURI(uri);
    this.setURI(uri, onionAliasURI);
    this._secInfo = gBrowser.securityUI.secInfo;

    // Then, update the user interface with the available data.
@@ -549,17 +549,18 @@ var gIdentityHandler = {
   * Attempt to provide proper IDN treatment for host names
   */
  getEffectiveHost() {
    let uri = this._onionAliasURI || this._uri;
    if (!this._IDNService) {
      this._IDNService = Cc["@mozilla.org/network/idn-service;1"].getService(
        Ci.nsIIDNService
      );
    }
    try {
      return this._IDNService.convertToDisplayIDN(this._uri.host, {});
      return this._IDNService.convertToDisplayIDN(uri.host, {});
    } catch (e) {
      // If something goes wrong (e.g. host is an IP address) just fail back
      // to the full domain.
      return this._uri.host;
      return uri.host;
    }
  },

@@ -984,8 +985,9 @@ var gIdentityHandler = {
    ContentBlocking.toggleReportBreakageButton();
  },

  setURI(uri) {
  setURI(uri, onionAliasURI) {
    this._uri = uri;
    this._onionAliasURI = onionAliasURI;

    try {
      // Account for file: urls and catch when "" is the value
+2 −1
Original line number Diff line number Diff line
@@ -6083,6 +6083,7 @@ var XULBrowserWindow = {
    // Don't need to do anything if the data we use to update the UI hasn't
    // changed
    let uri = gBrowser.currentURI;
    let onionAliasURI = gBrowser.selectedBrowser.currentOnionAliasURI;
    let spec = uri.spec;
    if (this._state == aState && this._lastLocation == spec) {
      // Switching to a tab of the same URL doesn't change most security
@@ -6100,7 +6101,7 @@ var XULBrowserWindow = {
    try {
      uri = Services.uriFixup.createExposableURI(uri);
    } catch (e) {}
    gIdentityHandler.updateIdentity(this._state, uri);
    gIdentityHandler.updateIdentity(this._state, uri, onionAliasURI);
  },

  // simulate all change notifications after switching tabs
+1 −1
Original line number Diff line number Diff line
@@ -412,7 +412,7 @@ function loadPageInfo(frameOuterWindowID, imageElement, browser) {
      );
    }
    onLoadPermission(uri, principal);
    securityOnLoad(uri, windowInfo);
    securityOnLoad(uri, windowInfo, browser.currentOnionAliasURI);
  });

  // Get the media elements from content script to setup the media tab.
+6 −0
Original line number Diff line number Diff line
@@ -294,6 +294,12 @@
                     control="security-identity-domain-value"/>
              <textbox id="security-identity-domain-value" readonly="true"/>
            </row>
            <!-- Onion Alias -->
            <row id="security-view-identity-onionalias-row">
              <label id="security-view-identity-onionalias"
                     control="security-view-identity-onionalias-value"/>
              <textbox id="security-view-identity-onionalias-value" readonly="true"/>
            </row>
            <!-- Owner -->
            <row>
              <label id="security-identity-owner-label"
+16 −1
Original line number Diff line number Diff line
@@ -227,7 +227,7 @@ var security = {
  _cert: null,
};

function securityOnLoad(uri, windowInfo) {
function securityOnLoad(uri, windowInfo, onionAliasURI) {
  security.init(uri, windowInfo);

  var info = security._getSecurityInfo();
@@ -240,6 +240,21 @@ function securityOnLoad(uri, windowInfo) {
  }
  document.getElementById("securityTab").hidden = false;

  if (onionAliasURI) {
    setText(
      "security-view-identity-onionalias",
      gTorButtonBundle.GetStringFromName("pageInfo_OnionName")
    );
    setText("security-view-identity-onionalias-value", onionAliasURI.host);
    document.getElementById(
      "security-view-identity-onionalias-row"
    ).hidden = false;
  } else {
    document.getElementById(
      "security-view-identity-onionalias-row"
    ).hidden = true;
  }

  /* Set Identity section text */
  setText("security-identity-domain-value", info.hostName);