[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [Git][tpo/applications/tor-browser][tor-browser-102.10.0esr-12.5-1] 6 commits: Bug 41736 - Customize toolbar for base-browser.



Title: GitLab

Richard Pospesel pushed to branch tor-browser-102.10.0esr-12.5-1 at The Tor Project / Applications / Tor Browser

Commits:

  • 1ce930e3
    by Henry Wilkes at 2023-04-20T20:03:08+00:00
    Bug 41736 - Customize toolbar for base-browser.
    
  • d354800c
    by Henry Wilkes at 2023-04-20T20:03:08+00:00
    fixup! Bug 40926: Implemented the New Identity feature
    
    Bug 41736 - Stop setting the browser.uiCustomization.state preference.
    
  • adacb2c3
    by Henry Wilkes at 2023-04-20T20:03:08+00:00
    fixup! Bug 40925: Implemented the Security Level component
    
    Bug 41736 - Stop setting the browser.uiCustomization.state preference.
    
  • 491718d1
    by Henry Wilkes at 2023-04-20T20:03:08+00:00
    fixup! Firefox preference overrides.
    
    Bug 41736 - Stop setting the browser.uiCustomization.state preference.
    
  • 352acb10
    by Henry Wilkes at 2023-04-20T20:03:08+00:00
    Bug 41736 - Customize toolbar for tor-browser.
    
  • 96796fa5
    by Henry Wilkes at 2023-04-20T20:03:08+00:00
    fixup! Bug 40562: Added Tor Browser preferences to 000-tor-browser.js
    
    Bug 41736 - Stop setting the browser.uiCustomization.state preference.
    

4 changed files:

Changes:

  • browser/app/profile/000-tor-browser.js
    ... ... @@ -30,8 +30,6 @@ pref("network.security.ports.banned", "", locked);
    30 30
     pref("network.dns.disabled", true); // This should cover the #5741 patch for DNS leaks
    
    31 31
     pref("network.http.max-persistent-connections-per-proxy", 256);
    
    32 32
     
    
    33
    -pref("browser.uiCustomization.state", "{\"placements\":{\"widget-overflow-fixed-list\":[],\"PersonalToolbar\":[\"personal-bookmarks\"],\"nav-bar\":[\"back-button\",\"forward-button\",\"stop-reload-button\",\"urlbar-container\",\"torbutton-button\",\"security-level-button\",\"new-identity-button\",\"downloads-button\"],\"TabsToolbar\":[\"tabbrowser-tabs\",\"new-tab-button\",\"alltabs-button\"],\"toolbar-menubar\":[\"menubar-items\"],\"PanelUI-contents\":[\"home-button\",\"edit-controls\",\"zoom-controls\",\"new-window-button\",\"save-page-button\",\"print-button\",\"bookmarks-menu-button\",\"history-panelmenu\",\"find-button\",\"preferences-button\",\"add-ons-button\",\"developer-button\"],\"addon-bar\":[\"addonbar-closebutton\",\"status-bar\"]},\"seen\":[\"developer-button\",\"_73a6fe31-595d-460b-a920-fcc0f8843232_-browser-action\"],\"dirtyAreaCache\":[\"PersonalToolbar\",\"nav-bar\",\"TabsToolbar\",\"toolbar-menubar\"],\"currentVersion\":14,\"newElementCount\":1}");
    
    34
    -
    
    35 33
     // Treat .onions as secure
    
    36 34
     pref("dom.securecontext.allowlist_onions", true);
    
    37 35
     
    

  • browser/app/profile/001-base-profile.js
    ... ... @@ -464,9 +464,6 @@ pref("intl.multilingual.downloadEnabled", false);
    464 464
     // Disk activity: Disable storage.sync (tor-browser#41424)
    
    465 465
     pref("webextensions.storage.sync.enabled", false);
    
    466 466
     
    
    467
    -// Toolbar layout
    
    468
    -pref("browser.uiCustomization.state", "{\"placements\":{\"widget-overflow-fixed-list\":[],\"PersonalToolbar\":[\"personal-bookmarks\"],\"nav-bar\":[\"back-button\",\"forward-button\",\"stop-reload-button\",\"urlbar-container\",\"security-level-button\",\"new-identity-button\",\"downloads-button\"],\"TabsToolbar\":[\"tabbrowser-tabs\",\"new-tab-button\",\"alltabs-button\"],\"toolbar-menubar\":[\"menubar-items\"],\"PanelUI-contents\":[\"home-button\",\"edit-controls\",\"zoom-controls\",\"new-window-button\",\"save-page-button\",\"print-button\",\"bookmarks-menu-button\",\"history-panelmenu\",\"find-button\",\"preferences-button\",\"add-ons-button\",\"developer-button\"],\"addon-bar\":[\"addonbar-closebutton\",\"status-bar\"]},\"seen\":[\"developer-button\"],\"dirtyAreaCache\":[\"PersonalToolbar\",\"nav-bar\",\"TabsToolbar\",\"toolbar-menubar\"],\"currentVersion\":14,\"newElementCount\":1}");
    
    469
    -
    
    470 467
     // Enforce certificate pinning, see: https://bugs.torproject.org/16206
    
    471 468
     pref("security.cert_pinning.enforcement_level", 2);
    
    472 469
     
    

  • browser/components/customizableui/CustomizableUI.jsm
    ... ... @@ -65,6 +65,16 @@ const kSubviewEvents = ["ViewShowing", "ViewHiding"];
    65 65
      */
    
    66 66
     var kVersion = 17;
    
    67 67
     
    
    68
    +/**
    
    69
    + * The current version for base browser.
    
    70
    + */
    
    71
    +var kVersionBaseBrowser = 1;
    
    72
    +
    
    73
    +/**
    
    74
    + * The current version for tor browser.
    
    75
    + */
    
    76
    +var kVersionTorBrowser = 1;
    
    77
    +
    
    68 78
     /**
    
    69 79
      * Buttons removed from built-ins by version they were removed. kVersion must be
    
    70 80
      * bumped any time a new id is added to this. Use the button id as key, and
    
    ... ... @@ -218,6 +228,8 @@ var CustomizableUIInternal = {
    218 228
         this._updateForNewVersion();
    
    219 229
         this._updateForNewProtonVersion();
    
    220 230
         this._markObsoleteBuiltinButtonsSeen();
    
    231
    +    this._updateForBaseBrowser();
    
    232
    +    this._updateForTorBrowser();
    
    221 233
     
    
    222 234
         this.registerArea(
    
    223 235
           CustomizableUI.AREA_FIXED_OVERFLOW_PANEL,
    
    ... ... @@ -236,10 +248,17 @@ var CustomizableUIInternal = {
    236 248
           Services.policies.isAllowed("removeHomeButtonByDefault")
    
    237 249
             ? null
    
    238 250
             : "home-button",
    
    239
    -      "spring",
    
    251
    +      // Don't want springs either side of the urlbar. tor-browser#41736
    
    240 252
           "urlbar-container",
    
    241
    -      "spring",
    
    242
    -      "save-to-pocket-button",
    
    253
    +      // save-to-pocket-button is entirely disabled. See tor-browser#18886 and
    
    254
    +      // tor-browser#31602.
    
    255
    +      // Base-browser additions tor-browser#41736. If you want to add to, remove
    
    256
    +      // from, or rearrange this list, then bump the kVersionBaseBrowser and
    
    257
    +      // update existing saved states in _updateForBaseBrowser.
    
    258
    +      // Or if the change is only meant for tor-browser, bump kVersionTorBrowser
    
    259
    +      // instead and update the existing saved states in _updateForTorBrowser.
    
    260
    +      "security-level-button",
    
    261
    +      "new-identity-button",
    
    243 262
           "downloads-button",
    
    244 263
           AppConstants.MOZ_DEV_EDITION ? "developer-button" : null,
    
    245 264
           "fxa-toolbar-menu-button",
    
    ... ... @@ -255,6 +274,10 @@ var CustomizableUIInternal = {
    255 274
           },
    
    256 275
           true
    
    257 276
         );
    
    277
    +    // navbarPlacements does not match the initial default XHTML layout.
    
    278
    +    // Therefore we always need to rebuild the navbar area when
    
    279
    +    // registerToolbarNode is called. tor-browser#41736
    
    280
    +    gDirtyAreaCache.add(CustomizableUI.AREA_NAVBAR);
    
    258 281
     
    
    259 282
         if (AppConstants.MENUBAR_CAN_AUTOHIDE) {
    
    260 283
           this.registerArea(
    
    ... ... @@ -687,6 +710,123 @@ var CustomizableUIInternal = {
    687 710
         }
    
    688 711
       },
    
    689 712
     
    
    713
    +  _updateForBaseBrowser() {
    
    714
    +    if (!gSavedState) {
    
    715
    +      // Use the defaults.
    
    716
    +      return;
    
    717
    +    }
    
    718
    +
    
    719
    +    const currentVersion = gSavedState.currentVersionBaseBrowser;
    
    720
    +
    
    721
    +    if (currentVersion < 1) {
    
    722
    +      // NOTE: In base-browser/tor-browser version 12.5a5, and earlier, the
    
    723
    +      // toolbar was configured by setting the full JSON string for the default
    
    724
    +      // "browser.uiCustomization.state" preference value. The disadvantage is
    
    725
    +      // that we could not update this value in a way that existing users (who
    
    726
    +      // would have non-default preference values) would also get the desired
    
    727
    +      // change (e.g. for adding or removing a button).
    
    728
    +      //
    
    729
    +      // With tor-browser#41736 we want to switch to changing the toolbar
    
    730
    +      // dynamically like firefox. Therefore, this first version transfer simply
    
    731
    +      // gets the toolbar into the same state we wanted before, away from the
    
    732
    +      // default firefox state.
    
    733
    +      //
    
    734
    +      // If an existing user state aligned with the previous default
    
    735
    +      // "browser.uiCustomization.state" then this shouldn't visibly change
    
    736
    +      // anything.
    
    737
    +      // If a user explicitly customized the toolbar to go back to the firefox
    
    738
    +      // default, then this may undo those changes.
    
    739
    +      const navbarPlacements =
    
    740
    +        gSavedState.placements[CustomizableUI.AREA_NAVBAR];
    
    741
    +      if (navbarPlacements) {
    
    742
    +        const getBeforeAfterUrlbar = () => {
    
    743
    +          // NOTE: The urlbar is non-removable from the navbar, so should have
    
    744
    +          // an index.
    
    745
    +          const index = navbarPlacements.indexOf("urlbar-container");
    
    746
    +          let after = index + 1;
    
    747
    +          if (
    
    748
    +            after < navbarPlacements.length &&
    
    749
    +            navbarPlacements[after] === "search-container"
    
    750
    +          ) {
    
    751
    +            // Skip past the search-container.
    
    752
    +            after++;
    
    753
    +          }
    
    754
    +          return { before: index - 1, after };
    
    755
    +        };
    
    756
    +
    
    757
    +        // Remove the urlbar springs either side of the urlbar.
    
    758
    +        const { before, after } = getBeforeAfterUrlbar();
    
    759
    +        if (
    
    760
    +          after < navbarPlacements.length &&
    
    761
    +          this.matchingSpecials(navbarPlacements[after], "spring")
    
    762
    +        ) {
    
    763
    +          // Remove the spring after.
    
    764
    +          navbarPlacements.splice(after, 1);
    
    765
    +          // NOTE: The `before` index does not change.
    
    766
    +        }
    
    767
    +        if (
    
    768
    +          before >= 0 &&
    
    769
    +          this.matchingSpecials(navbarPlacements[before], "spring")
    
    770
    +        ) {
    
    771
    +          // Remove the spring before.
    
    772
    +          navbarPlacements.splice(before, 1);
    
    773
    +        }
    
    774
    +
    
    775
    +        // Make sure the security-level-button and new-identity-button appears
    
    776
    +        // in the toolbar.
    
    777
    +        for (const id of ["new-identity-button", "security-level-button"]) {
    
    778
    +          let alreadyAdded = false;
    
    779
    +          for (const placements of Object.values(gSavedState.placements)) {
    
    780
    +            if (placements.includes(id)) {
    
    781
    +              alreadyAdded = true;
    
    782
    +              break;
    
    783
    +            }
    
    784
    +          }
    
    785
    +          if (alreadyAdded) {
    
    786
    +            continue;
    
    787
    +          }
    
    788
    +
    
    789
    +          // Add to the nav-bar, after the urlbar-container.
    
    790
    +          // NOTE: We have already removed the spring after the urlbar.
    
    791
    +          navbarPlacements.splice(getBeforeAfterUrlbar().after, 0, id);
    
    792
    +        }
    
    793
    +      }
    
    794
    +
    
    795
    +      // Remove save-to-pocket-button. See tor-browser#18886 and
    
    796
    +      // tor-browser#31602.
    
    797
    +      for (const placements of Object.values(gSavedState.placements)) {
    
    798
    +        let buttonIndex = placements.indexOf("save-to-pocket-button");
    
    799
    +        if (buttonIndex != -1) {
    
    800
    +          placements.splice(buttonIndex, 1);
    
    801
    +        }
    
    802
    +      }
    
    803
    +
    
    804
    +      // Remove unused fields that used to be part of
    
    805
    +      // "browser.uiCustomization.state".
    
    806
    +      delete gSavedState.placements["PanelUI-contents"];
    
    807
    +      delete gSavedState.placements["addon-bar"];
    
    808
    +    }
    
    809
    +  },
    
    810
    +
    
    811
    +  _updateForTorBrowser() {
    
    812
    +    if (!gSavedState) {
    
    813
    +      // Use the defaults.
    
    814
    +      return;
    
    815
    +    }
    
    816
    +
    
    817
    +    const currentVersion = gSavedState.currentVersionTorBrowser;
    
    818
    +
    
    819
    +    if (currentVersion < 1) {
    
    820
    +      // Remove torbutton-button, which no longer exists.
    
    821
    +      for (const placements of Object.values(gSavedState.placements)) {
    
    822
    +        let buttonIndex = placements.indexOf("torbutton-button");
    
    823
    +        if (buttonIndex != -1) {
    
    824
    +          placements.splice(buttonIndex, 1);
    
    825
    +        }
    
    826
    +      }
    
    827
    +    }
    
    828
    +  },
    
    829
    +
    
    690 830
       _placeNewDefaultWidgetsInArea(aArea) {
    
    691 831
         let futurePlacedWidgets = gFuturePlacements.get(aArea);
    
    692 832
         let savedPlacements =
    
    ... ... @@ -2501,6 +2641,14 @@ var CustomizableUIInternal = {
    2501 2641
           gSavedState.currentVersion = 0;
    
    2502 2642
         }
    
    2503 2643
     
    
    2644
    +    if (!("currentVersionBaseBrowser" in gSavedState)) {
    
    2645
    +      gSavedState.currentVersionBaseBrowser = 0;
    
    2646
    +    }
    
    2647
    +
    
    2648
    +    if (!("currentVersionTorBrowser" in gSavedState)) {
    
    2649
    +      gSavedState.currentVersionTorBrowser = 0;
    
    2650
    +    }
    
    2651
    +
    
    2504 2652
         gSeenWidgets = new Set(gSavedState.seen || []);
    
    2505 2653
         gDirtyAreaCache = new Set(gSavedState.dirtyAreaCache || []);
    
    2506 2654
         gNewElementCount = gSavedState.newElementCount || 0;
    
    ... ... @@ -2579,6 +2727,8 @@ var CustomizableUIInternal = {
    2579 2727
           seen: gSeenWidgets,
    
    2580 2728
           dirtyAreaCache: gDirtyAreaCache,
    
    2581 2729
           currentVersion: kVersion,
    
    2730
    +      currentVersionBaseBrowser: kVersionBaseBrowser,
    
    2731
    +      currentVersionTorBrowser: kVersionTorBrowser,
    
    2582 2732
           newElementCount: gNewElementCount,
    
    2583 2733
         };
    
    2584 2734
     
    

  • browser/components/extensions/parent/ext-browserAction.js
    ... ... @@ -193,6 +193,10 @@ this.browserAction = class extends ExtensionAPIPersistent {
    193 193
       }
    
    194 194
     
    
    195 195
       build() {
    
    196
    +    // The extension ID for NoScript (WebExtension)
    
    197
    +    const isNoScript =
    
    198
    +      this.extension.id === "{73a6fe31-595d-460b-a920-fcc0f8843232}";
    
    199
    +
    
    196 200
         let widget = CustomizableUI.createWidget({
    
    197 201
           id: this.id,
    
    198 202
           viewId: this.viewId,
    
    ... ... @@ -200,7 +204,11 @@ this.browserAction = class extends ExtensionAPIPersistent {
    200 204
           removable: true,
    
    201 205
           label: this.action.getProperty(null, "title"),
    
    202 206
           tooltiptext: this.action.getProperty(null, "title"),
    
    203
    -      defaultArea: browserAreas[this.action.getDefaultArea()],
    
    207
    +      // Do not want to add the NoScript extension to the toolbar by default.
    
    208
    +      // tor-browser#41736
    
    209
    +      defaultArea: isNoScript
    
    210
    +        ? null
    
    211
    +        : browserAreas[this.action.getDefaultArea()],
    
    204 212
           showInPrivateBrowsing: this.extension.privateBrowsingAllowed,
    
    205 213
     
    
    206 214
           // Don't attempt to load properties from the built-in widget string
    

  • _______________________________________________
    tor-commits mailing list
    tor-commits@xxxxxxxxxxxxxxxxxxxx
    https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits