mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-02 01:48:05 +00:00
Bug 1493563 - Part 10: Implement the per-document blocked states in terms of the content blocking log; r=baku
It is arguably more accurate to implement these boolean getters in terms of whether we remember blocking anything in the category being asked about. This will allow us to correctly account for hiding the sheild icon when all currently blocked trackers become unblocked, for example. Differential Revision: https://phabricator.services.mozilla.com/D6600
This commit is contained in:
parent
2f969011be
commit
214e30a710
@ -113,6 +113,22 @@ public:
|
||||
return buffer;
|
||||
}
|
||||
|
||||
bool HasBlockedAnyOfType(uint32_t aType)
|
||||
{
|
||||
for (auto iter = mLog.Iter(); !iter.Done(); iter.Next()) {
|
||||
if (!iter.UserData()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (auto& item: *iter.UserData()) {
|
||||
if ((item.mType & aType) != 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void AddSizeOfExcludingThis(nsWindowSizes& aSizes) const
|
||||
{
|
||||
aSizes.mDOMOtherSize += mLog.ShallowSizeOfExcludingThis(aSizes.mState.mMallocSizeOf);
|
||||
|
@ -1403,12 +1403,6 @@ nsIDocument::nsIDocument()
|
||||
mHasCSP(false),
|
||||
mHasUnsafeEvalCSP(false),
|
||||
mHasUnsafeInlineCSP(false),
|
||||
mHasTrackingContentBlocked(false),
|
||||
mHasSlowTrackingContentBlocked(false),
|
||||
mHasAllCookiesBlocked(false),
|
||||
mHasTrackingCookiesBlocked(false),
|
||||
mHasForeignCookiesBlocked(false),
|
||||
mHasCookiesBlockedByPermission(false),
|
||||
mHasTrackingContentLoaded(false),
|
||||
mBFCacheDisallowed(false),
|
||||
mHasHadDefaultView(false),
|
||||
|
@ -992,7 +992,8 @@ public:
|
||||
*/
|
||||
bool GetHasTrackingContentBlocked()
|
||||
{
|
||||
return mHasTrackingContentBlocked;
|
||||
return mContentBlockingLog.HasBlockedAnyOfType(
|
||||
nsIWebProgressListener::STATE_BLOCKED_TRACKING_CONTENT);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1000,7 +1001,8 @@ public:
|
||||
*/
|
||||
bool GetHasSlowTrackingContentBlocked()
|
||||
{
|
||||
return mHasSlowTrackingContentBlocked;
|
||||
return mContentBlockingLog.HasBlockedAnyOfType(
|
||||
nsIWebProgressListener::STATE_BLOCKED_SLOW_TRACKING_CONTENT);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1008,7 +1010,8 @@ public:
|
||||
*/
|
||||
bool GetHasAllCookiesBlocked()
|
||||
{
|
||||
return mHasAllCookiesBlocked;
|
||||
return mContentBlockingLog.HasBlockedAnyOfType(
|
||||
nsIWebProgressListener::STATE_COOKIES_BLOCKED_ALL);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1016,7 +1019,8 @@ public:
|
||||
*/
|
||||
bool GetHasTrackingCookiesBlocked()
|
||||
{
|
||||
return mHasTrackingCookiesBlocked;
|
||||
return mContentBlockingLog.HasBlockedAnyOfType(
|
||||
nsIWebProgressListener::STATE_COOKIES_BLOCKED_TRACKER);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1024,7 +1028,8 @@ public:
|
||||
*/
|
||||
bool GetHasForeignCookiesBlocked()
|
||||
{
|
||||
return mHasForeignCookiesBlocked;
|
||||
return mContentBlockingLog.HasBlockedAnyOfType(
|
||||
nsIWebProgressListener::STATE_COOKIES_BLOCKED_FOREIGN);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1032,7 +1037,8 @@ public:
|
||||
*/
|
||||
bool GetHasCookiesBlockedByPermission()
|
||||
{
|
||||
return mHasCookiesBlockedByPermission;
|
||||
return mContentBlockingLog.HasBlockedAnyOfType(
|
||||
nsIWebProgressListener::STATE_COOKIES_BLOCKED_BY_PERMISSION);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1041,7 +1047,6 @@ public:
|
||||
void SetHasTrackingContentBlocked(bool aHasTrackingContentBlocked,
|
||||
const nsAString& aOriginBlocked)
|
||||
{
|
||||
mHasTrackingContentBlocked = aHasTrackingContentBlocked;
|
||||
RecordContentBlockingLog(aOriginBlocked,
|
||||
nsIWebProgressListener::STATE_BLOCKED_TRACKING_CONTENT,
|
||||
aHasTrackingContentBlocked);
|
||||
@ -1053,7 +1058,6 @@ public:
|
||||
void SetHasSlowTrackingContentBlocked(bool aHasSlowTrackingContentBlocked,
|
||||
const nsAString& aOriginBlocked)
|
||||
{
|
||||
mHasSlowTrackingContentBlocked = aHasSlowTrackingContentBlocked;
|
||||
RecordContentBlockingLog(aOriginBlocked,
|
||||
nsIWebProgressListener::STATE_BLOCKED_SLOW_TRACKING_CONTENT,
|
||||
aHasSlowTrackingContentBlocked);
|
||||
@ -1065,7 +1069,6 @@ public:
|
||||
void SetHasAllCookiesBlocked(bool aHasAllCookiesBlocked,
|
||||
const nsAString& aOriginBlocked)
|
||||
{
|
||||
mHasAllCookiesBlocked = aHasAllCookiesBlocked;
|
||||
RecordContentBlockingLog(aOriginBlocked,
|
||||
nsIWebProgressListener::STATE_COOKIES_BLOCKED_ALL,
|
||||
aHasAllCookiesBlocked);
|
||||
@ -1077,7 +1080,6 @@ public:
|
||||
void SetHasTrackingCookiesBlocked(bool aHasTrackingCookiesBlocked,
|
||||
const nsAString& aOriginBlocked)
|
||||
{
|
||||
mHasTrackingCookiesBlocked = aHasTrackingCookiesBlocked;
|
||||
RecordContentBlockingLog(aOriginBlocked,
|
||||
nsIWebProgressListener::STATE_COOKIES_BLOCKED_TRACKER,
|
||||
aHasTrackingCookiesBlocked);
|
||||
@ -1089,7 +1091,6 @@ public:
|
||||
void SetHasForeignCookiesBlocked(bool aHasForeignCookiesBlocked,
|
||||
const nsAString& aOriginBlocked)
|
||||
{
|
||||
mHasForeignCookiesBlocked = aHasForeignCookiesBlocked;
|
||||
RecordContentBlockingLog(aOriginBlocked,
|
||||
nsIWebProgressListener::STATE_COOKIES_BLOCKED_FOREIGN,
|
||||
aHasForeignCookiesBlocked);
|
||||
@ -1101,7 +1102,6 @@ public:
|
||||
void SetHasCookiesBlockedByPermission(bool aHasCookiesBlockedByPermission,
|
||||
const nsAString& aOriginBlocked)
|
||||
{
|
||||
mHasCookiesBlockedByPermission = aHasCookiesBlockedByPermission;
|
||||
RecordContentBlockingLog(aOriginBlocked,
|
||||
nsIWebProgressListener::STATE_COOKIES_BLOCKED_BY_PERMISSION,
|
||||
aHasCookiesBlockedByPermission);
|
||||
@ -4190,24 +4190,6 @@ protected:
|
||||
// True if a document load has a CSP with unsafe-inline attached.
|
||||
bool mHasUnsafeInlineCSP : 1;
|
||||
|
||||
// True if a document has blocked Tracking Content
|
||||
bool mHasTrackingContentBlocked : 1;
|
||||
|
||||
// True if a document has blocked Slow Tracking Content
|
||||
bool mHasSlowTrackingContentBlocked : 1;
|
||||
|
||||
// True if a document has blocked All Cookies
|
||||
bool mHasAllCookiesBlocked : 1;
|
||||
|
||||
// True if a document has blocked Tracking Cookies
|
||||
bool mHasTrackingCookiesBlocked : 1;
|
||||
|
||||
// True if a document has blocked Foreign Cookies
|
||||
bool mHasForeignCookiesBlocked : 1;
|
||||
|
||||
// True if a document has blocked Cookies By Site Permission
|
||||
bool mHasCookiesBlockedByPermission : 1;
|
||||
|
||||
// True if a document has loaded Tracking Content
|
||||
bool mHasTrackingContentLoaded : 1;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user