Skip to content

Commit

Permalink
Bug 1842030 - Part 1: Adding CanonicalBrowsingContext::IsPrivateBrows…
Browse files Browse the repository at this point in the history
…ingActive(). r=nika

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
  • Loading branch information
artines1 committed Jul 26, 2023
1 parent 611cb12 commit 7812491
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions docshell/base/CanonicalBrowsingContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1433,6 +1433,11 @@ uint32_t CanonicalBrowsingContext::CountSiteOrigins(
return uniqueSiteOrigins.Count();
}

/* static */
bool CanonicalBrowsingContext::IsPrivateBrowsingActive() {
return gNumberOfPrivateContexts > 0;
}

void CanonicalBrowsingContext::UpdateMediaControlAction(
const MediaControlAction& aAction) {
if (IsDiscarded()) {
Expand Down
3 changes: 3 additions & 0 deletions docshell/base/CanonicalBrowsingContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,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);
Expand Down

0 comments on commit 7812491

Please sign in to comment.