blob: 3c2b0490a92c2157ed76e4114eee8b7b5e62ae61 [file] [log] [blame]
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import <Foundation/Foundation.h>
#include "base/macros.h"
@class TabModel;
class TabModelListObserver;
namespace ios {
class ChromeBrowserState;
// A class containing static functions to help maintain a 1:N relationship
// between an ios::ChromeBrowserState and multiple TabModels.
class TabModelList {
// Adds |observer| to the list of observers.
static void AddObserver(TabModelListObserver* observer);
// Removes |observer| from the list of observers.
static void RemoveObserver(TabModelListObserver* observer);
// Registers |tab_model| as associated to |browser_state|. The object will
// be retained until |UnregisterTabModelFromChromeBrowserState| is called.
// It is an error if |tab_model is already registered as associated to
// |browser_state|.
static void RegisterTabModelWithChromeBrowserState(
ios::ChromeBrowserState* browser_state,
TabModel* tab_model);
// Unregisters the association between |tab_model| and |browser_state|.
// It is an error if no such association exists.
static void UnregisterTabModelFromChromeBrowserState(
ios::ChromeBrowserState* browser_state,
TabModel* tab_model);
// Returns the list of all TabModels associated with |browser_state|.
static NSArray<TabModel*>* GetTabModelsForChromeBrowserState(
ios::ChromeBrowserState* browser_state);
// Returns the last active TabModel associated with |browser_state|.
static TabModel* GetLastActiveTabModelForChromeBrowserState(
ios::ChromeBrowserState* browser_state);
// Returns true if a incognito session is currently active (i.e. at least
// one incognito tab is open).
static bool IsOffTheRecordSessionActive();