Pier Angelo Vendrame pushed to branch mullvad-browser-147.0a1-16.0-1 at The Tor Project / Applications / Mullvad Browser

Commits:

12 changed files:

Changes:

  • browser/components/shell/ShellService.sys.mjs
    ... ... @@ -286,7 +286,7 @@ let ShellServiceInternal = {
    286 286
           ) {
    
    287 287
             if (this._shouldSetDefaultPDFHandler()) {
    
    288 288
               lazy.log.info("Setting Firefox as default PDF handler");
    
    289
    -          extraFileExtensions.push(".pdf", "FirefoxPDF");
    
    289
    +          extraFileExtensions.push(".pdf", "MullvadBrowserPDF");
    
    290 290
             } else {
    
    291 291
               lazy.log.info("Not setting Firefox as default PDF handler");
    
    292 292
             }
    
    ... ... @@ -324,7 +324,7 @@ let ShellServiceInternal = {
    324 324
           try {
    
    325 325
             this.defaultAgent.setDefaultExtensionHandlersUserChoice(aumi, [
    
    326 326
               ".pdf",
    
    327
    -          "FirefoxPDF",
    
    327
    +          "MullvadBrowserPDF",
    
    328 328
             ]);
    
    329 329
           } catch (err) {
    
    330 330
             telemetryResult = "ErrOther";
    

  • browser/components/shell/WindowsDefaultBrowser.cpp
    ... ... @@ -24,7 +24,7 @@
    24 24
     #include <wchar.h>
    
    25 25
     #include <windows.h>
    
    26 26
     
    
    27
    -#define APP_REG_NAME_BASE L"Firefox-"
    
    27
    +#define APP_REG_NAME_BASE L"MullvadBrowser-"
    
    28 28
     
    
    29 29
     static bool IsWindowsLogonConnected() {
    
    30 30
       WCHAR userName[UNLEN + 1];
    

  • browser/components/shell/nsWindowsShellService.cpp
    ... ... @@ -361,10 +361,12 @@ nsWindowsShellService::CheckAllProgIDsExist(bool* aResult) {
    361 361
     
    
    362 362
         *aResult = result;
    
    363 363
       } else {
    
    364
    -    *aResult =
    
    365
    -        CheckProgIDExists(FormatProgID(L"FirefoxURL", aumid.get()).get()) &&
    
    366
    -        CheckProgIDExists(FormatProgID(L"FirefoxHTML", aumid.get()).get()) &&
    
    367
    -        CheckProgIDExists(FormatProgID(L"FirefoxPDF", aumid.get()).get());
    
    364
    +    *aResult = CheckProgIDExists(
    
    365
    +                   FormatProgID(L"MullvadBrowserURL", aumid.get()).get()) &&
    
    366
    +               CheckProgIDExists(
    
    367
    +                   FormatProgID(L"MullvadBrowserHTML", aumid.get()).get()) &&
    
    368
    +               CheckProgIDExists(
    
    369
    +                   FormatProgID(L"MullvadBrowserPDF", aumid.get()).get());
    
    368 370
       }
    
    369 371
     
    
    370 372
       return NS_OK;
    

  • other-licenses/nsis/Contrib/ApplicationID/Makefile
    1
    +CXXFLAGS=-Icityhash -DWIN32 -DNDEBUG -D_WINDOWS -D_USRDLL -DCITYHASH_EXPORTS -DUNICODE
    
    2
    +SRCS=Set.cpp
    
    3
    +OBJS=$(subst .cpp,.o,$(SRCS))
    
    4
    +LDFLAGS=-lole32 -lshlwapi -shared -Wl,--no-insert-timestamp
    
    5
    +PLUGIN=ApplicationID.dll
    
    6
    +
    
    7
    +all: $(PLUGIN)
    
    8
    +
    
    9
    +$(PLUGIN): $(OBJS)
    
    10
    +	$(CXX) $(OBJS) $(LDFLAGS) -o $@
    
    11
    +	llvm-strip $@
    
    12
    +
    
    13
    +clean:
    
    14
    +	$(RM) $(OBJS) $(PLUGIN)

  • other-licenses/nsis/Contrib/ApplicationID/Set.cpp
    ... ... @@ -35,7 +35,8 @@ unsigned int g_stringsize;
    35 35
     TCHAR *g_variables;
    
    36 36
     
    
    37 37
     // Indicates that an application supports dual desktop and immersive modes. In Windows 8, this property is only applicable for web browsers.
    
    38
    -DEFINE_PROPERTYKEY(PKEY_AppUserModel_IsDualMode, 0x9F4C2855, 0x9F79, 0x4B39, 0xA8, 0xD0, 0xE1, 0xD4, 0x2D, 0xE1, 0xD5, 0xF3, 11);
    
    38
    +// mingw already defines this in propkey.h.
    
    39
    +// DEFINE_PROPERTYKEY(PKEY_AppUserModel_IsDualMode, 0x9F4C2855, 0x9F79, 0x4B39, 0xA8, 0xD0, 0xE1, 0xD4, 0x2D, 0xE1, 0xD5, 0xF3, 11);
    
    39 40
     
    
    40 41
     int popstring(TCHAR *str, int len);
    
    41 42
     void pushstring(const TCHAR *str, int len);
    

  • other-licenses/nsis/Contrib/CityHash/Makefile
    1
    +CXXFLAGS=-Icityhash -DWIN32 -DNDEBUG -D_WINDOWS -D_USRDLL -DCITYHASH_EXPORTS -DUNICODE
    
    2
    +SRCS=CityHash.cpp cityhash/city.cpp
    
    3
    +OBJS=$(subst .cpp,.o,$(SRCS))
    
    4
    +LDFLAGS=-shared -Wl,--no-insert-timestamp
    
    5
    +PLUGIN=CityHash.dll
    
    6
    +
    
    7
    +all: $(PLUGIN)
    
    8
    +
    
    9
    +$(PLUGIN): $(OBJS)
    
    10
    +	$(CXX) $(OBJS) $(LDFLAGS) -o $@
    
    11
    +	llvm-strip $@
    
    12
    +
    
    13
    +clean:
    
    14
    +	$(RM) $(OBJS) $(PLUGIN)

  • toolkit/components/resistfingerprinting/RFPHelper.sys.mjs
    ... ... @@ -920,20 +920,49 @@ class _RFPHelper {
    920 920
        * @param {CSSStyleDeclaration} style - The computed style for the element we
    
    921 921
        *   want to grab the color from.
    
    922 922
        * @param {string} property - The name of the property we want.
    
    923
    +   * @param {object} [options] - Optional details.
    
    924
    +   * @param {string} [options.fallbackProperty] - A fallback to use instead if
    
    925
    +   *   the property doesn't have a computed value.
    
    926
    +   * @param {string} [options.currentColorProperty] - The name of a property to
    
    927
    +   *   use as the currentColor.
    
    923 928
        *
    
    924 929
        * @returns {InspectorRGBATuple} - The RGBA color. The "r", "g", "b" fields
    
    925 930
        *   are relative to the 0-255 color range. The "a" field is in the 0-1 range.
    
    926 931
        */
    
    927
    -  _convertToRGBA(win, style, property) {
    
    932
    +  _convertToRGBA(win, style, property, options) {
    
    928 933
         let cssColor = style.getPropertyValue(property);
    
    929 934
         if (!cssColor) {
    
    935
    +      if (options?.fallbackProperty) {
    
    936
    +        lazy.logConsole.debug(
    
    937
    +          "Using fallback property for RGBA.",
    
    938
    +          property,
    
    939
    +          options.fallbackProperty
    
    940
    +        );
    
    941
    +        return this._convertToRGBA(win, style, options.fallbackProperty);
    
    942
    +      }
    
    930 943
           lazy.logConsole.error(`Missing color "${property}"`);
    
    931 944
           return { r: 0, g: 0, b: 0, a: 0 };
    
    932 945
         }
    
    933 946
         const currentColorRegex =
    
    934 947
           /(^|[^a-zA-Z0-9_-])currentColor($|[^a-zA-Z0-9_-])/g;
    
    935 948
         if (currentColorRegex.test(cssColor)) {
    
    936
    -      const currentColor = style.color;
    
    949
    +      let currentColor;
    
    950
    +      if (options?.currentColorProperty) {
    
    951
    +        const currRGBA = this._convertToRGBA(
    
    952
    +          win,
    
    953
    +          style,
    
    954
    +          options.currentColorProperty
    
    955
    +        );
    
    956
    +        currentColor = `rgba(${currRGBA.r}, ${currRGBA.g}, ${currRGBA.b}, ${currRGBA.a})`;
    
    957
    +      } else {
    
    958
    +        lazy.logConsole.warning(
    
    959
    +          "Missing a specification for the currentColor, using computed color."
    
    960
    +        );
    
    961
    +        // Use the current "color" value. NOTE: this may not be exactly what we
    
    962
    +        // want since it's current value may be effected by :hover, :active,
    
    963
    +        // :focus, etc. But we want this to be a stable colour for the theme.
    
    964
    +        currentColor = style.color;
    
    965
    +      }
    
    937 966
           cssColor = cssColor.replace(currentColorRegex, (_, pre, post) => {
    
    938 967
             return pre + currentColor + post;
    
    939 968
           });
    
    ... ... @@ -944,7 +973,7 @@ class _RFPHelper {
    944 973
             cssColor
    
    945 974
           );
    
    946 975
         }
    
    947
    -    /* Can drop the document argument after bugzilla bug 1973684 (142). */
    
    976
    +    // Can drop the document argument after bugzilla bug 1973684 (142).
    
    948 977
         const colorRGBA = win.InspectorUtils.colorToRGBA(cssColor, win.document);
    
    949 978
         if (!colorRGBA) {
    
    950 979
           lazy.logConsole.error(
    
    ... ... @@ -985,12 +1014,13 @@ class _RFPHelper {
    985 1014
        * @param {Window} win - The window to calculate the color for.
    
    986 1015
        * @param {CSSStyleDeclaration} style - The computed style for the #nav-bar
    
    987 1016
        *   element.
    
    1017
    +   * @param {boolean} verticalTabs - Whether vertical tabs are enabled.
    
    988 1018
        *
    
    989 1019
        * @returns {InspectorRGBATuple} - The calculated color, which will be opaque.
    
    990 1020
        */
    
    991
    -  _calculateUrlbarContainerColor(win, style) {
    
    1021
    +  _calculateUrlbarContainerColor(win, style, verticalTabs) {
    
    992 1022
         let colorRGBA;
    
    993
    -    if (!Services.prefs.getBoolPref(kPrefVerticalTabs)) {
    
    1023
    +    if (!verticalTabs) {
    
    994 1024
           lazy.logConsole.debug("Toolbar background used.");
    
    995 1025
           colorRGBA = this._convertToRGBA(win, style, "--toolbar-bgcolor");
    
    996 1026
           if (colorRGBA.a === 1) {
    
    ... ... @@ -1069,12 +1099,19 @@ class _RFPHelper {
    1069 1099
         if (letterboxingEnabled) {
    
    1070 1100
           // Want the effective colour of various elements without any alpha values
    
    1071 1101
           // so they can be used consistently.
    
    1102
    +
    
    1103
    +      const verticalTabs = Services.prefs.getBoolPref(kPrefVerticalTabs);
    
    1104
    +      const chromeTextColorProperty = verticalTabs
    
    1105
    +        ? "--toolbox-textcolor"
    
    1106
    +        : "--toolbar-color";
    
    1107
    +
    
    1072 1108
           const navbarStyle = win.getComputedStyle(
    
    1073 1109
             win.document.getElementById("nav-bar")
    
    1074 1110
           );
    
    1075 1111
           const containerRGBA = this._calculateUrlbarContainerColor(
    
    1076 1112
             win,
    
    1077
    -        navbarStyle
    
    1113
    +        navbarStyle,
    
    1114
    +        verticalTabs
    
    1078 1115
           );
    
    1079 1116
           urlbarBackgroundRGBA = this._composeRGBA(
    
    1080 1117
             this._convertToRGBA(
    
    ... ... @@ -1084,17 +1121,28 @@ class _RFPHelper {
    1084 1121
             ),
    
    1085 1122
             containerRGBA
    
    1086 1123
           );
    
    1124
    +      // NOTE: In the default theme (no "lwtheme" attribute) with
    
    1125
    +      // browser.theme.native-theme set to false, --toolbar-field-color can be
    
    1126
    +      // set to "inherit", which means it will have a blank computed value. We
    
    1127
    +      // fallback to --toolbar-color or --toolbox-textcolor in this case.
    
    1128
    +      // Similarly, for windows OS, it can be set to "currentColor".
    
    1087 1129
           urlbarTextRGBA = this._composeRGBA(
    
    1088
    -        this._convertToRGBA(win, navbarStyle, "--toolbar-field-color"),
    
    1130
    +        this._convertToRGBA(win, navbarStyle, "--toolbar-field-color", {
    
    1131
    +          fallbackProperty: chromeTextColorProperty,
    
    1132
    +          currentColorProperty: chromeTextColorProperty,
    
    1133
    +        }),
    
    1089 1134
             urlbarBackgroundRGBA
    
    1090 1135
           );
    
    1091
    -      /* Separator between the urlbar container #nav-bar and the tabbox. */
    
    1136
    +      // Separator between the urlbar container #nav-bar and the tabbox.
    
    1137
    +      // For the default theme, this can be set to --border-color-card, which
    
    1138
    +      // can use "currentColor".
    
    1092 1139
           const tabboxStyle = win.getComputedStyle(win.gBrowser.tabbox);
    
    1093 1140
           contentSeparatorRGBA = this._composeRGBA(
    
    1094 1141
             this._convertToRGBA(
    
    1095 1142
               win,
    
    1096 1143
               tabboxStyle,
    
    1097
    -          "--chrome-content-separator-color"
    
    1144
    +          "--chrome-content-separator-color",
    
    1145
    +          { currentColorProperty: chromeTextColorProperty }
    
    1098 1146
             ),
    
    1099 1147
             containerRGBA
    
    1100 1148
           );
    
    ... ... @@ -1114,8 +1162,8 @@ class _RFPHelper {
    1114 1162
             contrastRatio
    
    1115 1163
           );
    
    1116 1164
           urlbarBackgroundDark = bgColor.relativeLuminance < 0.5;
    
    1117
    -      /* Very low contrast ratio. For reference the default light theme has
    
    1118
    -       * a contrast ratio of ~1.1. */
    
    1165
    +      // Very low contrast ratio. For reference the default light theme has
    
    1166
    +      // a contrast ratio of ~1.1.
    
    1119 1167
           lowBackgroundOutlineContrast = contrastRatio < 1.05;
    
    1120 1168
         }
    
    1121 1169
         for (const { name, colorRGBA } of [
    

  • toolkit/mozapps/defaultagent/EventLog.h
    ... ... @@ -7,7 +7,7 @@
    7 7
     #ifndef __DEFAULT_BROWSER_AGENT_EVENT_LOG_H__
    
    8 8
     #define __DEFAULT_BROWSER_AGENT_EVENT_LOG_H__
    
    9 9
     
    
    10
    -#include "mozilla/Types.h"
    
    10
    +#include <cwchar>
    
    11 11
     
    
    12 12
     MOZ_BEGIN_EXTERN_C
    
    13 13
     
    
    ... ... @@ -15,10 +15,21 @@ extern MOZ_EXPORT const wchar_t* gWinEventLogSourceName;
    15 15
     
    
    16 16
     MOZ_END_EXTERN_C
    
    17 17
     
    
    18
    -#include "mozilla/WindowsEventLog.h"
    
    19
    -
    
    20
    -#define LOG_ERROR(hr) MOZ_WIN_EVENT_LOG_ERROR(gWinEventLogSourceName, hr)
    
    21
    -#define LOG_ERROR_MESSAGE(format, ...) \
    
    22
    -  MOZ_WIN_EVENT_LOG_ERROR_MESSAGE(gWinEventLogSourceName, format, __VA_ARGS__)
    
    18
    +#ifdef LOG_ERRORS_FILE
    
    19
    +extern FILE* gLogFile;
    
    20
    +#  define LOG_ERROR(hr)                                                 \
    
    21
    +    if (gLogFile) {                                                     \
    
    22
    +      fprintf(gLogFile, "Error in %s:%d: 0x%X\r\n", __FILE__, __LINE__, \
    
    23
    +              (unsigned int)hr);                                        \
    
    24
    +    }
    
    25
    +#  define LOG_ERROR_MESSAGE(format, ...)                     \
    
    26
    +    if (gLogFile) {                                          \
    
    27
    +      fwprintf(gLogFile, format __VA_OPT__(, ) __VA_ARGS__); \
    
    28
    +      fputs("\r\n", gLogFile);                               \
    
    29
    +    }
    
    30
    +#else
    
    31
    +#  define LOG_ERROR(hr)
    
    32
    +#  define LOG_ERROR_MESSAGE(format, ...)
    
    33
    +#endif
    
    23 34
     
    
    24 35
     #endif  // __DEFAULT_BROWSER_AGENT_EVENT_LOG_H__

  • toolkit/mozapps/defaultagent/SetDefaultBrowser.cpp
    ... ... @@ -444,9 +444,10 @@ nsresult SetDefaultBrowserUserChoice(
    444 444
         return NS_ERROR_FAILURE;
    
    445 445
       }
    
    446 446
     
    
    447
    -  nsTArray<nsString> browserDefaults = {
    
    448
    -      u"https"_ns, u"FirefoxURL"_ns,  u"http"_ns, u"FirefoxURL"_ns,
    
    449
    -      u".html"_ns, u"FirefoxHTML"_ns, u".htm"_ns, u"FirefoxHTML"_ns};
    
    447
    +  nsTArray<nsString> browserDefaults = {u"https"_ns, u"MullvadBrowserURL"_ns,
    
    448
    +                                        u"http"_ns,  u"MullvadBrowserURL"_ns,
    
    449
    +                                        u".html"_ns, u"MullvadBrowserHTML"_ns,
    
    450
    +                                        u".htm"_ns,  u"MullvadBrowserHTML"_ns};
    
    450 451
     
    
    451 452
       browserDefaults.AppendElements(aExtraFileExtensions);
    
    452 453
     
    

  • tools/base_browser/l10n/combine-translation-versions.py
    ... ... @@ -103,10 +103,11 @@ class BrowserBranch:
    103 103
     
    
    104 104
             self.name = branch_name
    
    105 105
             self.prefix = version_match.group("prefix")
    
    106
    -        self.browser_version = version_match.group("browser")
    
    106
    +        browser_version_str = version_match.group("browser")
    
    107
    +        self.browser_version = float(browser_version_str)
    
    107 108
             # Convert tor-browser to "Tor Browser", and similar.
    
    108 109
             browser_name = self.prefix.replace("-", " ").title()
    
    109
    -        self.browser_version_name = f"{browser_name} {self.browser_version}"
    
    110
    +        self.browser_version_name = f"{browser_name} {browser_version_str}"
    
    110 111
     
    
    111 112
             self._is_head = is_head
    
    112 113
             self._ref = "HEAD" if is_head else f"origin/{branch_name}"
    
    ... ... @@ -114,7 +115,7 @@ class BrowserBranch:
    114 115
             firefox_nums = [int(n) for n in version_match.group("firefox").split(".")]
    
    115 116
             if len(firefox_nums) == 2:
    
    116 117
                 firefox_nums.append(0)
    
    117
    -        browser_nums = [int(n) for n in self.browser_version.split(".")]
    
    118
    +        browser_nums = [int(n) for n in browser_version_str.split(".")]
    
    118 119
             branch_number = int(version_match.group("number"))
    
    119 120
             # Prioritise the firefox ESR version, then the browser version then the
    
    120 121
             # branch number.
    
    ... ... @@ -127,25 +128,8 @@ class BrowserBranch:
    127 128
                 branch_number,
    
    128 129
             )
    
    129 130
     
    
    130
    -        # Minor version for browser is only ever "0" or "5", so we can convert
    
    131
    -        # the version to an integer.
    
    132
    -        self._browser_int_version = int(2 * float(self.browser_version))
    
    133
    -
    
    134 131
             self._file_paths: list[str] | None = None
    
    135 132
     
    
    136
    -    def release_below(self, other: "BrowserBranch", num: int) -> bool:
    
    137
    -        """Determine whether another branch is within range of a previous
    
    138
    -        browser release.
    
    139
    -
    
    140
    -        The browser versions are expected to increment by "0.5", and a previous
    
    141
    -        release branch's version is expected to be `num * 0.5` behind the
    
    142
    -        current one.
    
    143
    -
    
    144
    -        :param other: The branch to compare.
    
    145
    -        :param num: The number of "0.5" releases behind to test with.
    
    146
    -        """
    
    147
    -        return other._browser_int_version == self._browser_int_version - num
    
    148
    -
    
    149 133
         def __lt__(self, other: "BrowserBranch") -> bool:
    
    150 134
             return self._ordered < other._ordered
    
    151 135
     
    
    ... ... @@ -259,16 +243,14 @@ def get_stable_branch(
    259 243
                 # Stable can be one release version behind.
    
    260 244
                 # NOTE: In principle, when switching between versions there may be a
    
    261 245
                 # window of time where the development branch has not yet progressed
    
    262
    -            # to the next "0.5" release, so has the same browser version as the
    
    246
    +            # to the next ".0" release, so has the same browser version as the
    
    263 247
                 # stable branch. So we also allow for matching browser versions.
    
    264 248
                 # NOTE:
    
    265 249
                 # 1. The "Will be unused in" message will not make sense, but we do
    
    266 250
                 #    not expect string differences in this scenario.
    
    267 251
                 # 2. We do not expect this scenario to last for long.
    
    268
    -            if not (
    
    269
    -                compare_version.release_below(branch, 1)
    
    270
    -                or compare_version.release_below(branch, 0)
    
    271
    -            ):
    
    252
    +            release_diff = compare_version.browser_version - branch.browser_version
    
    253
    +            if release_diff < 0.0 or release_diff > 1.0:
    
    272 254
                     continue
    
    273 255
                 stable_branches.append(branch)
    
    274 256
             elif is_legacy:
    

  • widget/windows/WinTaskbar.cpp
    ... ... @@ -249,7 +249,7 @@ bool WinTaskbar::GenerateAppUserModelID(nsAString& aAppUserModelId,
    249 249
       nsCString appName;
    
    250 250
       if (appInfo && NS_SUCCEEDED(appInfo->GetName(appName))) {
    
    251 251
         nsAutoString regKey;
    
    252
    -    regKey.AssignLiteral("Software\\Mozilla\\");
    
    252
    +    regKey.AssignLiteral("Software\\" MOZ_APP_VENDOR "\\");
    
    253 253
         AppendASCIItoUTF16(appName, regKey);
    
    254 254
         regKey.AppendLiteral("\\TaskBarIDs");
    
    255 255
     
    

  • widget/windows/moz.build
    ... ... @@ -203,6 +203,7 @@ DEFINES["MOZ_UNICODE"] = True
    203 203
     DEFINES["MOZ_APP_NAME"] = '"%s"' % CONFIG["MOZ_APP_NAME"]
    
    204 204
     # Turn `firefox` into `Firefox`.
    
    205 205
     DEFINES["MOZ_TOAST_APP_NAME"] = '"%s"' % CONFIG["MOZ_APP_NAME"].title()
    
    206
    +DEFINES["MOZ_APP_VENDOR"] = '"%s"' % CONFIG["MOZ_APP_VENDOR"]
    
    206 207
     
    
    207 208
     USE_LIBS += [
    
    208 209
         "jsoncpp",