mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 23:31:56 +00:00
Bug 1834274 - Part 1: Implement nsIRFPService.idl for nsRFPService. r=emilio
To allow remote settings client to set fingerprinting overrides from Javascript, we need to implement nsIRFPService for nsRFPService. This patch changes the return format of nsRFPService::GetOrCreate() to match the singleton implementation of nsIRFPService. As a result of it, we need to change the first init call in nsContentUtils because we cannot forward a already_AddRefed<> to mozilla::Unused. It will cause a memory leak. Differential Revision: https://phabricator.services.mozilla.com/D182809
This commit is contained in:
parent
9f496d89f4
commit
d68f687593
@ -825,7 +825,8 @@ nsresult nsContentUtils::Init() {
|
||||
|
||||
Element::InitCCCallbacks();
|
||||
|
||||
Unused << nsRFPService::GetOrCreate();
|
||||
RefPtr<nsRFPService> rfpService = nsRFPService::GetOrCreate();
|
||||
MOZ_ASSERT(rfpService);
|
||||
|
||||
if (XRE_IsParentProcess()) {
|
||||
AsyncPrecreateStringBundles();
|
||||
|
20
toolkit/components/resistfingerprinting/components.conf
Normal file
20
toolkit/components/resistfingerprinting/components.conf
Normal file
@ -0,0 +1,20 @@
|
||||
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
|
||||
# vim: set filetype=python:
|
||||
# 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/.
|
||||
|
||||
Classes = [
|
||||
{
|
||||
'name': 'RFPService',
|
||||
'cid': '{20093b2e-d5d5-4ce0-8355-96b8d2dc7ff5}',
|
||||
'interfaces': ['nsIRFPService'],
|
||||
'contract_ids': ['@mozilla.org/rfp-service;1'],
|
||||
'type': 'mozilla::nsRFPService',
|
||||
'headers': ['/toolkit/components/resistfingerprinting/nsRFPService.h'],
|
||||
'singleton': True,
|
||||
'constructor': 'mozilla::nsRFPService::GetOrCreate',
|
||||
'js_name': 'rfp',
|
||||
'processes': ProcessSelector.MAIN_PROCESS_ONLY,
|
||||
},
|
||||
]
|
@ -26,3 +26,13 @@ EXPORTS.mozilla += [
|
||||
EXTRA_JS_MODULES += [
|
||||
"RFPHelper.sys.mjs",
|
||||
]
|
||||
|
||||
XPIDL_MODULE = "toolkit_resistfingerprinting"
|
||||
|
||||
XPCOM_MANIFESTS += [
|
||||
"components.conf",
|
||||
]
|
||||
|
||||
XPIDL_SOURCES += [
|
||||
"nsIRFPService.idl",
|
||||
]
|
||||
|
13
toolkit/components/resistfingerprinting/nsIRFPService.idl
Normal file
13
toolkit/components/resistfingerprinting/nsIRFPService.idl
Normal file
@ -0,0 +1,13 @@
|
||||
/* 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 "nsISupports.idl"
|
||||
|
||||
/**
|
||||
* The singleton serivce which handles fingerprinting protection stuffs.
|
||||
*/
|
||||
[scriptable, builtinclass, uuid(20093b2e-d5d5-4ce0-8355-96b8d2dc7ff5)]
|
||||
interface nsIRFPService : nsISupports
|
||||
{
|
||||
};
|
@ -112,7 +112,7 @@ const RFPTarget kDefaultFingerintingProtections =
|
||||
// ============================================================================
|
||||
// Structural Stuff & Pref Observing
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsRFPService, nsIObserver)
|
||||
NS_IMPL_ISUPPORTS(nsRFPService, nsIObserver, nsIRFPService)
|
||||
|
||||
static StaticRefPtr<nsRFPService> sRFPService;
|
||||
static bool sInitialized = false;
|
||||
@ -121,7 +121,7 @@ static bool sInitialized = false;
|
||||
static Atomic<RFPTarget> sEnabledFingerintingProtections;
|
||||
|
||||
/* static */
|
||||
nsRFPService* nsRFPService::GetOrCreate() {
|
||||
already_AddRefed<nsRFPService> nsRFPService::GetOrCreate() {
|
||||
if (!sInitialized) {
|
||||
sRFPService = new nsRFPService();
|
||||
nsresult rv = sRFPService->Init();
|
||||
@ -135,7 +135,7 @@ nsRFPService* nsRFPService::GetOrCreate() {
|
||||
sInitialized = true;
|
||||
}
|
||||
|
||||
return sRFPService;
|
||||
return do_AddRef(sRFPService);
|
||||
}
|
||||
|
||||
static const char* gCallbackPrefs[] = {
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "nsICookieJarSettings.h"
|
||||
#include "nsIObserver.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsIRFPService.h"
|
||||
#include "nsStringFwd.h"
|
||||
|
||||
// Defines regarding spoofed values of Navigator object. These spoofed values
|
||||
@ -157,12 +158,13 @@ MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(RFPTarget);
|
||||
|
||||
// ============================================================================
|
||||
|
||||
class nsRFPService final : public nsIObserver {
|
||||
class nsRFPService final : public nsIObserver, public nsIRFPService {
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIOBSERVER
|
||||
NS_DECL_NSIRFPSERVICE
|
||||
|
||||
static nsRFPService* GetOrCreate();
|
||||
static already_AddRefed<nsRFPService> GetOrCreate();
|
||||
|
||||
// _Rarely_ you will need to know if RFP is enabled, or if FPP is enabled.
|
||||
// 98% of the time you should use nsContentUtils::ShouldResistFingerprinting
|
||||
|
@ -41,6 +41,7 @@
|
||||
"nsIProperties": "dirsvc",
|
||||
"nsIPropertyBag2": "sysinfo",
|
||||
"nsIQuotaManagerService": "qms",
|
||||
"nsIRFPService": "rfp",
|
||||
"nsIScriptSecurityManager": "scriptSecurityManager",
|
||||
"nsISearchService": "search",
|
||||
"nsISessionStorageService": "sessionStorage",
|
||||
|
Loading…
Reference in New Issue
Block a user