зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1839916 - Add navigation callbacks for BounceTrackingState in DocumentLoadListener. r=bvandersloot,smaug
Differential Revision: https://phabricator.services.mozilla.com/D182343
This commit is contained in:
Родитель
d26a3d493b
Коммит
b1a6751277
|
@ -12,6 +12,7 @@
|
|||
#include "mozilla/DebugOnly.h"
|
||||
#include "mozilla/LoadInfo.h"
|
||||
#include "mozilla/NullPrincipal.h"
|
||||
#include "mozilla/RefPtr.h"
|
||||
#include "mozilla/ResultVariant.h"
|
||||
#include "mozilla/ScopeExit.h"
|
||||
#include "mozilla/StaticPrefs_extensions.h"
|
||||
|
@ -929,6 +930,27 @@ auto DocumentLoadListener::OpenDocument(
|
|||
nsLoadFlags loadFlags = aLoadState->CalculateChannelLoadFlags(
|
||||
browsingContext, std::move(aUriModified), std::move(aIsXFOError));
|
||||
|
||||
// Keep track of navigation for the Bounce Tracking Protection.
|
||||
if (browsingContext->IsTopContent()) {
|
||||
RefPtr<BounceTrackingState> bounceTrackingState =
|
||||
browsingContext->GetBounceTrackingState();
|
||||
|
||||
// Not every browsing context has a BounceTrackingState. It's also null when
|
||||
// the feature is disabled.
|
||||
if (bounceTrackingState) {
|
||||
nsCOMPtr<nsIPrincipal> triggeringPrincipal;
|
||||
nsresult rv =
|
||||
loadInfo->GetTriggeringPrincipal(getter_AddRefs(triggeringPrincipal));
|
||||
|
||||
if (!NS_WARN_IF(NS_FAILED(rv))) {
|
||||
DebugOnly<nsresult> rv = bounceTrackingState->OnStartNavigation(
|
||||
triggeringPrincipal, loadInfo->GetHasValidUserGestureActivation());
|
||||
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv),
|
||||
"BounceTrackingState::OnStartNavigation failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Open(aLoadState, loadInfo, loadFlags, aCacheKey, aChannelId,
|
||||
aAsyncOpenTime, aTiming, std::move(aInfo), false, aContentParent,
|
||||
aRv);
|
||||
|
@ -2517,6 +2539,24 @@ DocumentLoadListener::OnStartRequest(nsIRequest* aRequest) {
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
// Keep track of server responses resulting in a document for the Bounce
|
||||
// Tracking Protection.
|
||||
if (mIsDocumentLoad && GetParentWindowContext() == nullptr &&
|
||||
loadingContext->IsTopContent()) {
|
||||
RefPtr<BounceTrackingState> bounceTrackingState =
|
||||
loadingContext->GetBounceTrackingState();
|
||||
|
||||
// Not every browsing context has a BounceTrackingState. It's also null when
|
||||
// the feature is disabled.
|
||||
if (bounceTrackingState) {
|
||||
DebugOnly<nsresult> rv =
|
||||
bounceTrackingState->OnDocumentStartRequest(mChannel);
|
||||
NS_WARNING_ASSERTION(
|
||||
NS_SUCCEEDED(rv),
|
||||
"BounceTrackingState::OnDocumentStartRequest failed.");
|
||||
}
|
||||
}
|
||||
|
||||
mChannel->Suspend();
|
||||
|
||||
mInitiatedRedirectToRealChannel = true;
|
||||
|
|
Загрузка…
Ссылка в новой задаче