Skip to content
Commit 10406026 authored by Sylvain Defresne's avatar Sylvain Defresne Committed by Chromium LUCI CQ
Browse files

[ios] IncognitoSessionTracker tracks whether the app has any OTR tabs

Multiple features needs to track whether any off-the-record tabs are
open in the application (by any ChromeBrowserState) so add new class
IncognitoSessionTracker to perform the tracking and offer a simple
API.

For code that only need to check at specific points in time, it
exposes a getter HasIncognitoSessionTabs() which returns whether
any off-the-record tabs are open or not.

For code that needs to be notified when the app transition from one
state to the other (i.e. no off-the-record tabs to some, or in the
other direction), it exposes RegisterCallback(...) which allow them
to register a callback that will be invoked on transitions. This is
simpler than an Observer API because base::CallbackListSubscription
simplify the unregistration independently in which order the objects
are destroyed.

In addition the class uses the ChromeBrowserStateManagerObserver API
to track when new ChromeBrowserStates are loaded/created while the
application is running, so this really tracks all ChromeBrowserStates.

Bug: 358291121, 358289106
Change-Id: I87ee825410302159b3c996eddd544c08be964940
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5773059


Reviewed-by: default avatarAliona Dangla <alionadangla@chromium.org>
Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com>
Auto-Submit: Sylvain Defresne <sdefresne@chromium.org>
Commit-Queue: Sylvain Defresne <sdefresne@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1339635}
parent 3d547637
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment