Merge remote-tracking branch 'origin/master' into custom

This commit is contained in:
roytam1 2021-06-24 11:13:09 +08:00
commit 20c6498ca1
395 changed files with 818 additions and 23422 deletions

View file

@ -10,8 +10,6 @@ XPIDL_MODULE = 'parentalcontrols'
if not CONFIG['MOZ_DISABLE_PARENTAL_CONTROLS']:
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows':
SOURCES += ['nsParentalControlsServiceWin.cpp']
elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
UNIFIED_SOURCES += ['nsParentalControlsServiceCocoa.mm']
else:
SOURCES += ['nsParentalControlsServiceDefault.cpp']

View file

@ -1,79 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode:nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsParentalControlsService.h"
#include "nsString.h"
#include "nsIFile.h"
#import <Cocoa/Cocoa.h>
NS_IMPL_ISUPPORTS(nsParentalControlsService, nsIParentalControlsService)
nsParentalControlsService::nsParentalControlsService() :
mEnabled(false)
{
mEnabled = CFPreferencesAppValueIsForced(CFSTR("restrictWeb"),
CFSTR("com.apple.familycontrols.contentfilter"));
}
nsParentalControlsService::~nsParentalControlsService()
{
}
NS_IMETHODIMP
nsParentalControlsService::GetParentalControlsEnabled(bool *aResult)
{
*aResult = mEnabled;
return NS_OK;
}
NS_IMETHODIMP
nsParentalControlsService::GetBlockFileDownloadsEnabled(bool *aResult)
{
*aResult = false;
return NS_OK;
}
NS_IMETHODIMP
nsParentalControlsService::GetLoggingEnabled(bool *aResult)
{
*aResult = false;
return NS_OK;
}
NS_IMETHODIMP
nsParentalControlsService::Log(int16_t aEntryType,
bool blocked,
nsIURI *aSource,
nsIFile *aTarget)
{
// silently drop on the floor
return NS_OK;
}
NS_IMETHODIMP
nsParentalControlsService::RequestURIOverride(nsIURI *aTarget,
nsIInterfaceRequestor *aWindowContext,
bool *_retval)
{
return NS_ERROR_NOT_AVAILABLE;
}
NS_IMETHODIMP
nsParentalControlsService::RequestURIOverrides(nsIArray *aTargets,
nsIInterfaceRequestor *aWindowContext,
bool *_retval)
{
return NS_ERROR_NOT_AVAILABLE;
}
NS_IMETHODIMP
nsParentalControlsService::IsAllowed(int16_t aAction,
nsIURI *aUri,
bool *_retval)
{
return NS_ERROR_NOT_AVAILABLE;
}

View file

@ -7,7 +7,7 @@ DIRS += ['public']
EXPORTS.mozilla += ['StartupTimeline.h']
UNIFIED_SOURCES += [
SOURCES += [
'nsAppStartup.cpp',
'StartupTimeline.cpp',
]
@ -16,9 +16,7 @@ if CONFIG['MOZ_USERINFO']:
if CONFIG['OS_ARCH'] == 'WINNT':
# This file cannot be built in unified mode because of name clashes with Windows headers.
SOURCES += ['nsUserInfoWin.cpp']
elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
UNIFIED_SOURCES += ['nsUserInfoMac.mm']
else:
UNIFIED_SOURCES += ['nsUserInfoUnix.cpp']
SOURCES += ['nsUserInfoUnix.cpp']
FINAL_LIBRARY = 'xul'

View file

@ -1,25 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef __nsUserInfoMac_h
#define __nsUserInfoMac_h
#include "nsIUserInfo.h"
#include "nsReadableUtils.h"
class nsUserInfo: public nsIUserInfo
{
public:
nsUserInfo();
NS_DECL_ISUPPORTS
NS_DECL_NSIUSERINFO
nsresult GetPrimaryEmailAddress(nsCString &aEmailAddress);
protected:
virtual ~nsUserInfo() {}
};
#endif /* __nsUserInfo_h */

View file

@ -1,84 +0,0 @@
/* -*- Mode: Objective-C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsUserInfoMac.h"
#include "nsObjCExceptions.h"
#include "nsString.h"
#import <Cocoa/Cocoa.h>
#import <AddressBook/AddressBook.h>
NS_IMPL_ISUPPORTS(nsUserInfo, nsIUserInfo)
nsUserInfo::nsUserInfo() {}
NS_IMETHODIMP
nsUserInfo::GetFullname(char16_t **aFullname)
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT
NS_ConvertUTF8toUTF16 fullName([NSFullUserName() UTF8String]);
*aFullname = ToNewUnicode(fullName);
return NS_OK;
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT
}
NS_IMETHODIMP
nsUserInfo::GetUsername(char **aUsername)
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT
nsAutoCString username([NSUserName() UTF8String]);
*aUsername = ToNewCString(username);
return NS_OK;
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT
}
nsresult
nsUserInfo::GetPrimaryEmailAddress(nsCString &aEmailAddress)
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT
// Try to get this user's primary email from the system addressbook's "me card"
// (if they've filled it)
ABPerson *me = [[ABAddressBook sharedAddressBook] me];
ABMultiValue *emailAddresses = [me valueForProperty:kABEmailProperty];
if ([emailAddresses count] > 0) {
// get the index of the primary email, in case there are more than one
int primaryEmailIndex = [emailAddresses indexForIdentifier:[emailAddresses primaryIdentifier]];
aEmailAddress.Assign([[emailAddresses valueAtIndex:primaryEmailIndex] UTF8String]);
return NS_OK;
}
return NS_ERROR_FAILURE;
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT
}
NS_IMETHODIMP
nsUserInfo::GetEmailAddress(char **aEmailAddress)
{
nsAutoCString email;
if (NS_SUCCEEDED(GetPrimaryEmailAddress(email)))
*aEmailAddress = ToNewCString(email);
return NS_OK;
}
NS_IMETHODIMP
nsUserInfo::GetDomain(char **aDomain)
{
nsAutoCString email;
if (NS_SUCCEEDED(GetPrimaryEmailAddress(email))) {
int32_t index = email.FindChar('@');
if (index != -1) {
// chop off everything before, and including the '@'
*aDomain = ToNewCString(Substring(email, index + 1));
}
}
return NS_OK;
}