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_ACTIVE_STATE_MANAGER_IMPL_H_
6 #define IOS_WEB_ACTIVE_STATE_MANAGER_IMPL_H_
8 #include "base/macros.h"
9 #include "base/observer_list.h"
10 #include "base/supports_user_data.h"
11 #include "ios/web/public/active_state_manager.h"
17 // Concrete subclass of web::ActiveStateManager. Informs observers when an
18 // ActiveStateManager becomes active/inactive.
19 class ActiveStateManagerImpl
: public ActiveStateManager
,
20 public base::SupportsUserData::Data
{
22 explicit ActiveStateManagerImpl(BrowserState
* browser_state
);
23 ~ActiveStateManagerImpl() override
;
25 // ActiveStateManager methods.
26 void SetActive(bool active
) override
;
27 bool IsActive() override
;
28 void AddObserver(ActiveStateManager::Observer
* observer
) override
;
29 void RemoveObserver(ActiveStateManager::Observer
* observer
) override
;
32 BrowserState
* browser_state_
; // weak, owns this object.
33 // true if the ActiveStateManager is active.
35 // The list of observers.
36 base::ObserverList
<Observer
> observer_list_
;
38 DISALLOW_COPY_AND_ASSIGN(ActiveStateManagerImpl
);
43 #endif // IOS_WEB_ACTIVE_STATE_MANAGER_IMPL_H_