1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef IOS_WEB_PUBLIC_ACTIVE_STATE_MANAGER_H_
6 #define IOS_WEB_PUBLIC_ACTIVE_STATE_MANAGER_H_
8 #include "base/macros.h"
14 // Manages the active state associated with a particular BrowserState. Not
15 // thread safe. Must be used only on the main thread.
16 class ActiveStateManager
{
18 // Sets the active state of the ActiveStateManager. At most one
19 // ActiveStateManager can be active at any given time in the app. A
20 // ActiveStateManager must be made inactive before it is destroyed. It is
21 // valid to call |SetActive(true)| on an already active ActiveStateManager.
22 virtual void SetActive(bool active
) = 0;
23 // Returns true if the BrowserState is active.
24 virtual bool IsActive() = 0;
26 // Observer that is notified when a ActiveStateManager becomes active,
27 // inactive or destroyed.
30 // Called when the ActiveStateManager becomes active.
31 virtual void OnActive() {}
32 // Called when the ActiveStateManager becomes inactive.
33 virtual void OnInactive() {}
34 // Called just before the ActiveStateManager is destroyed.
35 virtual void WillBeDestroyed() {}
37 // Adds an observer for this class. An observer should not be added more
38 // than once. The caller retains the ownership of the observer object.
39 virtual void AddObserver(Observer
* observer
) = 0;
40 // Removes an observer.
41 virtual void RemoveObserver(Observer
* observer
) = 0;
44 virtual ~ActiveStateManager(){};
49 #endif // IOS_WEB_PUBLIC_ACTIVE_STATE_MANAGER_H_