From ac25ec44da2244e16f6074eae3d20101e5038abe Mon Sep 17 00:00:00 2001 From: Ehsan Akhgari Date: Tue, 17 Jul 2018 06:12:00 +0300 Subject: [PATCH] Bug 1475697 - Part 2: Add infrastructure for notifying the DOM about a document containing blocked tracking cookies; r=baku --- dom/base/nsGlobalWindowOuter.cpp | 2 ++ dom/base/nsIDocument.h | 19 +++++++++++++++++++ uriloader/base/nsIWebProgressListener.idl | 12 ++++++++---- 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/dom/base/nsGlobalWindowOuter.cpp b/dom/base/nsGlobalWindowOuter.cpp index cbb4e625d092..b3dd81e87820 100644 --- a/dom/base/nsGlobalWindowOuter.cpp +++ b/dom/base/nsGlobalWindowOuter.cpp @@ -5377,6 +5377,8 @@ nsGlobalWindowOuter::NotifyContentBlockingState(unsigned aState, securityUI->GetState(&state); if (aState == nsIWebProgressListener::STATE_BLOCKED_TRACKING_CONTENT) { doc->SetHasTrackingContentBlocked(true); + } else if (aState == nsIWebProgressListener::STATE_BLOCKED_TRACKING_COOKIES) { + doc->SetHasTrackingCookiesBlocked(true); } else { // Ignore nsIWebProgressListener::STATE_BLOCKED_UNSAFE_CONTENT; } diff --git a/dom/base/nsIDocument.h b/dom/base/nsIDocument.h index 51206af6776a..bbd42af1df06 100644 --- a/dom/base/nsIDocument.h +++ b/dom/base/nsIDocument.h @@ -992,6 +992,14 @@ public: return mHasTrackingContentBlocked; } + /** + * Get tracking cookies blocked flag for this document. + */ + bool GetHasTrackingCookiesBlocked() + { + return mHasTrackingCookiesBlocked; + } + /** * Set the tracking content blocked flag for this document. */ @@ -1000,6 +1008,14 @@ public: mHasTrackingContentBlocked = aHasTrackingContentBlocked; } + /** + * Set the tracking cookies blocked flag for this document. + */ + void SetHasTrackingCookiesBlocked(bool aHasTrackingCookiesBlocked) + { + mHasTrackingCookiesBlocked = aHasTrackingCookiesBlocked; + } + /** * Get tracking content loaded flag for this document. */ @@ -3905,6 +3921,9 @@ protected: // True if a document has blocked Tracking Content bool mHasTrackingContentBlocked : 1; + // True if a document has blocked Tracking Cookies + bool mHasTrackingCookiesBlocked : 1; + // True if a document has loaded Tracking Content bool mHasTrackingContentLoaded : 1; diff --git a/uriloader/base/nsIWebProgressListener.idl b/uriloader/base/nsIWebProgressListener.idl index 01c2cdb64a30..38a0c6fd3570 100644 --- a/uriloader/base/nsIWebProgressListener.idl +++ b/uriloader/base/nsIWebProgressListener.idl @@ -218,10 +218,14 @@ interface nsIWebProgressListener : nsISupports * * STATE_BLOCKED_UNSAFE_CONTENT * Content which againts SafeBrowsing list has been blocked from loading. + * + * STATE_BLOCKED_TRACKING_COOKIES + * Tracking cookies has been blocked from loading. */ const unsigned long STATE_BLOCKED_TRACKING_CONTENT = 0x00001000; const unsigned long STATE_LOADED_TRACKING_CONTENT = 0x00002000; const unsigned long STATE_BLOCKED_UNSAFE_CONTENT = 0x00004000; + const unsigned long STATE_BLOCKED_TRACKING_COOKIES = 0x00008000; /** * Diagnostic flags @@ -233,7 +237,7 @@ interface nsIWebProgressListener : nsISupports * STATE_CERT_DISTRUST_IMMINENT * The certificate in use will be distrusted in the near future. */ - const unsigned long STATE_CERT_DISTRUST_IMMINENT = 0x00008000; + const unsigned long STATE_CERT_DISTRUST_IMMINENT = 0x00010000; /** * Security Strength Flags @@ -256,9 +260,9 @@ interface nsIWebProgressListener : nsISupports * STATE_SECURE_LOW * This flag indicates a low degree of security. */ - const unsigned long STATE_SECURE_HIGH = 0x00040000; - const unsigned long STATE_SECURE_MED = 0x00010000; - const unsigned long STATE_SECURE_LOW = 0x00020000; + const unsigned long STATE_SECURE_HIGH = 0x00080000; + const unsigned long STATE_SECURE_MED = 0x00020000; + const unsigned long STATE_SECURE_LOW = 0x00040000; /** * State bits for EV == Extended Validation == High Assurance