зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1648825 - Add nsISHEntry::hasUserActivation r=ckerschb,smaug
Differential Revision: https://phabricator.services.mozilla.com/D113818
This commit is contained in:
Родитель
a99952e786
Коммит
418fd21408
|
@ -11659,6 +11659,8 @@ nsresult nsDocShell::AddToSessionHistory(
|
|||
bool expired = false; // by default the page is not expired
|
||||
bool discardLayoutState = false;
|
||||
nsCOMPtr<nsICacheInfoChannel> cacheChannel;
|
||||
bool userActivation = false;
|
||||
|
||||
if (aChannel) {
|
||||
cacheChannel = do_QueryInterface(aChannel);
|
||||
|
||||
|
@ -11699,6 +11701,8 @@ nsresult nsDocShell::AddToSessionHistory(
|
|||
|
||||
loadInfo->GetResultPrincipalURI(getter_AddRefs(resultPrincipalURI));
|
||||
|
||||
userActivation = loadInfo->GetHasValidUserGestureActivation();
|
||||
|
||||
// For now keep storing just the principal in the SHEntry.
|
||||
if (!principalToInherit) {
|
||||
if (loadInfo->GetLoadingSandboxed()) {
|
||||
|
@ -11767,7 +11771,7 @@ nsresult nsDocShell::AddToSessionHistory(
|
|||
principalToInherit, partitionedPrincipalToInherit, csp,
|
||||
HistoryID(), GetCreatedDynamically(), originalURI,
|
||||
resultPrincipalURI, loadReplace, referrerInfo, srcdoc,
|
||||
srcdocEntry, baseURI, saveLayoutState, expired);
|
||||
srcdocEntry, baseURI, saveLayoutState, expired, userActivation);
|
||||
|
||||
if (mBrowsingContext->IsTop() && GetSessionHistory()) {
|
||||
bool shouldPersist = ShouldAddToSessionHistory(aURI, aChannel);
|
||||
|
@ -11880,7 +11884,8 @@ nsresult nsDocShell::LoadHistoryEntry(nsISHEntry* aEntry, uint32_t aLoadType,
|
|||
// in case.
|
||||
nsCOMPtr<nsISHEntry> kungFuDeathGrip(aEntry);
|
||||
|
||||
loadState->SetHasValidUserGestureActivation(aUserActivation);
|
||||
loadState->SetHasValidUserGestureActivation(
|
||||
loadState->HasValidUserGestureActivation() || aUserActivation);
|
||||
|
||||
return LoadHistoryEntry(loadState, aLoadType, aEntry == mOSHE);
|
||||
}
|
||||
|
@ -11889,7 +11894,8 @@ nsresult nsDocShell::LoadHistoryEntry(const LoadingSessionHistoryInfo& aEntry,
|
|||
uint32_t aLoadType,
|
||||
bool aUserActivation) {
|
||||
RefPtr<nsDocShellLoadState> loadState = aEntry.CreateLoadInfo();
|
||||
loadState->SetHasValidUserGestureActivation(aUserActivation);
|
||||
loadState->SetHasValidUserGestureActivation(
|
||||
loadState->HasValidUserGestureActivation() || aUserActivation);
|
||||
|
||||
return LoadHistoryEntry(loadState, aLoadType,
|
||||
aEntry.mLoadingCurrentActiveEntry);
|
||||
|
|
|
@ -48,6 +48,7 @@ SessionHistoryInfo::SessionHistoryInfo(nsDocShellLoadState* aLoadState,
|
|||
/* FIXME Should this be aLoadState->IsSrcdocLoad()? */
|
||||
mIsSrcdocEntry(!aLoadState->SrcdocData().IsEmpty()),
|
||||
mHasUserInteraction(false),
|
||||
mHasUserActivation(aLoadState->HasValidUserGestureActivation()),
|
||||
mSharedState(SharedState::Create(
|
||||
aLoadState->TriggeringPrincipal(), aLoadState->PrincipalToInherit(),
|
||||
aLoadState->PartitionedPrincipalToInherit(), aLoadState->Csp(),
|
||||
|
@ -140,6 +141,7 @@ void SessionHistoryInfo::Reset(nsIURI* aURI, const nsID& aDocShellID,
|
|||
mScrollRestorationIsManual = false;
|
||||
mPersist = false;
|
||||
mHasUserInteraction = false;
|
||||
mHasUserActivation = false;
|
||||
|
||||
mSharedState.Get()->mTriggeringPrincipal = aTriggeringPrincipal;
|
||||
mSharedState.Get()->mPrincipalToInherit = aPrincipalToInherit;
|
||||
|
@ -552,6 +554,18 @@ SessionHistoryEntry::SetHasUserInteraction(bool aFlag) {
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SessionHistoryEntry::GetHasUserActivation(bool* aFlag) {
|
||||
*aFlag = mInfo->mHasUserActivation;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SessionHistoryEntry::SetHasUserActivation(bool aFlag) {
|
||||
mInfo->mHasUserActivation = aFlag;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SessionHistoryEntry::GetReferrerInfo(nsIReferrerInfo** aReferrerInfo) {
|
||||
nsCOMPtr<nsIReferrerInfo> referrerInfo = mInfo->mReferrerInfo;
|
||||
|
@ -979,7 +993,8 @@ SessionHistoryEntry::Create(
|
|||
nsIContentSecurityPolicy* aCsp, const nsID& aDocshellID,
|
||||
bool aDynamicCreation, nsIURI* aOriginalURI, nsIURI* aResultPrincipalURI,
|
||||
bool aLoadReplace, nsIReferrerInfo* aReferrerInfo, const nsAString& aSrcdoc,
|
||||
bool aSrcdocEntry, nsIURI* aBaseURI, bool aSaveLayoutState, bool aExpired) {
|
||||
bool aSrcdocEntry, nsIURI* aBaseURI, bool aSaveLayoutState, bool aExpired,
|
||||
bool aUserActivation) {
|
||||
MOZ_CRASH("Might need to implement this");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
@ -1433,6 +1448,7 @@ void IPDLParamTraits<dom::SessionHistoryInfo>::Write(
|
|||
WriteIPDLParam(aMsg, aActor, aParam.mScrollRestorationIsManual);
|
||||
WriteIPDLParam(aMsg, aActor, aParam.mPersist);
|
||||
WriteIPDLParam(aMsg, aActor, aParam.mHasUserInteraction);
|
||||
WriteIPDLParam(aMsg, aActor, aParam.mHasUserActivation);
|
||||
WriteIPDLParam(aMsg, aActor, aParam.mSharedState.Get()->mId);
|
||||
WriteIPDLParam(aMsg, aActor, aParam.mSharedState.Get()->mTriggeringPrincipal);
|
||||
WriteIPDLParam(aMsg, aActor, aParam.mSharedState.Get()->mPrincipalToInherit);
|
||||
|
@ -1470,6 +1486,7 @@ bool IPDLParamTraits<dom::SessionHistoryInfo>::Read(
|
|||
&aResult->mScrollRestorationIsManual) ||
|
||||
!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mPersist) ||
|
||||
!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mHasUserInteraction) ||
|
||||
!ReadIPDLParam(aMsg, aIter, aActor, &aResult->mHasUserActivation) ||
|
||||
!ReadIPDLParam(aMsg, aIter, aActor, &sharedId)) {
|
||||
aActor->FatalError("Error reading fields for SessionHistoryInfo");
|
||||
return false;
|
||||
|
|
|
@ -169,6 +169,7 @@ class SessionHistoryInfo {
|
|||
bool mScrollRestorationIsManual = false;
|
||||
bool mPersist = true;
|
||||
bool mHasUserInteraction = false;
|
||||
bool mHasUserActivation = false;
|
||||
|
||||
union SharedState {
|
||||
SharedState();
|
||||
|
|
|
@ -97,6 +97,13 @@ interface nsISHEntry : nsISupports
|
|||
*/
|
||||
[infallible] attribute boolean hasUserInteraction;
|
||||
|
||||
/**
|
||||
* Whether the load that created this entry was triggered by user activation.
|
||||
* (e.g.: The user clicked a link)
|
||||
* Remembering this flag enables replaying the sec-fetch-* headers.
|
||||
*/
|
||||
[infallible] attribute boolean hasUserActivation;
|
||||
|
||||
/** Referrer Info*/
|
||||
[infallible] attribute nsIReferrerInfo referrerInfo;
|
||||
|
||||
|
@ -321,7 +328,8 @@ interface nsISHEntry : nsISupports
|
|||
in bool srcdocEntry,
|
||||
in nsIURI baseURI,
|
||||
in bool saveLayoutState,
|
||||
in bool expired);
|
||||
in bool expired,
|
||||
in bool userActivation);
|
||||
|
||||
nsISHEntry clone();
|
||||
|
||||
|
|
|
@ -43,7 +43,8 @@ nsSHEntry::nsSHEntry()
|
|||
mScrollRestorationIsManual(false),
|
||||
mLoadedInThisProcess(false),
|
||||
mPersist(true),
|
||||
mHasUserInteraction(false) {}
|
||||
mHasUserInteraction(false),
|
||||
mHasUserActivation(false) {}
|
||||
|
||||
nsSHEntry::nsSHEntry(const nsSHEntry& aOther)
|
||||
: mShared(aOther.mShared),
|
||||
|
@ -70,7 +71,8 @@ nsSHEntry::nsSHEntry(const nsSHEntry& aOther)
|
|||
mScrollRestorationIsManual(false),
|
||||
mLoadedInThisProcess(aOther.mLoadedInThisProcess),
|
||||
mPersist(aOther.mPersist),
|
||||
mHasUserInteraction(false) {}
|
||||
mHasUserInteraction(false),
|
||||
mHasUserActivation(aOther.mHasUserActivation) {}
|
||||
|
||||
nsSHEntry::~nsSHEntry() {
|
||||
// Null out the mParent pointers on all our kids.
|
||||
|
@ -324,6 +326,18 @@ nsSHEntry::SetHasUserInteraction(bool aFlag) {
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSHEntry::GetHasUserActivation(bool* aFlag) {
|
||||
*aFlag = mHasUserActivation;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSHEntry::SetHasUserActivation(bool aFlag) {
|
||||
mHasUserActivation = aFlag;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSHEntry::GetCacheKey(uint32_t* aResult) {
|
||||
*aResult = mShared->mCacheKey;
|
||||
|
@ -360,7 +374,7 @@ nsSHEntry::Create(nsIURI* aURI, const nsAString& aTitle,
|
|||
nsIURI* aResultPrincipalURI, bool aLoadReplace,
|
||||
nsIReferrerInfo* aReferrerInfo, const nsAString& aSrcdocData,
|
||||
bool aSrcdocEntry, nsIURI* aBaseURI, bool aSaveLayoutState,
|
||||
bool aExpired) {
|
||||
bool aExpired, bool aUserActivation) {
|
||||
MOZ_ASSERT(
|
||||
aTriggeringPrincipal,
|
||||
"need a valid triggeringPrincipal to create a session history entry");
|
||||
|
@ -402,6 +416,8 @@ nsSHEntry::Create(nsIURI* aURI, const nsAString& aTitle,
|
|||
mLoadReplace = aLoadReplace;
|
||||
mReferrerInfo = aReferrerInfo;
|
||||
|
||||
mHasUserActivation = aUserActivation;
|
||||
|
||||
mShared->mLayoutHistoryState = nullptr;
|
||||
|
||||
mShared->mSaveLayoutState = aSaveLayoutState;
|
||||
|
@ -918,6 +934,9 @@ nsSHEntry::CreateLoadInfo(nsDocShellLoadState** aLoadState) {
|
|||
loadState->SetInternalLoadFlags(flags);
|
||||
|
||||
loadState->SetFirstParty(true);
|
||||
|
||||
loadState->SetHasValidUserGestureActivation(GetHasUserActivation());
|
||||
|
||||
loadState->SetSHEntry(this);
|
||||
|
||||
loadState.forget(aLoadState);
|
||||
|
|
|
@ -65,6 +65,7 @@ class nsSHEntry : public nsISHEntry {
|
|||
bool mLoadedInThisProcess;
|
||||
bool mPersist;
|
||||
bool mHasUserInteraction;
|
||||
bool mHasUserActivation;
|
||||
};
|
||||
|
||||
#endif /* nsSHEntry_h */
|
||||
|
|
Загрузка…
Ссылка в новой задаче