blob: 842891e67f37d4f3600756806c9250abfcfb00b9 (
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
68
69
70
71
|
// Copyright 2014 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.
#include "google_apis/gaia/identity_provider.h"
IdentityProvider::Observer::~Observer() {}
IdentityProvider::~IdentityProvider() {}
void IdentityProvider::AddActiveAccountRefreshTokenObserver(
OAuth2TokenService::Observer* observer) {
OAuth2TokenService* token_service = GetTokenService();
if (!token_service || token_service_observers_.HasObserver(observer))
return;
token_service_observers_.AddObserver(observer);
if (++token_service_observer_count_ == 1)
token_service->AddObserver(this);
}
void IdentityProvider::RemoveActiveAccountRefreshTokenObserver(
OAuth2TokenService::Observer* observer) {
OAuth2TokenService* token_service = GetTokenService();
if (!token_service || !token_service_observers_.HasObserver(observer))
return;
token_service_observers_.RemoveObserver(observer);
if (--token_service_observer_count_ == 0)
token_service->RemoveObserver(this);
}
void IdentityProvider::AddObserver(Observer* observer) {
observers_.AddObserver(observer);
}
void IdentityProvider::RemoveObserver(Observer* observer) {
observers_.RemoveObserver(observer);
}
void IdentityProvider::OnRefreshTokenAvailable(const std::string& account_id) {
if (account_id != GetActiveAccountId())
return;
FOR_EACH_OBSERVER(OAuth2TokenService::Observer,
token_service_observers_,
OnRefreshTokenAvailable(account_id));
}
void IdentityProvider::OnRefreshTokenRevoked(const std::string& account_id) {
if (account_id != GetActiveAccountId())
return;
FOR_EACH_OBSERVER(OAuth2TokenService::Observer,
token_service_observers_,
OnRefreshTokenRevoked(account_id));
}
void IdentityProvider::OnRefreshTokensLoaded() {
FOR_EACH_OBSERVER(OAuth2TokenService::Observer,
token_service_observers_,
OnRefreshTokensLoaded());
}
IdentityProvider::IdentityProvider() : token_service_observer_count_(0) {}
void IdentityProvider::FireOnActiveAccountLogin() {
FOR_EACH_OBSERVER(Observer, observers_, OnActiveAccountLogin());
}
void IdentityProvider::FireOnActiveAccountLogout() {
FOR_EACH_OBSERVER(Observer, observers_, OnActiveAccountLogout());
}
|