Ticket #13398: 13398-pospeselr.patch

File 13398-pospeselr.patch, 12.2 KB (added by pospeselr, 2 years ago)
  • browser/app/profile/000-tor-browser.js

    diff --git a/browser/app/profile/000-tor-browser.js b/browser/app/profile/000-tor-browser.js
    index aaeba63..4699157 100644
    a b pref("social.toast-notifications.enabled", false); 
    133133pref("social.whitelist", "");
    134134
    135135// Fingerprinting
     136pref("privacy.hide_user_info", true); // Bug 13398: nsUserInfo interface properties return empty string
    136137pref("webgl.min_capability_mode", true);
    137138pref("webgl.disable-extensions", true);
    138139pref("webgl.disable-fail-if-major-performance-caveat", true);
  • toolkit/components/startup/moz.build

    diff --git a/toolkit/components/startup/moz.build b/toolkit/components/startup/moz.build
    index dbd5803..aea1087 100644
    a b XPCSHELL_TESTS_MANIFESTS += ['tests/unit/xpcshell.ini'] 
    1515
    1616UNIFIED_SOURCES += [
    1717    'nsAppStartup.cpp',
     18    'nsUserInfo.cpp',
    1819    'StartupTimeline.cpp',
    1920]
    2021
  • toolkit/components/startup/nsAppStartup.cpp

    diff --git a/toolkit/components/startup/nsAppStartup.cpp b/toolkit/components/startup/nsAppStartup.cpp
    index 85d5afd..2f79f61 100644
    a b  
    44 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
    55
    66#include "nsAppStartup.h"
     7#include "nsUserInfo.h"
    78
    89#include "nsIAppShellService.h"
    910#include "nsPIDOMWindow.h"
    static NS_DEFINE_CID(kPlacesInitCompleteCID, 
    9394static NS_DEFINE_CID(kSessionStoreWindowRestoredCID,
    9495  NS_SESSION_STORE_WINDOW_RESTORED_EVENT_CID);
    9596static NS_DEFINE_CID(kXPCOMShutdownCID,
    96   NS_XPCOM_SHUTDOWN_EVENT_CID);
     97  NS_XPCOM_SHUTDOWN_EVENT_CID);
    9798#endif //defined(XP_WIN)
    9899
    99100using namespace mozilla;
    nsAppStartup::Init() 
    214215  }
    215216#endif //defined(XP_WIN)
    216217
     218  nsUserInfo::InitializeStatics();
     219
    217220  return NS_OK;
    218221}
    219222
  • new file toolkit/components/startup/nsUserInfo.cpp

    diff --git a/toolkit/components/startup/nsUserInfo.cpp b/toolkit/components/startup/nsUserInfo.cpp
    new file mode 100644
    index 0000000..06ad8c9
    - +  
     1/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2/* This Source Code Form is subject to the terms of the Mozilla Public
     3 * License, v. 2.0. If a copy of the MPL was not distributed with this
     4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     5
     6#include "nsUserInfo.h"
     7
     8#include "mozilla/Preferences.h"
     9using mozilla::Preferences;
     10
     11bool nsUserInfo::sHideUserInfo = false;
     12
     13void nsUserInfo::InitializeStatics()
     14{
     15  Preferences::AddBoolVarCache(&sHideUserInfo,
     16                               "privacy.hide_user_info", false);
     17}
     18
     19NS_IMETHODIMP
     20nsUserInfo::GetFullname(char16_t** aFullname)
     21{
     22  NS_ENSURE_ARG_POINTER(aFullname);
     23
     24  if(sHideUserInfo) {
     25    auto fullname = ToNewUnicode(NS_LITERAL_STRING(""));
     26    if(fullname) {
     27      *aFullname = fullname;
     28      return NS_OK;
     29    }
     30
     31    *aFullname = nullptr;
     32    return NS_ERROR_FAILURE;
     33  }
     34
     35  return this->GetFullnameImpl(aFullname);
     36}
     37
     38NS_IMETHODIMP
     39nsUserInfo::GetUsername(char** aUsername)
     40{
     41  NS_ENSURE_ARG_POINTER(aUsername);
     42
     43  if(sHideUserInfo) {
     44    auto username = ToNewUTF8String(NS_LITERAL_STRING(""));
     45    if(username) {
     46      *aUsername = username;
     47      return NS_OK;
     48    }
     49
     50    *aUsername = nullptr;
     51    return NS_ERROR_FAILURE;
     52  }
     53
     54  return this->GetUsernameImpl(aUsername);
     55}
     56
     57NS_IMETHODIMP
     58nsUserInfo::GetEmailAddress(char** aEmailAddress)
     59{
     60  NS_ENSURE_ARG_POINTER(aEmailAddress);
     61
     62  if(sHideUserInfo) {
     63    auto emailAddress = ToNewUTF8String(NS_LITERAL_STRING(""));
     64    if(emailAddress) {
     65      *aEmailAddress = emailAddress;
     66      return NS_OK;
     67    }
     68
     69    *aEmailAddress = nullptr;
     70    return NS_ERROR_FAILURE;
     71  }
     72
     73  return this->GetEmailAddressImpl(aEmailAddress);
     74}
     75
     76NS_IMETHODIMP
     77nsUserInfo::GetDomain(char** aDomain)
     78{
     79  NS_ENSURE_ARG_POINTER(aDomain);
     80
     81  if(sHideUserInfo) {
     82    auto domain = ToNewUTF8String(NS_LITERAL_STRING(""));
     83    if(domain) {
     84      *aDomain = domain;
     85      return NS_OK;
     86    }
     87
     88    *aDomain = nullptr;
     89    return NS_ERROR_FAILURE;
     90  }
     91
     92  return this->GetDomainImpl(aDomain);
     93}
  • toolkit/components/startup/nsUserInfo.h

    diff --git a/toolkit/components/startup/nsUserInfo.h b/toolkit/components/startup/nsUserInfo.h
    index 49e86c6..10b3d0a 100644
    a b public: 
    1616  NS_DECL_ISUPPORTS
    1717  NS_DECL_NSIUSERINFO
    1818
     19  static void InitializeStatics();
     20
    1921protected:
    2022  virtual ~nsUserInfo();
     23
     24  static bool sHideUserInfo;
     25
     26  nsresult GetFullnameImpl(char16_t** aFullname);
     27  nsresult GetUsernameImpl(char** aUsername);
     28  nsresult GetEmailAddressImpl(char** aEmailAddress);
     29  nsresult GetDomainImpl(char** aDomain);
    2130};
    2231
    2332#endif /* __nsUserInfo_h */
  • deleted file toolkit/components/startup/nsUserInfoMac.h

    diff --git a/toolkit/components/startup/nsUserInfoMac.h b/toolkit/components/startup/nsUserInfoMac.h
    deleted file mode 100644
    index 822e0ed..0000000
    + -  
    1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
    2 /* This Source Code Form is subject to the terms of the Mozilla Public
    3  * License, v. 2.0. If a copy of the MPL was not distributed with this
    4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
    5 #ifndef __nsUserInfoMac_h
    6 #define __nsUserInfoMac_h
    7 
    8 #include "nsIUserInfo.h"
    9 #include "nsReadableUtils.h"
    10 
    11 class nsUserInfo: public nsIUserInfo
    12 {
    13 public:
    14   nsUserInfo();
    15 
    16   NS_DECL_ISUPPORTS
    17   NS_DECL_NSIUSERINFO
    18 
    19   nsresult GetPrimaryEmailAddress(nsCString &aEmailAddress);
    20 
    21 protected:
    22   virtual ~nsUserInfo() {}
    23 };
    24 
    25 #endif /* __nsUserInfo_h */
  • toolkit/components/startup/nsUserInfoMac.mm

    diff --git a/toolkit/components/startup/nsUserInfoMac.mm b/toolkit/components/startup/nsUserInfoMac.mm
    index 1895cf1..1e815d8 100644
    a b  
    44 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
    55
    66
    7 #include "nsUserInfoMac.h"
     7#include "nsUserInfo.h"
    88#include "nsObjCExceptions.h"
    99#include "nsString.h"
     10#include "nsReadableUtils.h"
    1011
    1112#import <Cocoa/Cocoa.h>
    1213#import <AddressBook/AddressBook.h>
    NS_IMPL_ISUPPORTS(nsUserInfo, nsIUserInfo) 
    1617nsUserInfo::nsUserInfo() {}
    1718
    1819NS_IMETHODIMP
    19 nsUserInfo::GetFullname(char16_t **aFullname)
     20nsUserInfo::GetFullnameImpl(char16_t **aFullname)
    2021{
    2122  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT
    22 
     23
    2324  NS_ConvertUTF8toUTF16 fullName([NSFullUserName() UTF8String]);
    2425  *aFullname = ToNewUnicode(fullName);
    2526  return NS_OK;
    26 
     27
    2728  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT
    2829}
    2930
    30 NS_IMETHODIMP
    31 nsUserInfo::GetUsername(char **aUsername)
     31NS_IMETHODIMP
     32nsUserInfo::GetUsernameImpl(char **aUsername)
    3233{
    3334  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT
    34 
     35
    3536  nsAutoCString username([NSUserName() UTF8String]);
    3637  *aUsername = ToNewCString(username);
    3738  return NS_OK;
    38 
     39
    3940  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT
    4041}
    4142
    42 nsresult
    43 nsUserInfo::GetPrimaryEmailAddress(nsCString &aEmailAddress)
     43static nsresult
     44GetPrimaryEmailAddress(nsCString &aEmailAddress)
    4445{
    4546  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT
    46 
    47   // Try to get this user's primary email from the system addressbook's "me card"
     47
     48  // Try to get this user's primary email from the system addressbook's "me card"
    4849  // (if they've filled it)
    4950  ABPerson *me = [[ABAddressBook sharedAddressBook] me];
    5051  ABMultiValue *emailAddresses = [me valueForProperty:kABEmailProperty];
    nsUserInfo::GetPrimaryEmailAddress(nsCString &aEmailAddress) 
    5455    aEmailAddress.Assign([[emailAddresses valueAtIndex:primaryEmailIndex] UTF8String]);
    5556    return NS_OK;
    5657  }
    57 
     58
    5859  return NS_ERROR_FAILURE;
    59 
     60
    6061  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT
    6162}
    6263
    63 NS_IMETHODIMP
    64 nsUserInfo::GetEmailAddress(char **aEmailAddress)
     64NS_IMETHODIMP
     65nsUserInfo::GetEmailAddressImpl(char **aEmailAddress)
    6566{
    6667  nsAutoCString email;
    67   if (NS_SUCCEEDED(GetPrimaryEmailAddress(email)))
     68  if (NS_SUCCEEDED(GetPrimaryEmailAddress(email)))
    6869    *aEmailAddress = ToNewCString(email);
    6970  return NS_OK;
    7071}
    7172
    72 NS_IMETHODIMP
    73 nsUserInfo::GetDomain(char **aDomain)
     73NS_IMETHODIMP
     74nsUserInfo::GetDomainImpl(char **aDomain)
    7475{
    7576  nsAutoCString email;
    7677  if (NS_SUCCEEDED(GetPrimaryEmailAddress(email))) {
  • toolkit/components/startup/nsUserInfoUnix.cpp

    diff --git a/toolkit/components/startup/nsUserInfoUnix.cpp b/toolkit/components/startup/nsUserInfoUnix.cpp
    index 71bc46d..79589fa 100644
    a b nsUserInfo::~nsUserInfo() 
    3434NS_IMPL_ISUPPORTS(nsUserInfo,nsIUserInfo)
    3535
    3636NS_IMETHODIMP
    37 nsUserInfo::GetFullname(char16_t **aFullname)
     37nsUserInfo::GetFullnameImpl(char16_t **aFullname)
    3838{
    3939    struct passwd *pw = nullptr;
    4040
    nsUserInfo::GetFullname(char16_t **aFullname) 
    5252    // Full Name, <other stuff> - eliminate the ", <other stuff>
    5353    // also, sometimes GECOS uses "&" to mean "the user name" so do
    5454    // the appropriate substitution
    55 
     55
    5656    // truncate at first comma (field delimiter)
    5757    int32_t index;
    5858    if ((index = fullname.Find(",")) != kNotFound)
    nsUserInfo::GetFullname(char16_t **aFullname) 
    6363        nsAutoCString username(pw->pw_name);
    6464        if (!username.IsEmpty() && nsCRT::IsLower(username.CharAt(0)))
    6565            username.SetCharAt(nsCRT::ToUpper(username.CharAt(0)), 0);
    66 
     66
    6767        fullname.ReplaceSubstring("&", username.get());
    6868    }
    6969
    nsUserInfo::GetFullname(char16_t **aFullname) 
    7878    return NS_ERROR_FAILURE;
    7979}
    8080
    81 NS_IMETHODIMP
    82 nsUserInfo::GetUsername(char * *aUsername)
     81NS_IMETHODIMP
     82nsUserInfo::GetUsernameImpl(char * *aUsername)
    8383{
    8484    struct passwd *pw = nullptr;
    8585
    nsUserInfo::GetUsername(char * *aUsername) 
    9797    return NS_OK;
    9898}
    9999
    100 NS_IMETHODIMP
    101 nsUserInfo::GetDomain(char * *aDomain)
     100NS_IMETHODIMP
     101nsUserInfo::GetDomainImpl(char * *aDomain)
    102102{
    103103    nsresult rv = NS_ERROR_FAILURE;
    104104
    105105    struct utsname buf;
    106106    char *domainname = nullptr;
    107107
    108     if (uname(&buf) < 0) {
     108    if (uname(&buf) < 0) {
    109109        return rv;
    110110    }
    111111
    nsUserInfo::GetDomain(char * *aDomain) 
    113113    domainname = buf.domainname;
    114114#endif
    115115
    116     if (domainname && domainname[0]) {
     116    if (domainname && domainname[0]) {
    117117        *aDomain = strdup(domainname);
    118118        rv = NS_OK;
    119119    }
    nsUserInfo::GetDomain(char * *aDomain) 
    130130            }
    131131        }
    132132    }
    133 
     133
    134134    return rv;
    135135}
    136136
    137 NS_IMETHODIMP
    138 nsUserInfo::GetEmailAddress(char * *aEmailAddress)
     137NS_IMETHODIMP
     138nsUserInfo::GetEmailAddressImpl(char * *aEmailAddress)
    139139{
    140140    // use username + "@" + domain for the email address
    141141
    nsUserInfo::GetEmailAddress(char * *aEmailAddress) 
    145145    nsXPIDLCString username;
    146146    nsXPIDLCString domain;
    147147
    148     rv = GetUsername(getter_Copies(username));
     148    rv = GetUsernameImpl(getter_Copies(username));
    149149    if (NS_FAILED(rv)) return rv;
    150150
    151     rv = GetDomain(getter_Copies(domain));
     151    rv = GetDomainImpl(getter_Copies(domain));
    152152    if (NS_FAILED(rv)) return rv;
    153153
    154154    if (!username.IsEmpty() && !domain.IsEmpty()) {
    nsUserInfo::GetEmailAddress(char * *aEmailAddress) 
    161161    }
    162162
    163163    *aEmailAddress = ToNewCString(emailAddress);
    164 
     164
    165165    return NS_OK;
    166166}
    167167
  • toolkit/components/startup/nsUserInfoWin.cpp

    diff --git a/toolkit/components/startup/nsUserInfoWin.cpp b/toolkit/components/startup/nsUserInfoWin.cpp
    index b27a2c4..bff971e 100644
    a b nsUserInfo::~nsUserInfo() 
    2626NS_IMPL_ISUPPORTS(nsUserInfo, nsIUserInfo)
    2727
    2828NS_IMETHODIMP
    29 nsUserInfo::GetUsername(char **aUsername)
     29nsUserInfo::GetUsernameImpl(char **aUsername)
    3030{
    3131  NS_ENSURE_ARG_POINTER(aUsername);
    3232  *aUsername = nullptr;
    nsUserInfo::GetUsername(char **aUsername) 
    4242}
    4343
    4444NS_IMETHODIMP
    45 nsUserInfo::GetFullname(char16_t **aFullname)
     45nsUserInfo::GetFullnameImpl(char16_t **aFullname)
    4646{
    4747  NS_ENSURE_ARG_POINTER(aFullname);
    4848  *aFullname = nullptr;
    nsUserInfo::GetFullname(char16_t **aFullname) 
    9494}
    9595
    9696NS_IMETHODIMP
    97 nsUserInfo::GetDomain(char **aDomain)
     97nsUserInfo::GetDomainImpl(char **aDomain)
    9898{
    9999  NS_ENSURE_ARG_POINTER(aDomain);
    100100  *aDomain = nullptr;
    nsUserInfo::GetDomain(char **aDomain) 
    113113}
    114114
    115115NS_IMETHODIMP
    116 nsUserInfo::GetEmailAddress(char **aEmailAddress)
     116nsUserInfo::GetEmailAddressImpl(char **aEmailAddress)
    117117{
    118118  NS_ENSURE_ARG_POINTER(aEmailAddress);
    119119  *aEmailAddress = nullptr;