| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef GOOGLE_APIS_GAIA_IDENTITY_PROVIDER_H_ | 5 #ifndef GOOGLE_APIS_GAIA_IDENTITY_PROVIDER_H_ |
| 6 #define GOOGLE_APIS_GAIA_IDENTITY_PROVIDER_H_ | 6 #define GOOGLE_APIS_GAIA_IDENTITY_PROVIDER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 // Called when the active GAIA account logs out. The account information may | 34 // Called when the active GAIA account logs out. The account information may |
| 35 // have been cleared already when this method is called. The | 35 // have been cleared already when this method is called. The |
| 36 // |IdentityProvider| methods may return inconsistent or outdated | 36 // |IdentityProvider| methods may return inconsistent or outdated |
| 37 // information if called from within OnLogout(). | 37 // information if called from within OnLogout(). |
| 38 virtual void OnActiveAccountLogout() {} | 38 virtual void OnActiveAccountLogout() {} |
| 39 | 39 |
| 40 protected: | 40 protected: |
| 41 virtual ~Observer(); | 41 virtual ~Observer(); |
| 42 }; | 42 }; |
| 43 | 43 |
| 44 virtual ~IdentityProvider(); | 44 ~IdentityProvider() override; |
| 45 | 45 |
| 46 // Adds and removes observers that will be notified of changes to the refresh | 46 // Adds and removes observers that will be notified of changes to the refresh |
| 47 // token availability for the active account. | 47 // token availability for the active account. |
| 48 void AddActiveAccountRefreshTokenObserver( | 48 void AddActiveAccountRefreshTokenObserver( |
| 49 OAuth2TokenService::Observer* observer); | 49 OAuth2TokenService::Observer* observer); |
| 50 void RemoveActiveAccountRefreshTokenObserver( | 50 void RemoveActiveAccountRefreshTokenObserver( |
| 51 OAuth2TokenService::Observer* observer); | 51 OAuth2TokenService::Observer* observer); |
| 52 | 52 |
| 53 // Gets the active account's user name. | 53 // Gets the active account's user name. |
| 54 virtual std::string GetActiveUsername() = 0; | 54 virtual std::string GetActiveUsername() = 0; |
| 55 | 55 |
| 56 // Gets the active account's account ID. | 56 // Gets the active account's account ID. |
| 57 virtual std::string GetActiveAccountId() = 0; | 57 virtual std::string GetActiveAccountId() = 0; |
| 58 | 58 |
| 59 // Gets the token service vending OAuth tokens for all logged-in accounts. | 59 // Gets the token service vending OAuth tokens for all logged-in accounts. |
| 60 virtual OAuth2TokenService* GetTokenService() = 0; | 60 virtual OAuth2TokenService* GetTokenService() = 0; |
| 61 | 61 |
| 62 // Requests login to a GAIA account. Implementations can show a login UI, log | 62 // Requests login to a GAIA account. Implementations can show a login UI, log |
| 63 // in automatically if sufficient credentials are available or may ignore the | 63 // in automatically if sufficient credentials are available or may ignore the |
| 64 // request. Returns true if the login request was processed and false if it | 64 // request. Returns true if the login request was processed and false if it |
| 65 // was ignored. | 65 // was ignored. |
| 66 virtual bool RequestLogin() = 0; | 66 virtual bool RequestLogin() = 0; |
| 67 | 67 |
| 68 void AddObserver(Observer* observer); | 68 void AddObserver(Observer* observer); |
| 69 void RemoveObserver(Observer* observer); | 69 void RemoveObserver(Observer* observer); |
| 70 | 70 |
| 71 // OAuth2TokenService::Observer: | 71 // OAuth2TokenService::Observer: |
| 72 virtual void OnRefreshTokenAvailable(const std::string& account_id) override; | 72 void OnRefreshTokenAvailable(const std::string& account_id) override; |
| 73 virtual void OnRefreshTokenRevoked(const std::string& account_id) override; | 73 void OnRefreshTokenRevoked(const std::string& account_id) override; |
| 74 virtual void OnRefreshTokensLoaded() override; | 74 void OnRefreshTokensLoaded() override; |
| 75 | 75 |
| 76 protected: | 76 protected: |
| 77 IdentityProvider(); | 77 IdentityProvider(); |
| 78 | 78 |
| 79 // Fires an OnActiveAccountLogin notification. | 79 // Fires an OnActiveAccountLogin notification. |
| 80 void FireOnActiveAccountLogin(); | 80 void FireOnActiveAccountLogin(); |
| 81 | 81 |
| 82 // Fires an OnActiveAccountLogout notification. | 82 // Fires an OnActiveAccountLogout notification. |
| 83 void FireOnActiveAccountLogout(); | 83 void FireOnActiveAccountLogout(); |
| 84 | 84 |
| 85 private: | 85 private: |
| 86 ObserverList<Observer, true> observers_; | 86 ObserverList<Observer, true> observers_; |
| 87 ObserverList<OAuth2TokenService::Observer, true> token_service_observers_; | 87 ObserverList<OAuth2TokenService::Observer, true> token_service_observers_; |
| 88 int token_service_observer_count_; | 88 int token_service_observer_count_; |
| 89 | 89 |
| 90 DISALLOW_COPY_AND_ASSIGN(IdentityProvider); | 90 DISALLOW_COPY_AND_ASSIGN(IdentityProvider); |
| 91 }; | 91 }; |
| 92 | 92 |
| 93 #endif // GOOGLE_APIS_GAIA_IDENTITY_PROVIDER_H_ | 93 #endif // GOOGLE_APIS_GAIA_IDENTITY_PROVIDER_H_ |
| OLD | NEW |