blob: a2e0590da423b25fbd38b0d5661506c1de42386d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
// 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.
#ifndef CHROME_BROWSER_SIGNIN_IDENTITY_MANAGER_FACTORY_H_
#define CHROME_BROWSER_SIGNIN_IDENTITY_MANAGER_FACTORY_H_
#include "base/memory/singleton.h"
#include "base/observer_list.h"
#include "components/keyed_service/content/browser_context_keyed_service_factory.h"
namespace signin {
class IdentityManager;
}
class Profile;
// Singleton that owns all IdentityManager instances and associates them with
// Profiles.
class IdentityManagerFactory : public BrowserContextKeyedServiceFactory {
public:
class Observer : public base::CheckedObserver {
public:
// Called when a IdentityManager instance is created.
virtual void IdentityManagerCreated(
signin::IdentityManager* identity_manager) {}
protected:
~Observer() override {}
};
static signin::IdentityManager* GetForProfile(Profile* profile);
static signin::IdentityManager* GetForProfileIfExists(const Profile* profile);
// Returns an instance of the IdentityManagerFactory singleton.
static IdentityManagerFactory* GetInstance();
IdentityManagerFactory(const IdentityManagerFactory&) = delete;
IdentityManagerFactory& operator=(const IdentityManagerFactory&) = delete;
// Ensures that IdentityManagerFactory and the factories on which it depends
// are built.
static void EnsureFactoryAndDependeeFactoriesBuilt();
// Methods to register or remove observers of IdentityManager
// creation/shutdown.
void AddObserver(Observer* observer);
void RemoveObserver(Observer* observer);
private:
friend struct base::DefaultSingletonTraits<IdentityManagerFactory>;
IdentityManagerFactory();
~IdentityManagerFactory() override;
// BrowserContextKeyedServiceFactory:
KeyedService* BuildServiceInstanceFor(
content::BrowserContext* profile) const override;
void RegisterProfilePrefs(
user_prefs::PrefRegistrySyncable* registry) override;
// List of observers. Checks that list is empty on destruction.
base::ObserverList<Observer, /*check_empty=*/true, /*allow_reentrancy=*/false>
observer_list_;
};
#endif // CHROME_BROWSER_SIGNIN_IDENTITY_MANAGER_FACTORY_H_
|