author | Andrea Marchesini <amarchesini@mozilla.com> |
Wed, 20 Jun 2018 13:38:22 -0400 | |
changeset 423174 | 0ffa02850c0426401f86ce9a9ef6ac1344f14718 |
parent 423173 | f1401b74761911baf8a453d26bfc2add5573e1e2 |
child 423175 | 8b97ba3dd284fb55c8dab911c32ef58a3e900641 |
push id | 34164 |
push user | csabou@mozilla.com |
push date | Thu, 21 Jun 2018 01:17:13 +0000 |
treeherder | mozilla-central@d231a3231680 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | mayhemer, ehsan |
bugs | 1461921 |
milestone | 62.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/dom/base/nsContentUtils.cpp +++ b/dom/base/nsContentUtils.cpp @@ -75,16 +75,17 @@ #include "mozilla/IMEStateManager.h" #include "mozilla/InternalMutationEvent.h" #include "mozilla/Likely.h" #include "mozilla/ManualNAC.h" #include "mozilla/MouseEvents.h" #include "mozilla/Preferences.h" #include "mozilla/ResultExtensions.h" #include "mozilla/dom/Selection.h" +#include "mozilla/Services.h" #include "mozilla/StaticPrefs.h" #include "mozilla/TextEvents.h" #include "nsArrayUtils.h" #include "nsAString.h" #include "nsAttrName.h" #include "nsAttrValue.h" #include "nsAttrValueInlines.h" #include "nsBindingManager.h" @@ -516,34 +517,31 @@ EventListenerManagerHashClearEntry(PLDHa static bool IsThirdPartyWindowOrChannel(nsPIDOMWindowInner* aWindow, nsIChannel* aChannel, nsIURI* aURI) { MOZ_ASSERT(!aWindow || !aChannel, "A window and channel should not both be provided."); + nsCOMPtr<mozIThirdPartyUtil> thirdPartyUtil = services::GetThirdPartyUtil(); + if (!thirdPartyUtil) { + return false; + } + // In the absence of a window or channel, we assume that we are first-party. bool thirdParty = false; if (aWindow) { - nsCOMPtr<mozIThirdPartyUtil> thirdPartyUtil = - do_GetService(THIRDPARTYUTIL_CONTRACTID); - MOZ_ASSERT(thirdPartyUtil); - Unused << thirdPartyUtil->IsThirdPartyWindow(aWindow->GetOuterWindow(), aURI, &thirdParty); } if (aChannel) { - nsCOMPtr<mozIThirdPartyUtil> thirdPartyUtil = - do_GetService(THIRDPARTYUTIL_CONTRACTID); - MOZ_ASSERT(thirdPartyUtil); - // Note, we must call IsThirdPartyChannel() here and not just try to // use nsILoadInfo.isThirdPartyContext. That nsILoadInfo property only // indicates if the parent loading window is third party or not. We // want to check the channel URI against the loading principal as well. Unused << thirdPartyUtil->IsThirdPartyChannel(aChannel, nullptr, &thirdParty); }
--- a/netwerk/protocol/http/HttpBaseChannel.cpp +++ b/netwerk/protocol/http/HttpBaseChannel.cpp @@ -37,16 +37,17 @@ #include "nsIScriptSecurityManager.h" #include "nsIObserverService.h" #include "nsProxyRelease.h" #include "nsPIDOMWindow.h" #include "nsIDocShell.h" #include "nsINetworkInterceptController.h" #include "mozilla/dom/Performance.h" #include "mozilla/dom/PerformanceStorage.h" +#include "mozilla/Services.h" #include "mozIThirdPartyUtil.h" #include "nsStreamUtils.h" #include "nsThreadUtils.h" #include "nsContentSecurityManager.h" #include "nsIChannelEventSink.h" #include "nsILoadGroupChild.h" #include "mozilla/ConsoleReportCollector.h" #include "LoadInfo.h" @@ -2374,17 +2375,17 @@ HttpBaseChannel::SetTopWindowURIIfUnknow NS_IMETHODIMP HttpBaseChannel::GetTopWindowURI(nsIURI **aTopWindowURI) { nsresult rv = NS_OK; nsCOMPtr<mozIThirdPartyUtil> util; // Only compute the top window URI once. In e10s, this must be computed in the // child. The parent gets the top window URI through HttpChannelOpenArgs. if (!mTopWindowURI) { - util = do_GetService(THIRDPARTYUTIL_CONTRACTID); + util = services::GetThirdPartyUtil(); if (!util) { return NS_ERROR_NOT_AVAILABLE; } nsCOMPtr<mozIDOMWindowProxy> win; rv = util->GetTopWindowForChannel(this, getter_AddRefs(win)); if (NS_SUCCEEDED(rv)) { rv = util->GetURIFromWindow(win, getter_AddRefs(mTopWindowURI)); #if DEBUG
--- a/netwerk/protocol/http/nsHttpChannel.cpp +++ b/netwerk/protocol/http/nsHttpChannel.cpp @@ -40,28 +40,30 @@ #include "nsIStreamTransportService.h" #include "prnetdb.h" #include "nsEscape.h" #include "nsStreamUtils.h" #include "nsIOService.h" #include "nsDNSPrefetch.h" #include "nsChannelClassifier.h" #include "nsIRedirectResultListener.h" +#include "mozIThirdPartyUtil.h" #include "mozilla/dom/ContentVerifier.h" #include "mozilla/TimeStamp.h" #include "nsError.h" #include "nsPrintfCString.h" #include "nsAlgorithm.h" #include "nsQueryObject.h" #include "nsThreadUtils.h" #include "GeckoProfiler.h" #include "nsIConsoleService.h" #include "mozilla/Attributes.h" #include "mozilla/DebugOnly.h" #include "mozilla/Preferences.h" +#include "mozilla/Services.h" #include "nsISSLSocketControl.h" #include "sslt.h" #include "nsContentUtils.h" #include "nsContentSecurityManager.h" #include "nsIClassOfService.h" #include "nsIPermissionManager.h" #include "nsIPrincipal.h" #include "nsIScriptError.h" @@ -97,16 +99,17 @@ #include "nsIDeprecationWarner.h" #include "nsIDocument.h" #include "nsICompressConvStats.h" #include "nsCORSListenerProxy.h" #include "nsISocketProvider.h" #include "mozilla/extensions/StreamFilterParent.h" #include "mozilla/net/Predictor.h" #include "mozilla/MathAlgorithms.h" +#include "mozilla/StaticPrefs.h" #include "CacheControlParser.h" #include "nsMixedContentBlocker.h" #include "CacheStorageService.h" #include "HttpChannelParent.h" #include "InterceptedHttpChannel.h" #include "nsIBufferedStreams.h" #include "nsIFileStreams.h" #include "nsIMIMEInputStream.h" @@ -3732,16 +3735,40 @@ nsHttpChannel::OpenCacheEntryInternal(bo if (mPostID) { extension.Append(nsPrintfCString("%d", mPostID)); } if (mTRR) { extension.Append("TRR"); } + if (StaticPrefs::privacy_trackingprotection_storagerestriction_enabled() && + mIsTrackingResource) { + nsCOMPtr<mozIThirdPartyUtil> thirdPartyUtil = + services::GetThirdPartyUtil(); + if (thirdPartyUtil) { + bool thirdParty = false; + Unused << thirdPartyUtil->IsThirdPartyChannel(this, + nullptr, + &thirdParty); + if (thirdParty) { + nsCOMPtr<nsIURI> topWindowURI; + rv = GetTopWindowURI(getter_AddRefs(topWindowURI)); + NS_ENSURE_SUCCESS(rv, rv); + + nsAutoString topWindowOrigin; + rv = nsContentUtils::GetUTFOrigin(topWindowURI, topWindowOrigin); + NS_ENSURE_SUCCESS(rv, rv); + + extension.Append("-trackerFor:"); + extension.Append(NS_ConvertUTF16toUTF8(topWindowOrigin)); + } + } + } + mCacheOpenWithPriority = cacheEntryOpenFlags & nsICacheStorage::OPEN_PRIORITY; mCacheQueueSizeWhenOpen = CacheStorageService::CacheQueueSize(mCacheOpenWithPriority); if (sRCWNEnabled && maybeRCWN && !mApplicationCacheForWrite) { bool hasAltData = false; uint32_t sizeInKb = 0; rv = cacheStorage->GetCacheIndexEntryAttrs(openURI, extension, &hasAltData, &sizeInKb);
--- a/xpcom/build/Services.py +++ b/xpcom/build/Services.py @@ -41,23 +41,26 @@ service('StreamTransportService', 'nsISt service('CacheStorageService', 'nsICacheStorageService', "@mozilla.org/netwerk/cache-storage-service;1") service('URIClassifier', 'nsIURIClassifier', "@mozilla.org/uriclassifierservice") service('ActivityDistributor', 'nsIHttpActivityDistributor', "@mozilla.org/network/http-activity-distributor;1") service('HistoryService', 'mozilla::IHistory', "@mozilla.org/browser/history;1") +service('ThirdPartyUtil', 'mozIThirdPartyUtil', + "@mozilla.org/thirdpartyutil;1") # The definition file needs access to the definitions of the particular # interfaces. If you add a new interface here, make sure the necessary includes # are also listed in the following code snippet. CPP_INCLUDES = """ #include "mozilla/Likely.h" #include "mozilla/Services.h" +#include "mozIThirdPartyUtil.h" #include "nsComponentManager.h" #include "nsIObserverService.h" #include "nsNetCID.h" #include "nsObserverService.h" #include "nsXPCOMPrivate.h" #include "nsIIOService.h" #include "nsIDirectoryService.h" #include "nsIChromeRegistry.h"