Bug 1842030 - Part 1: Adding CanonicalBrowsingContext::IsPrivateBrowsingActive(). r=nika, a=dmeehan

The CanonicalBrowsingContext::IsPrivateBrowsingActive() function allows
us to know if private browsing is active. We need it to prevent setting
cookies if there is no active private browsing session.

Differential Revision: https://phabricator.services.mozilla.com/D184010
This commit is contained in:
Tim Huang 2023-07-26 10:14:37 +00:00
parent dd4b1838be
commit a00674cffd
2 changed files with 8 additions and 0 deletions

View File

@ -1430,6 +1430,11 @@ uint32_t CanonicalBrowsingContext::CountSiteOrigins(
return uniqueSiteOrigins.Count();
}
/* static */
bool CanonicalBrowsingContext::IsPrivateBrowsingActive() {
return gNumberOfPrivateContexts > 0;
}
void CanonicalBrowsingContext::UpdateMediaControlAction(
const MediaControlAction& aAction) {
if (IsDiscarded()) {

View File

@ -202,6 +202,9 @@ class CanonicalBrowsingContext final : public BrowsingContext {
GlobalObject& aGlobal,
const Sequence<mozilla::OwningNonNull<BrowsingContext>>& aRoots);
// Return true if a private browsing session is active.
static bool IsPrivateBrowsingActive();
// This function would propogate the action to its all child browsing contexts
// in content processes.
void UpdateMediaControlAction(const MediaControlAction& aAction);