зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1191313 - Get rid of third-party-cookie-accepted and third-party-cookie-rejected notifications, r=Ehsan
Differential Revision: https://phabricator.services.mozilla.com/D32665 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
c355651b11
Коммит
67e56bf7fb
|
@ -2185,18 +2185,12 @@ void nsCookieService::SetCookieStringInternal(
|
|||
switch (cookieStatus) {
|
||||
case STATUS_REJECTED:
|
||||
NotifyRejected(aHostURI, aChannel, rejectedReason, OPERATION_WRITE);
|
||||
if (aIsForeign) {
|
||||
NotifyThirdParty(aHostURI, false, aChannel);
|
||||
}
|
||||
return; // Stop here
|
||||
case STATUS_REJECTED_WITH_ERROR:
|
||||
return;
|
||||
case STATUS_ACCEPTED: // Fallthrough
|
||||
case STATUS_ACCEPT_SESSION:
|
||||
NotifyAccepted(aChannel);
|
||||
if (aIsForeign) {
|
||||
NotifyThirdParty(aHostURI, true, aChannel);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -2234,59 +2228,6 @@ void nsCookieService::NotifyRejected(nsIURI* aHostURI, nsIChannel* aChannel,
|
|||
aChannel, AntiTrackingCommon::BlockingDecision::eBlock, aRejectedReason);
|
||||
}
|
||||
|
||||
// notify observers that a third-party cookie was accepted/rejected
|
||||
// if the cookie issuer is unknown, it defaults to "?"
|
||||
void nsCookieService::NotifyThirdParty(nsIURI* aHostURI, bool aIsAccepted,
|
||||
nsIChannel* aChannel) {
|
||||
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
|
||||
if (!os) {
|
||||
return;
|
||||
}
|
||||
|
||||
const char* topic;
|
||||
|
||||
if (mDBState != mPrivateDBState) {
|
||||
// Regular (non-private) browsing
|
||||
if (aIsAccepted) {
|
||||
topic = "third-party-cookie-accepted";
|
||||
} else {
|
||||
topic = "third-party-cookie-rejected";
|
||||
}
|
||||
} else {
|
||||
// Private browsing
|
||||
if (aIsAccepted) {
|
||||
topic = "private-third-party-cookie-accepted";
|
||||
} else {
|
||||
topic = "private-third-party-cookie-rejected";
|
||||
}
|
||||
}
|
||||
|
||||
do {
|
||||
// Attempt to find the host of aChannel.
|
||||
if (!aChannel) {
|
||||
break;
|
||||
}
|
||||
nsCOMPtr<nsIURI> channelURI;
|
||||
nsresult rv = aChannel->GetURI(getter_AddRefs(channelURI));
|
||||
if (NS_FAILED(rv)) {
|
||||
break;
|
||||
}
|
||||
|
||||
nsAutoCString referringHost;
|
||||
rv = channelURI->GetHost(referringHost);
|
||||
if (NS_FAILED(rv)) {
|
||||
break;
|
||||
}
|
||||
|
||||
nsAutoString referringHostUTF16 = NS_ConvertUTF8toUTF16(referringHost);
|
||||
os->NotifyObservers(aHostURI, topic, referringHostUTF16.get());
|
||||
return;
|
||||
} while (false);
|
||||
|
||||
// This can fail for a number of reasons, in which kind we fallback to "?"
|
||||
os->NotifyObservers(aHostURI, topic, u"?");
|
||||
}
|
||||
|
||||
// notify observers that the cookie list changed. there are five possible
|
||||
// values for aData:
|
||||
// "deleted" means a cookie was deleted. aSubject is the deleted cookie.
|
||||
|
|
|
@ -364,7 +364,6 @@ class nsCookieService final : public nsICookieService,
|
|||
void NotifyAccepted(nsIChannel* aChannel);
|
||||
void NotifyRejected(nsIURI* aHostURI, nsIChannel* aChannel,
|
||||
uint32_t aRejectedReason, CookieOperation aOperation);
|
||||
void NotifyThirdParty(nsIURI* aHostURI, bool aAccepted, nsIChannel* aChannel);
|
||||
void NotifyChanged(nsISupports* aSubject, const char16_t* aData,
|
||||
bool aOldCookieIsSession = false, bool aFromHttp = false);
|
||||
void NotifyPurged(nsICookie2* aCookie);
|
||||
|
|
|
@ -65,18 +65,6 @@ interface nsICookieTransactionCallback : nsISupports
|
|||
* subject: an nsIURI interface pointer representing the URI that attempted
|
||||
* to set the cookie.
|
||||
* data : none.
|
||||
*
|
||||
* topic : "third-party-cookie-accepted"
|
||||
* broadcast whenever a third party cookie was accepted
|
||||
* subject: an nsIURI interface pointer representing the URI that attempted
|
||||
* to set the cookie.
|
||||
* data : the referrer, or "?" if unknown
|
||||
*
|
||||
* topic : "third-party-cookie-rejected"
|
||||
* broadcast whenever a third party cookie was rejected
|
||||
* subject: an nsIURI interface pointer representing the URI that attempted
|
||||
* to set the cookie.
|
||||
* data : the referrer, or "?" if unknown
|
||||
*/
|
||||
[scriptable, uuid(1e94e283-2811-4f43-b947-d22b1549d824)]
|
||||
interface nsICookieService : nsISupports
|
||||
|
|
Загрузка…
Ссылка в новой задаче